summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--.travis.yml2
-rw-r--r--ISSUE_TEMPLATE.md18
-rw-r--r--SConstruct4
-rw-r--r--core/SCsub5
-rw-r--r--core/array.cpp1
-rw-r--r--core/bind/core_bind.cpp700
-rw-r--r--core/bind/core_bind.h61
-rw-r--r--core/class_db.cpp (renamed from core/object_type_db.cpp)47
-rw-r--r--core/class_db.h (renamed from core/object_type_db.h)37
-rw-r--r--core/color.cpp1
-rw-r--r--core/color_names.inc2
-rw-r--r--core/command_queue_mt.cpp1
-rw-r--r--core/command_queue_mt.h34
-rw-r--r--core/compressed_translation.cpp15
-rw-r--r--core/core_string_names.cpp2
-rw-r--r--core/dictionary.cpp1
-rw-r--r--core/dvector.h13
-rw-r--r--core/engine.cpp (renamed from modules/chibi/cp_sample_manager.cpp)127
-rw-r--r--core/engine.h (renamed from scene/2d/sound_player_2d.h)76
-rw-r--r--core/error_list.h2
-rw-r--r--core/error_macros.cpp1
-rw-r--r--core/func_ref.cpp4
-rw-r--r--core/global_config.cpp (renamed from core/globals.cpp)209
-rw-r--r--core/global_config.h (renamed from core/globals.h)4
-rw-r--r--core/global_constants.cpp3
-rw-r--r--core/hash_map.h63
-rw-r--r--core/hashfuncs.h42
-rw-r--r--core/helper/SCsub (renamed from tools/doc/SCsub)2
-rw-r--r--core/helper/math_fieldwise.cpp171
-rw-r--r--core/helper/math_fieldwise.h (renamed from modules/chibi/register_types.cpp)17
-rw-r--r--core/image.cpp73
-rw-r--r--core/image.h2
-rw-r--r--core/input_map.cpp47
-rw-r--r--core/input_map.h2
-rw-r--r--core/io/aes256.cpp6
-rw-r--r--core/io/base64.c8
-rw-r--r--core/io/base64.h8
-rw-r--r--core/io/compression.cpp2
-rw-r--r--core/io/config_file.cpp21
-rw-r--r--core/io/config_file.h2
-rw-r--r--core/io/file_access_buffered_fa.h9
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/file_access_network.cpp8
-rw-r--r--core/io/file_access_pack.cpp10
-rw-r--r--core/io/file_access_pack.h2
-rw-r--r--core/io/file_access_zip.cpp2
-rw-r--r--core/io/http_client.cpp69
-rw-r--r--core/io/http_client.h4
-rw-r--r--core/io/image_loader.cpp4
-rw-r--r--core/io/ip.cpp16
-rw-r--r--core/io/ip_address.cpp27
-rw-r--r--core/io/ip_address.h9
-rw-r--r--core/io/json.cpp6
-rw-r--r--core/io/marshalls.cpp4
-rw-r--r--core/io/networked_multiplayer_peer.cpp44
-rw-r--r--core/io/networked_multiplayer_peer.h28
-rw-r--r--core/io/packet_peer.cpp16
-rw-r--r--core/io/packet_peer_udp.cpp32
-rw-r--r--core/io/packet_peer_udp.h9
-rw-r--r--core/io/pck_packer.cpp8
-rw-r--r--core/io/resource_format_binary.cpp169
-rw-r--r--core/io/resource_format_binary.h3
-rw-r--r--core/io/resource_import.cpp259
-rw-r--r--core/io/resource_import.h77
-rw-r--r--core/io/resource_loader.cpp175
-rw-r--r--core/io/resource_loader.h9
-rw-r--r--core/io/resource_saver.cpp6
-rw-r--r--core/io/stream_peer.cpp92
-rw-r--r--core/io/stream_peer_ssl.cpp8
-rw-r--r--core/io/stream_peer_ssl.h6
-rw-r--r--core/io/stream_peer_tcp.cpp25
-rw-r--r--core/io/stream_peer_tcp.h9
-rw-r--r--core/io/tcp_server.cpp26
-rw-r--r--core/io/tcp_server.h6
-rw-r--r--core/io/translation_loader_po.cpp2
-rw-r--r--core/io/xml_parser.cpp34
-rw-r--r--core/io/zip.c2
-rw-r--r--core/map.h4
-rw-r--r--core/math/a_star.cpp46
-rw-r--r--core/math/a_star.h8
-rw-r--r--core/math/audio_frame.cpp2
-rw-r--r--core/math/audio_frame.h61
-rw-r--r--core/math/bsp_tree.cpp38
-rw-r--r--core/math/bsp_tree.h10
-rw-r--r--core/math/camera_matrix.cpp113
-rw-r--r--core/math/camera_matrix.h24
-rw-r--r--core/math/face3.cpp56
-rw-r--r--core/math/face3.h24
-rw-r--r--core/math/geometry.cpp22
-rw-r--r--core/math/geometry.h152
-rw-r--r--core/math/math_2d.cpp6
-rw-r--r--core/math/math_2d.h2
-rw-r--r--core/math/math_funcs.cpp87
-rw-r--r--core/math/math_funcs.h236
-rw-r--r--core/math/matrix3.cpp20
-rw-r--r--core/math/octree.h22
-rw-r--r--core/math/pcg.cpp15
-rw-r--r--core/math/pcg.h14
-rw-r--r--core/math/plane.h2
-rw-r--r--core/math/quat.cpp18
-rw-r--r--core/math/quat.h4
-rw-r--r--core/math/quick_hull.cpp8
-rw-r--r--core/math/quick_hull.h2
-rw-r--r--core/math/rect3.cpp (renamed from core/math/aabb.cpp)14
-rw-r--r--core/math/rect3.h (renamed from core/math/aabb.h)26
-rw-r--r--core/math/transform.h2
-rw-r--r--core/math/triangle_mesh.cpp51
-rw-r--r--core/math/triangulate.cpp24
-rw-r--r--core/math/triangulate.h10
-rw-r--r--core/math/triangulator.cpp2
-rw-r--r--core/math/vector3.cpp74
-rw-r--r--core/math/vector3.h16
-rw-r--r--core/message_queue.cpp4
-rw-r--r--core/method_bind.cpp3
-rw-r--r--core/method_ptrcall.h16
-rw-r--r--core/object.cpp91
-rw-r--r--core/object.h21
-rw-r--r--core/os/dir_access.cpp2
-rw-r--r--core/os/dir_access.h2
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/input.cpp72
-rw-r--r--core/os/input.h6
-rw-r--r--core/os/input_event.cpp3
-rw-r--r--core/os/keyboard.cpp7
-rw-r--r--core/os/main_loop.cpp12
-rw-r--r--core/os/memory.h4
-rw-r--r--core/os/mutex.cpp2
-rw-r--r--core/os/os.cpp82
-rw-r--r--core/os/os.h39
-rw-r--r--core/packed_data_container.cpp28
-rw-r--r--core/pair.h9
-rw-r--r--core/path_db.cpp4
-rw-r--r--core/path_remap.cpp173
-rw-r--r--core/path_remap.h35
-rw-r--r--core/pool_allocator.cpp7
-rw-r--r--core/print_string.cpp2
-rw-r--r--core/profile_clock.cpp3
-rw-r--r--core/profile_clock.h7
-rw-r--r--core/ref_ptr.cpp1
-rw-r--r--core/reference.cpp9
-rw-r--r--core/reference.h2
-rw-r--r--core/register_core_types.cpp21
-rw-r--r--core/resource.cpp181
-rw-r--r--core/resource.h56
-rw-r--r--core/safe_refcount.cpp8
-rw-r--r--core/script_debugger_local.cpp3
-rw-r--r--core/script_debugger_remote.cpp16
-rw-r--r--core/script_language.cpp14
-rw-r--r--core/set.h6
-rw-r--r--core/string_db.cpp2
-rw-r--r--core/string_db.h3
-rw-r--r--core/translation.cpp54
-rw-r--r--core/translation.h1
-rw-r--r--core/typedefs.h74
-rw-r--r--core/undo_redo.cpp23
-rw-r--r--core/ustring.cpp163
-rw-r--r--core/ustring.h8
-rw-r--r--core/variant.cpp190
-rw-r--r--core/variant.h7
-rw-r--r--core/variant_call.cpp71
-rw-r--r--core/variant_construct_string.cpp2
-rw-r--r--core/variant_op.cpp6
-rw-r--r--core/variant_parser.cpp54
-rw-r--r--core/vector.h2
-rw-r--r--doc/base/classes.xml99
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp14
-rw-r--r--drivers/alsa/audio_driver_alsa.h8
-rw-r--r--drivers/convex_decomp/b2Glue.h12
-rw-r--r--drivers/convex_decomp/b2Polygon.cpp20
-rw-r--r--drivers/convex_decomp/b2Polygon.h8
-rw-r--r--drivers/convex_decomp/b2d_decompose.cpp2
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp202
-rw-r--r--drivers/gles2/rasterizer_gles2.h8
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp28
-rw-r--r--drivers/gles2/shader_gles2.cpp2
-rw-r--r--drivers/gles2/shader_gles2.h4
-rw-r--r--drivers/gles2/shaders/canvas.glsl2
-rw-r--r--drivers/gles2/shaders/material.glsl10
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp29
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp18
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp203
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h6
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp236
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h49
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp4
-rw-r--r--drivers/gles3/shader_gles3.cpp4
-rw-r--r--drivers/gles3/shader_gles3.h2
-rw-r--r--drivers/gles3/shaders/canvas.glsl2
-rw-r--r--drivers/gles3/shaders/scene.glsl163
-rw-r--r--drivers/gles3/shaders/ssao.glsl18
-rw-r--r--drivers/gles3/shaders/ssao_blur.glsl8
-rw-r--r--drivers/gles3/shaders/ssao_minify.glsl2
-rw-r--r--drivers/png/image_loader_png.cpp2
-rw-r--r--drivers/png/resource_saver_png.cpp2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp33
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h8
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp41
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.h8
-rw-r--r--drivers/unix/dir_access_unix.cpp8
-rw-r--r--drivers/unix/dir_access_unix.h2
-rw-r--r--drivers/unix/os_unix.cpp26
-rw-r--r--drivers/unix/os_unix.h2
-rw-r--r--drivers/unix/packet_peer_udp_posix.cpp42
-rw-r--r--drivers/unix/packet_peer_udp_posix.h5
-rw-r--r--drivers/unix/socket_helpers.h16
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp50
-rw-r--r--drivers/unix/stream_peer_tcp_posix.h13
-rw-r--r--drivers/unix/tcp_server_posix.cpp26
-rw-r--r--drivers/unix/tcp_server_posix.h3
-rw-r--r--drivers/windows/dir_access_windows.cpp4
-rw-r--r--drivers/windows/dir_access_windows.h2
-rw-r--r--drivers/windows/file_access_windows.cpp2
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp9
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.h9
-rw-r--r--main/input_default.cpp67
-rw-r--r--main/input_default.h12
-rw-r--r--main/main.cpp160
-rw-r--r--main/performance.cpp10
-rw-r--r--main/tests/test_containers.cpp3
-rw-r--r--main/tests/test_gdscript.cpp6
-rw-r--r--main/tests/test_gui.cpp8
-rw-r--r--main/tests/test_io.cpp2
-rw-r--r--main/tests/test_main.cpp6
-rw-r--r--main/tests/test_math.cpp6
-rw-r--r--main/tests/test_physics.cpp13
-rw-r--r--main/tests/test_physics_2d.cpp37
-rw-r--r--main/tests/test_render.cpp6
-rw-r--r--main/tests/test_sound.cpp5
-rw-r--r--main/tests/test_string.cpp3
-rw-r--r--misc/dist/docker/Dockerfile (renamed from tools/dist/docker/Dockerfile)0
-rw-r--r--misc/dist/docker/README.md (renamed from tools/dist/docker/README.md)0
-rw-r--r--misc/dist/docker/scripts/install-android-tools (renamed from tools/dist/docker/scripts/install-android-tools)0
-rw-r--r--misc/dist/html_fs/godotfs.js (renamed from tools/dist/html_fs/godotfs.js)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/data.pck (renamed from tools/dist/ios_xcode/godot_xcode/data.pck)0
-rwxr-xr-xmisc/dist/ios_xcode/godot_xcode/godot_debug.iphone (renamed from tools/dist/ios_xcode/godot_xcode/godot_debug.iphone)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png)bin564 -> 564 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png)bin683 -> 683 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png)bin817 -> 817 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png)bin1676 -> 1676 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png)bin2582 -> 2582 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png)bin2582 -> 2582 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png)bin3131 -> 3131 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png)bin634 -> 634 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png)bin3070 -> 3070 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png)bin589 -> 589 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png)bin515 -> 515 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png)bin309 -> 309 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png)bin250 -> 250 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png)bin253 -> 253 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png)bin253 -> 253 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png)bin259 -> 259 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png)bin260 -> 260 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png)bin265 -> 265 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png)bin242 -> 242 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png)bin240 -> 240 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png)bin243 -> 243 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png)bin243 -> 243 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png)bin243 -> 243 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png)bin244 -> 244 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png)bin244 -> 244 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png)bin246 -> 246 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png)bin245 -> 245 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png)bin262 -> 262 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png)bin247 -> 247 bytes
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist)0
-rw-r--r--misc/dist/ios_xcode/godot_xcode/godot_ios/main.m (renamed from tools/dist/ios_xcode/godot_xcode/godot_ios/main.m)0
-rwxr-xr-xmisc/dist/ios_xcode/godot_xcode/godot_opt.iphone (renamed from tools/dist/ios_xcode/godot_xcode/godot_opt.iphone)0
-rwxr-xr-xmisc/dist/osx_template.app/Contents/Info.plist (renamed from tools/dist/osx_template.app/Contents/Info.plist)0
-rw-r--r--misc/dist/osx_template.app/Contents/PkgInfo (renamed from tools/dist/osx_template.app/Contents/PkgInfo)0
-rw-r--r--misc/dist/osx_template.app/Contents/Resources/icon.icns (renamed from tools/dist/osx_template.app/Contents/Resources/icon.icns)bin120942 -> 120942 bytes
-rwxr-xr-xmisc/dist/osx_tools.app/Contents/Info.plist (renamed from tools/dist/osx_tools.app/Contents/Info.plist)0
-rw-r--r--misc/dist/osx_tools.app/Contents/PkgInfo (renamed from tools/dist/osx_tools.app/Contents/PkgInfo)0
-rw-r--r--misc/dist/osx_tools.app/Contents/Resources/Godot.icns (renamed from tools/dist/osx_tools.app/Contents/Resources/Godot.icns)bin120942 -> 120942 bytes
-rw-r--r--misc/dist/uwp_template/AppxManifest.xml (renamed from tools/dist/uwp_template/AppxManifest.xml)0
-rw-r--r--misc/dist/uwp_template/Assets/SplashScreen.scale-100.png (renamed from tools/dist/uwp_template/Assets/SplashScreen.scale-100.png)bin14919 -> 14919 bytes
-rw-r--r--misc/dist/uwp_template/Assets/Square150x150Logo.scale-100.png (renamed from tools/dist/uwp_template/Assets/Square150x150Logo.scale-100.png)bin7001 -> 7001 bytes
-rw-r--r--misc/dist/uwp_template/Assets/Square310x310Logo.scale-100.png (renamed from tools/dist/uwp_template/Assets/Square310x310Logo.scale-100.png)bin14490 -> 14490 bytes
-rw-r--r--misc/dist/uwp_template/Assets/Square44x44Logo.scale-100.png (renamed from tools/dist/uwp_template/Assets/Square44x44Logo.scale-100.png)bin2067 -> 2067 bytes
-rw-r--r--misc/dist/uwp_template/Assets/Square71x71Logo.scale-100.png (renamed from tools/dist/uwp_template/Assets/Square71x71Logo.scale-100.png)bin3369 -> 3369 bytes
-rw-r--r--misc/dist/uwp_template/Assets/StoreLogo.scale-100.png (renamed from tools/dist/uwp_template/Assets/StoreLogo.scale-100.png)bin2339 -> 2339 bytes
-rw-r--r--misc/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png (renamed from tools/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png)bin7390 -> 7390 bytes
-rw-r--r--misc/scripts/addheader.py (renamed from tools/scripts/addheader.py)0
-rwxr-xr-xmisc/scripts/file-hex-array.py (renamed from tools/scripts/file-hex-array.py)0
-rw-r--r--misc/scripts/make_bmfhdr.py (renamed from tools/scripts/make_bmfhdr.py)0
-rw-r--r--misc/scripts/make_glwrapper.py (renamed from tools/scripts/make_glwrapper.py)0
-rw-r--r--misc/scripts/make_icons.sh (renamed from tools/scripts/make_icons.sh)0
-rw-r--r--misc/scripts/makeargs.py (renamed from tools/scripts/makeargs.py)0
-rw-r--r--misc/scripts/memsort.py (renamed from tools/scripts/memsort.py)0
-rw-r--r--misc/scripts/sort-demos.sh (renamed from tools/scripts/sort-demos.sh)4
-rw-r--r--misc/scripts/svgs_2_pngs.py (renamed from tools/scripts/svgs_2_pngs.py)0
-rw-r--r--modules/chibi/SCsub9
-rw-r--r--modules/chibi/cp_config.h52
-rw-r--r--modules/chibi/cp_envelope.cpp369
-rw-r--r--modules/chibi/cp_envelope.h129
-rw-r--r--modules/chibi/cp_file_access_wrapper.h96
-rw-r--r--modules/chibi/cp_instrument.cpp344
-rw-r--r--modules/chibi/cp_instrument.h219
-rw-r--r--modules/chibi/cp_loader.h64
-rw-r--r--modules/chibi/cp_loader_it.cpp216
-rw-r--r--modules/chibi/cp_loader_it.h125
-rw-r--r--modules/chibi/cp_loader_it_info.cpp268
-rw-r--r--modules/chibi/cp_loader_it_instruments.cpp224
-rw-r--r--modules/chibi/cp_loader_it_patterns.cpp166
-rw-r--r--modules/chibi/cp_loader_it_samples.cpp620
-rw-r--r--modules/chibi/cp_loader_mod.cpp482
-rw-r--r--modules/chibi/cp_loader_mod.h52
-rw-r--r--modules/chibi/cp_loader_s3m.cpp413
-rw-r--r--modules/chibi/cp_loader_s3m.h111
-rw-r--r--modules/chibi/cp_loader_xm.cpp752
-rw-r--r--modules/chibi/cp_loader_xm.h89
-rw-r--r--modules/chibi/cp_mixer.h115
-rw-r--r--modules/chibi/cp_note.h102
-rw-r--r--modules/chibi/cp_pattern.cpp574
-rw-r--r--modules/chibi/cp_pattern.h94
-rw-r--r--modules/chibi/cp_player_data.cpp151
-rw-r--r--modules/chibi/cp_player_data.h582
-rw-r--r--modules/chibi/cp_player_data_control.cpp324
-rw-r--r--modules/chibi/cp_player_data_effects.cpp1232
-rw-r--r--modules/chibi/cp_player_data_envelopes.cpp89
-rw-r--r--modules/chibi/cp_player_data_events.cpp679
-rw-r--r--modules/chibi/cp_player_data_filter.cpp89
-rw-r--r--modules/chibi/cp_player_data_nna.cpp144
-rw-r--r--modules/chibi/cp_player_data_notes.cpp345
-rw-r--r--modules/chibi/cp_player_data_utils.cpp138
-rw-r--r--modules/chibi/cp_sample.cpp203
-rw-r--r--modules/chibi/cp_sample.h112
-rw-r--r--modules/chibi/cp_sample_defs.h97
-rw-r--r--modules/chibi/cp_sample_manager.h99
-rw-r--r--modules/chibi/cp_song.cpp957
-rw-r--r--modules/chibi/cp_song.h261
-rw-r--r--modules/chibi/cp_tables.cpp254
-rw-r--r--modules/chibi/cp_tables.h67
-rw-r--r--modules/chibi/event_stream_chibi.cpp872
-rw-r--r--modules/chibi/event_stream_chibi.h314
-rw-r--r--modules/dds/texture_loader_dds.cpp14
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp18
-rw-r--r--modules/etc1/image_etc.cpp23
-rw-r--r--modules/etc1/texture_loader_pkm.cpp2
-rw-r--r--modules/gdscript/gd_compiler.cpp83
-rw-r--r--modules/gdscript/gd_compiler.h2
-rw-r--r--modules/gdscript/gd_editor.cpp41
-rw-r--r--modules/gdscript/gd_function.cpp119
-rw-r--r--modules/gdscript/gd_functions.cpp72
-rw-r--r--modules/gdscript/gd_parser.cpp675
-rw-r--r--modules/gdscript/gd_parser.h52
-rw-r--r--modules/gdscript/gd_script.cpp27
-rw-r--r--modules/gdscript/gd_script.h2
-rw-r--r--modules/gdscript/gd_tokenizer.cpp26
-rw-r--r--modules/gdscript/gd_tokenizer.h4
-rw-r--r--modules/gdscript/register_types.cpp11
-rw-r--r--modules/gridmap/config.py3
-rw-r--r--modules/gridmap/grid_map.cpp608
-rw-r--r--modules/gridmap/grid_map.h22
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp100
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h9
-rw-r--r--modules/gridmap/register_types.cpp2
-rw-r--r--modules/ogg/config.py3
-rw-r--r--modules/openssl/stream_peer_openssl.cpp18
-rw-r--r--modules/openssl/stream_peer_openssl.h8
-rw-r--r--modules/opus/audio_stream_opus.cpp2
-rw-r--r--modules/opus/config.py3
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp74
-rw-r--r--modules/regex/regex.cpp36
-rw-r--r--modules/regex/register_types.cpp2
-rw-r--r--modules/squish/image_compress_squish.cpp11
-rw-r--r--modules/stb_vorbis/SCsub10
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp232
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h83
-rw-r--r--modules/stb_vorbis/config.py (renamed from modules/chibi/config.py)0
-rw-r--r--modules/stb_vorbis/register_types.cpp (renamed from modules/chibi/cp_order.h)26
-rw-r--r--modules/stb_vorbis/register_types.h (renamed from modules/chibi/register_types.h)4
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp84
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.h28
-rw-r--r--modules/theora/config.py3
-rw-r--r--modules/theora/video_stream_theora.cpp13
-rw-r--r--modules/theora/yuv2rgb.h3
-rw-r--r--modules/visual_script/register_types.cpp2
-rw-r--r--modules/visual_script/visual_script.cpp118
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp76
-rw-r--r--modules/visual_script/visual_script_editor.cpp28
-rw-r--r--modules/visual_script/visual_script_editor.h2
-rw-r--r--modules/visual_script/visual_script_expression.cpp6
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp32
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp174
-rw-r--r--modules/visual_script/visual_script_nodes.cpp192
-rw-r--r--modules/visual_script/visual_script_nodes.h4
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp36
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp6
-rw-r--r--modules/vorbis/config.py3
-rw-r--r--modules/webm/config.py3
-rw-r--r--modules/webm/video_stream_webm.cpp4
-rw-r--r--modules/webp/SCsub188
-rw-r--r--platform/android/audio_driver_jandroid.cpp10
-rw-r--r--platform/android/audio_driver_jandroid.h7
-rw-r--r--platform/android/audio_driver_opensl.cpp17
-rw-r--r--platform/android/audio_driver_opensl.h12
-rw-r--r--platform/android/build.gradle.template3
-rw-r--r--platform/android/dir_access_android.cpp8
-rw-r--r--platform/android/dir_access_android.h2
-rw-r--r--platform/android/dir_access_jandroid.cpp8
-rw-r--r--platform/android/dir_access_jandroid.h2
-rw-r--r--platform/android/export/export.cpp35
-rw-r--r--platform/android/file_access_jandroid.cpp2
-rw-r--r--platform/android/globals/global_defaults.cpp4
-rw-r--r--platform/android/godot_android.cpp50
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java30
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java49
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java16
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java4
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java22
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java4
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java22
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java14
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java10
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java14
-rw-r--r--platform/android/java_class_wrapper.cpp4
-rw-r--r--platform/android/java_glue.cpp14
-rw-r--r--platform/android/os_android.cpp32
-rw-r--r--platform/android/os_android.h21
-rw-r--r--platform/bb10/audio_driver_bb10.cpp14
-rw-r--r--platform/bb10/audio_driver_bb10.h8
-rw-r--r--platform/bb10/bbutil.c2
-rw-r--r--platform/bb10/bbutil.h6
-rw-r--r--platform/bb10/export/export.cpp13
-rw-r--r--platform/bb10/os_bb10.cpp55
-rw-r--r--platform/bb10/os_bb10.h12
-rw-r--r--platform/bb10/payment_service.cpp8
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp8
-rw-r--r--platform/haiku/audio_driver_media_kit.h8
-rw-r--r--platform/haiku/haiku_direct_window.cpp14
-rw-r--r--platform/haiku/os_haiku.cpp34
-rw-r--r--platform/haiku/os_haiku.h10
-rw-r--r--platform/iphone/app_delegate.h6
-rw-r--r--platform/iphone/app_delegate.mm99
-rw-r--r--platform/iphone/audio_driver_iphone.cpp4
-rw-r--r--platform/iphone/audio_driver_iphone.h7
-rw-r--r--platform/iphone/detect.py11
-rw-r--r--platform/iphone/game_center.mm38
-rwxr-xr-xplatform/iphone/gl_view.mm4
-rwxr-xr-xplatform/iphone/globals/global_defaults.cpp2
-rw-r--r--platform/iphone/icloud.mm28
-rw-r--r--platform/iphone/in_app_store.mm26
-rw-r--r--platform/iphone/ios.mm2
-rw-r--r--platform/iphone/os_iphone.cpp76
-rw-r--r--platform/iphone/os_iphone.h19
-rw-r--r--platform/iphone/platform_config.h4
-rw-r--r--platform/iphone/rasterizer_iphone.cpp2
-rw-r--r--platform/iphone/rasterizer_iphone.h4
-rw-r--r--platform/javascript/SCsub40
-rw-r--r--platform/javascript/audio_driver_javascript.cpp31
-rw-r--r--platform/javascript/audio_driver_javascript.h8
-rw-r--r--platform/javascript/audio_server_javascript.cpp197
-rw-r--r--platform/javascript/audio_server_javascript.h4
-rw-r--r--platform/javascript/detect.py66
-rw-r--r--platform/javascript/export/export.cpp34
-rw-r--r--platform/javascript/godot_shell.html381
-rw-r--r--platform/javascript/javascript_eval.cpp9
-rw-r--r--platform/javascript/javascript_main.cpp51
-rw-r--r--platform/javascript/os_javascript.cpp112
-rw-r--r--platform/javascript/os_javascript.h14
-rw-r--r--platform/osx/audio_driver_osx.cpp4
-rw-r--r--platform/osx/audio_driver_osx.h6
-rw-r--r--platform/osx/export/export.cpp13
-rw-r--r--platform/osx/joypad_osx.cpp17
-rw-r--r--platform/osx/joypad_osx.h3
-rw-r--r--platform/osx/os_osx.h11
-rw-r--r--platform/osx/os_osx.mm134
-rw-r--r--platform/server/os_server.cpp14
-rw-r--r--platform/server/os_server.h13
-rw-r--r--platform/uwp/app.h72
-rw-r--r--platform/uwp/export/export.cpp33
-rw-r--r--platform/uwp/joypad_uwp.h4
-rw-r--r--platform/uwp/os_uwp.cpp51
-rw-r--r--platform/uwp/os_uwp.h22
-rw-r--r--platform/windows/context_gl_win.cpp2
-rw-r--r--platform/windows/export/export.cpp6
-rw-r--r--platform/windows/joypad.cpp16
-rw-r--r--platform/windows/joypad.h1
-rw-r--r--platform/windows/os_windows.cpp161
-rw-r--r--platform/windows/os_windows.h22
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp37
-rw-r--r--platform/windows/packet_peer_udp_winsock.h5
-rw-r--r--platform/windows/stream_peer_winsock.cpp58
-rw-r--r--platform/windows/stream_peer_winsock.h11
-rw-r--r--platform/windows/tcp_server_winsock.cpp21
-rw-r--r--platform/windows/tcp_server_winsock.h3
-rw-r--r--platform/x11/context_gl_x11.cpp9
-rw-r--r--platform/x11/context_gl_x11.h2
-rw-r--r--platform/x11/detect.py25
-rw-r--r--platform/x11/export/export.cpp20
-rw-r--r--platform/x11/godot_x11.cpp10
-rw-r--r--platform/x11/joypad_linux.cpp11
-rw-r--r--platform/x11/joypad_linux.h1
-rw-r--r--platform/x11/key_mapping_x11.cpp4
-rw-r--r--platform/x11/os_x11.cpp180
-rw-r--r--platform/x11/os_x11.h12
-rw-r--r--prop_renames.txt524
-rw-r--r--scene/2d/animated_sprite.cpp102
-rw-r--r--scene/2d/area_2d.cpp108
-rw-r--r--scene/2d/area_2d.h4
-rw-r--r--scene/2d/back_buffer_copy.cpp12
-rw-r--r--scene/2d/camera_2d.cpp129
-rw-r--r--scene/2d/canvas_item.cpp251
-rw-r--r--scene/2d/canvas_item.h12
-rw-r--r--scene/2d/canvas_modulate.cpp14
-rw-r--r--scene/2d/collision_object_2d.cpp39
-rw-r--r--scene/2d/collision_polygon_2d.cpp31
-rw-r--r--scene/2d/collision_shape_2d.cpp25
-rw-r--r--scene/2d/joints_2d.cpp66
-rw-r--r--scene/2d/light_2d.cpp123
-rw-r--r--scene/2d/light_occluder_2d.cpp35
-rw-r--r--scene/2d/line_2d.cpp307
-rw-r--r--scene/2d/line_2d.h80
-rw-r--r--scene/2d/line_builder.cpp563
-rw-r--r--scene/2d/line_builder.h76
-rw-r--r--scene/2d/navigation2d.cpp18
-rw-r--r--scene/2d/navigation_polygon.cpp63
-rw-r--r--scene/2d/node_2d.cpp94
-rw-r--r--scene/2d/parallax_background.cpp38
-rw-r--r--scene/2d/parallax_layer.cpp18
-rw-r--r--scene/2d/particles_2d.cpp256
-rw-r--r--scene/2d/particles_2d.h14
-rw-r--r--scene/2d/path_2d.cpp38
-rw-r--r--scene/2d/physics_body_2d.cpp263
-rw-r--r--scene/2d/physics_body_2d.h8
-rw-r--r--scene/2d/polygon_2d.cpp70
-rw-r--r--scene/2d/ray_cast_2d.cpp52
-rw-r--r--scene/2d/remote_transform_2d.cpp8
-rw-r--r--scene/2d/sample_player_2d.cpp263
-rw-r--r--scene/2d/sample_player_2d.h94
-rw-r--r--scene/2d/screen_button.cpp257
-rw-r--r--scene/2d/screen_button.h15
-rw-r--r--scene/2d/sound_player_2d.cpp125
-rw-r--r--scene/2d/sprite.cpp98
-rw-r--r--scene/2d/sprite.h4
-rw-r--r--scene/2d/tile_map.cpp170
-rw-r--r--scene/2d/tile_map.h7
-rw-r--r--scene/2d/visibility_notifier_2d.cpp27
-rw-r--r--scene/2d/y_sort.cpp6
-rw-r--r--scene/3d/area.cpp108
-rw-r--r--scene/3d/area.h4
-rw-r--r--scene/3d/baked_light_instance.cpp61
-rw-r--r--scene/3d/body_shape.cpp32
-rw-r--r--scene/3d/bone_attachment.cpp8
-rw-r--r--scene/3d/camera.cpp87
-rw-r--r--scene/3d/character_camera.cpp52
-rw-r--r--scene/3d/collision_object.cpp43
-rw-r--r--scene/3d/collision_polygon.cpp30
-rw-r--r--scene/3d/gi_probe.cpp287
-rw-r--r--scene/3d/gi_probe.h18
-rw-r--r--scene/3d/immediate_geometry.cpp20
-rw-r--r--scene/3d/interpolated_camera.cpp20
-rw-r--r--scene/3d/light.cpp103
-rw-r--r--scene/3d/light.h1
-rw-r--r--scene/3d/listener.cpp9
-rw-r--r--scene/3d/mesh_instance.cpp22
-rw-r--r--scene/3d/multimesh_instance.cpp6
-rw-r--r--scene/3d/navigation.cpp28
-rw-r--r--scene/3d/navigation_mesh.cpp35
-rw-r--r--scene/3d/particles.cpp136
-rw-r--r--scene/3d/path.cpp36
-rw-r--r--scene/3d/physics_body.cpp261
-rw-r--r--scene/3d/physics_body.h8
-rw-r--r--scene/3d/physics_joint.cpp349
-rw-r--r--scene/3d/portal.cpp22
-rw-r--r--scene/3d/proximity_group.cpp17
-rw-r--r--scene/3d/quad.cpp24
-rw-r--r--scene/3d/ray_cast.cpp46
-rw-r--r--scene/3d/reflection_probe.cpp72
-rw-r--r--scene/3d/remote_transform.cpp7
-rw-r--r--scene/3d/room_instance.cpp53
-rw-r--r--scene/3d/room_instance.h10
-rw-r--r--scene/3d/scenario_fx.cpp8
-rw-r--r--scene/3d/skeleton.cpp48
-rw-r--r--scene/3d/spatial.cpp162
-rw-r--r--scene/3d/spatial.h12
-rw-r--r--scene/3d/spatial_indexer.cpp2
-rw-r--r--scene/3d/spatial_player.cpp134
-rw-r--r--scene/3d/spatial_player.h87
-rw-r--r--scene/3d/spatial_sample_player.cpp241
-rw-r--r--scene/3d/spatial_sample_player.h90
-rw-r--r--scene/3d/spatial_stream_player.cpp403
-rw-r--r--scene/3d/spatial_stream_player.h120
-rw-r--r--scene/3d/sprite_3d.cpp160
-rw-r--r--scene/3d/sprite_3d.h4
-rw-r--r--scene/3d/vehicle_body.cpp115
-rw-r--r--scene/3d/vehicle_body.h2
-rw-r--r--scene/3d/visibility_notifier.cpp19
-rw-r--r--scene/3d/visual_instance.cpp79
-rw-r--r--scene/animation/animation_cache.cpp6
-rw-r--r--scene/animation/animation_player.cpp150
-rw-r--r--scene/animation/animation_player.h6
-rw-r--r--scene/animation/animation_tree_player.cpp152
-rw-r--r--scene/animation/animation_tree_player.h6
-rw-r--r--scene/animation/tween.cpp164
-rw-r--r--scene/animation/tween.h22
-rw-r--r--scene/animation/tween_interpolaters.cpp3
-rw-r--r--scene/audio/audio_player.cpp301
-rw-r--r--scene/audio/audio_player.h75
-rw-r--r--scene/audio/event_player.cpp357
-rw-r--r--scene/audio/event_player.h109
-rw-r--r--scene/audio/sample_player.cpp718
-rw-r--r--scene/audio/sample_player.h200
-rw-r--r--scene/audio/sound_room_params.cpp180
-rw-r--r--scene/audio/sound_room_params.h100
-rw-r--r--scene/audio/stream_player.cpp424
-rw-r--r--scene/audio/stream_player.h124
-rw-r--r--scene/gui/base_button.cpp78
-rw-r--r--scene/gui/base_button.h16
-rw-r--r--scene/gui/box_container.cpp20
-rw-r--r--scene/gui/button.cpp45
-rw-r--r--scene/gui/button_array.cpp52
-rw-r--r--scene/gui/button_array.h1
-rw-r--r--scene/gui/button_group.cpp12
-rw-r--r--scene/gui/center_container.cpp8
-rw-r--r--scene/gui/color_picker.cpp88
-rw-r--r--scene/gui/color_picker.h14
-rw-r--r--scene/gui/color_ramp_edit.cpp6
-rw-r--r--scene/gui/color_rect.cpp47
-rw-r--r--scene/gui/color_rect.h40
-rw-r--r--scene/gui/container.cpp10
-rw-r--r--scene/gui/control.cpp280
-rw-r--r--scene/gui/dialogs.cpp285
-rw-r--r--scene/gui/dialogs.h22
-rw-r--r--scene/gui/file_dialog.cpp90
-rw-r--r--scene/gui/graph_edit.cpp60
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/graph_node.cpp88
-rw-r--r--scene/gui/graph_node.h5
-rw-r--r--scene/gui/grid_container.cpp16
-rw-r--r--scene/gui/input_action.cpp12
-rw-r--r--scene/gui/item_list.cpp128
-rw-r--r--scene/gui/item_list.h1
-rw-r--r--scene/gui/label.cpp70
-rw-r--r--scene/gui/line_edit.cpp90
-rw-r--r--scene/gui/link_button.cpp12
-rw-r--r--scene/gui/margin_container.cpp2
-rw-r--r--scene/gui/menu_button.cpp16
-rw-r--r--scene/gui/option_button.cpp58
-rw-r--r--scene/gui/panel_container.cpp4
-rw-r--r--scene/gui/patch_9_rect.cpp (renamed from scene/gui/patch_9_frame.cpp)68
-rw-r--r--scene/gui/patch_9_rect.h (renamed from scene/gui/patch_9_frame.h)10
-rw-r--r--scene/gui/popup.cpp30
-rw-r--r--scene/gui/popup.h4
-rw-r--r--scene/gui/popup_menu.cpp120
-rw-r--r--scene/gui/progress_bar.cpp10
-rw-r--r--scene/gui/range.cpp84
-rw-r--r--scene/gui/range.h14
-rw-r--r--scene/gui/reference_rect.cpp (renamed from scene/gui/reference_frame.cpp)8
-rw-r--r--scene/gui/reference_rect.h (renamed from scene/gui/reference_frame.h)14
-rw-r--r--scene/gui/rich_text_label.cpp143
-rw-r--r--scene/gui/rich_text_label.h4
-rw-r--r--scene/gui/scroll_bar.cpp52
-rw-r--r--scene/gui/scroll_container.cpp46
-rw-r--r--scene/gui/separator.h2
-rw-r--r--scene/gui/slider.cpp40
-rw-r--r--scene/gui/spin_box.cpp46
-rw-r--r--scene/gui/split_container.cpp22
-rw-r--r--scene/gui/tab_container.cpp779
-rw-r--r--scene/gui/tab_container.h7
-rw-r--r--scene/gui/tabs.cpp70
-rw-r--r--scene/gui/tabs.h4
-rw-r--r--scene/gui/text_edit.cpp202
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/gui/texture_button.cpp184
-rw-r--r--scene/gui/texture_button.h29
-rw-r--r--scene/gui/texture_progress.cpp59
-rw-r--r--scene/gui/texture_rect.cpp (renamed from scene/gui/texture_frame.cpp)64
-rw-r--r--scene/gui/texture_rect.h (renamed from scene/gui/texture_frame.h)14
-rw-r--r--scene/gui/tree.cpp297
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/gui/video_player.cpp77
-rw-r--r--scene/gui/video_player.h6
-rw-r--r--scene/gui/viewport_container.cpp8
-rw-r--r--scene/io/resource_format_image.cpp9
-rw-r--r--scene/io/resource_format_image.h3
-rw-r--r--scene/io/resource_format_wav.cpp4
-rw-r--r--scene/io/resource_format_wav.h2
-rw-r--r--scene/main/canvas_layer.cpp50
-rw-r--r--scene/main/http_request.cpp43
-rw-r--r--scene/main/http_request.h1
-rw-r--r--scene/main/instance_placeholder.cpp6
-rw-r--r--scene/main/node.cpp254
-rw-r--r--scene/main/node.h22
-rw-r--r--scene/main/resource_preloader.cpp18
-rw-r--r--scene/main/scene_main_loop.cpp222
-rw-r--r--scene/main/scene_main_loop.h20
-rw-r--r--scene/main/timer.cpp34
-rw-r--r--scene/main/viewport.cpp401
-rw-r--r--scene/main/viewport.h4
-rw-r--r--scene/register_scene_types.cpp92
-rw-r--r--scene/resources/animation.cpp85
-rw-r--r--scene/resources/audio_stream_resampled.cpp2
-rw-r--r--scene/resources/audio_stream_resampled.h2
-rw-r--r--scene/resources/audio_stream_sample.cpp557
-rw-r--r--scene/resources/audio_stream_sample.h128
-rw-r--r--scene/resources/bit_mask.cpp20
-rw-r--r--scene/resources/bounds.cpp6
-rw-r--r--scene/resources/box_shape.cpp6
-rw-r--r--scene/resources/capsule_shape.cpp16
-rw-r--r--scene/resources/capsule_shape_2d.cpp12
-rw-r--r--scene/resources/circle_shape_2d.cpp6
-rw-r--r--scene/resources/color_ramp.cpp36
-rw-r--r--scene/resources/concave_polygon_shape.cpp4
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp6
-rw-r--r--scene/resources/convex_polygon_shape.cpp6
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp8
-rw-r--r--scene/resources/curve.cpp168
-rw-r--r--scene/resources/default_theme/default_theme.cpp39
-rw-r--r--scene/resources/default_theme/theme_data.h10
-rw-r--r--scene/resources/default_theme/vslider_grabber.pngbin554 -> 394 bytes
-rw-r--r--scene/resources/default_theme/vslider_grabber_hl.pngbin701 -> 439 bytes
-rw-r--r--scene/resources/dynamic_font.cpp58
-rw-r--r--scene/resources/dynamic_font_stb.cpp14
-rw-r--r--scene/resources/environment.cpp356
-rw-r--r--scene/resources/event_stream.cpp85
-rw-r--r--scene/resources/event_stream.h118
-rw-r--r--scene/resources/font.cpp76
-rw-r--r--scene/resources/gibberish_stream.cpp24
-rw-r--r--scene/resources/material.cpp250
-rw-r--r--scene/resources/mesh.cpp54
-rw-r--r--scene/resources/mesh_data_tool.cpp76
-rw-r--r--scene/resources/mesh_library.cpp26
-rw-r--r--scene/resources/multimesh.cpp56
-rw-r--r--scene/resources/packed_scene.cpp88
-rw-r--r--scene/resources/packed_scene.h4
-rw-r--r--scene/resources/plane_shape.cpp6
-rw-r--r--scene/resources/polygon_path_finder.cpp24
-rw-r--r--scene/resources/ray_shape.cpp6
-rw-r--r--scene/resources/rectangle_shape_2d.cpp6
-rw-r--r--scene/resources/room.cpp8
-rw-r--r--scene/resources/sample.cpp248
-rw-r--r--scene/resources/sample.h108
-rw-r--r--scene/resources/sample_library.cpp215
-rw-r--r--scene/resources/sample_library.h78
-rw-r--r--scene/resources/scene_format_text.cpp37
-rw-r--r--scene/resources/scene_format_text.h2
-rw-r--r--scene/resources/segment_shape_2d.cpp18
-rw-r--r--scene/resources/shader.cpp16
-rw-r--r--scene/resources/shader_graph.cpp163
-rw-r--r--scene/resources/shape_2d.cpp16
-rw-r--r--scene/resources/shape_line_2d.cpp12
-rw-r--r--scene/resources/sky_box.cpp22
-rw-r--r--scene/resources/space_2d.cpp6
-rw-r--r--scene/resources/sphere_shape.cpp10
-rw-r--r--scene/resources/style_box.cpp114
-rw-r--r--scene/resources/surface_tool.cpp48
-rw-r--r--scene/resources/texture.cpp509
-rw-r--r--scene/resources/texture.h85
-rw-r--r--scene/resources/theme.cpp100
-rw-r--r--scene/resources/tile_set.cpp81
-rw-r--r--scene/resources/tile_set.h7
-rw-r--r--scene/resources/world.cpp19
-rw-r--r--scene/resources/world.h3
-rw-r--r--scene/resources/world_2d.cpp22
-rw-r--r--scene/resources/world_2d.h2
-rw-r--r--scene/scene_string_names.cpp2
-rw-r--r--scene/scene_string_names.h1
-rw-r--r--servers/audio/SCsub2
-rw-r--r--servers/audio/audio_driver_dummy.cpp10
-rw-r--r--servers/audio/audio_driver_dummy.h8
-rw-r--r--servers/audio/audio_effect.cpp6
-rw-r--r--servers/audio/audio_effect.h26
-rw-r--r--servers/audio/audio_filter_sw.cpp4
-rw-r--r--servers/audio/audio_filter_sw.h2
-rw-r--r--servers/audio/audio_mixer_sw.cpp1222
-rw-r--r--servers/audio/audio_mixer_sw.h264
-rw-r--r--servers/audio/audio_server_sw.cpp1028
-rw-r--r--servers/audio/audio_server_sw.h286
-rw-r--r--servers/audio/audio_stream.cpp (renamed from scene/resources/audio_stream.cpp)57
-rw-r--r--servers/audio/audio_stream.h (renamed from scene/resources/audio_stream.h)60
-rw-r--r--servers/audio/effects/SCsub (renamed from servers/spatial_sound/SCsub)0
-rw-r--r--servers/audio/effects/audio_effect_amplify.cpp50
-rw-r--r--servers/audio/effects/audio_effect_amplify.h40
-rw-r--r--servers/audio/effects/audio_effect_chorus.cpp365
-rw-r--r--servers/audio/effects/audio_effect_chorus.h115
-rw-r--r--servers/audio/effects/audio_effect_compressor.cpp227
-rw-r--r--servers/audio/effects/audio_effect_compressor.h70
-rw-r--r--servers/audio/effects/audio_effect_delay.cpp326
-rw-r--r--servers/audio/effects/audio_effect_delay.h112
-rw-r--r--servers/audio/effects/audio_effect_distortion.cpp171
-rw-r--r--servers/audio/effects/audio_effect_distortion.h69
-rw-r--r--servers/audio/effects/audio_effect_eq.cpp122
-rw-r--r--servers/audio/effects/audio_effect_eq.h72
-rw-r--r--servers/audio/effects/audio_effect_filter.cpp151
-rw-r--r--servers/audio/effects/audio_effect_filter.h125
-rw-r--r--servers/audio/effects/audio_effect_limiter.cpp124
-rw-r--r--servers/audio/effects/audio_effect_limiter.h58
-rw-r--r--servers/audio/effects/audio_effect_panner.cpp47
-rw-r--r--servers/audio/effects/audio_effect_panner.h40
-rw-r--r--servers/audio/effects/audio_effect_phaser.cpp148
-rw-r--r--servers/audio/effects/audio_effect_phaser.h81
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.cpp298
-rw-r--r--servers/audio/effects/audio_effect_pitch_shift.h89
-rw-r--r--servers/audio/effects/audio_effect_reverb.cpp182
-rw-r--r--servers/audio/effects/audio_effect_reverb.h76
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.cpp135
-rw-r--r--servers/audio/effects/audio_effect_stereo_enhance.h62
-rw-r--r--servers/audio/effects/eq.cpp219
-rw-r--r--servers/audio/effects/eq.h106
-rw-r--r--servers/audio/effects/reverb.cpp364
-rw-r--r--servers/audio/effects/reverb.h111
-rw-r--r--servers/audio/reverb_sw.cpp116
-rw-r--r--servers/audio/sample_manager_sw.cpp320
-rw-r--r--servers/audio/sample_manager_sw.h129
-rw-r--r--servers/audio_server.cpp1233
-rw-r--r--servers/audio_server.h409
-rw-r--r--servers/physics/area_pair_sw.cpp10
-rw-r--r--servers/physics/area_pair_sw.h8
-rw-r--r--servers/physics/area_sw.cpp16
-rw-r--r--servers/physics/area_sw.h30
-rw-r--r--servers/physics/body_pair_sw.cpp18
-rw-r--r--servers/physics/body_pair_sw.h6
-rw-r--r--servers/physics/body_sw.cpp76
-rw-r--r--servers/physics/body_sw.h22
-rw-r--r--servers/physics/broad_phase_sw.h2
-rw-r--r--servers/physics/collision_solver_sat.cpp68
-rw-r--r--servers/physics/collision_solver_sat.h2
-rw-r--r--servers/physics/collision_solver_sw.cpp20
-rw-r--r--servers/physics/collision_solver_sw.h4
-rw-r--r--servers/physics/constraint_sw.h4
-rw-r--r--servers/physics/joints/cone_twist_joint_sw.cpp10
-rw-r--r--servers/physics/joints/cone_twist_joint_sw.h8
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.cpp81
-rw-r--r--servers/physics/joints/generic_6dof_joint_sw.h8
-rw-r--r--servers/physics/joints/hinge_joint_sw.cpp18
-rw-r--r--servers/physics/joints/hinge_joint_sw.h8
-rw-r--r--servers/physics/joints/pin_joint_sw.cpp12
-rw-r--r--servers/physics/joints/pin_joint_sw.h8
-rw-r--r--servers/physics/joints/slider_joint_sw.cpp6
-rw-r--r--servers/physics/joints/slider_joint_sw.h8
-rw-r--r--servers/physics/physics_server_sw.cpp52
-rw-r--r--servers/physics/physics_server_sw.h32
-rw-r--r--servers/physics/shape_sw.cpp120
-rw-r--r--servers/physics/shape_sw.h44
-rw-r--r--servers/physics/space_sw.cpp30
-rw-r--r--servers/physics/space_sw.h18
-rw-r--r--servers/physics/step_sw.cpp10
-rw-r--r--servers/physics/step_sw.h8
-rw-r--r--servers/physics_2d/area_2d_sw.cpp16
-rw-r--r--servers/physics_2d/area_2d_sw.h30
-rw-r--r--servers/physics_2d/area_pair_2d_sw.cpp8
-rw-r--r--servers/physics_2d/area_pair_2d_sw.h8
-rw-r--r--servers/physics_2d/body_2d_sw.cpp62
-rw-r--r--servers/physics_2d/body_2d_sw.h24
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp14
-rw-r--r--servers/physics_2d/body_pair_2d_sw.h8
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp22
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp58
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.h2
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp20
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.h4
-rw-r--r--servers/physics_2d/constraint_2d_sw.h4
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp22
-rw-r--r--servers/physics_2d/joints_2d_sw.h16
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp46
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h24
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp8
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h24
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp60
-rw-r--r--servers/physics_2d/shape_2d_sw.h28
-rw-r--r--servers/physics_2d/space_2d_sw.cpp89
-rw-r--r--servers/physics_2d/space_2d_sw.h18
-rw-r--r--servers/physics_2d/step_2d_sw.cpp10
-rw-r--r--servers/physics_2d/step_2d_sw.h8
-rw-r--r--servers/physics_2d_server.cpp318
-rw-r--r--servers/physics_server.cpp352
-rw-r--r--servers/physics_server.h4
-rw-r--r--servers/register_server_types.cpp58
-rw-r--r--servers/spatial_sound/spatial_sound_server_sw.cpp1071
-rw-r--r--servers/spatial_sound/spatial_sound_server_sw.h266
-rw-r--r--servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp1042
-rw-r--r--servers/spatial_sound_2d/spatial_sound_2d_server_sw.h265
-rw-r--r--servers/spatial_sound_2d_server.cpp44
-rw-r--r--servers/spatial_sound_2d_server.h164
-rw-r--r--servers/spatial_sound_server.cpp44
-rw-r--r--servers/spatial_sound_server.h168
-rw-r--r--servers/visual/rasterizer.cpp2
-rw-r--r--servers/visual/rasterizer.h13
-rw-r--r--servers/visual/shader_language.cpp12
-rw-r--r--servers/visual/shader_language.h2
-rw-r--r--servers/visual/visual_server_canvas.cpp10
-rw-r--r--servers/visual/visual_server_raster.cpp55
-rw-r--r--servers/visual/visual_server_raster.h11
-rw-r--r--servers/visual/visual_server_scene.cpp65
-rw-r--r--servers/visual/visual_server_scene.h3
-rw-r--r--servers/visual/visual_server_viewport.cpp6
-rw-r--r--servers/visual_server.cpp28
-rw-r--r--servers/visual_server.h16
-rw-r--r--thirdparty/README.md22
-rw-r--r--thirdparty/certs/ca-certificates.crt (renamed from tools/certs/ca-certificates.crt)0
-rw-r--r--thirdparty/fonts/DroidSans.ttf (renamed from tools/editor_fonts/DroidSans.ttf)bin190044 -> 190044 bytes
-rw-r--r--thirdparty/fonts/DroidSansArabic.ttf (renamed from tools/editor_fonts/DroidSansArabic.ttf)bin35908 -> 35908 bytes
-rw-r--r--thirdparty/fonts/DroidSansFallback.ttf (renamed from tools/editor_fonts/DroidSansFallback.ttf)bin3640264 -> 3640264 bytes
-rw-r--r--thirdparty/fonts/DroidSansHebrew.ttf (renamed from tools/editor_fonts/DroidSansHebrew.ttf)bin23076 -> 23076 bytes
-rw-r--r--thirdparty/fonts/DroidSansJapanese.ttf (renamed from tools/editor_fonts/DroidSansJapanese.ttf)bin1173140 -> 1173140 bytes
-rw-r--r--thirdparty/fonts/DroidSansThai.ttf (renamed from tools/editor_fonts/DroidSansThai.ttf)bin36028 -> 36028 bytes
-rw-r--r--thirdparty/fonts/LICENSE.DroidSans.txt (renamed from tools/editor_fonts/LICENSE.DroidSans.txt)0
-rw-r--r--thirdparty/fonts/LICENSE.SourceCodePro.txt (renamed from tools/editor_fonts/LICENSE.SourceCodePro.txt)0
-rw-r--r--thirdparty/fonts/source_code_pro.otf (renamed from tools/editor_fonts/source_code_pro.otf)bin140088 -> 140088 bytes
-rw-r--r--thirdparty/libwebp/dec/alpha_dec.c (renamed from thirdparty/libwebp/dec/alpha.c)8
-rw-r--r--thirdparty/libwebp/dec/alphai_dec.h (renamed from thirdparty/libwebp/dec/alphai.h)4
-rw-r--r--thirdparty/libwebp/dec/buffer_dec.c (renamed from thirdparty/libwebp/dec/buffer.c)4
-rw-r--r--thirdparty/libwebp/dec/common_dec.h (renamed from thirdparty/libwebp/dec/common.h)0
-rw-r--r--thirdparty/libwebp/dec/frame_dec.c (renamed from thirdparty/libwebp/dec/frame.c)4
-rw-r--r--thirdparty/libwebp/dec/idec_dec.c (renamed from thirdparty/libwebp/dec/idec.c)6
-rw-r--r--thirdparty/libwebp/dec/io_dec.c (renamed from thirdparty/libwebp/dec/io.c)113
-rw-r--r--thirdparty/libwebp/dec/quant_dec.c (renamed from thirdparty/libwebp/dec/quant.c)2
-rw-r--r--thirdparty/libwebp/dec/tree_dec.c (renamed from thirdparty/libwebp/dec/tree.c)7
-rw-r--r--thirdparty/libwebp/dec/vp8_dec.c (renamed from thirdparty/libwebp/dec/vp8.c)72
-rw-r--r--thirdparty/libwebp/dec/vp8_dec.h (renamed from thirdparty/libwebp/dec/decode_vp8.h)0
-rw-r--r--thirdparty/libwebp/dec/vp8i_dec.h (renamed from thirdparty/libwebp/dec/vp8i.h)14
-rw-r--r--thirdparty/libwebp/dec/vp8l_dec.c (renamed from thirdparty/libwebp/dec/vp8l.c)37
-rw-r--r--thirdparty/libwebp/dec/vp8li_dec.h (renamed from thirdparty/libwebp/dec/vp8li.h)8
-rw-r--r--thirdparty/libwebp/dec/webp_dec.c (renamed from thirdparty/libwebp/dec/webp.c)17
-rw-r--r--thirdparty/libwebp/dec/webpi_dec.h (renamed from thirdparty/libwebp/dec/webpi.h)17
-rw-r--r--thirdparty/libwebp/demux/demux.c5
-rw-r--r--thirdparty/libwebp/dsp/alpha_processing.c38
-rw-r--r--thirdparty/libwebp/dsp/alpha_processing_neon.c191
-rw-r--r--thirdparty/libwebp/dsp/alpha_processing_sse2.c141
-rw-r--r--thirdparty/libwebp/dsp/common_sse2.h85
-rw-r--r--thirdparty/libwebp/dsp/cost.c2
-rw-r--r--thirdparty/libwebp/dsp/cost_mips32.c2
-rw-r--r--thirdparty/libwebp/dsp/cost_mips_dsp_r2.c2
-rw-r--r--thirdparty/libwebp/dsp/cost_sse2.c4
-rw-r--r--thirdparty/libwebp/dsp/cpu.c45
-rw-r--r--thirdparty/libwebp/dsp/dec.c2
-rw-r--r--thirdparty/libwebp/dsp/dec_clip_tables.c8
-rw-r--r--thirdparty/libwebp/dsp/dec_msa.c847
-rw-r--r--thirdparty/libwebp/dsp/dec_neon.c40
-rw-r--r--thirdparty/libwebp/dsp/dec_sse2.c4
-rw-r--r--thirdparty/libwebp/dsp/dec_sse41.c2
-rw-r--r--thirdparty/libwebp/dsp/dsp.h57
-rw-r--r--thirdparty/libwebp/dsp/enc.c178
-rw-r--r--thirdparty/libwebp/dsp/enc_mips32.c4
-rw-r--r--thirdparty/libwebp/dsp/enc_mips_dsp_r2.c4
-rw-r--r--thirdparty/libwebp/dsp/enc_msa.c892
-rw-r--r--thirdparty/libwebp/dsp/enc_neon.c42
-rw-r--r--thirdparty/libwebp/dsp/enc_sse2.c182
-rw-r--r--thirdparty/libwebp/dsp/enc_sse41.c2
-rw-r--r--thirdparty/libwebp/dsp/filters.c12
-rw-r--r--thirdparty/libwebp/dsp/filters_msa.c202
-rw-r--r--thirdparty/libwebp/dsp/filters_neon.c327
-rw-r--r--thirdparty/libwebp/dsp/lossless.c186
-rw-r--r--thirdparty/libwebp/dsp/lossless.h225
-rw-r--r--thirdparty/libwebp/dsp/lossless_common.h210
-rw-r--r--thirdparty/libwebp/dsp/lossless_enc.c953
-rw-r--r--thirdparty/libwebp/dsp/lossless_enc_mips32.c47
-rw-r--r--thirdparty/libwebp/dsp/lossless_enc_msa.c147
-rw-r--r--thirdparty/libwebp/dsp/lossless_enc_sse2.c320
-rw-r--r--thirdparty/libwebp/dsp/lossless_enc_sse41.c4
-rw-r--r--thirdparty/libwebp/dsp/lossless_mips_dsp_r2.c79
-rw-r--r--thirdparty/libwebp/dsp/lossless_msa.c355
-rw-r--r--thirdparty/libwebp/dsp/lossless_neon.c395
-rw-r--r--thirdparty/libwebp/dsp/lossless_sse2.c389
-rw-r--r--thirdparty/libwebp/dsp/msa_macro.h1097
-rw-r--r--thirdparty/libwebp/dsp/neon.h18
-rw-r--r--thirdparty/libwebp/dsp/rescaler.c8
-rw-r--r--thirdparty/libwebp/dsp/rescaler_mips32.c2
-rw-r--r--thirdparty/libwebp/dsp/rescaler_mips_dsp_r2.c2
-rw-r--r--thirdparty/libwebp/dsp/rescaler_msa.c444
-rw-r--r--thirdparty/libwebp/dsp/rescaler_neon.c2
-rw-r--r--thirdparty/libwebp/dsp/rescaler_sse2.c2
-rw-r--r--thirdparty/libwebp/dsp/upsampling.c6
-rw-r--r--thirdparty/libwebp/dsp/upsampling_msa.c678
-rw-r--r--thirdparty/libwebp/dsp/upsampling_neon.c77
-rw-r--r--thirdparty/libwebp/dsp/yuv.c57
-rw-r--r--thirdparty/libwebp/dsp/yuv.h2
-rw-r--r--thirdparty/libwebp/dsp/yuv_sse2.c304
-rw-r--r--thirdparty/libwebp/dsp/yuv_tables_sse2.h536
-rw-r--r--thirdparty/libwebp/enc/alpha_enc.c (renamed from thirdparty/libwebp/enc/alpha.c)8
-rw-r--r--thirdparty/libwebp/enc/analysis_enc.c (renamed from thirdparty/libwebp/enc/analysis.c)47
-rw-r--r--thirdparty/libwebp/enc/backward_references_enc.c (renamed from thirdparty/libwebp/enc/backward_references.c)327
-rw-r--r--thirdparty/libwebp/enc/backward_references_enc.h (renamed from thirdparty/libwebp/enc/backward_references.h)3
-rw-r--r--thirdparty/libwebp/enc/config_enc.c (renamed from thirdparty/libwebp/enc/config.c)91
-rw-r--r--thirdparty/libwebp/enc/cost_enc.c (renamed from thirdparty/libwebp/enc/cost.c)2
-rw-r--r--thirdparty/libwebp/enc/cost_enc.h (renamed from thirdparty/libwebp/enc/cost.h)2
-rw-r--r--thirdparty/libwebp/enc/delta_palettization_enc.c (renamed from thirdparty/libwebp/enc/delta_palettization.c)2
-rw-r--r--thirdparty/libwebp/enc/delta_palettization_enc.h (renamed from thirdparty/libwebp/enc/delta_palettization.h)2
-rw-r--r--thirdparty/libwebp/enc/filter_enc.c (renamed from thirdparty/libwebp/enc/filter.c)107
-rw-r--r--thirdparty/libwebp/enc/frame_enc.c (renamed from thirdparty/libwebp/enc/frame.c)10
-rw-r--r--thirdparty/libwebp/enc/histogram_enc.c (renamed from thirdparty/libwebp/enc/histogram.c)304
-rw-r--r--thirdparty/libwebp/enc/histogram_enc.h (renamed from thirdparty/libwebp/enc/histogram.h)2
-rw-r--r--thirdparty/libwebp/enc/iterator_enc.c (renamed from thirdparty/libwebp/enc/iterator.c)19
-rw-r--r--thirdparty/libwebp/enc/near_lossless_enc.c (renamed from thirdparty/libwebp/enc/near_lossless.c)4
-rw-r--r--thirdparty/libwebp/enc/picture_csp_enc.c (renamed from thirdparty/libwebp/enc/picture_csp.c)269
-rw-r--r--thirdparty/libwebp/enc/picture_enc.c (renamed from thirdparty/libwebp/enc/picture.c)2
-rw-r--r--thirdparty/libwebp/enc/picture_psnr.c177
-rw-r--r--thirdparty/libwebp/enc/picture_psnr_enc.c213
-rw-r--r--thirdparty/libwebp/enc/picture_rescale_enc.c (renamed from thirdparty/libwebp/enc/picture_rescale.c)4
-rw-r--r--thirdparty/libwebp/enc/picture_tools_enc.c (renamed from thirdparty/libwebp/enc/picture_tools.c)2
-rw-r--r--thirdparty/libwebp/enc/predictor_enc.c750
-rw-r--r--thirdparty/libwebp/enc/quant_enc.c (renamed from thirdparty/libwebp/enc/quant.c)21
-rw-r--r--thirdparty/libwebp/enc/syntax_enc.c (renamed from thirdparty/libwebp/enc/syntax.c)5
-rw-r--r--thirdparty/libwebp/enc/token_enc.c (renamed from thirdparty/libwebp/enc/token.c)7
-rw-r--r--thirdparty/libwebp/enc/tree_enc.c (renamed from thirdparty/libwebp/enc/tree.c)2
-rw-r--r--thirdparty/libwebp/enc/vp8i_enc.h (renamed from thirdparty/libwebp/enc/vp8enci.h)19
-rw-r--r--thirdparty/libwebp/enc/vp8l_enc.c (renamed from thirdparty/libwebp/enc/vp8l.c)253
-rw-r--r--thirdparty/libwebp/enc/vp8li_enc.h (renamed from thirdparty/libwebp/enc/vp8li.h)22
-rw-r--r--thirdparty/libwebp/enc/webp_enc.c (renamed from thirdparty/libwebp/enc/webpenc.c)27
-rw-r--r--thirdparty/libwebp/mux/anim_encode.c51
-rw-r--r--thirdparty/libwebp/mux/animi.h43
-rw-r--r--thirdparty/libwebp/mux/muxedit.c157
-rw-r--r--thirdparty/libwebp/mux/muxi.h16
-rw-r--r--thirdparty/libwebp/mux/muxinternal.c21
-rw-r--r--thirdparty/libwebp/mux/muxread.c48
-rw-r--r--thirdparty/libwebp/utils/bit_reader_inl_utils.h (renamed from thirdparty/libwebp/utils/bit_reader_inl.h)79
-rw-r--r--thirdparty/libwebp/utils/bit_reader_utils.c (renamed from thirdparty/libwebp/utils/bit_reader.c)2
-rw-r--r--thirdparty/libwebp/utils/bit_reader_utils.h (renamed from thirdparty/libwebp/utils/bit_reader.h)0
-rw-r--r--thirdparty/libwebp/utils/bit_writer_utils.c (renamed from thirdparty/libwebp/utils/bit_writer.c)10
-rw-r--r--thirdparty/libwebp/utils/bit_writer_utils.h (renamed from thirdparty/libwebp/utils/bit_writer.h)3
-rw-r--r--thirdparty/libwebp/utils/color_cache_utils.c (renamed from thirdparty/libwebp/utils/color_cache.c)2
-rw-r--r--thirdparty/libwebp/utils/color_cache_utils.h (renamed from thirdparty/libwebp/utils/color_cache.h)15
-rw-r--r--thirdparty/libwebp/utils/endian_inl_utils.h (renamed from thirdparty/libwebp/utils/endian_inl.h)0
-rw-r--r--thirdparty/libwebp/utils/filters_utils.c (renamed from thirdparty/libwebp/utils/filters.c)2
-rw-r--r--thirdparty/libwebp/utils/filters_utils.h (renamed from thirdparty/libwebp/utils/filters.h)0
-rw-r--r--thirdparty/libwebp/utils/huffman_encode_utils.c (renamed from thirdparty/libwebp/utils/huffman_encode.c)2
-rw-r--r--thirdparty/libwebp/utils/huffman_encode_utils.h (renamed from thirdparty/libwebp/utils/huffman_encode.h)0
-rw-r--r--thirdparty/libwebp/utils/huffman_utils.c (renamed from thirdparty/libwebp/utils/huffman.c)48
-rw-r--r--thirdparty/libwebp/utils/huffman_utils.h (renamed from thirdparty/libwebp/utils/huffman.h)0
-rw-r--r--thirdparty/libwebp/utils/quant_levels_dec_utils.c (renamed from thirdparty/libwebp/utils/quant_levels_dec.c)2
-rw-r--r--thirdparty/libwebp/utils/quant_levels_dec_utils.h (renamed from thirdparty/libwebp/utils/quant_levels_dec.h)0
-rw-r--r--thirdparty/libwebp/utils/quant_levels_utils.c (renamed from thirdparty/libwebp/utils/quant_levels.c)2
-rw-r--r--thirdparty/libwebp/utils/quant_levels_utils.h (renamed from thirdparty/libwebp/utils/quant_levels.h)0
-rw-r--r--thirdparty/libwebp/utils/random_utils.c (renamed from thirdparty/libwebp/utils/random.c)2
-rw-r--r--thirdparty/libwebp/utils/random_utils.h (renamed from thirdparty/libwebp/utils/random.h)0
-rw-r--r--thirdparty/libwebp/utils/rescaler_utils.c (renamed from thirdparty/libwebp/utils/rescaler.c)2
-rw-r--r--thirdparty/libwebp/utils/rescaler_utils.h (renamed from thirdparty/libwebp/utils/rescaler.h)0
-rw-r--r--thirdparty/libwebp/utils/thread_utils.c (renamed from thirdparty/libwebp/utils/thread.c)8
-rw-r--r--thirdparty/libwebp/utils/thread_utils.h (renamed from thirdparty/libwebp/utils/thread.h)0
-rw-r--r--thirdparty/libwebp/utils/utils.c37
-rw-r--r--thirdparty/libwebp/utils/utils.h50
-rw-r--r--thirdparty/libwebp/webp/config.h150
-rw-r--r--thirdparty/libwebp/webp/encode.h35
-rw-r--r--thirdparty/libwebp/webp/format_constants.h3
-rw-r--r--thirdparty/libwebp/webp/mux.h50
-rw-r--r--thirdparty/libwebp/webp/mux_types.h5
-rw-r--r--thirdparty/stb_vorbis/stb_vorbis.c5399
-rw-r--r--thirdparty/zlib/deflate.c19
-rw-r--r--thirdparty/zlib/gzlib.c2
-rw-r--r--thirdparty/zlib/gzwrite.c2
-rw-r--r--thirdparty/zlib/inffast.c2
-rw-r--r--thirdparty/zlib/inftrees.c4
-rw-r--r--thirdparty/zlib/trees.c4
-rw-r--r--thirdparty/zlib/zlib.h17
-rw-r--r--thirdparty/zlib/zutil.c2
-rw-r--r--tools/SCsub121
-rw-r--r--tools/editor/SCsub148
-rw-r--r--tools/editor/animation_editor.cpp133
-rw-r--r--tools/editor/animation_editor.h6
-rw-r--r--tools/editor/array_property_edit.cpp8
-rw-r--r--tools/editor/asset_library_editor_plugin.cpp30
-rw-r--r--tools/editor/asset_library_editor_plugin.h6
-rw-r--r--tools/editor/call_dialog.cpp4
-rw-r--r--tools/editor/code_editor.cpp19
-rw-r--r--tools/editor/collada/SCsub (renamed from tools/collada/SCsub)2
-rw-r--r--tools/editor/collada/collada.cpp (renamed from tools/collada/collada.cpp)46
-rw-r--r--tools/editor/collada/collada.h (renamed from tools/collada/collada.h)2
-rw-r--r--tools/editor/connections_dialog.cpp9
-rw-r--r--tools/editor/connections_dialog.h6
-rw-r--r--tools/editor/create_dialog.cpp24
-rw-r--r--tools/editor/dependency_editor.cpp11
-rw-r--r--tools/editor/doc/SCsub (renamed from servers/spatial_sound_2d/SCsub)2
-rw-r--r--tools/editor/doc/doc_data.cpp (renamed from tools/doc/doc_data.cpp)8
-rw-r--r--tools/editor/doc/doc_data.h (renamed from tools/doc/doc_data.h)0
-rw-r--r--tools/editor/doc/doc_dump.cpp (renamed from tools/doc/doc_dump.cpp)3
-rw-r--r--tools/editor/doc/doc_dump.h (renamed from tools/doc/doc_dump.h)2
-rw-r--r--tools/editor/editor_asset_installer.cpp4
-rw-r--r--tools/editor/editor_audio_buses.cpp1192
-rw-r--r--tools/editor/editor_audio_buses.h186
-rw-r--r--tools/editor/editor_autoload_settings.cpp6
-rw-r--r--tools/editor/editor_data.cpp43
-rw-r--r--tools/editor/editor_data.h3
-rw-r--r--tools/editor/editor_dir_dialog.cpp15
-rw-r--r--tools/editor/editor_export.cpp (renamed from tools/editor/editor_import_export.cpp)1071
-rw-r--r--tools/editor/editor_export.h297
-rw-r--r--tools/editor/editor_file_dialog.cpp128
-rw-r--r--tools/editor/editor_file_dialog.h4
-rw-r--r--tools/editor/editor_file_system.cpp708
-rw-r--r--tools/editor/editor_file_system.h61
-rw-r--r--tools/editor/editor_fonts.cpp7
-rw-r--r--tools/editor/editor_help.cpp66
-rw-r--r--tools/editor/editor_help.h2
-rw-r--r--tools/editor/editor_import_export.h422
-rw-r--r--tools/editor/editor_initialize_ssl.cpp1
-rw-r--r--tools/editor/editor_log.cpp15
-rw-r--r--tools/editor/editor_log.h6
-rw-r--r--tools/editor/editor_name_dialog.cpp4
-rw-r--r--tools/editor/editor_node.cpp975
-rw-r--r--tools/editor/editor_node.h65
-rw-r--r--tools/editor/editor_path.cpp1
-rw-r--r--tools/editor/editor_plugin.cpp98
-rw-r--r--tools/editor/editor_plugin.h12
-rw-r--r--tools/editor/editor_plugin_settings.cpp3
-rw-r--r--tools/editor/editor_profiler.cpp55
-rw-r--r--tools/editor/editor_profiler.h32
-rw-r--r--tools/editor/editor_reimport_dialog.cpp4
-rw-r--r--tools/editor/editor_reimport_dialog.h2
-rw-r--r--tools/editor/editor_resource_preview.cpp13
-rw-r--r--tools/editor/editor_run.cpp11
-rw-r--r--tools/editor/editor_run.h2
-rw-r--r--tools/editor/editor_run_native.cpp9
-rw-r--r--tools/editor/editor_run_script.cpp11
-rw-r--r--tools/editor/editor_scale.cpp29
-rw-r--r--tools/editor/editor_scale.h28
-rw-r--r--tools/editor/editor_settings.cpp59
-rw-r--r--tools/editor/editor_settings.h4
-rw-r--r--tools/editor/editor_sub_scene.cpp13
-rw-r--r--tools/editor/editor_themes.cpp4
-rw-r--r--tools/editor/editor_themes.h2
-rw-r--r--tools/editor/file_type_cache.cpp4
-rw-r--r--tools/editor/fileserver/SCsub2
-rw-r--r--tools/editor/fileserver/editor_file_server.cpp3
-rw-r--r--tools/editor/filesystem_dock.cpp289
-rw-r--r--tools/editor/filesystem_dock.h16
-rw-r--r--tools/editor/groups_editor.cpp1
-rw-r--r--tools/editor/icons/2x/icon_anchor.pngbin816 -> 828 bytes
-rw-r--r--tools/editor/icons/2x/icon_animation.pngbin907 -> 912 bytes
-rw-r--r--tools/editor/icons/2x/icon_area.pngbin231 -> 209 bytes
-rw-r--r--tools/editor/icons/2x/icon_auto_play.pngbin696 -> 699 bytes
-rw-r--r--tools/editor/icons/2x/icon_bitmap_font.pngbin255 -> 191 bytes
-rw-r--r--tools/editor/icons/2x/icon_canvas_layer.pngbin857 -> 860 bytes
-rw-r--r--tools/editor/icons/2x/icon_canvas_modulate.pngbin536 -> 273 bytes
-rw-r--r--tools/editor/icons/2x/icon_color_rect.pngbin0 -> 289 bytes
-rw-r--r--tools/editor/icons/2x/icon_copy_node_path.pngbin0 -> 356 bytes
-rw-r--r--tools/editor/icons/2x/icon_create_new_scene_from.pngbin613 -> 639 bytes
-rw-r--r--tools/editor/icons/2x/icon_dynamic_font_data.pngbin358 -> 379 bytes
-rw-r--r--tools/editor/icons/2x/icon_error.pngbin100 -> 155 bytes
-rw-r--r--tools/editor/icons/2x/icon_fixed_spatial_material.pngbin1619 -> 768 bytes
-rw-r--r--tools/editor/icons/2x/icon_key_next.pngbin534 -> 579 bytes
-rw-r--r--tools/editor/icons/2x/icon_line_2d.pngbin0 -> 795 bytes
-rw-r--r--tools/editor/icons/2x/icon_material_shader.pngbin768 -> 342 bytes
-rw-r--r--tools/editor/icons/2x/icon_nine_patch_rect.png (renamed from tools/editor/icons/2x/icon_patch_9_frame.png)bin162 -> 162 bytes
-rw-r--r--tools/editor/icons/2x/icon_patch_9_rect.pngbin0 -> 162 bytes
-rw-r--r--tools/editor/icons/2x/icon_reference_rect.png (renamed from tools/editor/icons/2x/icon_reference_frame.png)bin160 -> 160 bytes
-rw-r--r--tools/editor/icons/2x/icon_reparent.pngbin631 -> 741 bytes
-rw-r--r--tools/editor/icons/2x/icon_script_remove.pngbin0 -> 787 bytes
-rw-r--r--tools/editor/icons/2x/icon_shader.pngbin768 -> 342 bytes
-rw-r--r--tools/editor/icons/2x/icon_shader_material.pngbin768 -> 342 bytes
-rw-r--r--tools/editor/icons/2x/icon_spot_light.pngbin714 -> 669 bytes
-rw-r--r--tools/editor/icons/2x/icon_tab_container.pngbin330 -> 334 bytes
-rw-r--r--tools/editor/icons/2x/icon_tabs.pngbin210 -> 222 bytes
-rw-r--r--tools/editor/icons/2x/icon_texture_rect.png (renamed from tools/editor/icons/2x/icon_texture_frame.png)bin201 -> 201 bytes
-rw-r--r--tools/editor/icons/2x/icon_track_add_key.pngbin125 -> 127 bytes
-rw-r--r--tools/editor/icons/2x/icon_track_add_key_hl.pngbin126 -> 128 bytes
-rw-r--r--tools/editor/icons/2x/icon_transparent.pngbin0 -> 177 bytes
-rw-r--r--tools/editor/icons/2x/icon_viewport_container.pngbin0 -> 528 bytes
-rw-r--r--tools/editor/icons/2x/icon_warning.pngbin100 -> 154 bytes
-rw-r--r--tools/editor/icons/SCsub2
-rw-r--r--tools/editor/icons/icon_accept_dialog.pngbin336 -> 338 bytes
-rw-r--r--tools/editor/icons/icon_anchor.pngbin441 -> 451 bytes
-rw-r--r--tools/editor/icons/icon_animation.pngbin398 -> 399 bytes
-rw-r--r--tools/editor/icons/icon_area.pngbin196 -> 176 bytes
-rw-r--r--tools/editor/icons/icon_audio_effect_amplify.pngbin0 -> 379 bytes
-rw-r--r--tools/editor/icons/icon_auto_play.pngbin375 -> 370 bytes
-rw-r--r--tools/editor/icons/icon_bitmap_font.pngbin218 -> 160 bytes
-rw-r--r--tools/editor/icons/icon_bus_vu_db.pngbin0 -> 1136 bytes
-rw-r--r--tools/editor/icons/icon_bus_vu_empty.pngbin0 -> 1631 bytes
-rw-r--r--tools/editor/icons/icon_bus_vu_frozen.pngbin0 -> 267 bytes
-rw-r--r--tools/editor/icons/icon_bus_vu_full.pngbin0 -> 2463 bytes
-rw-r--r--tools/editor/icons/icon_canvas_layer.pngbin478 -> 474 bytes
-rw-r--r--tools/editor/icons/icon_canvas_modulate.pngbin348 -> 213 bytes
-rw-r--r--tools/editor/icons/icon_color_frame.pngbin360 -> 0 bytes
-rw-r--r--tools/editor/icons/icon_color_rect.pngbin0 -> 214 bytes
-rw-r--r--tools/editor/icons/icon_copy_node_path.pngbin0 -> 248 bytes
-rw-r--r--tools/editor/icons/icon_create_new_scene_from.pngbin322 -> 349 bytes
-rw-r--r--tools/editor/icons/icon_dynamic_font_data.pngbin237 -> 246 bytes
-rw-r--r--tools/editor/icons/icon_error.pngbin95 -> 121 bytes
-rw-r--r--tools/editor/icons/icon_fixed_spatial_material.pngbin681 -> 409 bytes
-rw-r--r--tools/editor/icons/icon_key_next.pngbin302 -> 321 bytes
-rw-r--r--tools/editor/icons/icon_line_2d.pngbin0 -> 474 bytes
-rw-r--r--tools/editor/icons/icon_material_shader.pngbin409 -> 254 bytes
-rw-r--r--tools/editor/icons/icon_nine_patch_rect.png (renamed from tools/editor/icons/icon_patch_9_frame.png)bin128 -> 128 bytes
-rw-r--r--tools/editor/icons/icon_patch_9_rect.pngbin0 -> 128 bytes
-rw-r--r--tools/editor/icons/icon_reference_rect.png (renamed from tools/editor/icons/icon_reference_frame.png)bin128 -> 128 bytes
-rw-r--r--tools/editor/icons/icon_reparent.pngbin320 -> 390 bytes
-rw-r--r--tools/editor/icons/icon_script_remove.pngbin0 -> 411 bytes
-rw-r--r--tools/editor/icons/icon_shader.pngbin409 -> 254 bytes
-rw-r--r--tools/editor/icons/icon_shader_material.pngbin409 -> 254 bytes
-rw-r--r--tools/editor/icons/icon_spot_light.pngbin359 -> 341 bytes
-rw-r--r--tools/editor/icons/icon_tab_container.pngbin215 -> 214 bytes
-rw-r--r--tools/editor/icons/icon_tabs.pngbin147 -> 146 bytes
-rw-r--r--tools/editor/icons/icon_texture_rect.png (renamed from tools/editor/icons/icon_texture_frame.png)bin158 -> 158 bytes
-rw-r--r--tools/editor/icons/icon_track_add_key.pngbin113 -> 113 bytes
-rw-r--r--tools/editor/icons/icon_track_add_key_hl.pngbin113 -> 113 bytes
-rw-r--r--tools/editor/icons/icon_transparent.pngbin0 -> 158 bytes
-rw-r--r--tools/editor/icons/icon_viewport_container.pngbin0 -> 284 bytes
-rw-r--r--tools/editor/icons/icon_vu_db.pngbin0 -> 1015 bytes
-rw-r--r--tools/editor/icons/icon_warning.pngbin95 -> 120 bytes
-rw-r--r--tools/editor/icons/source/icon_accept_dialog.svg14
-rw-r--r--tools/editor/icons/source/icon_add_track.svg28
-rw-r--r--tools/editor/icons/source/icon_anchor.svg27
-rw-r--r--tools/editor/icons/source/icon_animation.svg53
-rw-r--r--tools/editor/icons/source/icon_area.svg99
-rw-r--r--tools/editor/icons/source/icon_area_2d.svg99
-rw-r--r--tools/editor/icons/source/icon_arrow_left.svg32
-rw-r--r--tools/editor/icons/source/icon_arrow_right.svg11
-rw-r--r--tools/editor/icons/source/icon_auto_play.svg45
-rw-r--r--tools/editor/icons/source/icon_back_buffer_copy.svg61
-rw-r--r--tools/editor/icons/source/icon_bake.svg22
-rw-r--r--tools/editor/icons/source/icon_baked_light.svg24
-rw-r--r--tools/editor/icons/source/icon_baked_light_instance.svg20
-rw-r--r--tools/editor/icons/source/icon_baked_light_sampler.svg18
-rw-r--r--tools/editor/icons/source/icon_bitmap_font.svg66
-rw-r--r--tools/editor/icons/source/icon_canvas_layer.svg38
-rw-r--r--tools/editor/icons/source/icon_canvas_modulate.svg102
-rw-r--r--tools/editor/icons/source/icon_color_rect.svg156
-rw-r--r--tools/editor/icons/source/icon_connect.svg58
-rw-r--r--tools/editor/icons/source/icon_connection_and_groups.svg101
-rw-r--r--tools/editor/icons/source/icon_copy_node_path.svg98
-rw-r--r--tools/editor/icons/source/icon_create_new_scene_from.svg29
-rw-r--r--tools/editor/icons/source/icon_dynamic_font_data.svg10
-rw-r--r--tools/editor/icons/source/icon_error.svg7
-rw-r--r--tools/editor/icons/source/icon_fixed_spatial_material.svg148
-rw-r--r--tools/editor/icons/source/icon_key_next.svg31
-rw-r--r--tools/editor/icons/source/icon_line_2d.svg82
-rw-r--r--tools/editor/icons/source/icon_nine_patch_rect.svg (renamed from tools/editor/icons/source/icon_patch_9_frame.svg)0
-rw-r--r--tools/editor/icons/source/icon_patch_9_rect.svg130
-rw-r--r--tools/editor/icons/source/icon_reference_rect.svg (renamed from tools/editor/icons/source/icon_reference_frame.svg)2
-rw-r--r--tools/editor/icons/source/icon_reparent.svg57
-rw-r--r--tools/editor/icons/source/icon_script_remove.svg99
-rw-r--r--tools/editor/icons/source/icon_shader.svg15
-rw-r--r--tools/editor/icons/source/icon_spot_light.svg50
-rw-r--r--tools/editor/icons/source/icon_static_body.svg66
-rw-r--r--tools/editor/icons/source/icon_static_body_2d.svg43
-rw-r--r--tools/editor/icons/source/icon_tab_container.svg28
-rw-r--r--tools/editor/icons/source/icon_tabs.svg46
-rw-r--r--tools/editor/icons/source/icon_text_edit.svg27
-rw-r--r--tools/editor/icons/source/icon_texture_rect.svg (renamed from tools/editor/icons/source/icon_texture_frame.svg)2
-rw-r--r--tools/editor/icons/source/icon_track_add_key.svg6
-rw-r--r--tools/editor/icons/source/icon_track_add_key_hl.svg15
-rw-r--r--tools/editor/icons/source/icon_viewport.svg22
-rw-r--r--tools/editor/icons/source/icon_viewport_container.svg82
-rw-r--r--tools/editor/icons/source/icon_warning.svg17
-rw-r--r--tools/editor/import/SCsub5
-rw-r--r--tools/editor/import/editor_import_collada.cpp (renamed from tools/editor/io_plugins/editor_import_collada.cpp)131
-rw-r--r--tools/editor/import/editor_import_collada.h (renamed from tools/editor/io_plugins/editor_import_collada.h)2
-rw-r--r--tools/editor/import/resource_importer_csv_translation.cpp126
-rw-r--r--tools/editor/import/resource_importer_csv_translation.h27
-rw-r--r--tools/editor/import/resource_importer_obj.cpp231
-rw-r--r--tools/editor/import/resource_importer_obj.h28
-rw-r--r--tools/editor/import/resource_importer_scene.cpp1328
-rw-r--r--tools/editor/import/resource_importer_scene.h93
-rw-r--r--tools/editor/import/resource_importer_texture.cpp393
-rw-r--r--tools/editor/import/resource_importer_texture.h70
-rw-r--r--tools/editor/import/resource_importer_wav.cpp619
-rw-r--r--tools/editor/import/resource_importer_wav.h30
-rw-r--r--tools/editor/import_dock.cpp331
-rw-r--r--tools/editor/import_dock.h42
-rw-r--r--tools/editor/io_plugins/SCsub2
-rw-r--r--tools/editor/io_plugins/editor_atlas.cpp1
-rw-r--r--tools/editor/io_plugins/editor_bitmask_import_plugin.cpp40
-rw-r--r--tools/editor/io_plugins/editor_bitmask_import_plugin.h31
-rw-r--r--tools/editor/io_plugins/editor_export_scene.cpp6
-rw-r--r--tools/editor/io_plugins/editor_export_scene.h6
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.cpp83
-rw-r--r--tools/editor/io_plugins/editor_font_import_plugin.h5
-rw-r--r--tools/editor/io_plugins/editor_mesh_import_plugin.cpp9
-rw-r--r--tools/editor/io_plugins/editor_mesh_import_plugin.h3
-rw-r--r--tools/editor/io_plugins/editor_sample_import_plugin.cpp34
-rw-r--r--tools/editor/io_plugins/editor_sample_import_plugin.h2
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.cpp58
-rw-r--r--tools/editor/io_plugins/editor_scene_import_plugin.h4
-rw-r--r--tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp1
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.cpp82
-rw-r--r--tools/editor/io_plugins/editor_texture_import_plugin.h7
-rw-r--r--tools/editor/io_plugins/editor_translation_import_plugin.cpp18
-rw-r--r--tools/editor/io_plugins/editor_translation_import_plugin.h5
-rw-r--r--tools/editor/multi_node_edit.cpp34
-rw-r--r--tools/editor/multi_node_edit.h4
-rw-r--r--tools/editor/node_dock.cpp33
-rw-r--r--tools/editor/node_dock.h28
-rw-r--r--tools/editor/output_strings.cpp2
-rw-r--r--tools/editor/plugins/SCsub2
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.cpp151
-rw-r--r--tools/editor/plugins/animation_player_editor_plugin.h4
-rw-r--r--tools/editor/plugins/animation_tree_editor_plugin.cpp42
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp44
-rw-r--r--tools/editor/plugins/baked_light_baker.h9
-rw-r--r--tools/editor/plugins/baked_light_editor_plugin.cpp9
-rw-r--r--tools/editor/plugins/camera_editor_plugin.cpp7
-rw-r--r--tools/editor/plugins/camera_editor_plugin.h2
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp164
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.h4
-rw-r--r--tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp8
-rw-r--r--tools/editor/plugins/collision_polygon_editor_plugin.cpp7
-rw-r--r--tools/editor/plugins/collision_shape_2d_editor_plugin.cpp1
-rw-r--r--tools/editor/plugins/color_ramp_editor_plugin.cpp5
-rw-r--r--tools/editor/plugins/cube_grid_theme_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp15
-rw-r--r--tools/editor/plugins/editor_preview_plugins.h4
-rw-r--r--tools/editor/plugins/gi_probe_editor_plugin.cpp32
-rw-r--r--tools/editor/plugins/gi_probe_editor_plugin.h28
-rw-r--r--tools/editor/plugins/light_occluder_2d_editor_plugin.cpp10
-rw-r--r--tools/editor/plugins/line_2d_editor_plugin.cpp283
-rw-r--r--tools/editor/plugins/line_2d_editor_plugin.h90
-rw-r--r--tools/editor/plugins/material_editor_plugin.cpp37
-rw-r--r--tools/editor/plugins/material_editor_plugin.h28
-rw-r--r--tools/editor/plugins/mesh_editor_plugin.cpp8
-rw-r--r--tools/editor/plugins/mesh_instance_editor_plugin.cpp28
-rw-r--r--tools/editor/plugins/mesh_instance_editor_plugin.h28
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.cpp5
-rw-r--r--tools/editor/plugins/navigation_polygon_editor_plugin.cpp12
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.cpp6
-rw-r--r--tools/editor/plugins/particles_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/path_2d_editor_plugin.cpp14
-rw-r--r--tools/editor/plugins/path_editor_plugin.cpp13
-rw-r--r--tools/editor/plugins/path_editor_plugin.h2
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.cpp32
-rw-r--r--tools/editor/plugins/polygon_2d_editor_plugin.h2
-rw-r--r--tools/editor/plugins/resource_preloader_editor_plugin.cpp43
-rw-r--r--tools/editor/plugins/rich_text_editor_plugin.cpp5
-rw-r--r--tools/editor/plugins/sample_editor_plugin.cpp17
-rw-r--r--tools/editor/plugins/sample_editor_plugin.h6
-rw-r--r--tools/editor/plugins/sample_library_editor_plugin.cpp41
-rw-r--r--tools/editor/plugins/sample_library_editor_plugin.h3
-rw-r--r--tools/editor/plugins/sample_player_editor_plugin.cpp11
-rw-r--r--tools/editor/plugins/sample_player_editor_plugin.h3
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp95
-rw-r--r--tools/editor/plugins/script_editor_plugin.h16
-rw-r--r--tools/editor/plugins/script_text_editor.cpp8
-rw-r--r--tools/editor/plugins/shader_editor_plugin.cpp20
-rw-r--r--tools/editor/plugins/shader_graph_editor_plugin.cpp27
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp252
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.h4
-rw-r--r--tools/editor/plugins/sprite_frames_editor_plugin.cpp52
-rw-r--r--tools/editor/plugins/stream_editor_plugin.cpp7
-rw-r--r--tools/editor/plugins/stream_editor_plugin.h3
-rw-r--r--tools/editor/plugins/style_box_editor_plugin.cpp8
-rw-r--r--tools/editor/plugins/style_box_editor_plugin.h2
-rw-r--r--tools/editor/plugins/texture_editor_plugin.cpp36
-rw-r--r--tools/editor/plugins/texture_editor_plugin.h28
-rw-r--r--tools/editor/plugins/texture_region_editor_plugin.cpp41
-rw-r--r--tools/editor/plugins/texture_region_editor_plugin.h8
-rw-r--r--tools/editor/plugins/theme_editor_plugin.cpp15
-rw-r--r--tools/editor/plugins/theme_editor_plugin.h2
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp30
-rw-r--r--tools/editor/plugins/tile_set_editor_plugin.cpp4
-rw-r--r--tools/editor/progress_dialog.cpp2
-rw-r--r--tools/editor/project_export.cpp2351
-rw-r--r--tools/editor/project_export.h198
-rw-r--r--tools/editor/project_manager.cpp47
-rw-r--r--tools/editor/project_settings.cpp158
-rw-r--r--tools/editor/project_settings.h2
-rw-r--r--tools/editor/property_editor.cpp337
-rw-r--r--tools/editor/property_editor.h16
-rw-r--r--tools/editor/property_selector.cpp38
-rw-r--r--tools/editor/property_selector.h28
-rw-r--r--tools/editor/pvrtc_compress.cpp2
-rw-r--r--tools/editor/quick_open.cpp8
-rw-r--r--tools/editor/reparent_dialog.cpp6
-rw-r--r--tools/editor/resources_dock.cpp25
-rw-r--r--tools/editor/scene_tree_dock.cpp149
-rw-r--r--tools/editor/scene_tree_dock.h3
-rw-r--r--tools/editor/scene_tree_editor.cpp58
-rw-r--r--tools/editor/scene_tree_editor.h4
-rw-r--r--tools/editor/script_create_dialog.cpp15
-rw-r--r--tools/editor/script_editor_debugger.cpp107
-rw-r--r--tools/editor/settings_config_dialog.cpp46
-rw-r--r--tools/editor/spatial_editor_gizmos.cpp118
-rw-r--r--tools/editor/spatial_editor_gizmos.h32
-rw-r--r--tools/editor/translations/Makefile (renamed from tools/translations/Makefile)0
-rw-r--r--tools/editor/translations/README.md (renamed from tools/translations/README.md)0
-rw-r--r--tools/editor/translations/ar.po (renamed from tools/translations/ar.po)10
-rw-r--r--tools/editor/translations/bg.po (renamed from tools/translations/bg.po)10
-rw-r--r--tools/editor/translations/bn.po (renamed from tools/translations/bn.po)20
-rw-r--r--tools/editor/translations/ca.po (renamed from tools/translations/ca.po)12
-rw-r--r--tools/editor/translations/cs.po (renamed from tools/translations/cs.po)10
-rw-r--r--tools/editor/translations/da.po (renamed from tools/translations/da.po)10
-rw-r--r--tools/editor/translations/de.po (renamed from tools/translations/de.po)20
-rw-r--r--tools/editor/translations/de_CH.po (renamed from tools/translations/de_CH.po)18
-rw-r--r--tools/editor/translations/es.po (renamed from tools/translations/es.po)20
-rw-r--r--tools/editor/translations/es_AR.po (renamed from tools/translations/es_AR.po)20
-rwxr-xr-xtools/editor/translations/extract.py (renamed from tools/translations/extract.py)0
-rw-r--r--tools/editor/translations/fa.po (renamed from tools/translations/fa.po)10
-rw-r--r--tools/editor/translations/fr.po (renamed from tools/translations/fr.po)20
-rw-r--r--tools/editor/translations/hu.po (renamed from tools/translations/hu.po)10
-rw-r--r--tools/editor/translations/id.po (renamed from tools/translations/id.po)10
-rw-r--r--tools/editor/translations/it.po (renamed from tools/translations/it.po)20
-rw-r--r--tools/editor/translations/ja.po (renamed from tools/translations/ja.po)10
-rw-r--r--tools/editor/translations/ko.po (renamed from tools/translations/ko.po)20
-rw-r--r--tools/editor/translations/nb.po (renamed from tools/translations/nb.po)10
-rw-r--r--tools/editor/translations/pl.po (renamed from tools/translations/pl.po)26
-rw-r--r--tools/editor/translations/pr.po (renamed from tools/translations/pr.po)10
-rw-r--r--tools/editor/translations/pt_BR.po (renamed from tools/translations/pt_BR.po)20
-rw-r--r--tools/editor/translations/pt_PT.po (renamed from tools/translations/pt_PT.po)10
-rw-r--r--tools/editor/translations/ru.po (renamed from tools/translations/ru.po)20
-rw-r--r--tools/editor/translations/sk.po (renamed from tools/translations/sk.po)10
-rw-r--r--tools/editor/translations/sl.po (renamed from tools/translations/sl.po)10
-rw-r--r--tools/editor/translations/tools.pot (renamed from tools/translations/tools.pot)10
-rw-r--r--tools/editor/translations/tr.po (renamed from tools/translations/tr.po)20
-rw-r--r--tools/editor/translations/ur_PK.po (renamed from tools/translations/ur_PK.po)10
-rw-r--r--tools/editor/translations/zh_CN.po (renamed from tools/translations/zh_CN.po)16
-rw-r--r--tools/editor/translations/zh_HK.po (renamed from tools/translations/zh_HK.po)10
-rw-r--r--tools/editor/translations/zh_TW.po (renamed from tools/translations/zh_TW.po)10
1404 files changed, 52106 insertions, 48527 deletions
diff --git a/.gitignore b/.gitignore
index abbda17ee2..8ab969c9a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -144,7 +144,9 @@ ipch/
*.sdf
*.cachefile
*.VC.db
+*.VC.opendb
*.VC.VC.opendb
+enc_temp_folder/
# Visual Studio profiler
*.psess
@@ -244,6 +246,9 @@ node_modules/
#Kdevelop project files
*.kdev4
+# xCode
+xcuserdata
+
# RIA/Silverlight projects
Generated_Code/
diff --git a/.travis.yml b/.travis.yml
index 12b49f4c07..ca110a3073 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ os:
- osx
env:
- #- GODOT_TARGET=iphone
+ - GODOT_TARGET=iphone
- GODOT_TARGET=osx
- GODOT_TARGET=x11
#- GODOT_TARGET=android
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index 294acd5bae..93ded6c954 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -1,19 +1,17 @@
-vvv Remove me vvv
-
-*NOTE:* If you using the current master branch / 3.0-alpha version, do note that
-breakage is *expected*. Projects from Godot 2.x are expected not to work. Please
-wait for the upcoming stabilisation period to report bugs regarding recent changes.
-
-^^^ Remove me ^^^
-
+<!--
+README: Incompatibilities and broken features in the current master branch / 3.0-alpha
+are known and expected due to important refactoring work, so no need to report them for now. Thanks!
+-->
**Operating system or device - Godot version:**
-**Issue description** (what happened, and what was expected):
+**Issue description:**
+<!-- What happened, and what was expected. -->
**Steps to reproduce:**
-**Link to minimal example project** (optional but very welcome):
+**Link to minimal example project:**
+<!-- Optional but very welcome. You can drag and drop a zip archive to upload it. -->:
diff --git a/SConstruct b/SConstruct
index 2ecfea92e3..4c79304ef2 100644
--- a/SConstruct
+++ b/SConstruct
@@ -358,7 +358,7 @@ if selected_platform in platform_list:
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
- SConscript("tools/SCsub")
+ SConscript("tools/editor/SCsub")
SConscript("drivers/SCsub")
SConscript("modules/SCsub")
@@ -374,7 +374,7 @@ if selected_platform in platform_list:
AddToVSProject(env.modules_sources)
AddToVSProject(env.scene_sources)
AddToVSProject(env.servers_sources)
- AddToVSProject(env.tool_sources)
+ AddToVSProject(env.editor_sources)
# this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0')
# Even then, SCons still seems to ignore it and builds with the latest MSVC...
diff --git a/core/SCsub b/core/SCsub
index 8d89f6427b..77c8288846 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -13,7 +13,7 @@ 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 "globals.h"\n'
+gd_cpp = '#include "global_config.h"\n'
gd_cpp += gd_inc
gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n"
@@ -45,7 +45,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
f = open("script_encryption_key.cpp", "wb")
-f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
+f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
@@ -61,6 +61,7 @@ SConscript('os/SCsub')
SConscript('math/SCsub')
SConscript('io/SCsub')
SConscript('bind/SCsub')
+SConscript('helper/SCsub')
lib = env.Library("core", env.core_sources)
diff --git a/core/array.cpp b/core/array.cpp
index b9c8f543da..16598a044d 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "array.h"
+
#include "vector.h"
#include "hashfuncs.h"
#include "variant.h"
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 8f1c1779bd..79cfae0a3a 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -31,7 +31,7 @@
#include "geometry.h"
#include "io/marshalls.h"
#include "io/base64.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "io/file_access_encrypted.h"
#include "os/keyboard.h"
@@ -106,21 +106,16 @@ bool _ResourceLoader::has(const String &p_path) {
return ResourceCache::has(local_path);
};
-Ref<ResourceImportMetadata> _ResourceLoader::load_import_metadata(const String& p_path) {
-
- return ResourceLoader::load_import_metadata(p_path);
-}
void _ResourceLoader::_bind_methods() {
- ClassDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL(""));
- ClassDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false));
- ClassDB::bind_method(_MD("load_import_metadata:ResourceImportMetadata","path"),&_ResourceLoader::load_import_metadata);
- ClassDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type);
- ClassDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources);
- ClassDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies);
- ClassDB::bind_method(_MD("has","path"),&_ResourceLoader::has);
+ ClassDB::bind_method(D_METHOD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type);
+ ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources);
+ ClassDB::bind_method(D_METHOD("get_dependencies","path"),&_ResourceLoader::get_dependencies);
+ ClassDB::bind_method(D_METHOD("has","path"),&_ResourceLoader::has);
}
_ResourceLoader::_ResourceLoader() {
@@ -153,8 +148,8 @@ _ResourceSaver *_ResourceSaver::singleton=NULL;
void _ResourceSaver::_bind_methods() {
- ClassDB::bind_method(_MD("save","path","resource:Resource","flags"),&_ResourceSaver::save,DEFVAL(0));
- ClassDB::bind_method(_MD("get_recognized_extensions","type"),&_ResourceSaver::get_recognized_extensions);
+ 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);
BIND_CONSTANT(FLAG_RELATIVE_PATHS);
BIND_CONSTANT(FLAG_BUNDLE_RESOURCES);
@@ -340,24 +335,6 @@ Array _OS::get_fullscreen_mode_list(int p_screen) const {
return vmarr;
}
-void _OS::set_iterations_per_second(int p_ips) {
-
- OS::get_singleton()->set_iterations_per_second(p_ips);
-}
-int _OS::get_iterations_per_second() const {
-
- return OS::get_singleton()->get_iterations_per_second();
-
-}
-
-void _OS::set_target_fps(int p_fps) {
- OS::get_singleton()->set_target_fps(p_fps);
-}
-
-float _OS::get_target_fps() const {
- return OS::get_singleton()->get_target_fps();
-}
-
void _OS::set_low_processor_usage_mode(bool p_enabled) {
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
@@ -449,22 +426,10 @@ String _OS::get_latin_keyboard_variant() const {
String _OS::get_model_name() const {
- return OS::get_singleton()->get_model_name();
+ return OS::get_singleton()->get_model_name();
}
-MainLoop *_OS::get_main_loop() const {
- return OS::get_singleton()->get_main_loop();
-}
-
-void _OS::set_time_scale(float p_scale) {
- OS::get_singleton()->set_time_scale(p_scale);
-}
-
-float _OS::get_time_scale() {
-
- return OS::get_singleton()->get_time_scale();
-}
bool _OS::is_ok_left_and_cancel_right() const {
@@ -622,28 +587,20 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
static const unsigned int SECONDS_PER_MINUTE = 60;
static const unsigned int MINUTES_PER_HOUR = 60;
static const unsigned int HOURS_PER_DAY = 24;
- static const unsigned int SECONDS_PER_HOUR = MINUTES_PER_HOUR *
- SECONDS_PER_MINUTE;
+ static const unsigned int SECONDS_PER_HOUR = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;
static const unsigned int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
// Get all time values from the dictionary, set to zero if it doesn't exist.
// Risk incorrect calculation over throwing errors
- unsigned int second = ((datetime.has(SECOND_KEY))?
- static_cast<unsigned int>(datetime[SECOND_KEY]): 0);
- unsigned int minute = ((datetime.has(MINUTE_KEY))?
- static_cast<unsigned int>(datetime[MINUTE_KEY]): 0);
- unsigned int hour = ((datetime.has(HOUR_KEY))?
- static_cast<unsigned int>(datetime[HOUR_KEY]): 0);
- unsigned int day = ((datetime.has(DAY_KEY))?
- static_cast<unsigned int>(datetime[DAY_KEY]): 0);
- unsigned int month = ((datetime.has(MONTH_KEY))?
- static_cast<unsigned int>(datetime[MONTH_KEY]) -1: 0);
- unsigned int year = ((datetime.has(YEAR_KEY))?
- static_cast<unsigned int>(datetime[YEAR_KEY]):0);
+ unsigned int second = ((datetime.has(SECOND_KEY)) ? static_cast<unsigned int>(datetime[SECOND_KEY]): 0);
+ unsigned int minute = ((datetime.has(MINUTE_KEY)) ? static_cast<unsigned int>(datetime[MINUTE_KEY]): 0);
+ unsigned int hour = ((datetime.has(HOUR_KEY)) ? static_cast<unsigned int>(datetime[HOUR_KEY]): 0);
+ unsigned int day = ((datetime.has(DAY_KEY)) ? static_cast<unsigned int>(datetime[DAY_KEY]): 0);
+ unsigned int month = ((datetime.has(MONTH_KEY)) ? static_cast<unsigned int>(datetime[MONTH_KEY]) -1: 0);
+ unsigned int year = ((datetime.has(YEAR_KEY)) ? static_cast<unsigned int>(datetime[YEAR_KEY]):0);
/// How many days come before each month (0-12)
- static const unsigned short int DAYS_PAST_THIS_YEAR_TABLE[2][13] =
- {
+ static const unsigned short int DAYS_PAST_THIS_YEAR_TABLE[2][13] = {
/* Normal years. */
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
/* Leap years. */
@@ -663,19 +620,16 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
ERR_FAIL_COND_V( month+1 > 12, 0);
// Do this check after month is tested as valid
- ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger "
- "than "+ itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month]));
+ ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger than "+ itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month]));
ERR_FAIL_COND_V( day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month], 0);
// Calculate all the seconds from months past in this year
- uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR =
- DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY;
+ uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY;
uint64_t SECONDS_FROM_YEARS_PAST = 0;
for(unsigned int iyear = EPOCH_YR; iyear < year; iyear++) {
- SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) *
- SECONDS_PER_DAY;
+ SECONDS_FROM_YEARS_PAST += YEARSIZE(iyear) * SECONDS_PER_DAY;
}
uint64_t epoch =
@@ -706,8 +660,7 @@ Dictionary _OS::get_datetime_from_unix_time( uint64_t unix_time_val) const {
// Just fail if unix time is negative (when interpreted as an int).
// This means the user passed in a negative value by accident
- ERR_EXPLAIN("unix_time_val was really huge!"+ itos(unix_time_val) +
- " You probably passed in a negative value!");
+ ERR_EXPLAIN("unix_time_val was really huge!"+ itos(unix_time_val) + " You probably passed in a negative value!");
ERR_FAIL_COND_V( (int64_t)unix_time_val < 0, Dictionary());
OS::Date date;
@@ -804,10 +757,6 @@ bool _OS::can_draw() const {
return OS::get_singleton()->can_draw();
}
-int _OS::get_frames_drawn() {
-
- return OS::get_singleton()->get_frames_drawn();
-}
int _OS::get_processor_count() const {
@@ -936,11 +885,6 @@ String _OS::get_data_dir() const {
return OS::get_singleton()->get_data_dir();
};
-float _OS::get_frames_per_second() const {
-
- return OS::get_singleton()->get_frames_per_second();
-}
-
Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
return OS::get_singleton()->native_video_play(p_path, p_volume, p_audio_track, p_subtitle_track);
@@ -1005,10 +949,7 @@ String _OS::get_system_dir(SystemDir p_dir) const {
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
}
-String _OS::get_custom_level() const {
- return OS::get_singleton()->get_custom_level();
-}
String _OS::get_scancode_string(uint32_t p_code) const {
@@ -1028,166 +969,149 @@ void _OS::alert(const String& p_alert,const String& p_title) {
OS::get_singleton()->alert(p_alert,p_title);
}
-Dictionary _OS::get_engine_version() const {
-
- return OS::get_singleton()->get_engine_version();
-}
-
_OS *_OS::singleton=NULL;
void _OS::_bind_methods() {
- //ClassDB::bind_method(_MD("get_mouse_pos"),&_OS::get_mouse_pos);
- //ClassDB::bind_method(_MD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled);
-
- ClassDB::bind_method(_MD("set_clipboard","clipboard"),&_OS::set_clipboard);
- ClassDB::bind_method(_MD("get_clipboard"),&_OS::get_clipboard);
-
- ClassDB::bind_method(_MD("set_video_mode","size","fullscreen","resizable","screen"),&_OS::set_video_mode,DEFVAL(0));
- ClassDB::bind_method(_MD("get_video_mode_size","screen"),&_OS::get_video_mode,DEFVAL(0));
- ClassDB::bind_method(_MD("is_video_mode_fullscreen","screen"),&_OS::is_video_mode_fullscreen,DEFVAL(0));
- ClassDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
- ClassDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
-
-
- ClassDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count);
- ClassDB::bind_method(_MD("get_current_screen"),&_OS::get_current_screen);
- ClassDB::bind_method(_MD("set_current_screen","screen"),&_OS::set_current_screen);
- ClassDB::bind_method(_MD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0));
- ClassDB::bind_method(_MD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0));
- ClassDB::bind_method(_MD("get_screen_dpi","screen"),&_OS::get_screen_dpi,DEFVAL(0));
- ClassDB::bind_method(_MD("get_window_position"),&_OS::get_window_position);
- ClassDB::bind_method(_MD("set_window_position","position"),&_OS::set_window_position);
- ClassDB::bind_method(_MD("get_window_size"),&_OS::get_window_size);
- ClassDB::bind_method(_MD("set_window_size","size"),&_OS::set_window_size);
- ClassDB::bind_method(_MD("set_window_fullscreen","enabled"),&_OS::set_window_fullscreen);
- ClassDB::bind_method(_MD("is_window_fullscreen"),&_OS::is_window_fullscreen);
- ClassDB::bind_method(_MD("set_window_resizable","enabled"),&_OS::set_window_resizable);
- ClassDB::bind_method(_MD("is_window_resizable"),&_OS::is_window_resizable);
- ClassDB::bind_method(_MD("set_window_minimized", "enabled"),&_OS::set_window_minimized);
- ClassDB::bind_method(_MD("is_window_minimized"),&_OS::is_window_minimized);
- ClassDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized);
- ClassDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized);
- ClassDB::bind_method(_MD("request_attention"), &_OS::request_attention);
-
- ClassDB::bind_method(_MD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
- ClassDB::bind_method(_MD("get_borderless_window"), &_OS::get_borderless_window);
-
- ClassDB::bind_method(_MD("set_screen_orientation","orientation"),&_OS::set_screen_orientation);
- ClassDB::bind_method(_MD("get_screen_orientation"),&_OS::get_screen_orientation);
-
- ClassDB::bind_method(_MD("set_keep_screen_on","enabled"),&_OS::set_keep_screen_on);
- ClassDB::bind_method(_MD("is_keep_screen_on"),&_OS::is_keep_screen_on);
-
- ClassDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
- ClassDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
- ClassDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
- ClassDB::bind_method(_MD("get_target_fps"),&_OS::get_target_fps);
-
- ClassDB::bind_method(_MD("set_time_scale","time_scale"),&_OS::set_time_scale);
- ClassDB::bind_method(_MD("get_time_scale"),&_OS::get_time_scale);
-
- ClassDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
-
- ClassDB::bind_method(_MD("set_window_title","title"),&_OS::set_window_title);
-
- ClassDB::bind_method(_MD("set_low_processor_usage_mode","enable"),&_OS::set_low_processor_usage_mode);
- ClassDB::bind_method(_MD("is_in_low_processor_usage_mode"),&_OS::is_in_low_processor_usage_mode);
-
- ClassDB::bind_method(_MD("get_processor_count"),&_OS::get_processor_count);
-
- ClassDB::bind_method(_MD("get_executable_path"),&_OS::get_executable_path);
- ClassDB::bind_method(_MD("execute","path","arguments","blocking","output"),&_OS::execute,DEFVAL(Array()));
- ClassDB::bind_method(_MD("kill","pid"),&_OS::kill);
- ClassDB::bind_method(_MD("shell_open","uri"),&_OS::shell_open);
- ClassDB::bind_method(_MD("get_process_ID"),&_OS::get_process_ID);
-
- ClassDB::bind_method(_MD("get_environment","environment"),&_OS::get_environment);
- ClassDB::bind_method(_MD("has_environment","environment"),&_OS::has_environment);
-
- ClassDB::bind_method(_MD("get_name"),&_OS::get_name);
- ClassDB::bind_method(_MD("get_cmdline_args"),&_OS::get_cmdline_args);
- ClassDB::bind_method(_MD("get_main_loop"),&_OS::get_main_loop);
-
- ClassDB::bind_method(_MD("get_datetime","utc"),&_OS::get_datetime,DEFVAL(false));
- ClassDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false));
- ClassDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false));
- ClassDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info);
- ClassDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time);
- ClassDB::bind_method(_MD("get_datetime_from_unix_time", "unix_time_val"),
+ //ClassDB::bind_method(D_METHOD("get_mouse_pos"),&_OS::get_mouse_pos);
+ //ClassDB::bind_method(D_METHOD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_clipboard","clipboard"),&_OS::set_clipboard);
+ ClassDB::bind_method(D_METHOD("get_clipboard"),&_OS::get_clipboard);
+
+ //will not delete for now, just unexpose
+ //ClassDB::bind_method(D_METHOD("set_video_mode","size","fullscreen","resizable","screen"),&_OS::set_video_mode,DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("get_video_mode_size","screen"),&_OS::get_video_mode,DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("is_video_mode_fullscreen","screen"),&_OS::is_video_mode_fullscreen,DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
+
+
+ ClassDB::bind_method(D_METHOD("get_screen_count"),&_OS::get_screen_count);
+ ClassDB::bind_method(D_METHOD("get_current_screen"),&_OS::get_current_screen);
+ ClassDB::bind_method(D_METHOD("set_current_screen","screen"),&_OS::set_current_screen);
+ ClassDB::bind_method(D_METHOD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_screen_dpi","screen"),&_OS::get_screen_dpi,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_window_position"),&_OS::get_window_position);
+ ClassDB::bind_method(D_METHOD("set_window_position","position"),&_OS::set_window_position);
+ ClassDB::bind_method(D_METHOD("get_window_size"),&_OS::get_window_size);
+ ClassDB::bind_method(D_METHOD("set_window_size","size"),&_OS::set_window_size);
+ ClassDB::bind_method(D_METHOD("set_window_fullscreen","enabled"),&_OS::set_window_fullscreen);
+ ClassDB::bind_method(D_METHOD("is_window_fullscreen"),&_OS::is_window_fullscreen);
+ ClassDB::bind_method(D_METHOD("set_window_resizable","enabled"),&_OS::set_window_resizable);
+ ClassDB::bind_method(D_METHOD("is_window_resizable"),&_OS::is_window_resizable);
+ ClassDB::bind_method(D_METHOD("set_window_minimized", "enabled"),&_OS::set_window_minimized);
+ ClassDB::bind_method(D_METHOD("is_window_minimized"),&_OS::is_window_minimized);
+ ClassDB::bind_method(D_METHOD("set_window_maximized", "enabled"),&_OS::set_window_maximized);
+ ClassDB::bind_method(D_METHOD("is_window_maximized"),&_OS::is_window_maximized);
+ ClassDB::bind_method(D_METHOD("request_attention"), &_OS::request_attention);
+
+ 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_screen_orientation","orientation"),&_OS::set_screen_orientation);
+ ClassDB::bind_method(D_METHOD("get_screen_orientation"),&_OS::get_screen_orientation);
+
+ ClassDB::bind_method(D_METHOD("set_keep_screen_on","enabled"),&_OS::set_keep_screen_on);
+ ClassDB::bind_method(D_METHOD("is_keep_screen_on"),&_OS::is_keep_screen_on);
+
+
+ ClassDB::bind_method(D_METHOD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
+
+ ClassDB::bind_method(D_METHOD("set_window_title","title"),&_OS::set_window_title);
+
+ ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode","enable"),&_OS::set_low_processor_usage_mode);
+ ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"),&_OS::is_in_low_processor_usage_mode);
+
+ ClassDB::bind_method(D_METHOD("get_processor_count"),&_OS::get_processor_count);
+
+ ClassDB::bind_method(D_METHOD("get_executable_path"),&_OS::get_executable_path);
+ ClassDB::bind_method(D_METHOD("execute","path","arguments","blocking","output"),&_OS::execute,DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("kill","pid"),&_OS::kill);
+ ClassDB::bind_method(D_METHOD("shell_open","uri"),&_OS::shell_open);
+ ClassDB::bind_method(D_METHOD("get_process_ID"),&_OS::get_process_ID);
+
+ ClassDB::bind_method(D_METHOD("get_environment","environment"),&_OS::get_environment);
+ ClassDB::bind_method(D_METHOD("has_environment","environment"),&_OS::has_environment);
+
+ ClassDB::bind_method(D_METHOD("get_name"),&_OS::get_name);
+ ClassDB::bind_method(D_METHOD("get_cmdline_args"),&_OS::get_cmdline_args);
+
+ ClassDB::bind_method(D_METHOD("get_datetime","utc"),&_OS::get_datetime,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_date","utc"),&_OS::get_date,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_time","utc"),&_OS::get_time,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_time_zone_info"),&_OS::get_time_zone_info);
+ ClassDB::bind_method(D_METHOD("get_unix_time"),&_OS::get_unix_time);
+ ClassDB::bind_method(D_METHOD("get_datetime_from_unix_time", "unix_time_val"),
&_OS::get_datetime_from_unix_time);
- ClassDB::bind_method(_MD("get_unix_time_from_datetime", "datetime"),
+ ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime", "datetime"),
&_OS::get_unix_time_from_datetime);
- ClassDB::bind_method(_MD("get_system_time_secs"), &_OS::get_system_time_secs);
+ ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
- ClassDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon);
+ ClassDB::bind_method(D_METHOD("set_icon","icon"),&_OS::set_icon);
- ClassDB::bind_method(_MD("get_exit_code"),&_OS::get_exit_code);
- ClassDB::bind_method(_MD("set_exit_code","code"),&_OS::set_exit_code);
+ 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);
- ClassDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec);
- ClassDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec);
- ClassDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec);
- ClassDB::bind_method(_MD("get_splash_tick_msec"),&_OS::get_splash_tick_msec);
- ClassDB::bind_method(_MD("get_locale"),&_OS::get_locale);
- ClassDB::bind_method(_MD("get_latin_keyboard_variant"),&_OS::get_latin_keyboard_variant);
- ClassDB::bind_method(_MD("get_model_name"),&_OS::get_model_name);
+ ClassDB::bind_method(D_METHOD("delay_usec","usec"),&_OS::delay_usec);
+ ClassDB::bind_method(D_METHOD("delay_msec","msec"),&_OS::delay_msec);
+ ClassDB::bind_method(D_METHOD("get_ticks_msec"),&_OS::get_ticks_msec);
+ ClassDB::bind_method(D_METHOD("get_splash_tick_msec"),&_OS::get_splash_tick_msec);
+ ClassDB::bind_method(D_METHOD("get_locale"),&_OS::get_locale);
+ ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"),&_OS::get_latin_keyboard_variant);
+ ClassDB::bind_method(D_METHOD("get_model_name"),&_OS::get_model_name);
- ClassDB::bind_method(_MD("get_custom_level"),&_OS::get_custom_level);
- ClassDB::bind_method(_MD("can_draw"),&_OS::can_draw);
- ClassDB::bind_method(_MD("get_frames_drawn"),&_OS::get_frames_drawn);
- ClassDB::bind_method(_MD("is_stdout_verbose"),&_OS::is_stdout_verbose);
+ ClassDB::bind_method(D_METHOD("can_draw"),&_OS::can_draw);
+ ClassDB::bind_method(D_METHOD("is_stdout_verbose"),&_OS::is_stdout_verbose);
- ClassDB::bind_method(_MD("can_use_threads"),&_OS::can_use_threads);
+ ClassDB::bind_method(D_METHOD("can_use_threads"),&_OS::can_use_threads);
- ClassDB::bind_method(_MD("is_debug_build"),&_OS::is_debug_build);
+ ClassDB::bind_method(D_METHOD("is_debug_build"),&_OS::is_debug_build);
- //ClassDB::bind_method(_MD("get_mouse_button_state"),&_OS::get_mouse_button_state);
+ //ClassDB::bind_method(D_METHOD("get_mouse_button_state"),&_OS::get_mouse_button_state);
- ClassDB::bind_method(_MD("dump_memory_to_file","file"),&_OS::dump_memory_to_file);
- ClassDB::bind_method(_MD("dump_resources_to_file","file"),&_OS::dump_resources_to_file);
- ClassDB::bind_method(_MD("has_virtual_keyboard"),&_OS::has_virtual_keyboard);
- ClassDB::bind_method(_MD("show_virtual_keyboard", "existing_text"),&_OS::show_virtual_keyboard,DEFVAL(""));
- ClassDB::bind_method(_MD("hide_virtual_keyboard"),&_OS::hide_virtual_keyboard);
- ClassDB::bind_method(_MD("print_resources_in_use","short"),&_OS::print_resources_in_use,DEFVAL(false));
- ClassDB::bind_method(_MD("print_all_resources","tofile"),&_OS::print_all_resources,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("dump_memory_to_file","file"),&_OS::dump_memory_to_file);
+ ClassDB::bind_method(D_METHOD("dump_resources_to_file","file"),&_OS::dump_resources_to_file);
+ ClassDB::bind_method(D_METHOD("has_virtual_keyboard"),&_OS::has_virtual_keyboard);
+ ClassDB::bind_method(D_METHOD("show_virtual_keyboard", "existing_text"),&_OS::show_virtual_keyboard,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("hide_virtual_keyboard"),&_OS::hide_virtual_keyboard);
+ ClassDB::bind_method(D_METHOD("print_resources_in_use","short"),&_OS::print_resources_in_use,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("print_all_resources","tofile"),&_OS::print_all_resources,DEFVAL(""));
- ClassDB::bind_method(_MD("get_static_memory_usage"),&_OS::get_static_memory_usage);
- ClassDB::bind_method(_MD("get_static_memory_peak_usage"),&_OS::get_static_memory_peak_usage);
- ClassDB::bind_method(_MD("get_dynamic_memory_usage"),&_OS::get_dynamic_memory_usage);
+ ClassDB::bind_method(D_METHOD("get_static_memory_usage"),&_OS::get_static_memory_usage);
+ ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"),&_OS::get_static_memory_peak_usage);
+ ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"),&_OS::get_dynamic_memory_usage);
- ClassDB::bind_method(_MD("get_data_dir"),&_OS::get_data_dir);
- ClassDB::bind_method(_MD("get_system_dir","dir"),&_OS::get_system_dir);
- ClassDB::bind_method(_MD("get_unique_ID"),&_OS::get_unique_ID);
+ ClassDB::bind_method(D_METHOD("get_data_dir"),&_OS::get_data_dir);
+ ClassDB::bind_method(D_METHOD("get_system_dir","dir"),&_OS::get_system_dir);
+ ClassDB::bind_method(D_METHOD("get_unique_ID"),&_OS::get_unique_ID);
- ClassDB::bind_method(_MD("is_ok_left_and_cancel_right"),&_OS::is_ok_left_and_cancel_right);
+ ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"),&_OS::is_ok_left_and_cancel_right);
- ClassDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second);
- ClassDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
- ClassDB::bind_method(_MD("print_resources_by_type","types"),&_OS::print_resources_by_type);
+ ClassDB::bind_method(D_METHOD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
+ ClassDB::bind_method(D_METHOD("print_resources_by_type","types"),&_OS::print_resources_by_type);
- ClassDB::bind_method(_MD("native_video_play","path","volume","audio_track","subtitle_track"),&_OS::native_video_play);
- ClassDB::bind_method(_MD("native_video_is_playing"),&_OS::native_video_is_playing);
- ClassDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop);
- ClassDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause);
- ClassDB::bind_method(_MD("native_video_unpause"),&_OS::native_video_unpause);
+ ClassDB::bind_method(D_METHOD("native_video_play","path","volume","audio_track","subtitle_track"),&_OS::native_video_play);
+ ClassDB::bind_method(D_METHOD("native_video_is_playing"),&_OS::native_video_is_playing);
+ ClassDB::bind_method(D_METHOD("native_video_stop"),&_OS::native_video_stop);
+ ClassDB::bind_method(D_METHOD("native_video_pause"),&_OS::native_video_pause);
+ ClassDB::bind_method(D_METHOD("native_video_unpause"),&_OS::native_video_unpause);
- ClassDB::bind_method(_MD("get_scancode_string","code"),&_OS::get_scancode_string);
- ClassDB::bind_method(_MD("is_scancode_unicode","code"),&_OS::is_scancode_unicode);
- ClassDB::bind_method(_MD("find_scancode_from_string","string"),&_OS::find_scancode_from_string);
+ ClassDB::bind_method(D_METHOD("get_scancode_string","code"),&_OS::get_scancode_string);
+ ClassDB::bind_method(D_METHOD("is_scancode_unicode","code"),&_OS::is_scancode_unicode);
+ ClassDB::bind_method(D_METHOD("find_scancode_from_string","string"),&_OS::find_scancode_from_string);
- ClassDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap);
+ ClassDB::bind_method(D_METHOD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap);
- ClassDB::bind_method(_MD("alert","text","title"),&_OS::alert,DEFVAL("Alert!"));
+ ClassDB::bind_method(D_METHOD("alert","text","title"),&_OS::alert,DEFVAL("Alert!"));
- ClassDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name);
+ ClassDB::bind_method(D_METHOD("set_thread_name","name"),&_OS::set_thread_name);
- ClassDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync);
- ClassDB::bind_method(_MD("is_vsync_enabled"),&_OS::is_vsync_enabled);
-
- ClassDB::bind_method(_MD("get_engine_version"),&_OS::get_engine_version);
+ ClassDB::bind_method(D_METHOD("set_use_vsync","enable"),&_OS::set_use_vsync);
+ ClassDB::bind_method(D_METHOD("is_vsync_enabled"),&_OS::is_vsync_enabled);
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
@@ -1297,6 +1221,11 @@ PoolVector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3
return r;
}
+Vector2 _Geometry::get_closest_point_to_segment_2d(const Vector2& p_point, const Vector2& p_a,const Vector2& p_b) {
+
+ Vector2 s[2]={p_a,p_b};
+ return Geometry::get_closest_point_to_segment_2d(p_point,s);
+}
Vector3 _Geometry::get_closest_point_to_segment(const Vector3& p_point, const Vector3& p_a,const Vector3& p_b) {
Vector3 s[2]={p_a,p_b};
@@ -1409,29 +1338,30 @@ int _Geometry::get_uv84_normal_bit(const Vector3& p_vector) {
void _Geometry::_bind_methods() {
- ClassDB::bind_method(_MD("build_box_planes","extents"),&_Geometry::build_box_planes);
- ClassDB::bind_method(_MD("build_cylinder_planes","radius","height","sides","axis"),&_Geometry::build_cylinder_planes,DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(_MD("build_capsule_planes","radius","height","sides","lats","axis"),&_Geometry::build_capsule_planes,DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(_MD("segment_intersects_circle","segment_from","segment_to","circle_pos","circle_radius"),&_Geometry::segment_intersects_circle);
- ClassDB::bind_method(_MD("segment_intersects_segment_2d","from_a","to_a","from_b","to_b"),&_Geometry::segment_intersects_segment_2d);
+ ClassDB::bind_method(D_METHOD("build_box_planes","extents"),&_Geometry::build_box_planes);
+ ClassDB::bind_method(D_METHOD("build_cylinder_planes","radius","height","sides","axis"),&_Geometry::build_cylinder_planes,DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("build_capsule_planes","radius","height","sides","lats","axis"),&_Geometry::build_capsule_planes,DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("segment_intersects_circle","segment_from","segment_to","circle_pos","circle_radius"),&_Geometry::segment_intersects_circle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d","from_a","to_a","from_b","to_b"),&_Geometry::segment_intersects_segment_2d);
- ClassDB::bind_method(_MD("get_closest_points_between_segments_2d","p1","q1","p2","q2"),&_Geometry::get_closest_points_between_segments_2d);
- ClassDB::bind_method(_MD("get_closest_points_between_segments","p1","p2","q1","q2"),&_Geometry::get_closest_points_between_segments);
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments_2d","p1","q1","p2","q2"),&_Geometry::get_closest_points_between_segments_2d);
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments","p1","p2","q1","q2"),&_Geometry::get_closest_points_between_segments);
- ClassDB::bind_method(_MD("get_closest_point_to_segment","point","s1","s2"),&_Geometry::get_closest_point_to_segment);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_2d","point","s1","s2"),&_Geometry::get_closest_point_to_segment_2d);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment","point","s1","s2"),&_Geometry::get_closest_point_to_segment);
- ClassDB::bind_method(_MD("get_uv84_normal_bit","normal"),&_Geometry::get_uv84_normal_bit);
+ ClassDB::bind_method(D_METHOD("get_uv84_normal_bit","normal"),&_Geometry::get_uv84_normal_bit);
- ClassDB::bind_method(_MD("ray_intersects_triangle","from","dir","a","b","c"),&_Geometry::ray_intersects_triangle);
- ClassDB::bind_method(_MD("segment_intersects_triangle","from","to","a","b","c"),&_Geometry::segment_intersects_triangle);
- ClassDB::bind_method(_MD("segment_intersects_sphere","from","to","spos","sradius"),&_Geometry::segment_intersects_sphere);
- ClassDB::bind_method(_MD("segment_intersects_cylinder","from","to","height","radius"),&_Geometry::segment_intersects_cylinder);
- ClassDB::bind_method(_MD("segment_intersects_convex","from","to","planes"),&_Geometry::segment_intersects_convex);
- ClassDB::bind_method(_MD("point_is_inside_triangle","point","a","b","c"),&_Geometry::point_is_inside_triangle);
+ ClassDB::bind_method(D_METHOD("ray_intersects_triangle","from","dir","a","b","c"),&_Geometry::ray_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_triangle","from","to","a","b","c"),&_Geometry::segment_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_sphere","from","to","spos","sradius"),&_Geometry::segment_intersects_sphere);
+ ClassDB::bind_method(D_METHOD("segment_intersects_cylinder","from","to","height","radius"),&_Geometry::segment_intersects_cylinder);
+ ClassDB::bind_method(D_METHOD("segment_intersects_convex","from","to","planes"),&_Geometry::segment_intersects_convex);
+ ClassDB::bind_method(D_METHOD("point_is_inside_triangle","point","a","b","c"),&_Geometry::point_is_inside_triangle);
- ClassDB::bind_method(_MD("triangulate_polygon","polygon"),&_Geometry::triangulate_polygon);
+ ClassDB::bind_method(D_METHOD("triangulate_polygon","polygon"),&_Geometry::triangulate_polygon);
- ClassDB::bind_method(_MD("make_atlas","sizes"),&_Geometry::make_atlas);
+ ClassDB::bind_method(D_METHOD("make_atlas","sizes"),&_Geometry::make_atlas);
}
@@ -1803,54 +1733,60 @@ Variant _File::get_var() const {
return v;
}
+uint64_t _File::get_modified_time(const String &p_file) const {
+
+ return FileAccess::get_modified_time(p_file);
+}
+
void _File::_bind_methods() {
- ClassDB::bind_method(_MD("open_encrypted","path","mode_flags","key"),&_File::open_encrypted);
- ClassDB::bind_method(_MD("open_encrypted_with_pass","path","mode_flags","pass"),&_File::open_encrypted_pass);
-
- ClassDB::bind_method(_MD("open","path","flags"),&_File::open);
- ClassDB::bind_method(_MD("close"),&_File::close);
- ClassDB::bind_method(_MD("is_open"),&_File::is_open);
- ClassDB::bind_method(_MD("seek","pos"),&_File::seek);
- ClassDB::bind_method(_MD("seek_end","pos"),&_File::seek_end,DEFVAL(0));
- ClassDB::bind_method(_MD("get_pos"),&_File::get_pos);
- ClassDB::bind_method(_MD("get_len"),&_File::get_len);
- ClassDB::bind_method(_MD("eof_reached"),&_File::eof_reached);
- ClassDB::bind_method(_MD("get_8"),&_File::get_8);
- ClassDB::bind_method(_MD("get_16"),&_File::get_16);
- ClassDB::bind_method(_MD("get_32"),&_File::get_32);
- ClassDB::bind_method(_MD("get_64"),&_File::get_64);
- ClassDB::bind_method(_MD("get_float"),&_File::get_float);
- ClassDB::bind_method(_MD("get_double"),&_File::get_double);
- ClassDB::bind_method(_MD("get_real"),&_File::get_real);
- ClassDB::bind_method(_MD("get_buffer","len"),&_File::get_buffer);
- ClassDB::bind_method(_MD("get_line"),&_File::get_line);
- ClassDB::bind_method(_MD("get_as_text"),&_File::get_as_text);
- ClassDB::bind_method(_MD("get_md5","path"),&_File::get_md5);
- ClassDB::bind_method(_MD("get_sha256","path"),&_File::get_sha256);
- ClassDB::bind_method(_MD("get_endian_swap"),&_File::get_endian_swap);
- ClassDB::bind_method(_MD("set_endian_swap","enable"),&_File::set_endian_swap);
- ClassDB::bind_method(_MD("get_error:Error"),&_File::get_error);
- ClassDB::bind_method(_MD("get_var"),&_File::get_var);
- ClassDB::bind_method(_MD("get_csv_line","delim"),&_File::get_csv_line,DEFVAL(","));
-
- ClassDB::bind_method(_MD("store_8","value"),&_File::store_8);
- ClassDB::bind_method(_MD("store_16","value"),&_File::store_16);
- ClassDB::bind_method(_MD("store_32","value"),&_File::store_32);
- ClassDB::bind_method(_MD("store_64","value"),&_File::store_64);
- ClassDB::bind_method(_MD("store_float","value"),&_File::store_float);
- ClassDB::bind_method(_MD("store_double","value"),&_File::store_double);
- ClassDB::bind_method(_MD("store_real","value"),&_File::store_real);
- ClassDB::bind_method(_MD("store_buffer","buffer"),&_File::store_buffer);
- ClassDB::bind_method(_MD("store_line","line"),&_File::store_line);
- ClassDB::bind_method(_MD("store_string","string"),&_File::store_string);
- ClassDB::bind_method(_MD("store_var","value"),&_File::store_var);
-
- ClassDB::bind_method(_MD("store_pascal_string","string"),&_File::store_pascal_string);
- ClassDB::bind_method(_MD("get_pascal_string"),&_File::get_pascal_string);
-
- ClassDB::bind_method(_MD("file_exists","path"),&_File::file_exists);
+ ClassDB::bind_method(D_METHOD("open_encrypted","path","mode_flags","key"),&_File::open_encrypted);
+ ClassDB::bind_method(D_METHOD("open_encrypted_with_pass","path","mode_flags","pass"),&_File::open_encrypted_pass);
+
+ ClassDB::bind_method(D_METHOD("open","path","flags"),&_File::open);
+ ClassDB::bind_method(D_METHOD("close"),&_File::close);
+ ClassDB::bind_method(D_METHOD("is_open"),&_File::is_open);
+ ClassDB::bind_method(D_METHOD("seek","pos"),&_File::seek);
+ ClassDB::bind_method(D_METHOD("seek_end","pos"),&_File::seek_end,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_pos"),&_File::get_pos);
+ ClassDB::bind_method(D_METHOD("get_len"),&_File::get_len);
+ ClassDB::bind_method(D_METHOD("eof_reached"),&_File::eof_reached);
+ ClassDB::bind_method(D_METHOD("get_8"),&_File::get_8);
+ ClassDB::bind_method(D_METHOD("get_16"),&_File::get_16);
+ ClassDB::bind_method(D_METHOD("get_32"),&_File::get_32);
+ ClassDB::bind_method(D_METHOD("get_64"),&_File::get_64);
+ ClassDB::bind_method(D_METHOD("get_float"),&_File::get_float);
+ ClassDB::bind_method(D_METHOD("get_double"),&_File::get_double);
+ ClassDB::bind_method(D_METHOD("get_real"),&_File::get_real);
+ ClassDB::bind_method(D_METHOD("get_buffer","len"),&_File::get_buffer);
+ ClassDB::bind_method(D_METHOD("get_line"),&_File::get_line);
+ ClassDB::bind_method(D_METHOD("get_as_text"),&_File::get_as_text);
+ ClassDB::bind_method(D_METHOD("get_md5","path"),&_File::get_md5);
+ ClassDB::bind_method(D_METHOD("get_sha256","path"),&_File::get_sha256);
+ ClassDB::bind_method(D_METHOD("get_endian_swap"),&_File::get_endian_swap);
+ ClassDB::bind_method(D_METHOD("set_endian_swap","enable"),&_File::set_endian_swap);
+ ClassDB::bind_method(D_METHOD("get_error:Error"),&_File::get_error);
+ ClassDB::bind_method(D_METHOD("get_var"),&_File::get_var);
+ ClassDB::bind_method(D_METHOD("get_csv_line","delim"),&_File::get_csv_line,DEFVAL(","));
+
+ ClassDB::bind_method(D_METHOD("store_8","value"),&_File::store_8);
+ ClassDB::bind_method(D_METHOD("store_16","value"),&_File::store_16);
+ ClassDB::bind_method(D_METHOD("store_32","value"),&_File::store_32);
+ ClassDB::bind_method(D_METHOD("store_64","value"),&_File::store_64);
+ ClassDB::bind_method(D_METHOD("store_float","value"),&_File::store_float);
+ ClassDB::bind_method(D_METHOD("store_double","value"),&_File::store_double);
+ ClassDB::bind_method(D_METHOD("store_real","value"),&_File::store_real);
+ ClassDB::bind_method(D_METHOD("store_buffer","buffer"),&_File::store_buffer);
+ ClassDB::bind_method(D_METHOD("store_line","line"),&_File::store_line);
+ ClassDB::bind_method(D_METHOD("store_string","string"),&_File::store_string);
+ ClassDB::bind_method(D_METHOD("store_var","value"),&_File::store_var);
+
+ ClassDB::bind_method(D_METHOD("store_pascal_string","string"),&_File::store_pascal_string);
+ ClassDB::bind_method(D_METHOD("get_pascal_string"),&_File::get_pascal_string);
+
+ ClassDB::bind_method(D_METHOD("file_exists","path"),&_File::file_exists);
+ ClassDB::bind_method(D_METHOD("get_modified_time", "file"),&_File::get_modified_time);
BIND_CONSTANT( READ );
BIND_CONSTANT( WRITE );
@@ -1890,16 +1826,28 @@ Error _Directory::open(const String& p_path) {
return OK;
}
-bool _Directory::list_dir_begin() {
+Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
+
+ ERR_FAIL_COND_V(!d,ERR_UNCONFIGURED);
+
+ _list_skip_navigational = p_skip_navigational;
+ _list_skip_hidden = p_skip_hidden;
- ERR_FAIL_COND_V(!d,false);
return d->list_dir_begin();
}
String _Directory::get_next(){
ERR_FAIL_COND_V(!d,"");
- return d->get_next();
+
+ String next = d->get_next();
+ while (next != ""
+ && ((_list_skip_navigational && (next == "." || next == ".."))
+ || (_list_skip_hidden && d->current_is_hidden()))) {
+
+ next = d->get_next();
+ }
+ return next;
}
bool _Directory::current_is_dir() const{
@@ -1923,6 +1871,10 @@ String _Directory::get_drive(int p_drive){
ERR_FAIL_COND_V(!d,"");
return d->get_drive(p_drive);
}
+int _Directory::get_current_drive() {
+ ERR_FAIL_COND_V(!d,0);
+ return d->get_current_drive();
+}
Error _Directory::change_dir(String p_dir){
@@ -2024,24 +1976,25 @@ Error _Directory::remove(String p_name){
void _Directory::_bind_methods() {
- ClassDB::bind_method(_MD("open:Error","path"),&_Directory::open);
- ClassDB::bind_method(_MD("list_dir_begin"),&_Directory::list_dir_begin);
- ClassDB::bind_method(_MD("get_next"),&_Directory::get_next);
- ClassDB::bind_method(_MD("current_is_dir"),&_Directory::current_is_dir);
- ClassDB::bind_method(_MD("list_dir_end"),&_Directory::list_dir_end);
- ClassDB::bind_method(_MD("get_drive_count"),&_Directory::get_drive_count);
- ClassDB::bind_method(_MD("get_drive","idx"),&_Directory::get_drive);
- ClassDB::bind_method(_MD("change_dir:Error","todir"),&_Directory::change_dir);
- ClassDB::bind_method(_MD("get_current_dir"),&_Directory::get_current_dir);
- ClassDB::bind_method(_MD("make_dir:Error","path"),&_Directory::make_dir);
- ClassDB::bind_method(_MD("make_dir_recursive:Error","path"),&_Directory::make_dir_recursive);
- ClassDB::bind_method(_MD("file_exists","path"),&_Directory::file_exists);
- ClassDB::bind_method(_MD("dir_exists","path"),&_Directory::dir_exists);
-// ClassDB::bind_method(_MD("get_modified_time","file"),&_Directory::get_modified_time);
- ClassDB::bind_method(_MD("get_space_left"),&_Directory::get_space_left);
- ClassDB::bind_method(_MD("copy:Error","from","to"),&_Directory::copy);
- ClassDB::bind_method(_MD("rename:Error","from","to"),&_Directory::rename);
- ClassDB::bind_method(_MD("remove:Error","path"),&_Directory::remove);
+ ClassDB::bind_method(D_METHOD("open:Error","path"),&_Directory::open);
+ ClassDB::bind_method(D_METHOD("list_dir_begin", "skip_navigational", "skip_hidden"), &_Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_next"),&_Directory::get_next);
+ ClassDB::bind_method(D_METHOD("current_is_dir"),&_Directory::current_is_dir);
+ ClassDB::bind_method(D_METHOD("list_dir_end"),&_Directory::list_dir_end);
+ ClassDB::bind_method(D_METHOD("get_drive_count"),&_Directory::get_drive_count);
+ ClassDB::bind_method(D_METHOD("get_drive","idx"),&_Directory::get_drive);
+ ClassDB::bind_method(D_METHOD("get_current_drive"),&_Directory::get_current_drive);
+ ClassDB::bind_method(D_METHOD("change_dir:Error","todir"),&_Directory::change_dir);
+ ClassDB::bind_method(D_METHOD("get_current_dir"),&_Directory::get_current_dir);
+ ClassDB::bind_method(D_METHOD("make_dir:Error","path"),&_Directory::make_dir);
+ ClassDB::bind_method(D_METHOD("make_dir_recursive:Error","path"),&_Directory::make_dir_recursive);
+ ClassDB::bind_method(D_METHOD("file_exists","path"),&_Directory::file_exists);
+ ClassDB::bind_method(D_METHOD("dir_exists","path"),&_Directory::dir_exists);
+ //ClassDB::bind_method(D_METHOD("get_modified_time","file"),&_Directory::get_modified_time);
+ ClassDB::bind_method(D_METHOD("get_space_left"),&_Directory::get_space_left);
+ ClassDB::bind_method(D_METHOD("copy:Error","from","to"),&_Directory::copy);
+ ClassDB::bind_method(D_METHOD("rename:Error","from","to"),&_Directory::rename);
+ ClassDB::bind_method(D_METHOD("remove:Error","path"),&_Directory::remove);
}
@@ -2181,14 +2134,14 @@ String _Marshalls::base64_to_utf8(const String& p_str) {
void _Marshalls::_bind_methods() {
- ClassDB::bind_method(_MD("variant_to_base64:String","variant"),&_Marshalls::variant_to_base64);
- ClassDB::bind_method(_MD("base64_to_variant:Variant","base64_str"),&_Marshalls::base64_to_variant);
+ ClassDB::bind_method(D_METHOD("variant_to_base64:String","variant"),&_Marshalls::variant_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_variant:Variant","base64_str"),&_Marshalls::base64_to_variant);
- ClassDB::bind_method(_MD("raw_to_base64:String","array"),&_Marshalls::raw_to_base64);
- ClassDB::bind_method(_MD("base64_to_raw:RawArray","base64_str"),&_Marshalls::base64_to_raw);
+ ClassDB::bind_method(D_METHOD("raw_to_base64:String","array"),&_Marshalls::raw_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_raw:RawArray","base64_str"),&_Marshalls::base64_to_raw);
- ClassDB::bind_method(_MD("utf8_to_base64:String","utf8_str"),&_Marshalls::utf8_to_base64);
- ClassDB::bind_method(_MD("base64_to_utf8:String","base64_str"),&_Marshalls::base64_to_utf8);
+ ClassDB::bind_method(D_METHOD("utf8_to_base64:String","utf8_str"),&_Marshalls::utf8_to_base64);
+ ClassDB::bind_method(D_METHOD("base64_to_utf8:String","base64_str"),&_Marshalls::base64_to_utf8);
};
@@ -2212,8 +2165,8 @@ Error _Semaphore::post() {
void _Semaphore::_bind_methods() {
- ClassDB::bind_method(_MD("wait:Error"),&_Semaphore::wait);
- ClassDB::bind_method(_MD("post:Error"),&_Semaphore::post);
+ ClassDB::bind_method(D_METHOD("wait:Error"),&_Semaphore::wait);
+ ClassDB::bind_method(D_METHOD("post:Error"),&_Semaphore::post);
}
@@ -2249,9 +2202,9 @@ void _Mutex::unlock(){
void _Mutex::_bind_methods() {
- ClassDB::bind_method(_MD("lock"),&_Mutex::lock);
- ClassDB::bind_method(_MD("try_lock:Error"),&_Mutex::try_lock);
- ClassDB::bind_method(_MD("unlock"),&_Mutex::unlock);
+ ClassDB::bind_method(D_METHOD("lock"),&_Mutex::lock);
+ ClassDB::bind_method(D_METHOD("try_lock:Error"),&_Mutex::try_lock);
+ ClassDB::bind_method(D_METHOD("unlock"),&_Mutex::unlock);
}
@@ -2371,10 +2324,10 @@ Variant _Thread::wait_to_finish() {
void _Thread::_bind_methods() {
- ClassDB::bind_method(_MD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL));
- ClassDB::bind_method(_MD("get_id"),&_Thread::get_id);
- ClassDB::bind_method(_MD("is_active"),&_Thread::is_active);
- ClassDB::bind_method(_MD("wait_to_finish:Variant"),&_Thread::wait_to_finish);
+ ClassDB::bind_method(D_METHOD("start:Error","instance","method","userdata","priority"),&_Thread::start,DEFVAL(Variant()),DEFVAL(PRIORITY_NORMAL));
+ ClassDB::bind_method(D_METHOD("get_id"),&_Thread::get_id);
+ ClassDB::bind_method(D_METHOD("is_active"),&_Thread::is_active);
+ ClassDB::bind_method(D_METHOD("wait_to_finish:Variant"),&_Thread::wait_to_finish);
BIND_CONSTANT( PRIORITY_LOW );
BIND_CONSTANT( PRIORITY_NORMAL );
@@ -2559,31 +2512,31 @@ bool _ClassDB::is_class_enabled(StringName p_class) const {
void _ClassDB::_bind_methods() {
- ClassDB::bind_method(_MD("get_class_list"),&_ClassDB::get_class_list);
- ClassDB::bind_method(_MD("get_inheriters_from_class","class"),&_ClassDB::get_inheriters_from_class);
- ClassDB::bind_method(_MD("get_parent_class","class"),&_ClassDB::get_parent_class);
- ClassDB::bind_method(_MD("class_exists","class"),&_ClassDB::class_exists);
- ClassDB::bind_method(_MD("is_parent_class","class","inherits"),&_ClassDB::is_parent_class);
- ClassDB::bind_method(_MD("can_instance","class"),&_ClassDB::can_instance);
- ClassDB::bind_method(_MD("instance","class"),&_ClassDB::instance);
+ ClassDB::bind_method(D_METHOD("get_class_list"),&_ClassDB::get_class_list);
+ ClassDB::bind_method(D_METHOD("get_inheriters_from_class","class"),&_ClassDB::get_inheriters_from_class);
+ ClassDB::bind_method(D_METHOD("get_parent_class","class"),&_ClassDB::get_parent_class);
+ ClassDB::bind_method(D_METHOD("class_exists","class"),&_ClassDB::class_exists);
+ ClassDB::bind_method(D_METHOD("is_parent_class","class","inherits"),&_ClassDB::is_parent_class);
+ ClassDB::bind_method(D_METHOD("can_instance","class"),&_ClassDB::can_instance);
+ ClassDB::bind_method(D_METHOD("instance:Variant","class"),&_ClassDB::instance);
- ClassDB::bind_method(_MD("has_signal","class","signal"),&_ClassDB::has_signal);
- ClassDB::bind_method(_MD("get_signal","class","signal"),&_ClassDB::get_signal);
- ClassDB::bind_method(_MD("get_signal_list","class","no_inheritance"),&_ClassDB::get_signal_list,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_has_signal","class","signal"),&_ClassDB::has_signal);
+ ClassDB::bind_method(D_METHOD("class_get_signal","class","signal"),&_ClassDB::get_signal);
+ ClassDB::bind_method(D_METHOD("class_get_signal_list","class","no_inheritance"),&_ClassDB::get_signal_list,DEFVAL(false));
- ClassDB::bind_method(_MD("get_property_list","class","no_inheritance"),&_ClassDB::get_property_list,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_get_property_list","class","no_inheritance"),&_ClassDB::get_property_list,DEFVAL(false));
- ClassDB::bind_method(_MD("has_method","class","method","no_inheritance"),&_ClassDB::has_method,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_has_method","class","method","no_inheritance"),&_ClassDB::has_method,DEFVAL(false));
- ClassDB::bind_method(_MD("get_method_list","class","no_inheritance"),&_ClassDB::get_method_list,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_get_method_list","class","no_inheritance"),&_ClassDB::get_method_list,DEFVAL(false));
- ClassDB::bind_method(_MD("get_integer_constant_list","class","no_inheritance"),&_ClassDB::get_integer_constant_list,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("class_get_integer_constant_list","class","no_inheritance"),&_ClassDB::get_integer_constant_list,DEFVAL(false));
- ClassDB::bind_method(_MD("has_integer_constant","class","name"),&_ClassDB::has_integer_constant);
- ClassDB::bind_method(_MD("get_integer_constant","class","name"),&_ClassDB::get_integer_constant);
+ ClassDB::bind_method(D_METHOD("class_has_integer_constant","class","name"),&_ClassDB::has_integer_constant);
+ ClassDB::bind_method(D_METHOD("class_get_integer_constant","class","name"),&_ClassDB::get_integer_constant);
- ClassDB::bind_method(_MD("get_category","class"),&_ClassDB::get_category);
- ClassDB::bind_method(_MD("is_class_enabled","class"),&_ClassDB::is_class_enabled);
+ ClassDB::bind_method(D_METHOD("class_get_category","class"),&_ClassDB::get_category);
+ ClassDB::bind_method(D_METHOD("is_class_enabled","class"),&_ClassDB::is_class_enabled);
}
@@ -2596,3 +2549,88 @@ _ClassDB::~_ClassDB(){
}
+///////////////////////////////
+
+
+void _Engine::set_iterations_per_second(int p_ips) {
+
+ Engine::get_singleton()->set_iterations_per_second(p_ips);
+}
+int _Engine::get_iterations_per_second() const {
+
+ return Engine::get_singleton()->get_iterations_per_second();
+
+}
+
+void _Engine::set_target_fps(int p_fps) {
+ Engine::get_singleton()->set_target_fps(p_fps);
+}
+
+float _Engine::get_target_fps() const {
+ return Engine::get_singleton()->get_target_fps();
+}
+
+
+
+float _Engine::get_frames_per_second() const {
+
+ return Engine::get_singleton()->get_frames_per_second();
+}
+
+String _Engine::get_custom_level() const {
+
+ return Engine::get_singleton()->get_custom_level();
+}
+
+void _Engine::set_time_scale(float p_scale) {
+ Engine::get_singleton()->set_time_scale(p_scale);
+}
+
+float _Engine::get_time_scale() {
+
+ return Engine::get_singleton()->get_time_scale();
+}
+
+int _Engine::get_frames_drawn() {
+
+ return Engine::get_singleton()->get_frames_drawn();
+}
+
+MainLoop *_Engine::get_main_loop() const {
+
+ //needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here
+ return OS::get_singleton()->get_main_loop();
+}
+
+Dictionary _Engine::get_version_info() const {
+
+ return Engine::get_singleton()->get_version_info();
+}
+
+
+void _Engine::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_iterations_per_second","iterations_per_second"),&_Engine::set_iterations_per_second);
+ ClassDB::bind_method(D_METHOD("get_iterations_per_second"),&_Engine::get_iterations_per_second);
+ ClassDB::bind_method(D_METHOD("set_target_fps","target_fps"),&_Engine::set_target_fps);
+ ClassDB::bind_method(D_METHOD("get_target_fps"),&_Engine::get_target_fps);
+
+ ClassDB::bind_method(D_METHOD("set_time_scale","time_scale"),&_Engine::set_time_scale);
+ ClassDB::bind_method(D_METHOD("get_time_scale"),&_Engine::get_time_scale);
+
+ ClassDB::bind_method(D_METHOD("get_custom_level"),&_Engine::get_custom_level);
+
+ ClassDB::bind_method(D_METHOD("get_frames_drawn"),&_Engine::get_frames_drawn);
+ ClassDB::bind_method(D_METHOD("get_frames_per_second"),&_Engine::get_frames_per_second);
+
+ ClassDB::bind_method(D_METHOD("get_main_loop:MainLoop"),&_Engine::get_main_loop);
+
+ ClassDB::bind_method(D_METHOD("get_version_info"),&_Engine::get_version_info);
+
+}
+
+_Engine *_Engine::singleton = NULL;
+
+_Engine::_Engine() {
+ singleton=this;
+}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index d491483d82..4241912ddd 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -54,7 +54,6 @@ public:
void set_abort_on_missing_resources(bool p_abort);
PoolStringArray get_dependencies(const String& p_path);
bool has(const String& p_path);
- Ref<ResourceImportMetadata> load_import_metadata(const String& p_path);
_ResourceLoader();
};
@@ -169,12 +168,6 @@ public:
void native_video_unpause();
void native_video_stop();
- void set_iterations_per_second(int p_ips);
- int get_iterations_per_second() const;
-
- void set_target_fps(int p_fps);
- float get_target_fps() const;
-
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
@@ -196,11 +189,7 @@ public:
String get_latin_keyboard_variant() const;
String get_model_name() const;
- MainLoop *get_main_loop() const;
-
- String get_custom_level() const;
- float get_frames_per_second() const;
void dump_memory_to_file(const String& p_file);
void dump_resources_to_file(const String& p_file);
@@ -271,8 +260,6 @@ public:
bool can_draw() const;
- int get_frames_drawn();
-
bool is_stdout_verbose() const;
int get_processor_count() const;
@@ -313,8 +300,6 @@ public:
void set_keep_screen_on(bool p_enabled);
bool is_keep_screen_on() const;
- void set_time_scale(float p_scale);
- float get_time_scale();
bool is_ok_left_and_cancel_right() const;
@@ -323,8 +308,6 @@ public:
void set_use_vsync(bool p_enable);
bool is_vsync_enabled() const;
- Dictionary get_engine_version() const;
-
static _OS *get_singleton() { return singleton; }
_OS();
@@ -351,6 +334,7 @@ public:
Variant segment_intersects_segment_2d(const Vector2& p_from_a,const Vector2& p_to_a,const Vector2& p_from_b,const Vector2& p_to_b);
PoolVector<Vector2> get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2);
PoolVector<Vector3> get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2);
+ Vector2 get_closest_point_to_segment_2d(const Vector2& p_point, const Vector2& p_a,const Vector2& p_b);
Vector3 get_closest_point_to_segment(const Vector3& p_point, const Vector3& p_a,const Vector3& p_b);
Variant ray_intersects_triangle( const Vector3& p_from, const Vector3& p_dir, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
Variant segment_intersects_triangle( const Vector3& p_from, const Vector3& p_to, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
@@ -456,6 +440,8 @@ public:
bool file_exists(const String& p_name) const; ///< return true if a file exists
+ uint64_t get_modified_time(const String& p_file) const;
+
_File();
virtual ~_File();
@@ -472,7 +458,7 @@ public:
Error open(const String& p_path);
- bool list_dir_begin(); ///< This starts dir listing
+ Error list_dir_begin(bool p_skip_internal = false, bool p_skip_hidden = false); ///< This starts dir listing
String get_next();
bool current_is_dir() const;
@@ -480,6 +466,7 @@ public:
int get_drive_count();
String get_drive(int p_drive);
+ int get_current_drive();
Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
String get_current_dir(); ///< return current dir location
@@ -500,6 +487,9 @@ public:
_Directory();
virtual ~_Directory();
+private:
+ bool _list_skip_navigational;
+ bool _list_skip_hidden;
};
class _Marshalls : public Reference {
@@ -632,4 +622,39 @@ public:
~_ClassDB();
};
+
+class _Engine : public Object {
+ GDCLASS(_Engine,Object);
+
+protected:
+
+ static void _bind_methods();
+ static _Engine *singleton;
+
+public:
+
+ static _Engine* get_singleton() { return singleton; }
+ void set_iterations_per_second(int p_ips);
+ int get_iterations_per_second() const;
+
+ void set_target_fps(int p_fps);
+ float get_target_fps() const;
+
+ float get_frames_per_second() const;
+
+ int get_frames_drawn();
+
+ void set_time_scale(float p_scale);
+ float get_time_scale();
+
+ String get_custom_level() const;
+
+ MainLoop *get_main_loop() const;
+
+ Dictionary get_version_info() const;
+
+ _Engine();
+};
+
+
#endif // CORE_BIND_H
diff --git a/core/object_type_db.cpp b/core/class_db.cpp
index f3bb37421f..4bdae45fb9 100644
--- a/core/object_type_db.cpp
+++ b/core/class_db.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* object_type_db.cpp */
+/* class_db.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,12 +26,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "object_type_db.h"
+#include "class_db.h"
+
#include "os/mutex.h"
#ifdef NO_THREADS
#define OBJTYPE_RLOCK
+#define OBJTYPE_WLOCK
#else
@@ -45,14 +47,14 @@
ParamDef::ParamDef(const Variant& p_variant) { used=true; val=p_variant; }
-MethodDefinition _MD(const char* p_name) {
+MethodDefinition D_METHOD(const char* p_name) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -60,7 +62,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1) {
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -70,7 +72,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2) {
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -81,7 +83,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -93,7 +95,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -107,7 +109,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -121,7 +123,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -136,7 +138,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -152,7 +154,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -169,7 +171,7 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
return md;
}
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10) {
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10) {
MethodDefinition md;
md.name=StaticCString::create(p_name);
@@ -293,7 +295,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
OBJTYPE_RLOCK;
#ifdef DEBUG_METHODS_ENABLED
- uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME));
+ uint64_t hash = hash_djb2_one_64(HashMapHasherDefault::hash(VERSION_FULL_NAME));
List<StringName> names;
@@ -775,11 +777,15 @@ void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const
+#ifndef NO_THREADS
lock->read_lock();
+#endif
ClassInfo *type=classes.getptr(p_class);
+#ifndef NO_THREADS
lock->read_unlock();
+#endif
ERR_FAIL_COND(!type);
@@ -897,7 +903,7 @@ bool ClassDB::set_property(Object* p_object,const StringName& p_property, const
if (psg->index>=0) {
Variant index=psg->index;
const Variant* arg[2]={&index,&p_value};
-// p_object->call(psg->setter,arg,2,ce);
+ //p_object->call(psg->setter,arg,2,ce);
if (psg->_setptr) {
psg->_setptr->call(p_object,arg,2,ce);
} else {
@@ -1111,6 +1117,15 @@ MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const
String instance_type=p_bind->get_instance_class();
+#ifdef DEBUG_ENABLED
+
+ if (has_method(instance_type,mdname)) {
+ ERR_EXPLAIN("Class "+String(instance_type)+" already has a method "+String(mdname));
+ ERR_FAIL_V(NULL);
+ }
+#endif
+
+
ClassInfo *type=classes.getptr(instance_type);
if (!type) {
ERR_PRINTS("Couldn't bind method '"+mdname+"' for instance: "+instance_type);
@@ -1241,7 +1256,7 @@ void ClassDB::get_extensions_for_type(const StringName& p_class,List<String> *p_
while((K=resource_base_extensions.next(K))) {
StringName cmp = resource_base_extensions[*K];
- if (is_parent_class(cmp,p_class))
+ if (is_parent_class(p_class,cmp))
p_extensions->push_back(*K);
}
}
diff --git a/core/object_type_db.h b/core/class_db.h
index f745e3d5fd..6e02d0bf46 100644
--- a/core/object_type_db.h
+++ b/core/class_db.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* object_type_db.h */
+/* class_db.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,12 +26,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef OBJECT_TYPE_DB_H
-#define OBJECT_TYPE_DB_H
+#ifndef CLASS_DB_H
+#define CLASS_DB_H
#include "object.h"
#include "method_bind.h"
#include "print_string.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -80,17 +81,17 @@ struct MethodDefinition {
-MethodDefinition _MD(const char* p_name);
-MethodDefinition _MD(const char* p_name,const char *p_arg1);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9);
-MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10);
+MethodDefinition D_METHOD(const char* p_name);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9);
+MethodDefinition D_METHOD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10);
#else
@@ -98,11 +99,13 @@ MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,co
#ifdef NO_VARIADIC_MACROS
-static _FORCE_INLINE_ const char* _MD(const char* m_name, ...) { return m_name; }
+static _FORCE_INLINE_ const char* D_METHOD(const char* m_name, ...) { return m_name; }
#else
-#define _MD(m_c, ...) m_c
+// When DEBUG_METHODS_ENABLED is set this will let the engine know
+// the argument names for easier debugging.
+#define D_METHOD(m_c, ...) m_c
#endif
@@ -537,4 +540,4 @@ public:
-#endif
+#endif // CLASS_DB_H
diff --git a/core/color.cpp b/core/color.cpp
index 89accbb6d2..80a98da252 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "color.h"
+
#include "math_funcs.h"
#include "print_string.h"
#include "map.h"
diff --git a/core/color_names.inc b/core/color_names.inc
index 7b674bb289..b05684acc6 100644
--- a/core/color_names.inc
+++ b/core/color_names.inc
@@ -1,4 +1,6 @@
// Names from https://en.wikipedia.org/wiki/List_of_colors (through https://raw.githubusercontent.com/SuperUserNameMan/color_to_name/616a7cddafefda91478b7bc26167de97fb5badb1/godot_version.gd), slightly edited and normalized
+#include "map.h"
+
static Map<String, Color> _named_colors;
static void _populate_named_colors() {
if(!_named_colors.empty()) return;
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index 9b1c052eb9..6d50ed8d9a 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "command_queue_mt.h"
+
#include "os/os.h"
void CommandQueueMT::lock() {
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 779bbe1b58..3975df7658 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -179,7 +179,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class R>
@@ -204,7 +204,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class R>
@@ -218,7 +218,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class R>
@@ -233,7 +233,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class R>
@@ -249,7 +249,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class R>
@@ -266,7 +266,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class R>
@@ -284,7 +284,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8,class R>
@@ -303,7 +303,7 @@ class CommandQueueMT {
R* ret;
SyncSemaphore *sync;
- virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; }
};
/** commands that don't return but sync */
@@ -318,7 +318,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1>
@@ -330,7 +330,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2>
@@ -343,7 +343,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3>
@@ -357,7 +357,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4>
@@ -372,7 +372,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5>
@@ -388,7 +388,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6>
@@ -405,7 +405,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7>
@@ -423,7 +423,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class P8>
@@ -442,7 +442,7 @@ class CommandQueueMT {
SyncSemaphore *sync;
- virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; ; }
+ virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7,p8); sync->sem->post(); sync->in_use=false; }
};
/***** BASE *******/
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index 71f810422a..570cf114f7 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "compressed_translation.h"
+
#include "pair.h"
#include <string.h>
@@ -467,7 +468,7 @@ StringName PHashTranslation::get_message(const StringName& p_src_text) const {
//print_line("Hash: "+itos(p));
if (p==0xFFFFFFFF) {
-// print_line("GETMSG: Nothing!");
+ //print_line("GETMSG: Nothing!");
return StringName(); //nothing
}
@@ -489,7 +490,7 @@ StringName PHashTranslation::get_message(const StringName& p_src_text) const {
//print_line("bucket pos: "+itos(idx));
if (idx==-1) {
-// print_line("GETMSG: Not in Bucket!");
+ //print_line("GETMSG: Not in Bucket!");
return StringName();
}
@@ -497,8 +498,8 @@ StringName PHashTranslation::get_message(const StringName& p_src_text) const {
String rstr;
rstr.parse_utf8(&sptr[ bucket.elem[idx].str_offset ], bucket.elem[idx].uncomp_size );
-// print_line("Uncompressed, size: "+itos(bucket.elem[idx].comp_size));
-// print_line("Return: "+rstr);
+ //print_line("Uncompressed, size: "+itos(bucket.elem[idx].comp_size));
+ //print_line("Return: "+rstr);
return rstr;
} else {
@@ -508,8 +509,8 @@ StringName PHashTranslation::get_message(const StringName& p_src_text) const {
smaz_decompress(&sptr[ bucket.elem[idx].str_offset ], bucket.elem[idx].comp_size,uncomp.ptr(),bucket.elem[idx].uncomp_size );
String rstr;
rstr.parse_utf8(uncomp.get_data());
-// print_line("Compressed, size: "+itos(bucket.elem[idx].comp_size));
-// print_line("Return: "+rstr);
+ //print_line("Compressed, size: "+itos(bucket.elem[idx].comp_size));
+ //print_line("Return: "+rstr);
return rstr;
}
@@ -526,7 +527,7 @@ void PHashTranslation::_get_property_list( List<PropertyInfo> *p_list) const{
}
void PHashTranslation::_bind_methods() {
- ClassDB::bind_method(_MD("generate","from:Translation"),&PHashTranslation::generate);
+ ClassDB::bind_method(D_METHOD("generate","from:Translation"),&PHashTranslation::generate);
}
PHashTranslation::PHashTranslation()
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp
index a173f98602..f8c6f47797 100644
--- a/core/core_string_names.cpp
+++ b/core/core_string_names.cpp
@@ -35,7 +35,7 @@ CoreStringNames::CoreStringNames() {
_free=StaticCString::create("free");
changed=StaticCString::create("changed");
_meta=StaticCString::create("__meta__");
- _script=StaticCString::create("script/script");
+ _script=StaticCString::create("script");
script_changed=StaticCString::create("script_changed");
___pdcdata=StaticCString::create("___pdcdata");
__getvar=StaticCString::create("__getvar");
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 3b4d3b65d0..1176b9be3b 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dictionary.h"
+
#include "safe_refcount.h"
#include "variant.h"
diff --git a/core/dvector.h b/core/dvector.h
index cac9e8ef85..456be41289 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -34,6 +34,7 @@
#include "pool_allocator.h"
#include "safe_refcount.h"
#include "os/rw_lock.h"
+#include "ustring.h"
struct MemoryPool {
@@ -89,7 +90,7 @@ class PoolVector {
if (!alloc)
return;
- ERR_FAIL_COND(alloc->lock>0);
+// ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all
if (alloc->refcount.get()==1)
return; //nothing to do
@@ -466,6 +467,16 @@ public:
return OK;
}
+ String join(String delimiter) {
+ String rs = "";
+ int s = size();
+ Read r = read();
+ for(int i=0;i<s;i++) {
+ rs += r[i] + delimiter;
+ }
+ rs.erase( rs.length()-delimiter.length(), delimiter.length());
+ return rs;
+ }
bool is_locked() const { return alloc && alloc->lock>0; }
diff --git a/modules/chibi/cp_sample_manager.cpp b/core/engine.cpp
index 2ad0a720b4..b017e77275 100644
--- a/modules/chibi/cp_sample_manager.cpp
+++ b/core/engine.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cp_sample_manager.cpp */
+/* engine.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,53 +26,94 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "cp_sample_manager.h"
-
-
-CPSampleManager * CPSampleManager::singleton=NULL;
-
-
-void CPSampleManager::copy_to(CPSample_ID p_from,CPSample_ID &p_to) {
-
- ERR_FAIL_COND(!check( p_from ));
-
-
- if (p_to.is_null()) {
-
- p_to=create( is_16bits( p_from), is_stereo( p_from), get_size(p_from));
- } else {
-
- recreate( p_to, is_16bits( p_from), is_stereo( p_from), get_size(p_from));
-
- }
-
- int len=get_size( p_from );
- int ch=is_stereo( p_from ) ? 2 : 1;
-
- for (int c=0;c<ch;c++) {
-
- for (int i=0;i<len;i++) {
-
- int16_t s=get_data( p_from, i, c );
- set_data( p_to, i, s, c );
- }
- }
-
- set_loop_type( p_to, get_loop_type( p_from ) );
- set_loop_begin( p_to, get_loop_begin( p_from ) );
- set_loop_end( p_to, get_loop_end( p_from ) );
- set_c5_freq( p_to, get_c5_freq( p_from ) );
-
-
-
+#include "engine.h"
+
+#include "version.h"
+
+void Engine::set_iterations_per_second(int p_ips) {
+
+ ips=p_ips;
+}
+int Engine::get_iterations_per_second() const {
+
+ return ips;
}
-CPSampleManager::CPSampleManager() {
+void Engine::set_target_fps(int p_fps) {
+ _target_fps=p_fps>0? p_fps : 0;
+}
- singleton=this;
+float Engine::get_target_fps() const {
+ return _target_fps;
+}
+
+uint64_t Engine::get_frames_drawn() {
+
+ return frames_drawn;
+}
+
+void Engine::set_frame_delay(uint32_t p_msec) {
+
+ _frame_delay=p_msec;
+}
+
+uint32_t Engine::get_frame_delay() const {
+
+ return _frame_delay;
}
-CPSampleManager *CPSampleManager::get_singleton() {
+void Engine::set_time_scale(float p_scale) {
+ _time_scale=p_scale;
+}
+
+float Engine::get_time_scale() const {
+
+ return _time_scale;
+}
+
+Dictionary Engine::get_version_info() const {
+
+ Dictionary dict;
+ dict["major"] = VERSION_MAJOR;
+ dict["minor"] = VERSION_MINOR;
+ #ifdef VERSION_PATCH
+ dict["patch"] = VERSION_PATCH;
+ #else
+ dict["patch"] = 0;
+ #endif
+ dict["status"] = _MKSTR(VERSION_STATUS);
+ dict["revision"] = _MKSTR(VERSION_REVISION);
+ dict["year"] = VERSION_YEAR;
+
+ String stringver = String(dict["major"]) + "." + String(dict["minor"]);
+ if ((int)dict["patch"] != 0)
+ stringver += "." + String(dict["patch"]);
+ stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
+ dict["string"] = stringver;
+
+ return dict;
+}
+
+
+Engine *Engine::singleton=NULL;
+
+Engine *Engine::get_singleton() {
return singleton;
}
+
+Engine::Engine()
+{
+
+ singleton=this;
+ frames_drawn=0;
+ ips=60;
+ _frame_delay=0;
+ _fps=1;
+ _target_fps=0;
+ _time_scale=1.0;
+ _pixel_snap=false;
+ _fixed_frames=0;
+ _idle_frames=0;
+ _in_fixed=false;
+}
diff --git a/scene/2d/sound_player_2d.h b/core/engine.h
index bfabda4ec9..9af4219a68 100644
--- a/scene/2d/sound_player_2d.h
+++ b/core/engine.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* sound_player_2d.h */
+/* engine.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,57 +26,63 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef SOUND_PLAYER_2D_H
-#define SOUND_PLAYER_2D_H
+#ifndef ENGINE_H
+#define ENGINE_H
+#include "ustring.h"
+#include "list.h"
+#include "vector.h"
+#include "os/main_loop.h"
-#include "scene/2d/node_2d.h"
-#include "scene/resources/sample_library.h"
-#include "servers/spatial_sound_2d_server.h"
-#include "scene/main/viewport.h"
+class Engine {
-class SoundPlayer2D : public Node2D {
+friend class Main;
- GDCLASS(SoundPlayer2D,Node2D);
-public:
-
-
- enum Param {
+ String _custom_level;
+ uint64_t frames_drawn;
+ uint32_t _frame_delay;
- PARAM_VOLUME_DB=SpatialSound2DServer::SOURCE_PARAM_VOLUME_DB,
- PARAM_PITCH_SCALE=SpatialSound2DServer::SOURCE_PARAM_PITCH_SCALE,
- PARAM_ATTENUATION_MIN_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- PARAM_ATTENUATION_MAX_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- PARAM_ATTENUATION_DISTANCE_EXP=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- PARAM_MAX=SpatialSound2DServer::SOURCE_PARAM_MAX
- };
+ int ips;
+ float _fps;
+ int _target_fps;
+ float _time_scale;
+ bool _pixel_snap;
+ uint64_t _fixed_frames;
+ uint64_t _idle_frames;
+ bool _in_fixed;
-private:
+ static Engine *singleton;
+public:
- float params[PARAM_MAX];
- RID source_rid;
+ static Engine *get_singleton();
+ virtual void set_iterations_per_second(int p_ips);
+ virtual int get_iterations_per_second() const;
-protected:
+ virtual void set_target_fps(int p_fps);
+ virtual float get_target_fps() const;
- _FORCE_INLINE_ RID get_source_rid() const { return source_rid; }
+ virtual float get_frames_per_second() const { return _fps; }
- void _notification(int p_what);
+ String get_custom_level() const { return _custom_level; }
- static void _bind_methods();
+ uint64_t get_frames_drawn();
-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; }
- void set_param( Param p_param, float p_value);
- float get_param( Param p_param) const;
+ void set_time_scale(float p_scale);
+ float get_time_scale() const;
+ void set_frame_delay(uint32_t p_msec);
+ uint32_t get_frame_delay() const;
- SoundPlayer2D();
- ~SoundPlayer2D();
+ _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
+ Dictionary get_version_info() const;
+ Engine();
};
-VARIANT_ENUM_CAST(SoundPlayer2D::Param );
-
-#endif // SOUND_PLAYER_2D_H
+#endif // ENGINE_H
diff --git a/core/error_list.h b/core/error_list.h
index c3cd9b399d..f4063a9285 100644
--- a/core/error_list.h
+++ b/core/error_list.h
@@ -58,7 +58,7 @@ enum Error {
ERR_FILE_EOF,
ERR_CANT_OPEN, ///< Can't open a resource/socket/file
ERR_CANT_CREATE, // (20)
- ERROR_QUERY_FAILED,
+ ERR_QUERY_FAILED,
ERR_ALREADY_IN_USE,
ERR_LOCKED, ///< resource is locked
ERR_TIMEOUT,
diff --git a/core/error_macros.cpp b/core/error_macros.cpp
index 53a361fa3a..e963f6122b 100644
--- a/core/error_macros.cpp
+++ b/core/error_macros.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "error_macros.h"
+
#include "os/os.h"
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 1e8c229810..2233615e25 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -65,8 +65,8 @@ void FuncRef::_bind_methods() {
}
- ClassDB::bind_method(_MD("set_instance","instance"),&FuncRef::set_instance);
- ClassDB::bind_method(_MD("set_function","name"),&FuncRef::set_function);
+ ClassDB::bind_method(D_METHOD("set_instance","instance"),&FuncRef::set_instance);
+ ClassDB::bind_method(D_METHOD("set_function","name"),&FuncRef::set_function);
}
diff --git a/core/globals.cpp b/core/global_config.cpp
index 28fabac302..b76991c04e 100644
--- a/core/globals.cpp
+++ b/core/global_config.cpp
@@ -26,10 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "globals.h"
+#include "global_config.h"
+
#include "os/dir_access.h"
#include "os/file_access.h"
-
#include "os/keyboard.h"
#include "io/marshalls.h"
#include "bind/core_bind.h"
@@ -37,6 +37,9 @@
#include "io/file_access_pack.h"
#include "io/file_access_network.h"
#include "variant_parser.h"
+
+#define FORMAT_VERSION 3
+
GlobalConfig *GlobalConfig::singleton=NULL;
GlobalConfig *GlobalConfig::get_singleton() {
@@ -122,6 +125,7 @@ bool GlobalConfig::_set(const StringName& p_name, const Variant& p_value) {
_THREAD_SAFE_METHOD_
+
if (p_value.get_type()==Variant::NIL)
props.erase(p_name);
else {
@@ -166,8 +170,10 @@ bool GlobalConfig::_get(const StringName& p_name,Variant &r_ret) const {
_THREAD_SAFE_METHOD_
- if (!props.has(p_name))
+ if (!props.has(p_name)) {
+ print_line("WARNING: not found: "+String(p_name));
return false;
+ }
r_ret=props[p_name].variant;
return true;
@@ -241,76 +247,71 @@ bool GlobalConfig::_load_resource_pack(const String& p_pack) {
Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) {
- //an absolute mess of a function, must be cleaned up and reorganized somehow at some point
-
- //_load_settings(p_path+"/override.cfg");
+ //If looking for files in network, just use network!
- if (p_main_pack!="") {
-
- bool ok = _load_resource_pack(p_main_pack);
- ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
+ if (FileAccessNetworkClient::get_singleton()) {
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
+ if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
}
return OK;
-
}
- if (OS::get_singleton()->get_executable_path()!="") {
+ String exec_path = OS::get_singleton()->get_executable_path();
+
+ //Attempt with a passed main pack first
- if (_load_resource_pack(OS::get_singleton()->get_executable_path())) {
+ if (p_main_pack!="") {
- if (p_path!="") {
- resource_path=p_path;
- } else {
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- resource_path=d->get_current_dir();
- memdelete(d);
+ bool ok = _load_resource_pack(p_main_pack);
+ ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
- }
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
+ if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
+ //load override from location of the main pack
+ _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg"));
- _load_settings("res://override.cfg");
+ }
- }
+ return OK;
+ }
+ //Attempt with execname.pck
+ if (exec_path!="") {
- return OK;
- }
- }
+ if (_load_resource_pack(exec_path.get_basename()+".pck")) {
+ if (_load_settings("res://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
+ //load override from location of executable
+ _load_settings(exec_path.get_base_dir().plus_file("override.cfg"));
- if (FileAccessNetworkClient::get_singleton()) {
+ }
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
- _load_settings("res://override.cfg");
+ return OK;
}
- return OK;
}
+
+ //Try to use the filesystem for files, according to OS. (only Android -when reading from pck- and iOS use this)
if (OS::get_singleton()->get_resource_dir()!="") {
- //OS will call Globals->get_resource_path which will be empty if not overriden!
+ //OS will call Globals->get_resource_path which will be empty if not overriden!
//if the OS would rather use somewhere else, then it will not be empty.
+
resource_path=OS::get_singleton()->get_resource_dir().replace("\\","/");
if (resource_path.length() && resource_path[ resource_path.length()-1]=='/')
resource_path=resource_path.substr(0,resource_path.length()-1); // chop end
- print_line("has res dir: "+resource_path);
- if (!_load_resource_pack("res://data.pck"))
- _load_resource_pack("res://data.zip");
- // make sure this is load from the resource path
- print_line("exists engine cfg? "+itos(FileAccess::exists("/engine.cfg")));
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
- print_line("loaded engine.cfg");
+ // 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://godot.cfg")==OK || _load_settings_binary("res://godot.cfb")==OK) {
_load_settings("res://override.cfg");
}
@@ -318,67 +319,41 @@ Error GlobalConfig::setup(const String& p_path,const String & p_main_pack) {
return OK;
}
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (!d) {
-
- resource_path = p_path;
-
- } else {
+ //Nothing was found, try to find a godot.cfg somewhere!
- d->change_dir(p_path);
-
- String candidate = d->get_current_dir();
- String current_dir = d->get_current_dir();
- String exec_name = OS::get_singleton()->get_executable_path().get_file().basename();
- bool found = false;
- bool first_time=true;
-
- while(true) {
- //try to load settings in ascending through dirs shape!
-
- //tries to open pack, but only first time
- if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".zip") )) {
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
-
- _load_settings("res://override.cfg");
- found=true;
-
-
- }
- break;
- } else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.zip") )) {
- if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
+ DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ ERR_FAIL_COND_V(!d,ERR_CANT_CREATE);
- _load_settings("res://override.cfg");
- found=true;
+ d->change_dir(p_path);
+ String candidate = d->get_current_dir();
+ String current_dir = d->get_current_dir();
+ bool found = false;
- }
- break;
- } else if (_load_settings(current_dir+"/engine.cfg")==OK || _load_settings_binary(current_dir+"/engine.cfb")==OK) {
+ while(true) {
+ //try to load settings in ascending through dirs shape!
- _load_settings(current_dir+"/override.cfg");
- candidate=current_dir;
- found=true;
- break;
- }
+ if (_load_settings(current_dir+"/godot.cfg")==OK || _load_settings_binary(current_dir+"/godot.cfb")==OK) {
- d->change_dir("..");
- if (d->get_current_dir()==current_dir)
- break; //not doing anything useful
- current_dir=d->get_current_dir();
- first_time=false;
+ _load_settings(current_dir+"/override.cfg");
+ candidate=current_dir;
+ found=true;
+ break;
}
+ d->change_dir("..");
+ if (d->get_current_dir()==current_dir)
+ break; //not doing anything useful
+ current_dir=d->get_current_dir();
+ }
- resource_path=candidate;
- resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case
- memdelete(d);
- if (!found)
- return ERR_FILE_NOT_FOUND;
- };
+ resource_path=candidate;
+ resource_path = resource_path.replace("\\","/"); // windows path to unix path just in case
+ memdelete(d);
+ if (!found)
+ return ERR_FILE_NOT_FOUND;
if (resource_path.length() && resource_path[ resource_path.length()-1]=='/')
resource_path=resource_path.substr(0,resource_path.length()-1); // chop end
@@ -413,7 +388,7 @@ 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 engine.cfb (not ECFG)");
+ ERR_EXPLAIN("Corrupted header in binary godot.cfb (not ECFG)");
ERR_FAIL_V(ERR_FILE_CORRUPT;)
}
@@ -488,6 +463,14 @@ Error GlobalConfig::_load_settings(const String p_path) {
}
if (assign!=String()) {
+ if (section==String() && assign=="config_version") {
+ int config_version = value;
+ if (config_version > FORMAT_VERSION) {
+ memdelete(f);
+ ERR_FAIL_COND_V(config_version > FORMAT_VERSION,ERR_FILE_CANT_OPEN);
+ }
+
+ }
set(section+"/"+assign,value);
} else if (next_tag.name!=String()) {
section=next_tag.name;
@@ -523,7 +506,7 @@ void GlobalConfig::clear(const String& p_name) {
Error GlobalConfig::save() {
- return save_custom(get_resource_path()+"/engine.cfg");
+ return save_custom(get_resource_path()+"/godot.cfg");
}
Error GlobalConfig::_save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom) {
@@ -533,7 +516,7 @@ Error GlobalConfig::_save_settings_binary(const String& p_file,const Map<String,
FileAccess *file = FileAccess::open(p_file,FileAccess::WRITE,&err);
if (err!=OK) {
- ERR_EXPLAIN("Coudln't save engine.cfb at "+p_file);
+ ERR_EXPLAIN("Coudln't save godot.cfb at "+p_file);
ERR_FAIL_COND_V(err,err)
}
@@ -601,10 +584,13 @@ Error GlobalConfig::_save_settings_text(const String& p_file,const Map<String,Li
FileAccess *file = FileAccess::open(p_file,FileAccess::WRITE,&err);
if (err) {
- ERR_EXPLAIN("Coudln't save engine.cfg - "+p_file);
+ ERR_EXPLAIN("Coudln't save godot.cfg - "+p_file);
ERR_FAIL_COND_V(err,err)
}
+ file->store_string("config_version="+itos(FORMAT_VERSION)+"\n");
+
+
for(Map<String,List<String> >::Element *E=props.front();E;E=E->next()) {
if (E!=props.front())
@@ -731,7 +717,7 @@ Error GlobalConfig::save_custom(const String& p_path,const CustomMap& p_custom,c
Error err = file->open(dst_file,FileAccess::WRITE);
if (err) {
memdelete(file);
- ERR_EXPLAIN("Coudln't save engine.cfg");
+ ERR_EXPLAIN("Coudln't save godot.cfg");
ERR_FAIL_COND_V(err,err)
}
@@ -883,22 +869,22 @@ Variant GlobalConfig::property_get_revert(const String& p_name) {
void GlobalConfig::_bind_methods() {
- ClassDB::bind_method(_MD("has","name"),&GlobalConfig::has);
- ClassDB::bind_method(_MD("set_order","name","pos"),&GlobalConfig::set_order);
- ClassDB::bind_method(_MD("get_order","name"),&GlobalConfig::get_order);
- ClassDB::bind_method(_MD("set_initial_value","name","value"),&GlobalConfig::set_initial_value);
- ClassDB::bind_method(_MD("add_property_info", "hint"),&GlobalConfig::_add_property_info_bind);
- ClassDB::bind_method(_MD("clear","name"),&GlobalConfig::clear);
- ClassDB::bind_method(_MD("localize_path","path"),&GlobalConfig::localize_path);
- ClassDB::bind_method(_MD("globalize_path","path"),&GlobalConfig::globalize_path);
- ClassDB::bind_method(_MD("save"),&GlobalConfig::save);
- ClassDB::bind_method(_MD("has_singleton","name"),&GlobalConfig::has_singleton);
- ClassDB::bind_method(_MD("get_singleton","name"),&GlobalConfig::get_singleton_object);
- ClassDB::bind_method(_MD("load_resource_pack","pack"),&GlobalConfig::_load_resource_pack);
- ClassDB::bind_method(_MD("property_can_revert","name"),&GlobalConfig::property_can_revert);
- ClassDB::bind_method(_MD("property_get_revert","name"),&GlobalConfig::property_get_revert);
-
- ClassDB::bind_method(_MD("save_custom","file"),&GlobalConfig::_save_custom_bnd);
+ 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);
}
@@ -922,6 +908,7 @@ GlobalConfig::GlobalConfig() {
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);
@@ -1011,7 +998,7 @@ 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/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");
diff --git a/core/globals.h b/core/global_config.h
index faf077f2a5..471f1ff885 100644
--- a/core/globals.h
+++ b/core/global_config.h
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GLOBALS_H
-#define GLOBALS_H
+#ifndef GLOBAL_CONFIG_H
+#define GLOBAL_CONFIG_H
#include "object.h"
#include "set.h"
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 936facdd23..be811ccbd2 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_constants.h"
+
#include "variant.h"
#include "os/keyboard.h"
#include "object.h"
@@ -433,7 +434,7 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( ERR_CANT_OPEN ), ///< Can't open a resource/socket/file
BIND_GLOBAL_CONSTANT( ERR_CANT_CREATE ),
BIND_GLOBAL_CONSTANT( ERR_PARSE_ERROR ),
- BIND_GLOBAL_CONSTANT( ERROR_QUERY_FAILED ),
+ BIND_GLOBAL_CONSTANT( ERR_QUERY_FAILED ),
BIND_GLOBAL_CONSTANT( ERR_ALREADY_IN_USE ),
BIND_GLOBAL_CONSTANT( ERR_LOCKED ), ///< resource is locked
BIND_GLOBAL_CONSTANT( ERR_TIMEOUT ),
diff --git a/core/hash_map.h b/core/hash_map.h
index fba12b55ec..515fc6c4fe 100644
--- a/core/hash_map.h
+++ b/core/hash_map.h
@@ -30,38 +30,43 @@
#define HASH_MAP_H
#include "hashfuncs.h"
+#include "math_funcs.h"
#include "error_macros.h"
#include "ustring.h"
#include "os/memory.h"
#include "list.h"
-
-class HashMapHahserDefault {
-public:
-
+struct HashMapHasherDefault {
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); }
- static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) {
- uint64_t v=p_int;
- v = (~v) + (v << 18); // v = (v << 18) - v - 1;
- v = v ^ (v >> 31);
- v = v * 21; // v = (v + (v << 2)) + (v << 4);
- v = v ^ (v >> 11);
- v = v + (v << 6);
- v = v ^ (v >> 22);
- return (int) v;
- }
- static _FORCE_INLINE_ uint32_t hash(const int64_t p_int) { return hash(uint64_t(p_int)); }
+ static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); }
-
- static _FORCE_INLINE_ uint32_t hash(const uint32_t p_int) { return p_int; }
+ static _FORCE_INLINE_ uint32_t hash(const int64_t p_int) { return hash(uint64_t(p_int)); }
+ static _FORCE_INLINE_ uint32_t hash(const float p_float) { return hash_djb2_one_float(p_float); }
+ static _FORCE_INLINE_ uint32_t hash(const double p_double){ return hash_djb2_one_float(p_double); }
+ static _FORCE_INLINE_ uint32_t hash(const uint32_t p_int) { return p_int; }
static _FORCE_INLINE_ uint32_t hash(const int32_t p_int) { return (uint32_t)p_int; }
- static _FORCE_INLINE_ uint32_t hash(const uint16_t p_int) { return p_int; }
+ static _FORCE_INLINE_ uint32_t hash(const uint16_t p_int) { return p_int; }
static _FORCE_INLINE_ uint32_t hash(const int16_t p_int) { return (uint32_t)p_int; }
static _FORCE_INLINE_ uint32_t hash(const uint8_t p_int) { return p_int; }
- static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; }
- static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return (uint32_t)p_wchar; }
-// static _FORCE_INLINE_ uint32_t hash(const void* p_ptr) { return uint32_t(uint64_t(p_ptr))*(0x9e3779b1L); }
+ static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; }
+ static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar){ return (uint32_t)p_wchar; }
+ //static _FORCE_INLINE_ uint32_t hash(const void* p_ptr) { return uint32_t(uint64_t(p_ptr))*(0x9e3779b1L); }
+};
+
+template <typename T>
+struct HashMapComparatorDefault {
+ static bool compare(const T& p_lhs, const T& p_rhs) {
+ return p_lhs == p_rhs;
+ }
+
+ bool compare(const float& p_lhs, const float& p_rhs) {
+ return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs));
+ }
+
+ bool compare(const double& p_lhs, const double& p_rhs) {
+ return (p_lhs == p_rhs) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs));
+ }
};
/**
@@ -74,13 +79,14 @@ public:
* @param TKey Key, search is based on it, needs to be hasheable. It is unique in this container.
* @param TData Data, data associated with the key
* @param Hasher Hasher object, needs to provide a valid static hash function for TKey
+ * @param Comparator comparator object, needs to be able to safely compare two TKey values. It needs to ensure that x == x for any items inserted in the map. Bear in mind that nan != nan when implementing an equality check.
* @param MIN_HASH_TABLE_POWER Miminum size of the hash table, as a power of two. You rarely need to change this parameter.
* @param RELATIONSHIP Relationship at which the hash table is resized. if amount of elements is RELATIONSHIP
* times bigger than the hash table, table is resized to solve this condition. if RELATIONSHIP is zero, table is always MIN_HASH_TABLE_POWER.
*
*/
-template<class TKey, class TData, class Hasher=HashMapHahserDefault,uint8_t MIN_HASH_TABLE_POWER=3,uint8_t RELATIONSHIP=8>
+template<class TKey, class TData, class Hasher=HashMapHasherDefault, class Comparator=HashMapComparatorDefault<TKey>, uint8_t MIN_HASH_TABLE_POWER=3,uint8_t RELATIONSHIP=8>
class HashMap {
public:
@@ -194,7 +200,6 @@ private:
}
-
/* I want to have only one function.. */
_FORCE_INLINE_ const Entry * get_entry( const TKey& p_key ) const {
@@ -206,7 +211,7 @@ private:
while (e) {
/* checking hash first avoids comparing key, which may take longer */
- if (e->hash == hash && e->pair.key == p_key ) {
+ if (e->hash == hash && Comparator::compare(e->pair.key,p_key) ) {
/* the pair exists in this hashtable, so just update data */
return e;
@@ -253,7 +258,6 @@ private:
for (int i=0;i<( 1<<p_t.hash_table_power );i++) {
hash_table[i]=NULL;
- /* elements will be in the reverse order, but it doesn't matter */
const Entry *e = p_t.hash_table[i];
@@ -385,7 +389,7 @@ public:
while (e) {
/* checking hash first avoids comparing key, which may take longer */
- if (e->hash == hash && e->pair.key == p_custom_key ) {
+ if (e->hash == hash && Comparator::compare(e->pair.key,p_custom_key) ) {
/* the pair exists in this hashtable, so just update data */
return &e->pair.data;
@@ -411,7 +415,7 @@ public:
while (e) {
/* checking hash first avoids comparing key, which may take longer */
- if (e->hash == hash && e->pair.key == p_custom_key ) {
+ if (e->hash == hash && Comparator::compare(e->pair.key,p_custom_key) ) {
/* the pair exists in this hashtable, so just update data */
return &e->pair.data;
@@ -442,7 +446,7 @@ public:
while (e) {
/* checking hash first avoids comparing key, which may take longer */
- if (e->hash == hash && e->pair.key == p_key ) {
+ if (e->hash == hash && Comparator::compare(e->pair.key,p_key) ) {
if (p) {
@@ -637,7 +641,8 @@ public:
clear();
}
-
};
+
+
#endif
diff --git a/core/hashfuncs.h b/core/hashfuncs.h
index e9e57d8b42..121d7e8c59 100644
--- a/core/hashfuncs.h
+++ b/core/hashfuncs.h
@@ -29,7 +29,8 @@
#ifndef HASHFUNCS_H
#define HASHFUNCS_H
-
+#include "math_funcs.h"
+#include "math_defs.h"
#include "typedefs.h"
/**
@@ -69,19 +70,52 @@ static inline uint32_t hash_djb2_one_32(uint32_t p_in,uint32_t p_prev=5381) {
return ((p_prev<<5)+p_prev)+p_in;
}
+static inline uint32_t hash_one_uint64(const uint64_t p_int) {
+ uint64_t v=p_int;
+ v = (~v) + (v << 18); // v = (v << 18) - v - 1;
+ v = v ^ (v >> 31);
+ v = v * 21; // v = (v + (v << 2)) + (v << 4);
+ v = v ^ (v >> 11);
+ v = v + (v << 6);
+ v = v ^ (v >> 22);
+ return (int) v;
+}
+
static inline uint32_t hash_djb2_one_float(float p_in,uint32_t p_prev=5381) {
union {
float f;
uint32_t i;
} u;
- // handle -0 case
- if (p_in==0.0f) u.f=0.0f;
- else u.f=p_in;
+ // Normalize +/- 0.0 and NaN values so they hash the same.
+ if (p_in==0.0f)
+ u.f=0.0;
+ else if (Math::is_nan(p_in))
+ u.f=Math_NAN;
+ else
+ u.f=p_in;
return ((p_prev<<5)+p_prev)+u.i;
}
+// Overload for real_t size changes
+static inline uint32_t hash_djb2_one_float(double p_in,uint32_t p_prev=5381) {
+ union {
+ double d;
+ uint64_t i;
+ } u;
+
+ // Normalize +/- 0.0 and NaN values so they hash the same.
+ if (p_in==0.0f)
+ u.d=0.0;
+ else if (Math::is_nan(p_in))
+ u.d=Math_NAN;
+ else
+ u.d=p_in;
+
+ return ((p_prev<<5)+p_prev) + hash_one_uint64(u.i);
+}
+
template<class T>
static inline uint32_t make_uint32_t(T p_in) {
diff --git a/tools/doc/SCsub b/core/helper/SCsub
index 4bc64ffdc2..4efc902717 100644
--- a/tools/doc/SCsub
+++ b/core/helper/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.tool_sources, "*.cpp")
+env.add_source_files(env.core_sources, "*.cpp")
Export('env')
diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp
new file mode 100644
index 0000000000..204c431e1d
--- /dev/null
+++ b/core/helper/math_fieldwise.cpp
@@ -0,0 +1,171 @@
+/*************************************************************************/
+/* fieldwise.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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. */
+/*************************************************************************/
+
+#ifdef TOOLS_ENABLED
+
+#include "core/helper/math_fieldwise.h"
+
+#define SETUP_TYPE(m_type) m_type source=p_source; m_type target=p_target;
+#define TRY_TRANSFER_FIELD(m_name,m_member) if (p_field==m_name) { target.m_member=source.m_member; }
+
+Variant fieldwise_assign(const Variant& p_target, const Variant& p_source, const String& p_field) {
+
+ ERR_FAIL_COND_V(p_target.get_type()!=p_source.get_type(),p_target);
+
+ switch (p_source.get_type()) {
+
+ case Variant::VECTOR2: {
+
+ SETUP_TYPE(Vector2)
+
+ /**/ TRY_TRANSFER_FIELD("x",x)
+ else TRY_TRANSFER_FIELD("y",y)
+
+ return target;
+ }
+
+ case Variant::RECT2: {
+
+ SETUP_TYPE(Rect2)
+
+ /**/ TRY_TRANSFER_FIELD("x",pos.x)
+ else TRY_TRANSFER_FIELD("y",pos.y)
+ else TRY_TRANSFER_FIELD("w",size.x)
+ else TRY_TRANSFER_FIELD("h",size.y)
+
+ return target;
+ }
+
+ case Variant::VECTOR3: {
+
+ SETUP_TYPE(Vector3)
+
+ /**/ TRY_TRANSFER_FIELD("x",x)
+ else TRY_TRANSFER_FIELD("y",y)
+ else TRY_TRANSFER_FIELD("z",z)
+
+ return target;
+ }
+
+ case Variant::PLANE: {
+
+ SETUP_TYPE(Plane)
+
+ /**/ TRY_TRANSFER_FIELD("x",normal.x)
+ else TRY_TRANSFER_FIELD("y",normal.y)
+ else TRY_TRANSFER_FIELD("z",normal.z)
+ else TRY_TRANSFER_FIELD("d",d)
+
+ return target;
+ }
+
+ case Variant::QUAT: {
+
+ SETUP_TYPE(Quat)
+
+ /**/ TRY_TRANSFER_FIELD("x",x)
+ else TRY_TRANSFER_FIELD("y",y)
+ else TRY_TRANSFER_FIELD("z",z)
+ else TRY_TRANSFER_FIELD("w",w)
+
+ return target;
+ }
+
+ case Variant::RECT3: {
+
+ SETUP_TYPE(Rect3)
+
+ /**/ TRY_TRANSFER_FIELD("px",pos.x)
+ else TRY_TRANSFER_FIELD("py",pos.y)
+ else TRY_TRANSFER_FIELD("pz",pos.z)
+ else TRY_TRANSFER_FIELD("sx",size.x)
+ else TRY_TRANSFER_FIELD("sy",size.y)
+ else TRY_TRANSFER_FIELD("sz",size.z)
+
+ return target;
+ }
+
+ case Variant::TRANSFORM2D: {
+
+ SETUP_TYPE(Transform2D)
+
+ /**/ TRY_TRANSFER_FIELD("xx",elements[0][0])
+ else TRY_TRANSFER_FIELD("xy",elements[0][1])
+ else TRY_TRANSFER_FIELD("yx",elements[1][0])
+ else TRY_TRANSFER_FIELD("yy",elements[1][1])
+ else TRY_TRANSFER_FIELD("ox",elements[2][0])
+ else TRY_TRANSFER_FIELD("oy",elements[2][1])
+
+ return target;
+ }
+
+ case Variant::BASIS: {
+
+ SETUP_TYPE(Basis)
+
+ /**/ TRY_TRANSFER_FIELD("xx",elements[0][0])
+ else TRY_TRANSFER_FIELD("xy",elements[0][1])
+ else TRY_TRANSFER_FIELD("xz",elements[0][2])
+ else TRY_TRANSFER_FIELD("yx",elements[1][0])
+ else TRY_TRANSFER_FIELD("yy",elements[1][1])
+ else TRY_TRANSFER_FIELD("yz",elements[1][2])
+ else TRY_TRANSFER_FIELD("zx",elements[2][0])
+ else TRY_TRANSFER_FIELD("zy",elements[2][1])
+ else TRY_TRANSFER_FIELD("zz",elements[2][2])
+
+ return target;
+ }
+
+ case Variant::TRANSFORM: {
+
+ SETUP_TYPE(Transform)
+
+ /**/ TRY_TRANSFER_FIELD("xx",basis.elements[0][0])
+ else TRY_TRANSFER_FIELD("xy",basis.elements[0][1])
+ else TRY_TRANSFER_FIELD("xz",basis.elements[0][2])
+ else TRY_TRANSFER_FIELD("yx",basis.elements[1][0])
+ else TRY_TRANSFER_FIELD("yy",basis.elements[1][1])
+ else TRY_TRANSFER_FIELD("yz",basis.elements[1][2])
+ else TRY_TRANSFER_FIELD("zx",basis.elements[2][0])
+ else TRY_TRANSFER_FIELD("zy",basis.elements[2][1])
+ else TRY_TRANSFER_FIELD("zz",basis.elements[2][2])
+ else TRY_TRANSFER_FIELD("xo",origin.x)
+ else TRY_TRANSFER_FIELD("yo",origin.y)
+ else TRY_TRANSFER_FIELD("zo",origin.z)
+
+ return target;
+ }
+
+ default: {
+ ERR_FAIL_V(p_target);
+ }
+ }
+}
+
+#endif // TOOLS_ENABLED
diff --git a/modules/chibi/register_types.cpp b/core/helper/math_fieldwise.h
index 1a0c808819..31f9af8d0b 100644
--- a/modules/chibi/register_types.cpp
+++ b/core/helper/math_fieldwise.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* register_types.cpp */
+/* fieldwise.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,16 +26,15 @@
/* 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"
+#ifndef MATH_FIELDWISE_H
+#define MATH_FIELDWISE_H
-#include "event_stream_chibi.h"
+#ifdef TOOLS_ENABLED
-void register_chibi_types() {
+#include "core/variant.h"
- initialize_chibi();
-}
+Variant fieldwise_assign(const Variant& p_target, const Variant& p_source, const String& p_field);
-void unregister_chibi_types() {
+#endif // TOOLS_ENABLED
- finalize_chibi();
-}
+#endif // MATH_FIELDWISE_H
diff --git a/core/image.cpp b/core/image.cpp
index 174c840c23..037ff82452 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -27,11 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "image.h"
+
#include "hash_map.h"
#include "core/io/image_loader.h"
#include "core/os/copymem.h"
#include "hq2x.h"
#include "print_string.h"
+
#include <stdio.h>
@@ -243,7 +245,7 @@ void Image::_get_mipmap_offset_and_size(int p_mipmap,int &r_offset, int &r_width
}
int Image::get_mipmap_offset(int p_mipmap) const {
- ERR_FAIL_INDEX_V(p_mipmap,(mipmaps+1),-1);
+ ERR_FAIL_INDEX_V(p_mipmap,get_mipmap_count()+1,-1);
int ofs,w,h;
_get_mipmap_offset_and_size(p_mipmap,ofs,w,h);
@@ -363,7 +365,7 @@ void Image::convert( Format p_new_format ){
Image new_img(width,height,0,p_new_format);
-// int len=data.size();
+ //int len=data.size();
PoolVector<uint8_t>::Read r = data.read();
PoolVector<uint8_t>::Write w = new_img.data.write();
@@ -414,7 +416,7 @@ void Image::convert( Format p_new_format ){
bool gen_mipmaps=mipmaps;
-// mipmaps=false;
+ //mipmaps=false;
*this=new_img;
@@ -762,7 +764,7 @@ void Image::flip_y() {
bool gm=mipmaps;
if (gm)
- clear_mipmaps();;
+ clear_mipmaps();
@@ -789,7 +791,7 @@ void Image::flip_y() {
if (gm)
- generate_mipmaps();;
+ generate_mipmaps();
}
@@ -802,7 +804,7 @@ void Image::flip_x() {
bool gm=mipmaps;
if (gm)
- clear_mipmaps();;
+ clear_mipmaps();
{
@@ -827,7 +829,7 @@ void Image::flip_x() {
}
if (gm)
- generate_mipmaps();;
+ generate_mipmaps();
}
@@ -1009,7 +1011,7 @@ void Image::shrink_x2() {
}
}
-Error Image::generate_mipmaps(bool p_keep_existing) {
+Error Image::generate_mipmaps() {
if (!_can_modify(format)) {
ERR_EXPLAIN("Cannot generate mipmaps in indexed, compressed or custom image formats.");
@@ -1017,15 +1019,14 @@ Error Image::generate_mipmaps(bool p_keep_existing) {
}
- int mmcount = get_mipmap_count();
+ ERR_FAIL_COND_V(width==0 || height==0,ERR_UNCONFIGURED);
+
+ int mmcount;
- int from_mm=1;
- if (p_keep_existing) {
- from_mm=mmcount+1;
- }
int size = _get_dst_image_size(width,height,format,mmcount);
data.resize(size);
+ print_line("to gen mipmaps w "+itos(width)+" h "+itos(height) +" format "+get_format_name(format)+" mipmaps " +itos(mmcount)+" new size is: "+itos(size));
PoolVector<uint8_t>::Write wp=data.write();
@@ -1041,18 +1042,16 @@ Error Image::generate_mipmaps(bool p_keep_existing) {
int ofs,w,h;
_get_mipmap_offset_and_size(i,ofs, w,h);
- if (i>=from_mm) {
- switch(format) {
+ switch(format) {
- case FORMAT_L8:
- case FORMAT_R8: _generate_po2_mipmap<1>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
- case FORMAT_LA8:
- case FORMAT_RG8: _generate_po2_mipmap<2>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
- case FORMAT_RGB8: _generate_po2_mipmap<3>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
- case FORMAT_RGBA8: _generate_po2_mipmap<4>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
- default: {}
- }
+ case FORMAT_L8:
+ case FORMAT_R8: _generate_po2_mipmap<1>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
+ case FORMAT_LA8:
+ case FORMAT_RG8: _generate_po2_mipmap<2>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
+ case FORMAT_RGB8: _generate_po2_mipmap<3>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
+ case FORMAT_RGBA8: _generate_po2_mipmap<4>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h); break;
+ default: {}
}
prev_ofs=ofs;
@@ -1075,18 +1074,15 @@ Error Image::generate_mipmaps(bool p_keep_existing) {
int ofs,w,h;
_get_mipmap_offset_and_size(i,ofs, w,h);
- if (i>=from_mm) {
-
- switch(format) {
+ switch(format) {
- case FORMAT_L8:
- case FORMAT_R8: _scale_bilinear<1>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
- case FORMAT_LA8:
- case FORMAT_RG8: _scale_bilinear<2>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
- case FORMAT_RGB8:_scale_bilinear<3>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
- case FORMAT_RGBA8: _scale_bilinear<4>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
- default: {}
- }
+ case FORMAT_L8:
+ case FORMAT_R8: _scale_bilinear<1>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
+ case FORMAT_LA8:
+ case FORMAT_RG8: _scale_bilinear<2>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
+ case FORMAT_RGB8:_scale_bilinear<3>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
+ case FORMAT_RGBA8: _scale_bilinear<4>(&wp[prev_ofs], &wp[ofs], prev_w,prev_h,w,h); break;
+ default: {}
}
prev_ofs=ofs;
@@ -1094,8 +1090,11 @@ Error Image::generate_mipmaps(bool p_keep_existing) {
prev_h=h;
}
+
+
}
+ mipmaps=true;
return OK;
}
@@ -1152,7 +1151,7 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
ERR_FAIL_INDEX(p_height-1,MAX_HEIGHT);
int mm;
- int size = _get_dst_image_size(p_width,p_height,p_format,mm,p_use_mipmaps);
+ int size = _get_dst_image_size(p_width,p_height,p_format,mm,p_use_mipmaps?-1:0);
if (size!=p_data.size()) {
ERR_EXPLAIN("Expected data size of "+itos(size)+" in Image::create()");
@@ -1240,7 +1239,7 @@ void Image::create( const char ** p_xpm ) {
uint8_t col_r;
uint8_t col_g;
uint8_t col_b;
-// uint8_t col_a=255;
+ //uint8_t col_a=255;
for (int i=0;i<6;i++) {
@@ -2153,7 +2152,7 @@ void Image::fix_alpha_edges() {
return; //not needed
PoolVector<uint8_t> dcopy = data;
- PoolVector<uint8_t>::Read rp = data.read();
+ PoolVector<uint8_t>::Read rp = dcopy.read();
const uint8_t *srcptr=rp.ptr();
PoolVector<uint8_t>::Write wp = data.write();
diff --git a/core/image.h b/core/image.h
index 620160147b..1a257f28a0 100644
--- a/core/image.h
+++ b/core/image.h
@@ -196,7 +196,7 @@ public:
/**
* Generate a mipmap to an image (creates an image 1/4 the size, with averaging of 4->1)
*/
- Error generate_mipmaps(bool p_keep_existing=false);
+ Error generate_mipmaps();
void clear_mipmaps();
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 0379131dd3..444c55cac6 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -27,26 +27,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "input_map.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "os/keyboard.h"
InputMap *InputMap::singleton=NULL;
void InputMap::_bind_methods() {
- ClassDB::bind_method(_MD("has_action","action"),&InputMap::has_action);
- ClassDB::bind_method(_MD("get_action_id","action"),&InputMap::get_action_id);
- ClassDB::bind_method(_MD("get_action_from_id","id"),&InputMap::get_action_from_id);
- ClassDB::bind_method(_MD("get_actions"),&InputMap::_get_actions);
- ClassDB::bind_method(_MD("add_action","action"),&InputMap::add_action);
- ClassDB::bind_method(_MD("erase_action","action"),&InputMap::erase_action);
+ ClassDB::bind_method(D_METHOD("has_action","action"),&InputMap::has_action);
+ ClassDB::bind_method(D_METHOD("get_action_id","action"),&InputMap::get_action_id);
+ ClassDB::bind_method(D_METHOD("get_action_from_id","id"),&InputMap::get_action_from_id);
+ ClassDB::bind_method(D_METHOD("get_actions"),&InputMap::_get_actions);
+ 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(_MD("action_add_event","action","event"),&InputMap::action_add_event);
- ClassDB::bind_method(_MD("action_has_event","action","event"),&InputMap::action_has_event);
- ClassDB::bind_method(_MD("action_erase_event","action","event"),&InputMap::action_erase_event);
- ClassDB::bind_method(_MD("get_action_list","action"),&InputMap::_get_action_list);
- ClassDB::bind_method(_MD("event_is_action","event","action"),&InputMap::event_is_action);
- ClassDB::bind_method(_MD("load_from_globals"),&InputMap::load_from_globals);
+ 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("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("load_from_globals"),&InputMap::load_from_globals);
}
@@ -106,7 +107,7 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
-List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore=false) const {
+List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_action_test) const {
for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) {
@@ -122,7 +123,13 @@ List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const
case InputEvent::KEY: {
- same=(e.key.scancode==p_event.key.scancode && (p_mod_ignore || e.key.mod == p_event.key.mod));
+ if(p_action_test) {
+ uint32_t code = e.key.get_scancode_with_modifiers();
+ uint32_t event_code = p_event.key.get_scancode_with_modifiers();
+ same=(e.key.scancode==p_event.key.scancode && (!p_event.key.pressed || ((code & event_code) == code)));
+ } else {
+ same=(e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod);
+ }
} break;
case InputEvent::JOYPAD_BUTTON: {
@@ -198,7 +205,7 @@ Array InputMap::_get_action_list(const StringName& p_action) {
if (al) {
for(const List<InputEvent>::Element *E=al->front();E;E=E->next()) {
- ret.push_back(E->get());;
+ ret.push_back(E->get());
}
}
@@ -229,7 +236,7 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac
return p_event.action.action==E->get().id;
}
- return _find_event(E->get().inputs,p_event,!p_event.is_pressed())!=NULL;
+ return _find_event(E->get().inputs,p_event,true)!=NULL;
}
const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
@@ -238,7 +245,7 @@ const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
void InputMap::load_from_globals() {
- input_map.clear();;
+ input_map.clear();
List<PropertyInfo> pinfo;
GlobalConfig::get_singleton()->get_property_list(&pinfo);
@@ -253,7 +260,7 @@ void InputMap::load_from_globals() {
add_action(name);
- Array va = GlobalConfig::get_singleton()->get(pi.name);;
+ Array va = GlobalConfig::get_singleton()->get(pi.name);
for(int i=0;i<va.size();i++) {
@@ -324,7 +331,7 @@ void InputMap::load_default() {
key.key.scancode=KEY_PAGEDOWN;
action_add_event("ui_page_down",key);
-// set("display/handheld/orientation", "landscape");
+ //set("display/handheld/orientation", "landscape");
}
diff --git a/core/input_map.h b/core/input_map.h
index 306845fc89..6ccd24f29c 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -46,7 +46,7 @@ private:
mutable Map<StringName, Action> input_map;
mutable Map<int,StringName> input_id_map;
- List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore) const;
+ List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_action_test=false) const;
Array _get_action_list(const StringName& p_action);
Array _get_actions();
diff --git a/core/io/aes256.cpp b/core/io/aes256.cpp
index cfdac0214d..dc271928b4 100644
--- a/core/io/aes256.cpp
+++ b/core/io/aes256.cpp
@@ -44,8 +44,7 @@ static uint8_t rj_sbox_inv(uint8_t);
#ifdef BACK_TO_TABLES
-static const uint8_t sbox[256] =
-{
+static const uint8_t sbox[256] = {
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
@@ -79,8 +78,7 @@ static const uint8_t sbox[256] =
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
};
-static const uint8_t sboxinv[256] =
-{
+static const uint8_t sboxinv[256] = {
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
diff --git a/core/io/base64.c b/core/io/base64.c
index 0c799e9f07..0929ae5db5 100644
--- a/core/io/base64.c
+++ b/core/io/base64.c
@@ -1,3 +1,11 @@
+/*
+ * File: base64.c
+ * Description: Simple BASE64 conversion methods
+ * Author: Ari Edelkind
+ * License: Public Domain
+ * Website: http://episec.com/people/edelkind/c.html
+ */
+
#include <string.h>
char b64string[] =
diff --git a/core/io/base64.h b/core/io/base64.h
index b70b387983..456ef1811b 100644
--- a/core/io/base64.h
+++ b/core/io/base64.h
@@ -1,3 +1,11 @@
+/*
+ * File: base64.h
+ * Description: Simple BASE64 conversion methods
+ * Author: Ari Edelkind
+ * License: Public Domain
+ * Website: http://episec.com/people/edelkind/c.html
+ */
+
#ifndef BASE64_H
#define BASE64_H
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index 0d3b494106..6fda7d52f3 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -59,7 +59,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,M
return -1;
strm.avail_in=p_src_size;
- int aout = deflateBound(&strm,p_src_size);;
+ int aout = deflateBound(&strm,p_src_size);
/*if (aout>p_src_size) {
deflateEnd(&strm);
return -1;
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index a9de740806..fdfcc3ae3a 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -119,7 +119,10 @@ void ConfigFile::get_section_keys(const String& p_section,List<String> *r_keys)
}
+void ConfigFile::erase_section(const String& p_section) {
+ values.erase(p_section);
+}
Error ConfigFile::save(const String& p_path){
@@ -206,17 +209,19 @@ Error ConfigFile::load(const String& p_path) {
void ConfigFile::_bind_methods(){
- ClassDB::bind_method(_MD("set_value","section","key","value"),&ConfigFile::set_value);
- ClassDB::bind_method(_MD("get_value:Variant","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("set_value","section","key","value"),&ConfigFile::set_value);
+ ClassDB::bind_method(D_METHOD("get_value:Variant","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant()));
+
+ ClassDB::bind_method(D_METHOD("has_section","section"),&ConfigFile::has_section);
+ ClassDB::bind_method(D_METHOD("has_section_key","section","key"),&ConfigFile::has_section_key);
- ClassDB::bind_method(_MD("has_section","section"),&ConfigFile::has_section);
- ClassDB::bind_method(_MD("has_section_key","section","key"),&ConfigFile::has_section_key);
+ ClassDB::bind_method(D_METHOD("get_sections"),&ConfigFile::_get_sections);
+ ClassDB::bind_method(D_METHOD("get_section_keys","section"),&ConfigFile::_get_section_keys);
- ClassDB::bind_method(_MD("get_sections"),&ConfigFile::_get_sections);
- ClassDB::bind_method(_MD("get_section_keys","section"),&ConfigFile::_get_section_keys);
+ ClassDB::bind_method(D_METHOD("erase_section","section"),&ConfigFile::erase_section);
- ClassDB::bind_method(_MD("load:Error","path"),&ConfigFile::load);
- ClassDB::bind_method(_MD("save:Error","path"),&ConfigFile::save);
+ ClassDB::bind_method(D_METHOD("load:Error","path"),&ConfigFile::load);
+ ClassDB::bind_method(D_METHOD("save:Error","path"),&ConfigFile::save);
}
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 397342f90f..c9c4a9fbc0 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -54,6 +54,8 @@ public:
void get_sections(List<String> *r_sections) const;
void get_section_keys(const String& p_section,List<String> *r_keys) const;
+ void erase_section(const String& p_section);
+
Error save(const String& p_path);
Error load(const String& p_path);
diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h
index 884d40a266..000c2b45f3 100644
--- a/core/io/file_access_buffered_fa.h
+++ b/core/io/file_access_buffered_fa.h
@@ -127,10 +127,11 @@ public:
set_error(OK);
};
-// static void make_default() {
-
- //FileAccess::create_func = FileAccessBufferedFA<T>::create;
-// };
+ /*
+ static void make_default() {
+ FileAccess::create_func = FileAccessBufferedFA<T>::create;
+ };
+ */
virtual uint64_t _get_modified_time(const String& p_file) {
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index a9dbf56c15..b4ba14ddc9 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -30,7 +30,7 @@
#include "os/dir_access.h"
#include "os/copymem.h"
-#include "globals.h"
+#include "global_config.h"
#include "map.h"
static Map<String, Vector<uint8_t> >* files = NULL;
@@ -68,7 +68,7 @@ FileAccess* FileAccessMemory::create() {
bool FileAccessMemory::file_exists(const String& p_name) {
String name = fix_path(p_name);
-// name = DirAccess::normalize_path(name);
+ //name = DirAccess::normalize_path(name);
return files && (files->find(name) != NULL);
}
@@ -87,7 +87,7 @@ Error FileAccessMemory::_open(const String& p_path, int p_mode_flags) {
ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND);
String name = fix_path(p_path);
-// name = DirAccess::normalize_path(name);
+ //name = DirAccess::normalize_path(name);
Map<String, Vector<uint8_t> >::Element* E = files->find(name);
ERR_FAIL_COND_V(!E, ERR_FILE_NOT_FOUND);
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 19076b57be..d9fdc9cedc 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "file_access_network.h"
#include "marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
#include "io/ip.h"
@@ -206,7 +206,7 @@ Error FileAccessNetworkClient::connect(const String& p_host,int p_port,const Str
}
DEBUG_PRINT("IP: "+String(ip)+" port "+itos(p_port));
- Error err = client->connect(ip,p_port);
+ Error err = client->connect_to_host(ip,p_port);
ERR_FAIL_COND_V(err,err);
while(client->get_status()==StreamPeerTCP::STATUS_CONNECTING) {
//DEBUG_PRINT("trying to connect....");
@@ -325,7 +325,7 @@ Error FileAccessNetwork::_open(const String& p_path, int p_mode_flags) {
last_page=-1;
last_page_buff=NULL;
-// buffers.clear();
+ //buffers.clear();
nc->unlock_mutex();
DEBUG_PRINT("OPEN POST");
DEBUG_TIME("open_post");
@@ -437,7 +437,7 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const{
p_length=total_size-pos;
}
-// FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
+ //FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton;
uint8_t *buff=last_page_buff;
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 7e3a6d1fa0..fa1bebde16 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -31,7 +31,7 @@
#include <stdio.h>
-#define PACK_VERSION 0
+#define PACK_VERSION 1
Error PackedData::add_pack(const String& p_path) {
@@ -167,8 +167,8 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) {
uint32_t ver_minor = f->get_32();
uint32_t ver_rev = f->get_32();
- ERR_EXPLAIN("Pack version newer than supported by engine: "+itos(version));
- ERR_FAIL_COND_V( version > PACK_VERSION, ERR_INVALID_DATA);
+ ERR_EXPLAIN("Pack version unsupported: "+itos(version));
+ ERR_FAIL_COND_V( version != PACK_VERSION, ERR_INVALID_DATA);
ERR_EXPLAIN("Pack created with a newer version of the engine: "+itos(ver_major)+"."+itos(ver_minor)+"."+itos(ver_rev));
ERR_FAIL_COND_V( ver_major > VERSION_MAJOR || (ver_major == VERSION_MAJOR && ver_minor > VERSION_MINOR), ERR_INVALID_DATA);
@@ -340,7 +340,7 @@ FileAccessPack::~FileAccessPack() {
//////////////////////////////////////////////////////////////////////////////////
-bool DirAccessPack::list_dir_begin() {
+Error DirAccessPack::list_dir_begin() {
list_dirs.clear();
@@ -356,7 +356,7 @@ bool DirAccessPack::list_dir_begin() {
list_files.push_back(E->get());
}
- return true;
+ return OK;
}
String DirAccessPack::get_next(){
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 83340a662b..0a1320e57b 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -209,7 +209,7 @@ class DirAccessPack : public DirAccess {
public:
- virtual bool list_dir_begin();
+ virtual Error list_dir_begin();
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp
index c4439f2599..87f07cb7b1 100644
--- a/core/io/file_access_zip.cpp
+++ b/core/io/file_access_zip.cpp
@@ -165,7 +165,7 @@ unzFile ZipArchive::get_file_handle(String p_file) const {
bool ZipArchive::try_open_pack(const String& p_name) {
//printf("opening zip pack %ls, %i, %i\n", p_name.c_str(), p_name.extension().nocasecmp_to("zip"), p_name.extension().nocasecmp_to("pcz"));
- if (p_name.extension().nocasecmp_to("zip") != 0 && p_name.extension().nocasecmp_to("pcz") != 0)
+ if (p_name.get_extension().nocasecmp_to("zip") != 0 && p_name.get_extension().nocasecmp_to("pcz") != 0)
return false;
zlib_filefunc_def io;
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 5e57f55f87..ae14f8fa38 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -29,14 +29,9 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
-void HTTPClient::set_ip_type(IP::Type p_type) {
- ip_type = p_type;
-}
-
-Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
+Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){
close();
- tcp_connection->set_ip_type(ip_type);
conn_port=p_port;
conn_host=p_host;
@@ -57,7 +52,7 @@ Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_ve
if (conn_host.is_valid_ip_address()) {
//is ip
- Error err = tcp_connection->connect(IP_Address(conn_host),p_port);
+ Error err = tcp_connection->connect_to_host(IP_Address(conn_host),p_port);
if (err) {
status=STATUS_CANT_CONNECT;
return err;
@@ -66,7 +61,7 @@ Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_ve
status=STATUS_CONNECTING;
} else {
//is hostname
- resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host, ip_type);
+ resolving=IP::get_singleton()->resolve_hostname_queue_item(conn_host);
status=STATUS_RESOLVING;
}
@@ -232,7 +227,7 @@ Error HTTPClient::get_response_headers(List<String> *r_response) {
void HTTPClient::close(){
if (tcp_connection->get_status()!=StreamPeerTCP::STATUS_NONE)
- tcp_connection->disconnect();
+ tcp_connection->disconnect_from_host();
connection.unref();
status=STATUS_DISCONNECTED;
@@ -267,7 +262,7 @@ Error HTTPClient::poll(){
case IP::RESOLVER_STATUS_DONE: {
IP_Address host = IP::get_singleton()->get_resolve_item_address(resolving);
- Error err = tcp_connection->connect(host,conn_port);
+ Error err = tcp_connection->connect_to_host(host,conn_port);
IP::get_singleton()->erase_resolve_item(resolving);
resolving=IP::RESOLVER_INVALID_ID;
if (err) {
@@ -300,7 +295,7 @@ Error HTTPClient::poll(){
case StreamPeerTCP::STATUS_CONNECTED: {
if (ssl) {
Ref<StreamPeerSSL> ssl = StreamPeerSSL::create();
- Error err = ssl->connect(tcp_connection,true,ssl_verify_host?conn_host:String());
+ Error err = ssl->connect_to_stream(tcp_connection,true,ssl_verify_host?conn_host:String());
if (err!=OK) {
close();
status=STATUS_SSL_HANDSHAKE_ERROR;
@@ -345,7 +340,7 @@ Error HTTPClient::poll(){
int rs = response_str.size();
if (
(rs>=2 && response_str[rs-2]=='\n' && response_str[rs-1]=='\n') ||
- (rs>=4 && response_str[rs-4]=='\r' && response_str[rs-3]=='\n' && rs>=4 && response_str[rs-2]=='\r' && response_str[rs-1]=='\n')
+ (rs>=4 && response_str[rs-4]=='\r' && response_str[rs-3]=='\n' && response_str[rs-2]=='\r' && response_str[rs-1]=='\n')
) {
@@ -566,11 +561,13 @@ PoolByteArray HTTPClient::read_response_body_chunk() {
int to_read = MIN(body_left,read_chunk_size);
PoolByteArray ret;
ret.resize(to_read);
- PoolByteArray::Write w = ret.write();
int _offset = 0;
while (to_read > 0) {
int rec=0;
- err = _get_http_data(w.ptr()+_offset,to_read,rec);
+ {
+ PoolByteArray::Write w = ret.write();
+ err = _get_http_data(w.ptr()+_offset,to_read,rec);
+ }
if (rec>0) {
body_left-=rec;
to_read-=rec;
@@ -639,32 +636,31 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received)
void HTTPClient::_bind_methods() {
- ClassDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPClient::set_ip_type);
- ClassDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true));
- ClassDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
- ClassDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection);
- ClassDB::bind_method(_MD("request_raw","method","url","headers","body"),&HTTPClient::request_raw);
- ClassDB::bind_method(_MD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String()));
- ClassDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text);
- ClassDB::bind_method(_MD("send_body_data","body"),&HTTPClient::send_body_data);
- ClassDB::bind_method(_MD("close"),&HTTPClient::close);
+ ClassDB::bind_method(D_METHOD("connect_to_host:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect_to_host,DEFVAL(false),DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
+ ClassDB::bind_method(D_METHOD("get_connection:StreamPeer"),&HTTPClient::get_connection);
+ ClassDB::bind_method(D_METHOD("request_raw","method","url","headers","body"),&HTTPClient::request_raw);
+ ClassDB::bind_method(D_METHOD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("send_body_text","body"),&HTTPClient::send_body_text);
+ ClassDB::bind_method(D_METHOD("send_body_data","body"),&HTTPClient::send_body_data);
+ ClassDB::bind_method(D_METHOD("close"),&HTTPClient::close);
- ClassDB::bind_method(_MD("has_response"),&HTTPClient::has_response);
- ClassDB::bind_method(_MD("is_response_chunked"),&HTTPClient::is_response_chunked);
- ClassDB::bind_method(_MD("get_response_code"),&HTTPClient::get_response_code);
- ClassDB::bind_method(_MD("get_response_headers"),&HTTPClient::_get_response_headers);
- ClassDB::bind_method(_MD("get_response_headers_as_dictionary"),&HTTPClient::_get_response_headers_as_dictionary);
- ClassDB::bind_method(_MD("get_response_body_length"),&HTTPClient::get_response_body_length);
- ClassDB::bind_method(_MD("read_response_body_chunk"),&HTTPClient::read_response_body_chunk);
- ClassDB::bind_method(_MD("set_read_chunk_size","bytes"),&HTTPClient::set_read_chunk_size);
+ ClassDB::bind_method(D_METHOD("has_response"),&HTTPClient::has_response);
+ ClassDB::bind_method(D_METHOD("is_response_chunked"),&HTTPClient::is_response_chunked);
+ ClassDB::bind_method(D_METHOD("get_response_code"),&HTTPClient::get_response_code);
+ ClassDB::bind_method(D_METHOD("get_response_headers"),&HTTPClient::_get_response_headers);
+ ClassDB::bind_method(D_METHOD("get_response_headers_as_dictionary"),&HTTPClient::_get_response_headers_as_dictionary);
+ ClassDB::bind_method(D_METHOD("get_response_body_length"),&HTTPClient::get_response_body_length);
+ ClassDB::bind_method(D_METHOD("read_response_body_chunk"),&HTTPClient::read_response_body_chunk);
+ ClassDB::bind_method(D_METHOD("set_read_chunk_size","bytes"),&HTTPClient::set_read_chunk_size);
- ClassDB::bind_method(_MD("set_blocking_mode","enabled"),&HTTPClient::set_blocking_mode);
- ClassDB::bind_method(_MD("is_blocking_mode_enabled"),&HTTPClient::is_blocking_mode_enabled);
+ ClassDB::bind_method(D_METHOD("set_blocking_mode","enabled"),&HTTPClient::set_blocking_mode);
+ ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"),&HTTPClient::is_blocking_mode_enabled);
- ClassDB::bind_method(_MD("get_status"),&HTTPClient::get_status);
- ClassDB::bind_method(_MD("poll:Error"),&HTTPClient::poll);
+ ClassDB::bind_method(D_METHOD("get_status"),&HTTPClient::get_status);
+ ClassDB::bind_method(D_METHOD("poll:Error"),&HTTPClient::poll);
- ClassDB::bind_method(_MD("query_string_from_dict:String","fields"),&HTTPClient::query_string_from_dict);
+ ClassDB::bind_method(D_METHOD("query_string_from_dict:String","fields"),&HTTPClient::query_string_from_dict);
BIND_CONSTANT( METHOD_GET );
@@ -766,7 +762,6 @@ String HTTPClient::query_string_from_dict(const Dictionary& p_dict) {
HTTPClient::HTTPClient(){
- ip_type = IP::TYPE_ANY;
tcp_connection = StreamPeerTCP::create_ref();
resolving = IP::RESOLVER_INVALID_ID;
status=STATUS_DISCONNECTED;
diff --git a/core/io/http_client.h b/core/io/http_client.h
index c6f96db1d6..4b0c1b730f 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -132,7 +132,6 @@ public:
private:
- IP::Type ip_type;
Status status;
IP::ResolverID resolving;
int conn_port;
@@ -165,9 +164,8 @@ private:
public:
- void set_ip_type(IP::Type p_type);
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
- Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true);
+ Error connect_to_host(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true);
void set_connection(const Ref<StreamPeer>& p_connection);
Ref<StreamPeer> get_connection() const;
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index d4d10e2126..2b01e865f4 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -36,7 +36,7 @@ bool ImageFormatLoader::recognize(const String& p_extension) const {
get_recognized_extensions(&extensions);
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(p_extension.extension())==0)
+ if (E->get().nocasecmp_to(p_extension.get_extension())==0)
return true;
}
@@ -56,7 +56,7 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom
}
}
- String extension = p_file.extension();
+ String extension = p_file.get_extension();
for (int i=0;i<loader_count;i++) {
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 0eb1f221c9..d820273a14 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -82,7 +82,7 @@ struct _IP_ResolverPrivate {
continue;
queue[i].response=IP::get_singleton()->resolve_hostname(queue[i].hostname, queue[i].type);
- if (queue[i].response==IP_Address())
+ if (!queue[i].response.is_valid())
queue[i].status=IP::RESOLVER_STATUS_ERROR;
else
queue[i].status=IP::RESOLVER_STATUS_DONE;
@@ -218,13 +218,13 @@ Array IP::_get_local_addresses() const {
void IP::_bind_methods() {
- ClassDB::bind_method(_MD("resolve_hostname","host","ip_type"),&IP::resolve_hostname,DEFVAL(IP::TYPE_ANY));
- ClassDB::bind_method(_MD("resolve_hostname_queue_item","host","ip_type"),&IP::resolve_hostname_queue_item,DEFVAL(IP::TYPE_ANY));
- ClassDB::bind_method(_MD("get_resolve_item_status","id"),&IP::get_resolve_item_status);
- ClassDB::bind_method(_MD("get_resolve_item_address","id"),&IP::get_resolve_item_address);
- ClassDB::bind_method(_MD("erase_resolve_item","id"),&IP::erase_resolve_item);
- ClassDB::bind_method(_MD("get_local_addresses"),&IP::_get_local_addresses);
- ClassDB::bind_method(_MD("clear_cache"),&IP::clear_cache, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("resolve_hostname","host","ip_type"),&IP::resolve_hostname,DEFVAL(IP::TYPE_ANY));
+ ClassDB::bind_method(D_METHOD("resolve_hostname_queue_item","host","ip_type"),&IP::resolve_hostname_queue_item,DEFVAL(IP::TYPE_ANY));
+ ClassDB::bind_method(D_METHOD("get_resolve_item_status","id"),&IP::get_resolve_item_status);
+ 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(""));
BIND_CONSTANT( RESOLVER_STATUS_NONE );
BIND_CONSTANT( RESOLVER_STATUS_WAITING );
diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp
index 1fda7fed7b..69c7df619d 100644
--- a/core/io/ip_address.cpp
+++ b/core/io/ip_address.cpp
@@ -38,6 +38,9 @@ IP_Address::operator Variant() const {
IP_Address::operator String() const {
+ if(!valid)
+ return "";
+
if(is_ipv4())
// IPv4 address mapped to IPv6
return itos(field8[12])+"."+itos(field8[13])+"."+itos(field8[14])+"."+itos(field8[15]);
@@ -171,6 +174,8 @@ void IP_Address::_parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret
void IP_Address::clear() {
memset(&field8[0], 0, sizeof(field8));
+ valid = false;
+ wildcard = false;
};
bool IP_Address::is_ipv4() const{
@@ -184,6 +189,7 @@ const uint8_t *IP_Address::get_ipv4() const{
void IP_Address::set_ipv4(const uint8_t *p_ip) {
clear();
+ valid = true;
field16[5]=0xffff;
field32[3]=*((const uint32_t *)p_ip);
}
@@ -194,6 +200,7 @@ const uint8_t *IP_Address::get_ipv6() const{
void IP_Address::set_ipv6(const uint8_t *p_buf) {
clear();
+ valid = true;
for (int i=0; i<16; i++)
field8[i] = p_buf[i];
}
@@ -201,14 +208,25 @@ void IP_Address::set_ipv6(const uint8_t *p_buf) {
IP_Address::IP_Address(const String& p_string) {
clear();
- if (p_string.find(":") >= 0) {
+ if (p_string == "*") {
+ // Wildcard (not a vaild IP)
+ wildcard = true;
+
+ } else if (p_string.find(":") >= 0) {
+ // IPv6
_parse_ipv6(p_string);
- } else {
- // Mapped to IPv6
+ valid = true;
+
+ } else if (p_string.get_slice_count(".") == 4) {
+ // IPv4 (mapped to IPv6 internally)
field16[5] = 0xffff;
_parse_ipv4(p_string, 0, &field8[12]);
- };
+ valid = true;
+
+ } else {
+ ERR_PRINT("Invalid IP address");
+ }
}
_FORCE_INLINE_ static void _32_to_buf(uint8_t* p_dst, uint32_t p_n) {
@@ -222,6 +240,7 @@ _FORCE_INLINE_ static void _32_to_buf(uint8_t* p_dst, uint32_t p_n) {
IP_Address::IP_Address(uint32_t p_a,uint32_t p_b,uint32_t p_c,uint32_t p_d, bool is_v6) {
clear();
+ valid = true;
if (!is_v6) {
// Mapped to IPv6
field16[5]=0xffff;
diff --git a/core/io/ip_address.h b/core/io/ip_address.h
index 87f32b0ac2..257836601a 100644
--- a/core/io/ip_address.h
+++ b/core/io/ip_address.h
@@ -41,6 +41,9 @@ private:
uint32_t field32[4];
};
+ bool valid;
+ bool wildcard;
+
protected:
void _parse_ipv6(const String& p_string);
void _parse_ipv4(const String& p_string, int p_start, uint8_t* p_ret);
@@ -48,12 +51,16 @@ protected:
public:
//operator Variant() const;
bool operator==(const IP_Address& p_ip) const {
+ if (p_ip.valid != valid) return false;
+ if (!valid) return false;
for (int i=0; i<4; i++)
if (field32[i] != p_ip.field32[i])
return false;
return true;
}
bool operator!=(const IP_Address& p_ip) const {
+ if (p_ip.valid != valid) return true;
+ if (!valid) return true;
for (int i=0; i<4; i++)
if (field32[i] != p_ip.field32[i])
return true;
@@ -61,6 +68,8 @@ public:
}
void clear();
+ bool is_wildcard() const {return wildcard;}
+ bool is_valid() const {return valid;}
bool is_ipv4() const;
const uint8_t *get_ipv4() const;
void set_ipv4(const uint8_t *p_ip);
diff --git a/core/io/json.cpp b/core/io/json.cpp
index c0aa530a12..5ade25aab4 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -100,7 +100,7 @@ String JSON::print(const Variant& p_var) {
Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token& r_token,int &line,String &r_err_str) {
- while (true) {
+ while (p_len > 0) {
switch(p_str[idx]) {
case '\n': {
@@ -374,7 +374,7 @@ Error JSON::_parse_array(Array &array,const CharType *p_str,int &index, int p_le
}
- return OK;
+ return ERR_PARSE_ERROR;
}
@@ -446,7 +446,7 @@ Error JSON::_parse_object(Dictionary &object,const CharType *p_str,int &index, i
}
}
- return OK;
+ return ERR_PARSE_ERROR;
}
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index e958edc93e..a8c1cd0a10 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -641,7 +641,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
uint32_t count = decode_uint32(buf);
- ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
PoolVector<String> strings;
buf+=4;
@@ -691,7 +690,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
uint32_t count = decode_uint32(buf);
- ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
buf+=4;
len-=4;
@@ -729,7 +727,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
uint32_t count = decode_uint32(buf);
- ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
buf+=4;
len-=4;
@@ -768,7 +765,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
uint32_t count = decode_uint32(buf);
- ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA);
buf+=4;
len-=4;
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
index 6133401a8c..fb81a806e2 100644
--- a/core/io/networked_multiplayer_peer.cpp
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -1,20 +1,48 @@
+/*************************************************************************/
+/* networked_multiplayer_peer.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "networked_multiplayer_peer.h"
void NetworkedMultiplayerPeer::_bind_methods() {
- ClassDB::bind_method(_MD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode );
- ClassDB::bind_method(_MD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer );
+ ClassDB::bind_method(D_METHOD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode );
+ ClassDB::bind_method(D_METHOD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer );
- ClassDB::bind_method(_MD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer );
+ ClassDB::bind_method(D_METHOD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer );
- ClassDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll );
+ ClassDB::bind_method(D_METHOD("poll"), &NetworkedMultiplayerPeer::poll );
- ClassDB::bind_method(_MD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status );
- ClassDB::bind_method(_MD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id );
+ ClassDB::bind_method(D_METHOD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status );
+ ClassDB::bind_method(D_METHOD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id );
- ClassDB::bind_method(_MD("set_refuse_new_connections","enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections );
- ClassDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
+ ClassDB::bind_method(D_METHOD("set_refuse_new_connections","enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections );
+ ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE );
BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE_ORDERED );
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
index a59d9367d1..5d859a2f25 100644
--- a/core/io/networked_multiplayer_peer.h
+++ b/core/io/networked_multiplayer_peer.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* networked_multiplayer_peer.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 NETWORKED_MULTIPLAYER_PEER_H
#define NETWORKED_MULTIPLAYER_PEER_H
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 5ff09f9fb0..cf5883121f 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -29,7 +29,7 @@
#include "packet_peer.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
/* helpers / binders */
@@ -126,12 +126,12 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
- ClassDB::bind_method(_MD("get_var:Variant"),&PacketPeer::_bnd_get_var);
- ClassDB::bind_method(_MD("put_var", "var:Variant"),&PacketPeer::put_var);
- ClassDB::bind_method(_MD("get_packet"),&PacketPeer::_get_packet);
- ClassDB::bind_method(_MD("put_packet:Error", "buffer"),&PacketPeer::_put_packet);
- ClassDB::bind_method(_MD("get_packet_error:Error"),&PacketPeer::_get_packet_error);
- ClassDB::bind_method(_MD("get_available_packet_count"),&PacketPeer::get_available_packet_count);
+ ClassDB::bind_method(D_METHOD("get_var:Variant"),&PacketPeer::_bnd_get_var);
+ ClassDB::bind_method(D_METHOD("put_var", "var:Variant"),&PacketPeer::put_var);
+ ClassDB::bind_method(D_METHOD("get_packet"),&PacketPeer::_get_packet);
+ ClassDB::bind_method(D_METHOD("put_packet:Error", "buffer"),&PacketPeer::_put_packet);
+ ClassDB::bind_method(D_METHOD("get_packet_error:Error"),&PacketPeer::_get_packet_error);
+ ClassDB::bind_method(D_METHOD("get_available_packet_count"),&PacketPeer::get_available_packet_count);
};
/***************/
@@ -145,7 +145,7 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) {
void PacketPeerStream::_bind_methods() {
- ClassDB::bind_method(_MD("set_stream_peer","peer:StreamPeer"),&PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_stream_peer","peer:StreamPeer"),&PacketPeerStream::_set_stream_peer);
}
Error PacketPeerStream::_poll_buffer() const {
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 91d1fc5f98..c4a6fd79a8 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -36,37 +36,31 @@ String PacketPeerUDP::_get_packet_ip() const {
return get_packet_address();
}
-Error PacketPeerUDP::_set_send_address(const String& p_address, int p_port) {
+Error PacketPeerUDP::_set_dest_address(const String& p_address, int p_port) {
IP_Address ip;
if (p_address.is_valid_ip_address()) {
ip=p_address;
} else {
- ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
- if (ip==IP_Address())
+ ip=IP::get_singleton()->resolve_hostname(p_address);
+ if (!ip.is_valid())
return ERR_CANT_RESOLVE;
}
- set_send_address(ip,p_port);
+ set_dest_address(ip,p_port);
return OK;
}
-void PacketPeerUDP::set_ip_type(IP::Type p_type) {
- close();
- ip_type = p_type;
-}
-
void PacketPeerUDP::_bind_methods() {
- ClassDB::bind_method(_MD("set_ip_type","ip_type"),&PacketPeerUDP::set_ip_type);
- ClassDB::bind_method(_MD("listen:Error","port", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
- ClassDB::bind_method(_MD("close"),&PacketPeerUDP::close);
- ClassDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
- ClassDB::bind_method(_MD("is_listening"),&PacketPeerUDP::is_listening);
- ClassDB::bind_method(_MD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
- //ClassDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
- ClassDB::bind_method(_MD("get_packet_port"),&PacketPeerUDP::get_packet_port);
- ClassDB::bind_method(_MD("set_send_address","host","port"),&PacketPeerUDP::_set_send_address);
+ ClassDB::bind_method(D_METHOD("listen:Error","port", "bind_address", "recv_buf_size"),&PacketPeerUDP::listen,DEFVAL("*"),DEFVAL(65536));
+ ClassDB::bind_method(D_METHOD("close"),&PacketPeerUDP::close);
+ ClassDB::bind_method(D_METHOD("wait:Error"),&PacketPeerUDP::wait);
+ ClassDB::bind_method(D_METHOD("is_listening"),&PacketPeerUDP::is_listening);
+ ClassDB::bind_method(D_METHOD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
+ //ClassDB::bind_method(D_METHOD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
+ ClassDB::bind_method(D_METHOD("get_packet_port"),&PacketPeerUDP::get_packet_port);
+ ClassDB::bind_method(D_METHOD("set_dest_address","host","port"),&PacketPeerUDP::_set_dest_address);
}
@@ -87,5 +81,5 @@ PacketPeerUDP* PacketPeerUDP::create() {
PacketPeerUDP::PacketPeerUDP()
{
- ip_type = IP::TYPE_ANY;
+
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 17a2817f34..726406887c 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -38,25 +38,22 @@ class PacketPeerUDP : public PacketPeer {
protected:
- IP::Type ip_type;
-
static PacketPeerUDP* (*_create)();
static void _bind_methods();
String _get_packet_ip() const;
- virtual Error _set_send_address(const String& p_address,int p_port);
+ Error _set_dest_address(const String& p_address,int p_port);
public:
- virtual void set_ip_type(IP::Type p_type);
- virtual Error listen(int p_port, int p_recv_buffer_size=65536)=0;
+ virtual Error listen(int p_port, IP_Address p_bind_address=IP_Address("*"), int p_recv_buffer_size=65536)=0;
virtual void close()=0;
virtual Error wait()=0;
virtual bool is_listening() const=0;
virtual IP_Address get_packet_address() const=0;
virtual int get_packet_port() const=0;
- virtual void set_send_address(const IP_Address& p_address,int p_port)=0;
+ virtual void set_dest_address(const IP_Address& p_address,int p_port)=0;
static Ref<PacketPeerUDP> create_ref();
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index a9f357a7c8..2cd46843e8 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* pkc_packer.cpp */
+/* pck_packer.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -52,9 +52,9 @@ static void _pad(FileAccess* p_file, int p_bytes) {
void PCKPacker::_bind_methods() {
- ClassDB::bind_method(_MD("pck_start","pck_name","alignment"),&PCKPacker::pck_start);
- ClassDB::bind_method(_MD("add_file","pck_path","source_path"),&PCKPacker::add_file);
- ClassDB::bind_method(_MD("flush","verbose"),&PCKPacker::flush);
+ ClassDB::bind_method(D_METHOD("pck_start","pck_name","alignment"),&PCKPacker::pck_start);
+ ClassDB::bind_method(D_METHOD("add_file","pck_path","source_path"),&PCKPacker::add_file);
+ ClassDB::bind_method(D_METHOD("flush","verbose"),&PCKPacker::flush);
};
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index c093b087b8..2d733842fa 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "version.h"
#include "resource_format_binary.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
#include "os/dir_access.h"
@@ -80,7 +80,8 @@ enum {
OBJECT_EXTERNAL_RESOURCE=1,
OBJECT_INTERNAL_RESOURCE=2,
OBJECT_EXTERNAL_RESOURCE_INDEX=3,
- FORMAT_VERSION=1,
+ //version 2: added 64 bits support for float and int
+ FORMAT_VERSION=2,
FORMAT_VERSION_CAN_RENAME_DEPS=1
@@ -97,6 +98,27 @@ void ResourceInteractiveLoaderBinary::_advance_padding(uint32_t p_len) {
}
+
+StringName ResourceInteractiveLoaderBinary::_get_string() {
+
+ uint32_t id = f->get_32();
+ if (id&0x80000000) {
+ uint32_t len = id&0x7FFFFFFF;
+ if (len>str_buf.size()) {
+ str_buf.resize(len);
+ }
+ if (len==0)
+ return StringName();
+ f->get_buffer((uint8_t*)&str_buf[0],len);
+ String s;
+ s.parse_utf8(&str_buf[0]);
+ return s;
+ }
+
+ return string_map[id];
+
+}
+
Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
@@ -271,8 +293,8 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
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();
+ print_line("image format: "+String(Image::get_format_name(fmt))+" datalen "+itos(datalen));
PoolVector<uint8_t> imgdata;
imgdata.resize(datalen);
@@ -281,6 +303,14 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
_advance_padding(datalen);
w=PoolVector<uint8_t>::Write();
+#ifdef TOOLS_ENABLED
+//compatibility
+ int correct_size = Image::get_image_data_size(width,height,fmt,mipmaps?-1:0);
+ if (correct_size < datalen) {
+ WARN_PRINT("Image data was too large, shrinking for compatibility")
+ imgdata.resize(correct_size);
+ }
+#endif
r_v=Image(width,height,mipmaps,fmt,imgdata);
} else {
@@ -322,10 +352,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
for(int i=0;i<name_count;i++)
- names.push_back(string_map[f->get_32()]);
+ names.push_back(_get_string());
for(uint32_t i=0;i<subname_count;i++)
- subnames.push_back(string_map[f->get_32()]);
- property=string_map[f->get_32()];
+ subnames.push_back(_get_string());
+ property=_get_string();
NodePath np = NodePath(names,subnames,absolute,property);
//print_line("got path: "+String(np));
@@ -640,6 +670,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
if (s<external_resources.size()) {
String path = external_resources[s].path;
+
+ print_line("load external res: "+path);
if (remaps.has(path)) {
path=remaps[path];
}
@@ -710,6 +742,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
String t = get_unicode_string();
+// print_line("loading resource of type "+t+" path is "+path);
+
Object *obj = ClassDB::instance(t);
if (!obj) {
error=ERR_FILE_CORRUPT;
@@ -736,8 +770,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
for(int i=0;i<pc;i++) {
- uint32_t name_idx = f->get_32();
- if (name_idx>=(uint32_t)string_map.size()) {
+ StringName name = _get_string();
+ if (name==StringName()) {
error=ERR_FILE_CORRUPT;
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
@@ -748,7 +782,7 @@ Error ResourceInteractiveLoaderBinary::poll(){
if (error)
return error;
- res->set(string_map[name_idx],value);
+ res->set(name,value);
}
#ifdef TOOLS_ENABLED
res->set_edited(false);
@@ -758,30 +792,7 @@ Error ResourceInteractiveLoaderBinary::poll(){
resource_cache.push_back(res);
if (main) {
- if (importmd_ofs) {
-
- f->seek(importmd_ofs);
- Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- imd->set_editor(get_unicode_string());
- int sc = f->get_32();
- for(int i=0;i<sc;i++) {
-
- String src = get_unicode_string();
- String md5 = get_unicode_string();
- imd->add_source(src,md5);
- }
- int pc = f->get_32();
-
- for(int i=0;i<pc;i++) {
-
- String name = get_unicode_string();
- Variant val;
- parse_variant(val);
- imd->set_option(name,val);
- }
- res->set_import_metadata(imd);
- }
f->close();
resource=res;
error=ERR_FILE_EOF;
@@ -848,9 +859,6 @@ void ResourceInteractiveLoaderBinary::get_dependencies(FileAccess *p_f,List<Stri
for(int i=0;i<external_resources.size();i++) {
String dep=external_resources[i].path;
- if (dep.ends_with("*")) {
- dep=ResourceLoader::guess_full_filename(dep,external_resources[i].type);
- }
if (p_add_types && external_resources[i].type!=String()) {
dep+="::"+external_resources[i].type;
@@ -1059,7 +1067,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary );
ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
@@ -1103,53 +1111,6 @@ bool ResourceFormatLoaderBinary::handles_type(const String& p_type) const{
return true; //handles all
}
-Error ResourceFormatLoaderBinary::load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const {
-
-
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
- if (!f) {
- return ERR_FILE_CANT_OPEN;
- }
-
- Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary );
- ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
- ria->recognize(f);
- if(ria->error!=OK)
- return ERR_FILE_UNRECOGNIZED;
- f=ria->f;
- uint64_t imp_ofs = f->get_64();
-
- if (imp_ofs==0)
- return ERR_UNAVAILABLE;
-
- f->seek(imp_ofs);
- Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- imd->set_editor(ria->get_unicode_string());
- int sc = f->get_32();
- for(int i=0;i<sc;i++) {
-
- String src = ria->get_unicode_string();
- String md5 = ria->get_unicode_string();
- imd->add_source(src,md5);
- }
- int pc = f->get_32();
-
- for(int i=0;i<pc;i++) {
-
- String name = ria->get_unicode_string();
- Variant val;
- ria->parse_variant(val);
- imd->set_option(name,val);
- }
-
- r_var=imd;
-
- return OK;
-
-}
-
void ResourceFormatLoaderBinary::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types) {
@@ -1159,14 +1120,14 @@ void ResourceFormatLoaderBinary::get_dependencies(const String& p_path,List<Stri
Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary );
ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path);
ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f,p_dependencies,p_add_types);
}
Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path,const Map<String,String>& p_map) {
-// Error error=OK;
+ //Error error=OK;
FileAccess *f=FileAccess::open(p_path,FileAccess::READ);
@@ -1250,7 +1211,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path,const
ria->local_path=GlobalConfig::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) );
+ //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
err = ria->poll();
@@ -1384,7 +1345,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->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
return r;
@@ -1708,8 +1669,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
- //if (!_check_type(dict[E->get()]))
- // continue;
+ /*
+ if (!_check_type(dict[E->get()]))
+ continue;
+ */
write_variant(E->get());
write_variant(d[E->get()]);
@@ -2150,7 +2113,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
}
Vector<uint64_t> ofs_table;
-// int saved_idx=0;
+ //int saved_idx=0;
//now actually save the resources
for(List<ResourceData>::Element *E=resources.front();E;E=E->next()) {
@@ -2176,30 +2139,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
}
f->seek_end();
- print_line("SAVING: "+p_path);
- if (p_resource->get_import_metadata().is_valid()) {
- uint64_t md_pos = f->get_pos();
- Ref<ResourceImportMetadata> imd=p_resource->get_import_metadata();
- save_unicode_string(imd->get_editor());
- f->store_32(imd->get_source_count());
- for(int i=0;i<imd->get_source_count();i++) {
- save_unicode_string(imd->get_source_path(i));
- save_unicode_string(imd->get_source_md5(i));
- print_line("SAVE PATH: "+imd->get_source_path(i));
- print_line("SAVE MD5: "+imd->get_source_md5(i));
- }
- List<String> options;
- imd->get_options(&options);
- f->store_32(options.size());
- for(List<String>::Element *E=options.front();E;E=E->next()) {
- save_unicode_string(E->get());
- write_variant(imd->get_option(E->get()));
- }
-
- f->seek(md_at);
- f->store_64(md_pos);
- f->seek_end();
- }
f->store_buffer((const uint8_t*)"RSRC",4); //magic at end
@@ -2237,6 +2176,8 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES& p_resource,
String base = p_resource->get_base_extension().to_lower();
p_extensions->push_back(base);
+ if (base!="res")
+ p_extensions->push_back("res");
}
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 611029e792..1fab6144d5 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -54,6 +54,8 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader {
//Map<int,StringName> string_map;
Vector<StringName> string_map;
+ StringName _get_string();
+
struct ExtResoucre {
String path;
String type;
@@ -109,7 +111,6 @@ public:
virtual bool handles_type(const String& p_type) const;
virtual String get_resource_type(const String &p_path) const;
virtual void get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types=false);
- virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const;
virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
new file mode 100644
index 0000000000..892c2988dc
--- /dev/null
+++ b/core/io/resource_import.cpp
@@ -0,0 +1,259 @@
+#include "resource_import.h"
+#include "variant_parser.h"
+#include "os/os.h"
+
+Error ResourceFormatImporter::_get_path_and_type(const String& p_path, PathAndType &r_path_and_type) const {
+
+ Error err;
+ FileAccess *f= FileAccess::open(p_path+".import",FileAccess::READ,&err);
+
+ if (!f)
+ return err;
+
+ VariantParser::StreamFile stream;
+ stream.f=f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines=0;
+ String error_text;
+ while(true) {
+
+ assign=Variant();
+ next_tag.fields.clear();
+ next_tag.name=String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true);
+ if (err==ERR_FILE_EOF) {
+ memdelete(f);
+ return OK;
+ }
+ else if (err!=OK) {
+ ERR_PRINTS("ResourceFormatImporter::load - "+p_path+".import:"+itos(lines)+" error: "+error_text);
+ memdelete(f);
+ return err;
+ }
+
+ if (assign!=String()) {
+ if (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;
+ }
+
+ } else if (assign=="path") {
+ r_path_and_type.path=value;
+ } else if (assign=="type") {
+ r_path_and_type.type=value;
+ }
+
+ } else if (next_tag.name!="remap") {
+ break;
+ }
+ }
+
+ memdelete(f);
+
+ if (r_path_and_type.path==String() || r_path_and_type.type==String()) {
+ return ERR_FILE_CORRUPT;
+ }
+ return OK;
+
+}
+
+
+RES ResourceFormatImporter::load(const String &p_path,const String& p_original_path,Error *r_error) {
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ if (r_error)
+ *r_error=err;
+
+ return RES();
+ }
+
+
+ RES res = ResourceLoader::load(pat.path,pat.type,false,r_error);
+
+#ifdef TOOLS_ENABLED
+ if (res.is_valid()) {
+ res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used
+ res->set_import_path(pat.path);
+ }
+#endif
+
+ return res;
+
+}
+
+void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extensions) const{
+
+ Set<String> found;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (!found.has(F->get())) {
+ p_extensions->push_back(F->get());
+ found.insert(F->get());
+ }
+ }
+ }
+}
+
+void ResourceFormatImporter::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const{
+
+ if (p_type=="") {
+ return get_recognized_extensions(p_extensions);
+ }
+
+ Set<String> found;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ String res_type = E->get()->get_resource_type();
+ if (res_type==String())
+ continue;
+
+ if (!ClassDB::is_parent_class(res_type,p_type))
+ continue;
+
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (!found.has(F->get())) {
+ p_extensions->push_back(F->get());
+ found.insert(F->get());
+ }
+ }
+ }
+}
+
+bool ResourceFormatImporter::recognize_path(const String& p_path,const String& p_for_type) const{
+
+ return FileAccess::exists(p_path+".import");
+
+}
+
+bool ResourceFormatImporter::can_be_imported(const String& p_path) const {
+
+ return ResourceFormatLoader::recognize_path(p_path);
+}
+
+
+bool ResourceFormatImporter::handles_type(const String& p_type) const {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+
+ String res_type = E->get()->get_resource_type();
+ if (res_type==String())
+ continue;
+ if (ClassDB::is_parent_class(res_type,p_type))
+ return true;
+
+ }
+
+ return true;
+}
+
+
+String ResourceFormatImporter::get_internal_resource_path(const String& p_path) const {
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ return String();
+ }
+
+ return pat.path;
+}
+
+String ResourceFormatImporter::get_resource_type(const String &p_path) const {
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ return "";
+ }
+
+ return pat.type;
+}
+
+void ResourceFormatImporter::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types){
+
+ PathAndType pat;
+ Error err = _get_path_and_type(p_path,pat);
+
+ if (err!=OK) {
+
+ return;
+ }
+
+ return ResourceLoader::get_dependencies(pat.path,p_dependencies,p_add_types);
+}
+
+Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String& p_name) {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ if (E->get()->get_importer_name()==p_name) {
+ return E->get();
+ }
+ }
+
+ return Ref<ResourceImporter>();
+}
+
+
+void ResourceFormatImporter::get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers) {
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (p_extension.to_lower()==F->get()) {
+ r_importers->push_back(E->get());
+ }
+ }
+ }
+}
+
+Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String& p_extension) {
+
+
+ Ref<ResourceImporter> importer;
+ float priority=0;
+
+ for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) {
+
+ List<String> local_exts;
+ E->get()->get_recognized_extensions(&local_exts);
+ for (List<String>::Element *F=local_exts.front();F;F=F->next()) {
+ if (p_extension.to_lower()==F->get() && E->get()->get_priority() > priority) {
+ importer=E->get();
+ priority=E->get()->get_priority();
+ }
+ }
+ }
+
+ return importer;
+}
+
+String ResourceFormatImporter::get_import_base_path(const String& p_for_file) const {
+
+ return "res://.import/"+p_for_file.get_file()+"-"+p_for_file.md5_text();
+}
+
+ResourceFormatImporter *ResourceFormatImporter::singleton=NULL;
+
+ResourceFormatImporter::ResourceFormatImporter() {
+ singleton=this;
+}
diff --git a/core/io/resource_import.h b/core/io/resource_import.h
new file mode 100644
index 0000000000..387b3902fe
--- /dev/null
+++ b/core/io/resource_import.h
@@ -0,0 +1,77 @@
+#ifndef RESOURCE_IMPORT_H
+#define RESOURCE_IMPORT_H
+
+
+#include "io/resource_loader.h"
+class ResourceImporter;
+
+class ResourceFormatImporter : public ResourceFormatLoader {
+
+ struct PathAndType {
+ String path;
+ String type;
+ };
+
+
+ Error _get_path_and_type(const String& p_path,PathAndType & r_path_and_type) const;
+
+ static ResourceFormatImporter *singleton;
+
+ Set< Ref<ResourceImporter> > importers;
+public:
+
+ static ResourceFormatImporter *get_singleton() { return singleton; }
+ 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 void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
+ virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const;
+ virtual bool handles_type(const String& p_type) const;
+ virtual String get_resource_type(const String &p_path) const;
+ virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
+
+ virtual bool can_be_imported(const String& p_path) const;
+
+ String get_internal_resource_path(const String& p_path) const;
+
+ void add_importer(const Ref<ResourceImporter>& p_importer) { importers.insert(p_importer); }
+ Ref<ResourceImporter> get_importer_by_name(const String& p_name);
+ Ref<ResourceImporter> get_importer_by_extension(const String& p_extension);
+ void get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers);
+
+ String get_import_base_path(const String& p_for_file) const;
+ ResourceFormatImporter();
+};
+
+
+class ResourceImporter : public Reference {
+
+ GDCLASS(ResourceImporter,Reference)
+public:
+ virtual String get_importer_name() const=0;
+ virtual String get_visible_name() const=0;
+ virtual void get_recognized_extensions(List<String> *p_extensions) const=0;
+ virtual String get_save_extension() const=0;
+ virtual String get_resource_type() const=0;
+ virtual float get_priority() const { return 1.0; }
+
+ struct ImportOption {
+ PropertyInfo option;
+ Variant default_value;
+
+ ImportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; }
+ ImportOption() {}
+ };
+
+
+ virtual int get_preset_count() const { return 0; }
+ virtual String get_preset_name(int p_idx) const { return String(); }
+
+ virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const=0;
+ virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const=0;
+
+
+ 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)=0;
+
+};
+
+#endif // RESOURCE_IMPORT_H
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index cc3c8ce006..c14389eefa 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "resource_loader.h"
#include "print_string.h"
-#include "globals.h"
+#include "global_config.h"
#include "path_remap.h"
#include "os/file_access.h"
#include "os/os.h"
@@ -47,21 +47,30 @@ Error ResourceInteractiveLoader::wait() {
return err;
}
+bool ResourceFormatLoader::recognize_path(const String& p_path,const String& p_for_type) const {
-bool ResourceFormatLoader::recognize(const String& p_extension) const {
+ String extension = p_path.get_extension();
List<String> extensions;
- get_recognized_extensions(&extensions);
+ if (p_for_type==String()) {
+ get_recognized_extensions(&extensions);
+ } else {
+ get_recognized_extensions_for_type(p_for_type,&extensions);
+ }
+
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(p_extension.extension())==0)
+
+ if (E->get().nocasecmp_to(extension)==0)
return true;
}
return false;
+
}
+
void ResourceFormatLoader::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const {
if (p_type=="" || handles_type(p_type))
@@ -78,11 +87,11 @@ void ResourceLoader::get_recognized_extensions_for_type(const String& p_type,Lis
void ResourceInteractiveLoader::_bind_methods() {
- ClassDB::bind_method(_MD("get_resource"),&ResourceInteractiveLoader::get_resource);
- ClassDB::bind_method(_MD("poll"),&ResourceInteractiveLoader::poll);
- ClassDB::bind_method(_MD("wait"),&ResourceInteractiveLoader::wait);
- ClassDB::bind_method(_MD("get_stage"),&ResourceInteractiveLoader::get_stage);
- ClassDB::bind_method(_MD("get_stage_count"),&ResourceInteractiveLoader::get_stage_count);
+ ClassDB::bind_method(D_METHOD("get_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);
+ ClassDB::bind_method(D_METHOD("get_stage_count"),&ResourceInteractiveLoader::get_stage_count);
}
class ResourceInteractiveLoaderDefault : public ResourceInteractiveLoader {
@@ -166,7 +175,7 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- local_path=find_complete_path(local_path,p_type_hint);
+
ERR_FAIL_COND_V(local_path=="",RES());
if (!p_no_cache && ResourceCache::has(local_path)) {
@@ -177,31 +186,28 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
return RES( ResourceCache::get(local_path ) );
}
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
if (OS::get_singleton()->is_stdout_verbose())
- print_line("load resource: "+remapped_path);
-
- String extension=remapped_path.extension();
+ print_line("load resource: "+local_path);
bool found=false;
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
- continue;
- if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
+ if (!loader[i]->recognize_path(local_path,p_type_hint)) {
+ print_line("path not recognized");
continue;
+ }
found=true;
- RES res = loader[i]->load(remapped_path,local_path,r_error);
- if (res.is_null())
+ RES res = loader[i]->load(local_path,local_path,r_error);
+ if (res.is_null()) {
continue;
+ }
if (!p_no_cache)
res->set_path(local_path);
#ifdef TOOLS_ENABLED
res->set_edited(false);
if (timestamp_on_load) {
- uint64_t mt = FileAccess::get_modified_time(remapped_path);
+ uint64_t mt = FileAccess::get_modified_time(local_path);
//printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt);
res->set_last_modified_time(mt);
}
@@ -220,82 +226,6 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
}
-Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p_path) {
-
-
-
- String local_path;
- if (p_path.is_rel_path())
- local_path="res://"+p_path;
- else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
-
- String extension=p_path.extension();
- Ref<ResourceImportMetadata> ret;
-
- for (int i=0;i<loader_count;i++) {
-
- if (!loader[i]->recognize(extension))
- continue;
-
- Error err = loader[i]->load_import_metadata(local_path,ret);
- if (err==OK)
- break;
- }
-
-
- return ret;
-
-}
-
-
-
-String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) {
- //this is an old vestige when the engine saved files without extension.
- //remains here for compatibility with old projects and only because it
- //can be sometimes nice to open files using .* from a script and have it guess
- //the right extension.
-
- String local_path = p_path;
- if (local_path.ends_with("*")) {
-
- //find the extension for resource that ends with *
- local_path = local_path.substr(0,local_path.length()-1);
- List<String> extensions;
- get_recognized_extensions_for_type(p_type,&extensions);
- List<String> candidates;
-
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
-
- String path = local_path+E->get();
-
- if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) {
- candidates.push_back(path);
- }
-
- }
-
-
- if (candidates.size()==0) {
- return "";
- } else if (candidates.size()==1 || p_type=="") {
- return candidates.front()->get();
- } else {
-
- for(List<String>::Element *E=candidates.front();E;E=E->next()) {
-
- String rt = get_resource_type(E->get());
- if (ClassDB::is_parent_class(rt,p_type)) {
- return E->get();
- }
- }
-
- return "";
- }
- }
-
- return local_path;
-}
Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_path,const String& p_type_hint,bool p_no_cache,Error *r_error) {
@@ -309,7 +239,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- local_path=find_complete_path(local_path,p_type_hint);
+
ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>());
@@ -329,19 +259,14 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (OS::get_singleton()->is_stdout_verbose())
print_line("load resource: ");
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.extension();
bool found=false;
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
- continue;
- if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
+ if (!loader[i]->recognize_path(local_path,p_type_hint))
continue;
found=true;
- Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(remapped_path,r_error);
+ Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(local_path,r_error);
if (ril.is_null())
continue;
if (!p_no_cache)
@@ -383,18 +308,16 @@ void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_depe
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.extension();
-
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
+ if (!loader[i]->recognize_path(local_path))
+ continue;
+ /*
+ if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
- //if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
- // continue;
+ */
- loader[i]->get_dependencies(remapped_path,p_dependencies,p_add_types);
+ loader[i]->get_dependencies(local_path,p_dependencies,p_add_types);
}
}
@@ -408,18 +331,17 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String,
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
-
- String extension=remapped_path.extension();
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize(extension))
+ if (!loader[i]->recognize_path(local_path))
+ continue;
+ /*
+ if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
continue;
- //if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint))
- // continue;
+ */
- return loader[i]->rename_dependencies(p_path,p_map);
+ return loader[i]->rename_dependencies(local_path,p_map);
}
@@ -428,17 +350,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String,
}
-String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) {
-
- String local_path;
- if (p_path.is_rel_path())
- local_path="res://"+p_path;
- else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
-
- return find_complete_path(local_path,p_type);
-
-}
String ResourceLoader::get_resource_type(const String &p_path) {
@@ -448,8 +359,6 @@ String ResourceLoader::get_resource_type(const String &p_path) {
else
local_path = GlobalConfig::get_singleton()->localize_path(p_path);
- String remapped_path = PathRemap::get_singleton()->get_remap(local_path);
- String extension=remapped_path.extension();
for (int i=0;i<loader_count;i++) {
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 7979bd02a7..f464415e12 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -61,11 +61,10 @@ 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=0;
virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
- bool recognize(const String& p_extension) const;
+ virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const;
virtual bool handles_type(const String& p_type) const=0;
virtual String get_resource_type(const String &p_path) const=0;
virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
- virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const { return ERR_UNAVAILABLE; }
virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map) { return OK; }
virtual ~ResourceFormatLoader() {}
@@ -92,14 +91,12 @@ class ResourceLoader {
static DependencyErrorNotify dep_err_notify;
static bool abort_on_missing_resource;
- static String find_complete_path(const String& p_path,const String& p_type);
public:
static Ref<ResourceInteractiveLoader> load_interactive(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL);
static RES load(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL);
- static Ref<ResourceImportMetadata> load_import_metadata(const String &p_path);
static void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions);
static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false);
@@ -107,8 +104,6 @@ public:
static void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false);
static Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
- static String guess_full_filename(const String &p_path,const String& p_type);
-
static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load=p_timestamp; }
static void notify_load_error(const String& p_err) { if (err_notify) err_notify(err_notify_ud,p_err); }
@@ -122,4 +117,6 @@ public:
static bool get_abort_on_missing_resources() { return abort_on_missing_resource; }
};
+
+
#endif
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 9081adaa8f..f0bea30051 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "script_language.h"
#include "resource_loader.h"
@@ -40,7 +40,7 @@ ResourceSavedCallback ResourceSaver::save_callback=0;
Error ResourceSaver::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {
- String extension=p_path.extension();
+ String extension=p_path.get_extension();
Error err=ERR_FILE_UNRECOGNIZED;
for (int i=0;i<saver_count;i++) {
@@ -54,7 +54,7 @@ Error ResourceSaver::save(const String &p_path,const RES& p_resource,uint32_t p_
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get().nocasecmp_to(extension.extension())==0)
+ if (E->get().nocasecmp_to(extension.get_extension())==0)
recognized=true;
}
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index a2812edb81..3c4719269f 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -389,57 +389,57 @@ Variant StreamPeer::get_var(){
void StreamPeer::_bind_methods() {
- ClassDB::bind_method(_MD("put_data","data"),&StreamPeer::_put_data);
- ClassDB::bind_method(_MD("put_partial_data","data"),&StreamPeer::_put_partial_data);
-
- ClassDB::bind_method(_MD("get_data","bytes"),&StreamPeer::_get_data);
- ClassDB::bind_method(_MD("get_partial_data","bytes"),&StreamPeer::_get_partial_data);
-
- ClassDB::bind_method(_MD("get_available_bytes"),&StreamPeer::get_available_bytes);
-
- ClassDB::bind_method(_MD("set_big_endian","enable"),&StreamPeer::set_big_endian);
- ClassDB::bind_method(_MD("is_big_endian_enabled"),&StreamPeer::is_big_endian_enabled);
-
- ClassDB::bind_method(_MD("put_8","val"),&StreamPeer::put_8);
- ClassDB::bind_method(_MD("put_u8","val"),&StreamPeer::put_u8);
- ClassDB::bind_method(_MD("put_16","val"),&StreamPeer::put_16);
- ClassDB::bind_method(_MD("put_u16","val"),&StreamPeer::put_u16);
- ClassDB::bind_method(_MD("put_32","val"),&StreamPeer::put_32);
- ClassDB::bind_method(_MD("put_u32","val"),&StreamPeer::put_u32);
- ClassDB::bind_method(_MD("put_64","val"),&StreamPeer::put_64);
- ClassDB::bind_method(_MD("put_u64","val"),&StreamPeer::put_u64);
- ClassDB::bind_method(_MD("put_float","val"),&StreamPeer::put_float);
- ClassDB::bind_method(_MD("put_double","val"),&StreamPeer::put_double);
- ClassDB::bind_method(_MD("put_utf8_string","val"),&StreamPeer::put_utf8_string);
- ClassDB::bind_method(_MD("put_var","val:Variant"),&StreamPeer::put_var);
-
- ClassDB::bind_method(_MD("get_8"),&StreamPeer::get_8);
- ClassDB::bind_method(_MD("get_u8"),&StreamPeer::get_u8);
- ClassDB::bind_method(_MD("get_16"),&StreamPeer::get_16);
- ClassDB::bind_method(_MD("get_u16"),&StreamPeer::get_u16);
- ClassDB::bind_method(_MD("get_32"),&StreamPeer::get_32);
- ClassDB::bind_method(_MD("get_u32"),&StreamPeer::get_u32);
- ClassDB::bind_method(_MD("get_64"),&StreamPeer::get_64);
- ClassDB::bind_method(_MD("get_u64"),&StreamPeer::get_u64);
- ClassDB::bind_method(_MD("get_float"),&StreamPeer::get_float);
- ClassDB::bind_method(_MD("get_double"),&StreamPeer::get_double);
- ClassDB::bind_method(_MD("get_string","bytes"),&StreamPeer::get_string);
- ClassDB::bind_method(_MD("get_utf8_string","bytes"),&StreamPeer::get_utf8_string);
- ClassDB::bind_method(_MD("get_var:Variant"),&StreamPeer::get_var);
+ ClassDB::bind_method(D_METHOD("put_data","data"),&StreamPeer::_put_data);
+ ClassDB::bind_method(D_METHOD("put_partial_data","data"),&StreamPeer::_put_partial_data);
+
+ ClassDB::bind_method(D_METHOD("get_data","bytes"),&StreamPeer::_get_data);
+ ClassDB::bind_method(D_METHOD("get_partial_data","bytes"),&StreamPeer::_get_partial_data);
+
+ ClassDB::bind_method(D_METHOD("get_available_bytes"),&StreamPeer::get_available_bytes);
+
+ ClassDB::bind_method(D_METHOD("set_big_endian","enable"),&StreamPeer::set_big_endian);
+ ClassDB::bind_method(D_METHOD("is_big_endian_enabled"),&StreamPeer::is_big_endian_enabled);
+
+ ClassDB::bind_method(D_METHOD("put_8","val"),&StreamPeer::put_8);
+ ClassDB::bind_method(D_METHOD("put_u8","val"),&StreamPeer::put_u8);
+ ClassDB::bind_method(D_METHOD("put_16","val"),&StreamPeer::put_16);
+ ClassDB::bind_method(D_METHOD("put_u16","val"),&StreamPeer::put_u16);
+ ClassDB::bind_method(D_METHOD("put_32","val"),&StreamPeer::put_32);
+ ClassDB::bind_method(D_METHOD("put_u32","val"),&StreamPeer::put_u32);
+ ClassDB::bind_method(D_METHOD("put_64","val"),&StreamPeer::put_64);
+ ClassDB::bind_method(D_METHOD("put_u64","val"),&StreamPeer::put_u64);
+ ClassDB::bind_method(D_METHOD("put_float","val"),&StreamPeer::put_float);
+ ClassDB::bind_method(D_METHOD("put_double","val"),&StreamPeer::put_double);
+ ClassDB::bind_method(D_METHOD("put_utf8_string","val"),&StreamPeer::put_utf8_string);
+ ClassDB::bind_method(D_METHOD("put_var","val:Variant"),&StreamPeer::put_var);
+
+ ClassDB::bind_method(D_METHOD("get_8"),&StreamPeer::get_8);
+ ClassDB::bind_method(D_METHOD("get_u8"),&StreamPeer::get_u8);
+ ClassDB::bind_method(D_METHOD("get_16"),&StreamPeer::get_16);
+ ClassDB::bind_method(D_METHOD("get_u16"),&StreamPeer::get_u16);
+ ClassDB::bind_method(D_METHOD("get_32"),&StreamPeer::get_32);
+ ClassDB::bind_method(D_METHOD("get_u32"),&StreamPeer::get_u32);
+ ClassDB::bind_method(D_METHOD("get_64"),&StreamPeer::get_64);
+ ClassDB::bind_method(D_METHOD("get_u64"),&StreamPeer::get_u64);
+ ClassDB::bind_method(D_METHOD("get_float"),&StreamPeer::get_float);
+ ClassDB::bind_method(D_METHOD("get_double"),&StreamPeer::get_double);
+ ClassDB::bind_method(D_METHOD("get_string","bytes"),&StreamPeer::get_string);
+ ClassDB::bind_method(D_METHOD("get_utf8_string","bytes"),&StreamPeer::get_utf8_string);
+ ClassDB::bind_method(D_METHOD("get_var:Variant"),&StreamPeer::get_var);
}
////////////////////////////////
void StreamPeerBuffer::_bind_methods() {
- ClassDB::bind_method(_MD("seek","pos"),&StreamPeerBuffer::seek);
- ClassDB::bind_method(_MD("get_size"),&StreamPeerBuffer::get_size);
- ClassDB::bind_method(_MD("get_pos"),&StreamPeerBuffer::get_pos);
- ClassDB::bind_method(_MD("resize","size"),&StreamPeerBuffer::resize);
- ClassDB::bind_method(_MD("set_data_array","data"),&StreamPeerBuffer::set_data_array);
- ClassDB::bind_method(_MD("get_data_array"),&StreamPeerBuffer::get_data_array);
- ClassDB::bind_method(_MD("clear"),&StreamPeerBuffer::clear);
- ClassDB::bind_method(_MD("duplicate:StreamPeerBuffer"),&StreamPeerBuffer::duplicate);
+ ClassDB::bind_method(D_METHOD("seek","pos"),&StreamPeerBuffer::seek);
+ ClassDB::bind_method(D_METHOD("get_size"),&StreamPeerBuffer::get_size);
+ ClassDB::bind_method(D_METHOD("get_pos"),&StreamPeerBuffer::get_pos);
+ ClassDB::bind_method(D_METHOD("resize","size"),&StreamPeerBuffer::resize);
+ ClassDB::bind_method(D_METHOD("set_data_array","data"),&StreamPeerBuffer::set_data_array);
+ ClassDB::bind_method(D_METHOD("get_data_array"),&StreamPeerBuffer::get_data_array);
+ ClassDB::bind_method(D_METHOD("clear"),&StreamPeerBuffer::clear);
+ ClassDB::bind_method(D_METHOD("duplicate:StreamPeerBuffer"),&StreamPeerBuffer::duplicate);
}
@@ -492,6 +492,8 @@ Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_r
PoolVector<uint8_t>::Read r = data.read();
copymem(p_buffer,r.ptr(),r_received);
+
+ // FIXME: return what? OK or ERR_*
}
int StreamPeerBuffer::get_available_bytes() const {
diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp
index aab42a2989..5f7247bd7a 100644
--- a/core/io/stream_peer_ssl.cpp
+++ b/core/io/stream_peer_ssl.cpp
@@ -57,10 +57,10 @@ bool StreamPeerSSL::is_available() {
void StreamPeerSSL::_bind_methods() {
- ClassDB::bind_method(_MD("accept:Error","stream:StreamPeer"),&StreamPeerSSL::accept);
- ClassDB::bind_method(_MD("connect:Error","stream:StreamPeer","validate_certs","for_hostname"),&StreamPeerSSL::connect,DEFVAL(false),DEFVAL(String()));
- ClassDB::bind_method(_MD("get_status"),&StreamPeerSSL::get_status);
- ClassDB::bind_method(_MD("disconnect"),&StreamPeerSSL::disconnect);
+ ClassDB::bind_method(D_METHOD("accept_stream:Error","stream:StreamPeer"),&StreamPeerSSL::accept_stream);
+ ClassDB::bind_method(D_METHOD("connect_to_stream:Error","stream:StreamPeer","validate_certs","for_hostname"),&StreamPeerSSL::connect_to_stream,DEFVAL(false),DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("get_status"),&StreamPeerSSL::get_status);
+ ClassDB::bind_method(D_METHOD("disconnect_from_stream"),&StreamPeerSSL::disconnect_from_stream);
BIND_CONSTANT( STATUS_DISCONNECTED );
BIND_CONSTANT( STATUS_CONNECTED );
BIND_CONSTANT( STATUS_ERROR_NO_CERTIFICATE );
diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h
index 8675433a30..9aafac874d 100644
--- a/core/io/stream_peer_ssl.h
+++ b/core/io/stream_peer_ssl.h
@@ -57,11 +57,11 @@ public:
STATUS_ERROR_HOSTNAME_MISMATCH
};
- virtual Error accept(Ref<StreamPeer> p_base)=0;
- virtual Error connect(Ref<StreamPeer> p_base,bool p_validate_certs=false,const String& p_for_hostname=String())=0;
+ virtual Error accept_stream(Ref<StreamPeer> p_base)=0;
+ virtual Error connect_to_stream(Ref<StreamPeer> p_base,bool p_validate_certs=false,const String& p_for_hostname=String())=0;
virtual Status get_status() const=0;
- virtual void disconnect()=0;
+ virtual void disconnect_from_stream()=0;
static StreamPeerSSL* create();
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index 2218057cf7..cedc33079e 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -36,29 +36,23 @@ Error StreamPeerTCP::_connect(const String& p_address,int p_port) {
if (p_address.is_valid_ip_address()) {
ip=p_address;
} else {
- ip=IP::get_singleton()->resolve_hostname(p_address, ip_type);
- if (ip==IP_Address())
+ ip=IP::get_singleton()->resolve_hostname(p_address);
+ if (!ip.is_valid())
return ERR_CANT_RESOLVE;
}
- connect(ip,p_port);
+ connect_to_host(ip,p_port);
return OK;
}
-void StreamPeerTCP::set_ip_type(IP::Type p_type) {
- disconnect();
- ip_type = p_type;
-}
-
void StreamPeerTCP::_bind_methods() {
- ClassDB::bind_method(_MD("set_ip_type","ip_type"),&StreamPeerTCP::set_ip_type);
- ClassDB::bind_method(_MD("connect","host","port"),&StreamPeerTCP::_connect);
- ClassDB::bind_method(_MD("is_connected"),&StreamPeerTCP::is_connected);
- ClassDB::bind_method(_MD("get_status"),&StreamPeerTCP::get_status);
- ClassDB::bind_method(_MD("get_connected_host"),&StreamPeerTCP::get_connected_host);
- ClassDB::bind_method(_MD("get_connected_port"),&StreamPeerTCP::get_connected_port);
- ClassDB::bind_method(_MD("disconnect"),&StreamPeerTCP::disconnect);
+ ClassDB::bind_method(D_METHOD("connect_to_host","host","port"),&StreamPeerTCP::_connect);
+ ClassDB::bind_method(D_METHOD("is_connected_to_host"),&StreamPeerTCP::is_connected_to_host);
+ ClassDB::bind_method(D_METHOD("get_status"),&StreamPeerTCP::get_status);
+ ClassDB::bind_method(D_METHOD("get_connected_host"),&StreamPeerTCP::get_connected_host);
+ ClassDB::bind_method(D_METHOD("get_connected_port"),&StreamPeerTCP::get_connected_port);
+ ClassDB::bind_method(D_METHOD("disconnect_from_host"),&StreamPeerTCP::disconnect_from_host);
BIND_CONSTANT( STATUS_NONE );
BIND_CONSTANT( STATUS_CONNECTING );
@@ -83,7 +77,6 @@ StreamPeerTCP* StreamPeerTCP::create() {
StreamPeerTCP::StreamPeerTCP() {
- ip_type = IP::TYPE_ANY;
}
StreamPeerTCP::~StreamPeerTCP() {
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 8f6dfaf3f8..4401378743 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -51,22 +51,19 @@ public:
protected:
- IP::Type ip_type;
-
virtual Error _connect(const String& p_address, int p_port);
static StreamPeerTCP* (*_create)();
static void _bind_methods();
public:
- virtual void set_ip_type(IP::Type p_type);
- virtual Error connect(const IP_Address& p_host, uint16_t p_port)=0;
+ virtual Error connect_to_host(const IP_Address& p_host, uint16_t p_port)=0;
//read/write from streampeer
- virtual bool is_connected() const=0;
+ virtual bool is_connected_to_host() const=0;
virtual Status get_status() const=0;
- virtual void disconnect()=0;
+ virtual void disconnect_from_host()=0;
virtual IP_Address get_connected_host() const=0;
virtual uint16_t get_connected_port() const=0;
virtual void set_nodelay(bool p_enabled)=0;
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index bfa5dce58f..5127bd6e3b 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -44,33 +44,17 @@ TCP_Server* TCP_Server::create() {
return _create();
}
-Error TCP_Server::_listen(uint16_t p_port, PoolVector<String> p_accepted_hosts) {
-
- List<String> hosts;
- for(int i=0;i<p_accepted_hosts.size();i++)
- hosts.push_back(p_accepted_hosts.get(i));
-
- return listen(p_port, hosts.size()?&hosts:NULL);
-
-}
-
-void TCP_Server::set_ip_type(IP::Type p_type) {
- stop();
- ip_type = p_type;
-}
-
void TCP_Server::_bind_methods() {
- ClassDB::bind_method(_MD("set_ip_type","ip_type"),&TCP_Server::set_ip_type);
- ClassDB::bind_method(_MD("listen","port","accepted_hosts"),&TCP_Server::_listen,DEFVAL(PoolVector<String>()));
- ClassDB::bind_method(_MD("is_connection_available"),&TCP_Server::is_connection_available);
- ClassDB::bind_method(_MD("take_connection"),&TCP_Server::take_connection);
- ClassDB::bind_method(_MD("stop"),&TCP_Server::stop);
+ 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("stop"),&TCP_Server::stop);
}
TCP_Server::TCP_Server()
{
- ip_type = IP::TYPE_ANY;
+
}
diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h
index 3d7b3ddd8d..3cbd8c58cf 100644
--- a/core/io/tcp_server.h
+++ b/core/io/tcp_server.h
@@ -38,17 +38,13 @@ class TCP_Server : public Reference {
GDCLASS( TCP_Server, Reference );
protected:
- IP::Type ip_type;
-
static TCP_Server* (*_create)();
//bind helper
- Error _listen(uint16_t p_port, PoolVector<String> p_accepted_hosts=PoolVector<String>());
static void _bind_methods();
public:
- virtual void set_ip_type(IP::Type p_type);
- virtual Error listen(uint16_t p_port, const List<String> *p_accepted_hosts=NULL)=0;
+ virtual Error listen(uint16_t p_port, const IP_Address p_bind_address=IP_Address("*"))=0;
virtual bool is_connection_available() const=0;
virtual Ref<StreamPeerTCP> take_connection()=0;
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index 8c4c1c8180..bee38e037f 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -204,7 +204,7 @@ bool TranslationLoaderPO::handles_type(const String& p_type) const{
String TranslationLoaderPO::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="po")
+ if (p_path.get_extension().to_lower()=="po")
return "Translation";
return "";
}
diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp
index 0322f23056..1a4ff1a8d4 100644
--- a/core/io/xml_parser.cpp
+++ b/core/io/xml_parser.cpp
@@ -379,23 +379,23 @@ Error XMLParser::seek(uint64_t p_pos) {
void XMLParser::_bind_methods() {
- ClassDB::bind_method(_MD("read"),&XMLParser::read);
- ClassDB::bind_method(_MD("get_node_type"),&XMLParser::get_node_type);
- ClassDB::bind_method(_MD("get_node_name"),&XMLParser::get_node_name);
- ClassDB::bind_method(_MD("get_node_data"),&XMLParser::get_node_data);
- ClassDB::bind_method(_MD("get_node_offset"),&XMLParser::get_node_offset);
- ClassDB::bind_method(_MD("get_attribute_count"),&XMLParser::get_attribute_count);
- ClassDB::bind_method(_MD("get_attribute_name","idx"),&XMLParser::get_attribute_name);
- ClassDB::bind_method(_MD("get_attribute_value","idx"),(String (XMLParser::*)(int) const) &XMLParser::get_attribute_value);
- ClassDB::bind_method(_MD("has_attribute","name"),&XMLParser::has_attribute);
- ClassDB::bind_method(_MD("get_named_attribute_value","name"), (String (XMLParser::*)(const String&) const) &XMLParser::get_attribute_value);
- ClassDB::bind_method(_MD("get_named_attribute_value_safe","name"), &XMLParser::get_attribute_value_safe);
- ClassDB::bind_method(_MD("is_empty"),&XMLParser::is_empty);
- ClassDB::bind_method(_MD("get_current_line"),&XMLParser::get_current_line);
- ClassDB::bind_method(_MD("skip_section"),&XMLParser::skip_section);
- ClassDB::bind_method(_MD("seek","pos"),&XMLParser::seek);
- ClassDB::bind_method(_MD("open","file"),&XMLParser::open);
- ClassDB::bind_method(_MD("open_buffer","buffer"),&XMLParser::open_buffer);
+ ClassDB::bind_method(D_METHOD("read"),&XMLParser::read);
+ ClassDB::bind_method(D_METHOD("get_node_type"),&XMLParser::get_node_type);
+ ClassDB::bind_method(D_METHOD("get_node_name"),&XMLParser::get_node_name);
+ ClassDB::bind_method(D_METHOD("get_node_data"),&XMLParser::get_node_data);
+ ClassDB::bind_method(D_METHOD("get_node_offset"),&XMLParser::get_node_offset);
+ ClassDB::bind_method(D_METHOD("get_attribute_count"),&XMLParser::get_attribute_count);
+ ClassDB::bind_method(D_METHOD("get_attribute_name","idx"),&XMLParser::get_attribute_name);
+ ClassDB::bind_method(D_METHOD("get_attribute_value","idx"),(String (XMLParser::*)(int) const) &XMLParser::get_attribute_value);
+ ClassDB::bind_method(D_METHOD("has_attribute","name"),&XMLParser::has_attribute);
+ ClassDB::bind_method(D_METHOD("get_named_attribute_value","name"), (String (XMLParser::*)(const String&) const) &XMLParser::get_attribute_value);
+ ClassDB::bind_method(D_METHOD("get_named_attribute_value_safe","name"), &XMLParser::get_attribute_value_safe);
+ ClassDB::bind_method(D_METHOD("is_empty"),&XMLParser::is_empty);
+ ClassDB::bind_method(D_METHOD("get_current_line"),&XMLParser::get_current_line);
+ ClassDB::bind_method(D_METHOD("skip_section"),&XMLParser::skip_section);
+ ClassDB::bind_method(D_METHOD("seek","pos"),&XMLParser::seek);
+ ClassDB::bind_method(D_METHOD("open","file"),&XMLParser::open);
+ ClassDB::bind_method(D_METHOD("open_buffer","buffer"),&XMLParser::open_buffer);
BIND_CONSTANT( NODE_NONE );
BIND_CONSTANT( NODE_ELEMENT );
diff --git a/core/io/zip.c b/core/io/zip.c
index 44c79195d9..27a3d3cdc1 100644
--- a/core/io/zip.c
+++ b/core/io/zip.c
@@ -855,7 +855,7 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
ziinit.z_filefunc.zseek32_file = NULL;
ziinit.z_filefunc.ztell32_file = NULL;
if (pzlib_filefunc64_32_def==NULL) {
-// fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
+ //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
} else
ziinit.z_filefunc = *pzlib_filefunc64_32_def;
diff --git a/core/map.h b/core/map.h
index af35fec332..d1a4c209ad 100644
--- a/core/map.h
+++ b/core/map.h
@@ -149,7 +149,7 @@ private:
#ifdef GLOBALNIL_DISABLED
memdelete_allocator<Element,A>(_nil);
#endif
-// memdelete_allocator<Element,A>(_root);
+ //memdelete_allocator<Element,A>(_root);
}
};
@@ -428,7 +428,7 @@ private:
Element *aux=node->parent->left;
if (aux->color==RED) {
_set_color(aux,BLACK);
- _set_color(node->parent,RED);;
+ _set_color(node->parent,RED);
_rotate_right(node->parent);
aux=node->parent->left;
}
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 0d6997183f..7e31957e3e 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* a_star.cpp */
+/* a_star.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -39,7 +39,7 @@ int AStar::get_available_point_id() const {
return points.back()->key()+1;
}
-void AStar::add_point(int p_id, const Vector3 &p_pos, float p_weight_scale) {
+void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
ERR_FAIL_COND(p_id<0);
if (!points.has(p_id)) {
Point *pt = memnew( Point );
@@ -62,7 +62,7 @@ Vector3 AStar::get_point_pos(int p_id) const{
return points[p_id]->pos;
}
-float AStar::get_point_weight_scale(int p_id) const{
+real_t AStar::get_point_weight_scale(int p_id) const{
ERR_FAIL_COND_V(!points.has(p_id),0);
@@ -145,11 +145,11 @@ void AStar::clear(){
int AStar::get_closest_point(const Vector3& p_point) const{
int closest_id=-1;
- float closest_dist=1e20;
+ real_t closest_dist=1e20;
for (const Map<int,Point*>::Element *E=points.front();E;E=E->next()) {
- float d = p_point.distance_squared_to(E->get()->pos);
+ real_t d = p_point.distance_squared_to(E->get()->pos);
if (closest_id<0 || d<closest_dist) {
closest_dist=d;
closest_id=E->key();
@@ -162,7 +162,7 @@ int AStar::get_closest_point(const Vector3& p_point) const{
}
Vector3 AStar::get_closest_pos_in_segment(const Vector3& p_point) const {
- float closest_dist = 1e20;
+ real_t closest_dist = 1e20;
bool found=false;
Vector3 closest_point;
@@ -175,7 +175,7 @@ Vector3 AStar::get_closest_pos_in_segment(const Vector3& p_point) const {
};
Vector3 p = Geometry::get_closest_point_to_segment(p_point,segment);
- float d = p_point.distance_squared_to(p);
+ real_t d = p_point.distance_squared_to(p);
if (!found || d<closest_dist) {
closest_point=p;
@@ -220,14 +220,14 @@ bool AStar::_solve(Point* begin_point, Point* end_point) {
//check open list
SelfList<Point> *least_cost_point=NULL;
- float least_cost=1e30;
+ real_t least_cost=1e30;
//this could be faster (cache previous results)
for (SelfList<Point> *E=open_list.first();E;E=E->next()) {
Point *p=E->self();
- float cost=p->distance;
+ real_t cost=p->distance;
cost+=p->pos.distance_to(end_point->pos);
cost*=p->weight_scale;
@@ -249,7 +249,7 @@ bool AStar::_solve(Point* begin_point, Point* end_point) {
Point* e=p->neighbours[i];
- float distance = p->pos.distance_to(e->pos) + p->distance;
+ real_t distance = p->pos.distance_to(e->pos) + p->distance;
distance*=e->weight_scale;
@@ -407,23 +407,23 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
void AStar::_bind_methods() {
- ClassDB::bind_method(_MD("get_available_point_id"),&AStar::get_available_point_id);
- ClassDB::bind_method(_MD("add_point","id","pos","weight_scale"),&AStar::add_point,DEFVAL(1.0));
- ClassDB::bind_method(_MD("get_point_pos","id"),&AStar::get_point_pos);
- ClassDB::bind_method(_MD("get_point_weight_scale","id"),&AStar::get_point_weight_scale);
- ClassDB::bind_method(_MD("remove_point","id"),&AStar::remove_point);
+ ClassDB::bind_method(D_METHOD("get_available_point_id"),&AStar::get_available_point_id);
+ ClassDB::bind_method(D_METHOD("add_point","id","pos","weight_scale"),&AStar::add_point,DEFVAL(1.0));
+ 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(_MD("connect_points","id","to_id"),&AStar::connect_points);
- ClassDB::bind_method(_MD("disconnect_points","id","to_id"),&AStar::disconnect_points);
- ClassDB::bind_method(_MD("are_points_connected","id","to_id"),&AStar::are_points_connected);
+ ClassDB::bind_method(D_METHOD("connect_points","id","to_id"),&AStar::connect_points);
+ ClassDB::bind_method(D_METHOD("disconnect_points","id","to_id"),&AStar::disconnect_points);
+ ClassDB::bind_method(D_METHOD("are_points_connected","id","to_id"),&AStar::are_points_connected);
- ClassDB::bind_method(_MD("clear"),&AStar::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&AStar::clear);
- ClassDB::bind_method(_MD("get_closest_point","to_pos"),&AStar::get_closest_point);
- ClassDB::bind_method(_MD("get_closest_pos_in_segment","to_pos"),&AStar::get_closest_pos_in_segment);
+ ClassDB::bind_method(D_METHOD("get_closest_point","to_pos"),&AStar::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_pos_in_segment","to_pos"),&AStar::get_closest_pos_in_segment);
- ClassDB::bind_method(_MD("get_point_path","from_id","to_id"),&AStar::get_point_path);
- ClassDB::bind_method(_MD("get_id_path","from_id","to_id"),&AStar::get_id_path);
+ ClassDB::bind_method(D_METHOD("get_point_path","from_id","to_id"),&AStar::get_point_path);
+ ClassDB::bind_method(D_METHOD("get_id_path","from_id","to_id"),&AStar::get_id_path);
}
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 35e6ead226..c4c955ed2d 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -48,14 +48,14 @@ class AStar: public Reference {
int id;
Vector3 pos;
- float weight_scale;
+ real_t weight_scale;
uint64_t last_pass;
Vector<Point*> neighbours;
//used for pathfinding
Point *prev_point;
- float distance;
+ real_t distance;
Point() : list(this) {}
};
@@ -98,9 +98,9 @@ public:
int get_available_point_id() const;
- void add_point(int p_id,const Vector3& p_pos,float p_weight_scale=1);
+ void add_point(int p_id,const Vector3& p_pos,real_t p_weight_scale=1);
Vector3 get_point_pos(int p_id) const;
- float get_point_weight_scale(int p_id) const;
+ real_t get_point_weight_scale(int p_id) const;
void remove_point(int p_id);
void connect_points(int p_id,int p_with_id);
diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp
new file mode 100644
index 0000000000..566ba23992
--- /dev/null
+++ b/core/math/audio_frame.cpp
@@ -0,0 +1,2 @@
+#include "audio_frame.h"
+
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
new file mode 100644
index 0000000000..acd74903bb
--- /dev/null
+++ b/core/math/audio_frame.h
@@ -0,0 +1,61 @@
+#ifndef AUDIOFRAME_H
+#define AUDIOFRAME_H
+
+#include "typedefs.h"
+
+
+static inline float undenormalise(volatile float f)
+{
+ union {
+ uint32_t i;
+ float f;
+ } v;
+
+ v.f = f;
+
+ // original: return (v.i & 0x7f800000) == 0 ? 0.0f : f;
+ // version from Tim Blechmann:
+ return (v.i & 0x7f800000) < 0x08000000 ? 0.0f : f;
+}
+
+
+struct AudioFrame {
+
+ //left and right samples
+ float l,r;
+
+ _ALWAYS_INLINE_ const float& operator[](int idx) const { return idx==0?l:r; }
+ _ALWAYS_INLINE_ float& operator[](int idx) { return idx==0?l:r; }
+
+ _ALWAYS_INLINE_ AudioFrame operator+(const AudioFrame& p_frame) const { return AudioFrame(l+p_frame.l,r+p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator-(const AudioFrame& p_frame) const { return AudioFrame(l-p_frame.l,r-p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator*(const AudioFrame& p_frame) const { return AudioFrame(l*p_frame.l,r*p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator/(const AudioFrame& p_frame) const { return AudioFrame(l/p_frame.l,r/p_frame.r); }
+
+ _ALWAYS_INLINE_ AudioFrame operator+(float p_sample) const { return AudioFrame(l+p_sample,r+p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator-(float p_sample) const { return AudioFrame(l-p_sample,r-p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator*(float p_sample) const { return AudioFrame(l*p_sample,r*p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator/(float p_sample) const { return AudioFrame(l/p_sample,r/p_sample); }
+
+ _ALWAYS_INLINE_ void operator+=(const AudioFrame& p_frame) { l+=p_frame.l; r+=p_frame.r; }
+ _ALWAYS_INLINE_ void operator-=(const AudioFrame& p_frame) { l-=p_frame.l; r-=p_frame.r; }
+ _ALWAYS_INLINE_ void operator*=(const AudioFrame& p_frame) { l*=p_frame.l; r*=p_frame.r; }
+ _ALWAYS_INLINE_ void operator/=(const AudioFrame& p_frame) { l/=p_frame.l; r/=p_frame.r; }
+
+ _ALWAYS_INLINE_ void operator+=(float p_sample) { l+=p_sample; r+=p_sample; }
+ _ALWAYS_INLINE_ void operator-=(float p_sample) { l-=p_sample; r-=p_sample; }
+ _ALWAYS_INLINE_ void operator*=(float p_sample) { l*=p_sample; r*=p_sample; }
+ _ALWAYS_INLINE_ void operator/=(float p_sample) { l/=p_sample; r/=p_sample; }
+
+ _ALWAYS_INLINE_ void undenormalise() {
+ l = ::undenormalise(l);
+ r = ::undenormalise(r);
+ }
+
+ _ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {l=p_l; r=p_r;}
+ _ALWAYS_INLINE_ AudioFrame(const AudioFrame& p_frame) {l=p_frame.l; r=p_frame.r;}
+
+ _ALWAYS_INLINE_ AudioFrame() {}
+};
+
+#endif
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index b888b6b56c..1ca6385032 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -87,8 +87,8 @@ int BSP_Tree::_get_points_inside(int p_node,const Vector3* p_points,int *p_indic
max+=p_center;
min+=p_center;
- float dist_min = p.distance_to(min);
- float dist_max = p.distance_to(max);
+ real_t dist_min = p.distance_to(min);
+ real_t dist_max = p.distance_to(max);
if ((dist_min * dist_max) < CMP_EPSILON ) { //intersection, test point by point
@@ -290,13 +290,13 @@ bool BSP_Tree::point_is_inside(const Vector3& p_point) const {
}
-static int _bsp_find_best_half_plane(const Face3* p_faces,const Vector<int>& p_indices,float p_tolerance) {
+static int _bsp_find_best_half_plane(const Face3* p_faces,const Vector<int>& p_indices,real_t p_tolerance) {
int ic = p_indices.size();
const int*indices=p_indices.ptr();
int best_plane = -1;
- float best_plane_cost = 1e20;
+ real_t best_plane_cost = 1e20;
// Loop to find the polygon that best divides the set.
@@ -317,7 +317,7 @@ static int _bsp_find_best_half_plane(const Face3* p_faces,const Vector<int>& p_i
for(int k=0;k<3;k++) {
- float d = p.distance_to(g.vertex[j]);
+ real_t d = p.distance_to(g.vertex[j]);
if (Math::abs(d)>p_tolerance) {
@@ -340,13 +340,13 @@ static int _bsp_find_best_half_plane(const Face3* p_faces,const Vector<int>& p_i
- //double split_cost = num_spanning / (double) face_count;
- double relation = Math::abs(num_over-num_under) / (double) ic;
+ //real_t split_cost = num_spanning / (real_t) face_count;
+ real_t relation = Math::abs(num_over-num_under) / (real_t) ic;
// being honest, i never found a way to add split cost to the mix in a meaninguful way
// in this engine, also, will likely be ignored anyway
- double plane_cost = /*split_cost +*/ relation;
+ real_t plane_cost = /*split_cost +*/ relation;
//printf("plane %i, %i over, %i under, %i spanning, cost is %g\n",i,num_over,num_under,num_spanning,plane_cost);
if (plane_cost<best_plane_cost) {
@@ -362,7 +362,7 @@ static int _bsp_find_best_half_plane(const Face3* p_faces,const Vector<int>& p_i
}
-static int _bsp_create_node(const Face3 *p_faces,const Vector<int>& p_indices,Vector<Plane> &p_planes, Vector<BSP_Tree::Node> &p_nodes,float p_tolerance) {
+static int _bsp_create_node(const Face3 *p_faces,const Vector<int>& p_indices,Vector<Plane> &p_planes, Vector<BSP_Tree::Node> &p_nodes,real_t p_tolerance) {
ERR_FAIL_COND_V( p_nodes.size() == BSP_Tree::MAX_NODES, -1 );
@@ -390,15 +390,17 @@ static int _bsp_create_node(const Face3 *p_faces,const Vector<int>& p_indices,Ve
const Face3& f=p_faces[ indices[i] ];
- //if (f.get_plane().is_almost_like(divisor_plane))
- // continue;
+ /*
+ if (f.get_plane().is_almost_like(divisor_plane))
+ continue;
+ */
int over_count=0;
int under_count=0;
for(int j=0;j<3;j++) {
- float d = divisor_plane.distance_to(f.vertex[j]);
+ real_t d = divisor_plane.distance_to(f.vertex[j]);
if (Math::abs(d)>p_tolerance) {
if (d > 0)
@@ -471,7 +473,7 @@ BSP_Tree::operator Variant() const {
Dictionary d;
d["error_radius"]=error_radius;
- Vector<float> plane_values;
+ Vector<real_t> plane_values;
plane_values.resize(planes.size()*4);
for(int i=0;i<planes.size();i++) {
@@ -520,13 +522,13 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
if (d["planes"].get_type()==Variant::POOL_REAL_ARRAY) {
- PoolVector<float> src_planes=d["planes"];
+ PoolVector<real_t> src_planes=d["planes"];
int plane_count=src_planes.size();
ERR_FAIL_COND(plane_count%4);
planes.resize(plane_count/4);
if (plane_count) {
- PoolVector<float>::Read r = src_planes.read();
+ PoolVector<real_t>::Read r = src_planes.read();
for(int i=0;i<plane_count/4;i++) {
planes[i].normal.x=r[i*4+0];
@@ -546,7 +548,7 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
error_radius = d["error"];
aabb = d["aabb"];
-// int node_count = src_nodes.size();
+ //int node_count = src_nodes.size();
nodes.resize(src_nodes.size()/3);
PoolVector<int>::Read r = src_nodes.read();
@@ -560,7 +562,7 @@ BSP_Tree::BSP_Tree(const Variant& p_variant) {
}
-BSP_Tree::BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius) {
+BSP_Tree::BSP_Tree(const PoolVector<Face3>& p_faces,real_t p_error_radius) {
// compute aabb
@@ -613,7 +615,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius) {
error_radius=p_error_radius;
}
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3& p_aabb,float p_error_radius) {
+BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3& p_aabb,real_t p_error_radius) {
nodes=p_nodes;
planes=p_planes;
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index e01df96555..c0071438db 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -30,7 +30,7 @@
#define BSP_TREE_H
#include "plane.h"
-#include "aabb.h"
+#include "rect3.h"
#include "face3.h"
#include "vector.h"
#include "dvector.h"
@@ -66,7 +66,7 @@ private:
Vector<Node> nodes;
Vector<Plane> planes;
Rect3 aabb;
- float error_radius;
+ real_t error_radius;
int _get_points_inside(int p_node,const Vector3* p_points,int *p_indices, const Vector3& p_center,const Vector3& p_half_extents,int p_indices_count) const;
@@ -91,8 +91,8 @@ public:
BSP_Tree();
BSP_Tree(const Variant& p_variant);
- BSP_Tree(const PoolVector<Face3>& p_faces,float p_error_radius=0);
- BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3& p_aabb,float p_error_radius=0);
+ BSP_Tree(const PoolVector<Face3>& p_faces,real_t p_error_radius=0);
+ BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3& p_aabb,real_t p_error_radius=0);
~BSP_Tree();
};
@@ -110,7 +110,7 @@ bool BSP_Tree::_test_convex(const Node* p_nodes, const Plane* p_planes,int p_cur
const Plane& p=p_planes[n.plane];
- float min,max;
+ real_t min,max;
p_convex.project_range(p.normal,min,max);
bool go_under = min < p.d;
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index c44ff4682a..3b47a75c65 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -65,15 +65,15 @@ Plane CameraMatrix::xform4(const Plane& p_vec4) const {
return ret;
}
-void CameraMatrix::set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov) {
+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) {
if (p_flip_fov) {
p_fovy_degrees=get_fovy(p_fovy_degrees,1.0/p_aspect);
}
- float sine, cotangent, deltaZ;
- float radians = p_fovy_degrees / 2.0 * Math_PI / 180.0;
+ real_t sine, cotangent, deltaZ;
+ real_t radians = p_fovy_degrees / 2.0 * Math_PI / 180.0;
deltaZ = p_z_far - p_z_near;
sine = Math::sin(radians);
@@ -94,7 +94,7 @@ void CameraMatrix::set_perspective(float p_fovy_degrees, float p_aspect, float p
}
-void CameraMatrix::set_orthogonal(float p_left, float p_right, float p_bottom, float p_top, float p_znear, float p_zfar) {
+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();
@@ -109,7 +109,7 @@ void CameraMatrix::set_orthogonal(float p_left, float p_right, float p_bottom, f
}
-void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov) {
+void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar,bool p_flip_fov) {
if (!p_flip_fov) {
p_size*=p_aspect;
@@ -120,7 +120,7 @@ void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, f
-void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, float p_top, float p_near, float p_far) {
+void CameraMatrix::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) {
#if 0
///@TODO, give a check to this. I'm not sure if it's working.
set_identity();
@@ -134,19 +134,31 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa
matrix[3][2]=-1;
matrix[3][3]=0;
#else
- float *te = &matrix[0][0];
- float x = 2 * p_near / ( p_right - p_left );
- float y = 2 * p_near / ( p_top - p_bottom );
-
- float a = ( p_right + p_left ) / ( p_right - p_left );
- float b = ( p_top + p_bottom ) / ( p_top - p_bottom );
- float c = - ( p_far + p_near ) / ( p_far - p_near );
- float d = - 2 * p_far * p_near / ( p_far - p_near );
-
- te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
- te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
- te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
- te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
+ real_t *te = &matrix[0][0];
+ real_t x = 2 * p_near / ( p_right - p_left );
+ real_t y = 2 * p_near / ( p_top - p_bottom );
+
+ real_t a = ( p_right + p_left ) / ( p_right - p_left );
+ real_t b = ( p_top + p_bottom ) / ( p_top - p_bottom );
+ real_t c = - ( p_far + p_near ) / ( p_far - p_near );
+ real_t d = - 2 * p_far * p_near / ( p_far - p_near );
+
+ te[0] = x;
+ te[1] = 0;
+ te[2] = 0;
+ te[3] = 0;
+ te[4] = 0;
+ te[5] = y;
+ te[6] = 0;
+ te[7] = 0;
+ te[8] = a;
+ te[9] = b;
+ te[10] = c;
+ te[11] = -1;
+ te[12] = 0;
+ te[13] = 0;
+ te[14] = d;
+ te[15] = 0;
#endif
@@ -154,9 +166,9 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa
-float CameraMatrix::get_z_far() const {
+real_t CameraMatrix::get_z_far() const {
- const float * matrix = (const float*)this->matrix;
+ const real_t * matrix = (const real_t*)this->matrix;
Plane new_plane=Plane(matrix[ 3] - matrix[ 2],
matrix[ 7] - matrix[ 6],
matrix[11] - matrix[10],
@@ -167,9 +179,9 @@ float CameraMatrix::get_z_far() const {
return new_plane.d;
}
-float CameraMatrix::get_z_near() const {
+real_t CameraMatrix::get_z_near() const {
- const float * matrix = (const float*)this->matrix;
+ const real_t * matrix = (const real_t*)this->matrix;
Plane new_plane=Plane(matrix[ 3] + matrix[ 2],
matrix[ 7] + matrix[ 6],
matrix[11] + matrix[10],
@@ -179,25 +191,28 @@ float CameraMatrix::get_z_near() const {
return new_plane.d;
}
-void CameraMatrix::get_viewport_size(float& r_width, float& r_height) const {
+void CameraMatrix::get_viewport_size(real_t& r_width, real_t& r_height) const {
- const float * matrix = (const float*)this->matrix;
+ const real_t * matrix = (const real_t*)this->matrix;
///////--- Near Plane ---///////
Plane near_plane=Plane(matrix[ 3] + matrix[ 2],
matrix[ 7] + matrix[ 6],
matrix[11] + matrix[10],
- -matrix[15] - matrix[14]).normalized();
+ -matrix[15] - matrix[14]);
+ near_plane.normalize();
///////--- Right Plane ---///////
Plane right_plane=Plane(matrix[ 3] - matrix[ 0],
matrix[ 7] - matrix[ 4],
matrix[11] - matrix[ 8],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12]);
+ right_plane.normalize();
Plane top_plane=Plane(matrix[ 3] - matrix[ 1],
matrix[ 7] - matrix[ 5],
matrix[11] - matrix[ 9],
- -matrix[15] + matrix[13]).normalized();
+ -matrix[15] + matrix[13]);
+ top_plane.normalize();
Vector3 res;
near_plane.intersect_3(right_plane,top_plane,&res);
@@ -208,32 +223,35 @@ void CameraMatrix::get_viewport_size(float& r_width, float& r_height) const {
bool CameraMatrix::get_endpoints(const Transform& p_transform, Vector3 *p_8points) const {
- const float * matrix = (const float*)this->matrix;
+ const real_t * matrix = (const real_t*)this->matrix;
///////--- Near Plane ---///////
Plane near_plane=Plane(matrix[ 3] + matrix[ 2],
matrix[ 7] + matrix[ 6],
matrix[11] + matrix[10],
- -matrix[15] - matrix[14]).normalized();
+ -matrix[15] - matrix[14]);
+ near_plane.normalize();
///////--- Far Plane ---///////
Plane far_plane=Plane(matrix[ 2] - matrix[ 3],
matrix[ 6] - matrix[ 7],
matrix[10] - matrix[11],
- matrix[15] - matrix[14]).normalized();
-
+ matrix[15] - matrix[14]);
+ far_plane.normalize();
///////--- Right Plane ---///////
Plane right_plane=Plane(matrix[ 0] - matrix[ 3],
matrix[ 4] - matrix[ 7],
matrix[8] - matrix[ 11],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12]);
+ right_plane.normalize();
///////--- Top Plane ---///////
Plane top_plane=Plane(matrix[ 1] - matrix[ 3],
matrix[ 5] - matrix[ 7],
matrix[9] - matrix[ 11],
- -matrix[15] + matrix[13]).normalized();
+ -matrix[15] + matrix[13]);
+ top_plane.normalize();
Vector3 near_endpoint;
Vector3 far_endpoint;
@@ -266,7 +284,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform& p_transform)
Vector<Plane> planes;
- const float * matrix = (const float*)this->matrix;
+ const real_t * matrix = (const real_t*)this->matrix;
Plane new_plane;
@@ -359,9 +377,9 @@ void CameraMatrix::invert() {
int i,j,k;
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
- float pvt_val; /* Value of current pivot element */
- float hold; /* Temporary storage */
- float determinat; /* Determinant */
+ real_t pvt_val; /* Value of current pivot element */
+ real_t hold; /* Temporary storage */
+ real_t determinat; /* Determinant */
determinat = 1.0;
for (k=0; k<4; k++) {
@@ -474,7 +492,7 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix& p_matrix) const {
void CameraMatrix::set_light_bias() {
- float *m=&matrix[0][0];
+ real_t *m=&matrix[0][0];
m[0]=0.5,
m[1]=0.0,
@@ -497,7 +515,7 @@ void CameraMatrix::set_light_bias() {
void CameraMatrix::set_light_atlas_rect(const Rect2& p_rect) {
- float *m=&matrix[0][0];
+ real_t *m=&matrix[0][0];
m[0]=p_rect.size.width,
m[1]=0.0,
@@ -527,9 +545,9 @@ CameraMatrix::operator String() const {
return str;
}
-float CameraMatrix::get_aspect() const {
+real_t CameraMatrix::get_aspect() const {
- float w,h;
+ real_t w,h;
get_viewport_size(w,h);
return w/h;
}
@@ -543,13 +561,14 @@ int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
}
-float CameraMatrix::get_fov() const {
- const float * matrix = (const float*)this->matrix;
+real_t CameraMatrix::get_fov() const {
+ const real_t * matrix = (const real_t*)this->matrix;
Plane right_plane=Plane(matrix[ 3] - matrix[ 0],
matrix[ 7] - matrix[ 4],
matrix[11] - matrix[ 8],
- - matrix[15] + matrix[12]).normalized();
+ - matrix[15] + matrix[12]);
+ right_plane.normalize();
return Math::rad2deg(Math::acos(Math::abs(right_plane.normal.x)))*2.0;
}
@@ -594,7 +613,7 @@ void CameraMatrix::scale_translate_to_fit(const Rect3& p_aabb) {
CameraMatrix::operator Transform() const {
Transform tr;
- const float *m=&matrix[0][0];
+ const real_t *m=&matrix[0][0];
tr.basis.elements[0][0]=m[0];
tr.basis.elements[1][0]=m[1];
@@ -618,7 +637,7 @@ CameraMatrix::operator Transform() const {
CameraMatrix::CameraMatrix(const Transform& p_transform) {
const Transform &tr = p_transform;
- float *m=&matrix[0][0];
+ real_t *m=&matrix[0][0];
m[0]=tr.basis.elements[0][0];
m[1]=tr.basis.elements[1][0];
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 952f1e8fb2..c96f8259b5 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -48,32 +48,32 @@ struct CameraMatrix {
PLANE_BOTTOM
};
- float matrix[4][4];
+ real_t matrix[4][4];
void set_identity();
void set_zero();
void set_light_bias();
void set_light_atlas_rect(const Rect2& p_rect);
- void set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov=false);
- void set_orthogonal(float p_left, float p_right, float p_bottom, float p_top, float p_znear, float p_zfar);
- void set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov=false);
- void set_frustum(float p_left, float p_right, float p_bottom, float p_top, float p_near, float p_far);
+ 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_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);
- static float get_fovy(float p_fovx,float p_aspect) {
+ static real_t get_fovy(real_t p_fovx,real_t p_aspect) {
return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5))*2.0);
}
- float get_z_far() const;
- float get_z_near() const;
- float get_aspect() const;
- float get_fov() const;
+ real_t get_z_far() const;
+ real_t get_z_near() const;
+ real_t get_aspect() const;
+ real_t get_fov() const;
Vector<Plane> get_projection_planes(const Transform& p_transform) const;
bool get_endpoints(const Transform& p_transform,Vector3 *p_8points) const;
- void get_viewport_size(float& r_width, float& r_height) const;
+ void get_viewport_size(real_t& r_width, real_t& r_height) const;
void invert();
CameraMatrix inverse() const;
@@ -102,7 +102,7 @@ Vector3 CameraMatrix::xform(const Vector3& p_vec3) const {
ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0];
ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1];
ret.z = matrix[0][2] * p_vec3.x + matrix[1][2] * p_vec3.y + matrix[2][2] * p_vec3.z + matrix[3][2];
- float w = matrix[0][3] * p_vec3.x + matrix[1][3] * p_vec3.y + matrix[2][3] * p_vec3.z + matrix[3][3];
+ real_t w = matrix[0][3] * p_vec3.x + matrix[1][3] * p_vec3.y + matrix[2][3] * p_vec3.z + matrix[3][3];
return ret/w;
}
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index faf124593e..60fab6748a 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -168,8 +168,8 @@ Face3::Side Face3::get_side_of(const Face3& p_face,ClockDirection p_clock_dir) c
Vector3 Face3::get_random_point_inside() const {
- float a=Math::random(0,1);
- float b=Math::random(0,1);
+ real_t a=Math::random(0,1);
+ real_t b=Math::random(0,1);
if (a>b) {
SWAP(a,b);
}
@@ -215,9 +215,9 @@ bool Face3::intersects_aabb(const Rect3& p_aabb) const {
#define TEST_AXIS(m_ax)\
{\
- float aabb_min=p_aabb.pos.m_ax;\
- float aabb_max=p_aabb.pos.m_ax+p_aabb.size.m_ax;\
- float tri_min,tri_max;\
+ real_t aabb_min=p_aabb.pos.m_ax;\
+ real_t aabb_max=p_aabb.pos.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;\
@@ -255,7 +255,7 @@ bool Face3::intersects_aabb(const Rect3& p_aabb) const {
continue; // coplanar
axis.normalize();
- float minA,maxA,minB,maxB;
+ real_t minA,maxA,minB,maxB;
p_aabb.project_range_in_plane(Plane(axis,0),minA,maxA);
project_range(axis,Transform(),minB,maxB);
@@ -272,12 +272,12 @@ Face3::operator String() const {
return String()+vertex[0]+", "+vertex[1]+", "+vertex[2];
}
-void Face3::project_range(const Vector3& p_normal,const Transform& p_transform,float& r_min, float& r_max) const {
+void Face3::project_range(const Vector3& p_normal,const Transform& p_transform,real_t& r_min, real_t& r_max) const {
for (int i=0;i<3;i++) {
Vector3 v=p_transform.xform(vertex[i]);
- float d=p_normal.dot(v);
+ real_t d=p_normal.dot(v);
if (i==0 || d > r_max)
r_max=d;
@@ -316,11 +316,11 @@ void Face3::get_support(const Vector3& p_normal,const Transform& p_transform,Vec
/** FIND SUPPORT VERTEX **/
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<3;i++) {
- float d=n.dot(vertex[i]);
+ real_t d=n.dot(vertex[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -336,7 +336,7 @@ void Face3::get_support(const Vector3& p_normal,const Transform& p_transform,Vec
continue;
// check if edge is valid as a support
- float dot=(vertex[i]-vertex[(i+1)%3]).normalized().dot(n);
+ real_t dot=(vertex[i]-vertex[(i+1)%3]).normalized().dot(n);
dot=ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
@@ -362,15 +362,15 @@ Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
Vector3 edge1 = vertex[2] - vertex[0];
Vector3 v0 = vertex[0] - p_point;
- float a = edge0.dot( edge0 );
- float b = edge0.dot( edge1 );
- float c = edge1.dot( edge1 );
- float d = edge0.dot( v0 );
- float e = edge1.dot( v0 );
+ real_t a = edge0.dot( edge0 );
+ real_t b = edge0.dot( edge1 );
+ real_t c = edge1.dot( edge1 );
+ real_t d = edge0.dot( v0 );
+ real_t e = edge1.dot( v0 );
- float det = a*c - b*b;
- float s = b*e - c*d;
- float t = b*d - a*e;
+ real_t det = a*c - b*b;
+ real_t s = b*e - c*d;
+ real_t t = b*d - a*e;
if ( s + t < det )
{
@@ -402,7 +402,7 @@ Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
}
else
{
- float invDet = 1.f / det;
+ real_t invDet = 1.f / det;
s *= invDet;
t *= invDet;
}
@@ -411,12 +411,12 @@ Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
{
if ( s < 0.f )
{
- float tmp0 = b+d;
- float tmp1 = c+e;
+ real_t tmp0 = b+d;
+ real_t tmp1 = c+e;
if ( tmp1 > tmp0 )
{
- float numer = tmp1 - tmp0;
- float denom = a-2*b+c;
+ real_t numer = tmp1 - tmp0;
+ real_t denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1-s;
}
@@ -430,8 +430,8 @@ Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
{
if ( a+d > b+e )
{
- float numer = c+e-b-d;
- float denom = a-2*b+c;
+ real_t numer = c+e-b-d;
+ real_t denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1-s;
}
@@ -443,8 +443,8 @@ Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
}
else
{
- float numer = c+e-b-d;
- float denom = a-2*b+c;
+ real_t numer = c+e-b-d;
+ real_t denom = a-2*b+c;
s = CLAMP( numer/denom, 0.f, 1.f );
t = 1.f - s;
}
diff --git a/core/math/face3.h b/core/math/face3.h
index f08eb227b1..a0da588ea5 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -31,7 +31,7 @@
#include "vector3.h"
#include "plane.h"
-#include "aabb.h"
+#include "rect3.h"
#include "transform.h"
class Face3 {
@@ -76,7 +76,7 @@ public:
ClockDirection get_clock_dir() const; ///< todo, test if this is returning the proper clockwisity
void get_support(const Vector3& p_normal,const Transform& p_transform,Vector3 *p_vertices,int* p_count,int p_max) const;
- void project_range(const Vector3& p_normal,const Transform& p_transform,float& r_min, float& r_max) const;
+ void project_range(const Vector3& p_normal,const Transform& p_transform,real_t& r_min, real_t& r_max) const;
Rect3 get_aabb() const {
@@ -109,9 +109,9 @@ bool Face3::intersects_aabb2(const Rect3& p_aabb) const {
(perp.z>0) ? -half_extents.z : half_extents.z
);
- float d = perp.dot(vertex[0]);
- float dist_a = perp.dot(ofs+sup)-d;
- float dist_b = perp.dot(ofs-sup)-d;
+ real_t d = perp.dot(vertex[0]);
+ real_t dist_a = perp.dot(ofs+sup)-d;
+ real_t dist_b = perp.dot(ofs-sup)-d;
if (dist_a*dist_b > 0)
return false; //does not intersect the plane
@@ -119,9 +119,9 @@ bool Face3::intersects_aabb2(const Rect3& p_aabb) const {
#define TEST_AXIS(m_ax)\
{\
- float aabb_min=p_aabb.pos.m_ax;\
- float aabb_max=p_aabb.pos.m_ax+p_aabb.size.m_ax;\
- float tri_min,tri_max;\
+ real_t aabb_min=p_aabb.pos.m_ax;\
+ real_t aabb_max=p_aabb.pos.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;\
@@ -236,16 +236,16 @@ bool Face3::intersects_aabb2(const Rect3& p_aabb) const {
(axis.z>0) ? -half_extents.z : half_extents.z
);
- float maxB = axis.dot(ofs+sup2);
- float minB = axis.dot(ofs-sup2);
+ real_t maxB = axis.dot(ofs+sup2);
+ real_t minB = axis.dot(ofs-sup2);
if (minB>maxB) {
SWAP(maxB,minB);
}
- float minT=1e20,maxT=-1e20;
+ real_t minT=1e20,maxT=-1e20;
for (int k=0;k<3;k++) {
- float d=axis.dot(vertex[k]);
+ real_t d=axis.dot(vertex[k]);
if (d > maxT)
maxT=d;
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index bf3364a052..6570dfe672 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -580,7 +580,7 @@ static inline void _build_faces(uint8_t*** p_cell_status,int x,int y,int z,int l
}
-PoolVector< Face3 > Geometry::wrap_geometry( PoolVector< Face3 > p_array,float *p_error ) {
+PoolVector< Face3 > Geometry::wrap_geometry( PoolVector< Face3 > p_array,real_t *p_error ) {
#define _MIN_SIZE 1.0
#define _MAX_LENGTH 20
@@ -755,7 +755,7 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
#define SUBPLANE_SIZE 1024.0
- float subplane_size = 1024.0; // should compute this from the actual plane
+ real_t subplane_size = 1024.0; // should compute this from the actual plane
for (int i=0;i<p_planes.size();i++) {
Plane p =p_planes[i];
@@ -910,7 +910,7 @@ PoolVector<Plane> Geometry::build_box_planes(const Vector3& p_extents) {
return planes;
}
-PoolVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
PoolVector<Plane> planes;
@@ -933,7 +933,7 @@ PoolVector<Plane> Geometry::build_cylinder_planes(float p_radius, float p_height
}
-PoolVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats,int p_lons, Vector3::Axis p_axis) {
PoolVector<Plane> planes;
@@ -957,7 +957,7 @@ PoolVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p
for (int j=1;j<=p_lats;j++) {
//todo this is stupid, fix
- Vector3 angle = normal.linear_interpolate(axis,j/(float)p_lats).normalized();
+ Vector3 angle = normal.linear_interpolate(axis,j/(real_t)p_lats).normalized();
Vector3 pos = angle*p_radius;
planes.push_back( Plane( pos, angle ) );
planes.push_back( Plane( pos * axis_neg, angle * axis_neg) );
@@ -969,7 +969,7 @@ PoolVector<Plane> Geometry::build_sphere_planes(float p_radius, int p_lats,int p
}
-PoolVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+PoolVector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
PoolVector<Plane> planes;
@@ -991,7 +991,7 @@ PoolVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height,
for (int j=1;j<=p_lats;j++) {
- Vector3 angle = normal.linear_interpolate(axis,j/(float)p_lats).normalized();
+ Vector3 angle = normal.linear_interpolate(axis,j/(real_t)p_lats).normalized();
Vector3 pos = axis*p_height*0.5 + angle*p_radius;
planes.push_back( Plane( pos, angle ) );
planes.push_back( Plane( pos * axis_neg, angle * axis_neg) );
@@ -1108,13 +1108,13 @@ void Geometry::make_atlas(const Vector<Size2i>& p_rects,Vector<Point2i>& r_resul
//find the result with the best aspect ratio
int best=-1;
- float best_aspect=1e20;
+ real_t best_aspect=1e20;
for(int i=0;i<results.size();i++) {
- float h = nearest_power_of_2(results[i].max_h);
- float w = nearest_power_of_2(results[i].max_w);
- float aspect = h>w ? h/w : w/h;
+ real_t h = nearest_power_of_2(results[i].max_h);
+ real_t w = nearest_power_of_2(results[i].max_w);
+ real_t aspect = h>w ? h/w : w/h;
if (aspect < best_aspect) {
best=i;
best_aspect=aspect;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 9800e5513c..1dd7df038d 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -48,15 +48,15 @@ public:
- static float get_closest_points_between_segments( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2, Vector2& c1, Vector2& c2) {
+ static real_t get_closest_points_between_segments( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2, Vector2& c1, Vector2& c2) {
Vector2 d1 = q1 - p1; // Direction vector of segment S1
Vector2 d2 = q2 - p2; // Direction vector of segment S2
Vector2 r = p1 - p2;
- float a = d1.dot(d1); // Squared length of segment S1, always nonnegative
- float e = d2.dot(d2); // Squared length of segment S2, always nonnegative
- float f = d2.dot(r);
- float s,t;
+ real_t a = d1.dot(d1); // Squared length of segment S1, always nonnegative
+ real_t e = d2.dot(d2); // Squared length of segment S2, always nonnegative
+ real_t f = d2.dot(r);
+ real_t s,t;
// Check if either or both segments degenerate into points
if (a <= CMP_EPSILON && e <= CMP_EPSILON) {
// Both segments degenerate into points
@@ -66,25 +66,25 @@ public:
}
if (a <= CMP_EPSILON) {
// First segment degenerates into a point
- s = 0.0f;
+ s = 0.0;
t = f / e; // s = 0 => t = (b*s + f) / e = f / e
- t = CLAMP(t, 0.0f, 1.0f);
+ t = CLAMP(t, 0.0, 1.0);
} else {
- float c = d1.dot(r);
+ real_t c = d1.dot(r);
if (e <= CMP_EPSILON) {
// Second segment degenerates into a point
- t = 0.0f;
- s = CLAMP(-c / a, 0.0f, 1.0f); // t = 0 => s = (b*t - c) / a = -c / a
+ t = 0.0;
+ s = CLAMP(-c / a, 0.0, 1.0); // t = 0 => s = (b*t - c) / a = -c / a
} else {
// The general nondegenerate case starts here
- float b = d1.dot(d2);
- float denom = a*e-b*b; // Always nonnegative
+ real_t b = d1.dot(d2);
+ real_t denom = a*e-b*b; // Always nonnegative
// If segments not parallel, compute closest point on L1 to L2 and
// clamp to segment S1. Else pick arbitrary s (here 0)
- if (denom != 0.0f) {
- s = CLAMP((b*f - c*e) / denom, 0.0f, 1.0f);
+ if (denom != 0.0) {
+ s = CLAMP((b*f - c*e) / denom, 0.0, 1.0);
} else
- s = 0.0f;
+ s = 0.0;
// Compute point on L2 closest to S1(s) using
// t = Dot((P1 + D1*s) - P2,D2) / Dot(D2,D2) = (b*s + f) / e
t = (b*s + f) / e;
@@ -92,12 +92,12 @@ public:
//If t in [0,1] done. Else clamp t, recompute s for the new value
// of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
// and clamp s to [0, 1]
- if (t < 0.0f) {
- t = 0.0f;
- s = CLAMP(-c / a, 0.0f, 1.0f);
- } else if (t > 1.0f) {
- t = 1.0f;
- s = CLAMP((b - c) / a, 0.0f, 1.0f);
+ if (t < 0.0) {
+ t = 0.0;
+ s = CLAMP(-c / a, 0.0, 1.0);
+ } else if (t > 1.0) {
+ t = 1.0;
+ s = CLAMP((b - c) / a, 0.0, 1.0);
}
}
}
@@ -109,12 +109,13 @@ public:
static void get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2,Vector3& c1, Vector3& c2)
{
+#if 0
//do the function 'd' as defined by pb. I think is is dot product of some sort
#define d_of(m,n,o,p) ( (m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z) )
//caluclate the parpametric position on the 2 curves, mua and mub
- float mua = ( d_of(p1,q1,q2,q1) * d_of(q2,q1,p2,p1) - d_of(p1,q1,p2,p1) * d_of(q2,q1,q2,q1) ) / ( d_of(p2,p1,p2,p1) * d_of(q2,q1,q2,q1) - d_of(q2,q1,p2,p1) * d_of(q2,q1,p2,p1) );
- float mub = ( d_of(p1,q1,q2,q1) + mua * d_of(q2,q1,p2,p1) ) / d_of(q2,q1,q2,q1);
+ real_t mua = ( d_of(p1,q1,q2,q1) * d_of(q2,q1,p2,p1) - d_of(p1,q1,p2,p1) * d_of(q2,q1,q2,q1) ) / ( d_of(p2,p1,p2,p1) * d_of(q2,q1,q2,q1) - d_of(q2,q1,p2,p1) * d_of(q2,q1,p2,p1) );
+ real_t mub = ( d_of(p1,q1,q2,q1) + mua * d_of(q2,q1,p2,p1) ) / d_of(q2,q1,q2,q1);
//clip the value between [0..1] constraining the solution to lie on the original curves
if (mua < 0) mua = 0;
@@ -123,9 +124,36 @@ public:
if (mub > 1) mub = 1;
c1 = p1.linear_interpolate(p2,mua);
c2 = q1.linear_interpolate(q2,mub);
+#endif
+
+ Vector3 u = p2 - p1;
+ Vector3 v = q2 - q1;
+ Vector3 w = p1 - q1;
+ float a = u.dot(u);
+ float b = u.dot(v);
+ float c = v.dot(v); // always >= 0
+ float d = u.dot(w);
+ float e = v.dot(w);
+ float D = a*c - b*b; // always >= 0
+ float sc, tc;
+
+ // compute the line parameters of the two closest points
+ if (D < CMP_EPSILON) { // the lines are almost parallel
+ sc = 0.0;
+ tc = (b>c ? d/b : e/c); // use the largest denominator
+ }
+ else {
+ sc = (b*e - c*d) / D;
+ tc = (a*e - b*d) / D;
+ }
+
+ c1 = w + sc * u;
+ c2 = w + tc * v;
+ // get the difference of the two closest points
+ //Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc)
}
- static float get_closest_distance_between_segments( const Vector3& p_from_a,const Vector3& p_to_a, const Vector3& p_from_b,const Vector3& p_to_b) {
+ static real_t get_closest_distance_between_segments( const Vector3& p_from_a,const Vector3& p_to_a, const Vector3& p_from_b,const Vector3& p_to_b) {
Vector3 u = p_to_a - p_from_a;
Vector3 v = p_to_b - p_from_b;
Vector3 w = p_from_a - p_to_a;
@@ -273,22 +301,22 @@ public:
Vector3 sphere_pos=p_sphere_pos-p_from;
Vector3 rel=(p_to-p_from);
- float rel_l=rel.length();
+ real_t rel_l=rel.length();
if (rel_l<CMP_EPSILON)
return false; // both points are the same
Vector3 normal=rel/rel_l;
- float sphere_d=normal.dot(sphere_pos);
+ real_t sphere_d=normal.dot(sphere_pos);
//Vector3 ray_closest=normal*sphere_d;
- float ray_distance=sphere_pos.distance_to(normal*sphere_d);
+ real_t ray_distance=sphere_pos.distance_to(normal*sphere_d);
if (ray_distance>=p_sphere_radius)
return false;
- float inters_d2=p_sphere_radius*p_sphere_radius - ray_distance*ray_distance;
- float inters_d=sphere_d;
+ real_t inters_d2=p_sphere_radius*p_sphere_radius - ray_distance*ray_distance;
+ real_t inters_d=sphere_d;
if (inters_d2>=CMP_EPSILON)
inters_d-=Math::sqrt(inters_d2);
@@ -297,7 +325,7 @@ public:
if (inters_d<0 || inters_d>rel_l)
return false;
- Vector3 result=p_from+normal*inters_d;;
+ Vector3 result=p_from+normal*inters_d;
if (r_res)
*r_res=result;
@@ -307,17 +335,17 @@ public:
return true;
}
- static inline bool segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius,Vector3* r_res=0,Vector3 *r_norm=0) {
+ static inline bool segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, real_t p_height,real_t p_radius,Vector3* r_res=0,Vector3 *r_norm=0) {
Vector3 rel=(p_to-p_from);
- float rel_l=rel.length();
+ real_t rel_l=rel.length();
if (rel_l<CMP_EPSILON)
return false; // both points are the same
// first check if they are parallel
Vector3 normal=(rel/rel_l);
Vector3 crs = normal.cross(Vector3(0,0,1));
- float crs_l=crs.length();
+ real_t crs_l=crs.length();
Vector3 z_dir;
@@ -328,13 +356,13 @@ public:
z_dir=crs/crs_l;
}
- float dist=z_dir.dot(p_from);
+ real_t dist=z_dir.dot(p_from);
if (dist>=p_radius)
return false; // too far away
// convert to 2D
- float w2=p_radius*p_radius-dist*dist;
+ real_t w2=p_radius*p_radius-dist*dist;
if (w2<CMP_EPSILON)
return false; //avoid numerical error
Size2 size(Math::sqrt(w2),p_height*0.5);
@@ -344,7 +372,7 @@ public:
Vector2 from2D(x_dir.dot(p_from),p_from.z);
Vector2 to2D(x_dir.dot(p_to),p_to.z);
- float min=0,max=1;
+ real_t min=0,max=1;
int axis=-1;
@@ -464,12 +492,12 @@ public:
Vector3 p=p_point-p_segment[0];
Vector3 n=p_segment[1]-p_segment[0];
- float l =n.length();
+ real_t l =n.length();
if (l<1e-10)
return p_segment[0]; // both points are the same, just give any
n/=l;
- float d=n.dot(p);
+ real_t d=n.dot(p);
if (d<=0.0)
return p_segment[0]; // before first point
@@ -483,12 +511,12 @@ public:
Vector3 p=p_point-p_segment[0];
Vector3 n=p_segment[1]-p_segment[0];
- float l =n.length();
+ real_t l =n.length();
if (l<1e-10)
return p_segment[0]; // both points are the same, just give any
n/=l;
- float d=n.dot(p);
+ real_t d=n.dot(p);
return p_segment[0]+n*d; // inside
}
@@ -497,12 +525,12 @@ public:
Vector2 p=p_point-p_segment[0];
Vector2 n=p_segment[1]-p_segment[0];
- float l =n.length();
+ real_t l =n.length();
if (l<1e-10)
return p_segment[0]; // both points are the same, just give any
n/=l;
- float d=n.dot(p);
+ real_t d=n.dot(p);
if (d<=0.0)
return p_segment[0]; // before first point
@@ -529,12 +557,12 @@ public:
Vector2 p=p_point-p_segment[0];
Vector2 n=p_segment[1]-p_segment[0];
- float l =n.length();
+ real_t l =n.length();
if (l<1e-10)
return p_segment[0]; // both points are the same, just give any
n/=l;
- float d=n.dot(p);
+ real_t d=n.dot(p);
return p_segment[0]+n*d; // inside
}
@@ -555,7 +583,7 @@ public:
if ((C.y<0 && D.y<0) || (C.y>=0 && D.y>=0))
return false;
- float ABpos=D.x+(C.x-D.x)*D.y/(D.y-C.y);
+ real_t ABpos=D.x+(C.x-D.x)*D.y/(D.y-C.y);
// Fail if segment C-D crosses line A-B outside of segment A-B.
if (ABpos<0 || ABpos>1.0)
@@ -595,7 +623,7 @@ public:
static inline bool triangle_sphere_intersection_test(const Vector3 *p_triangle,const Vector3& p_normal,const Vector3& p_sphere_pos, real_t p_sphere_radius,Vector3& r_triangle_contact,Vector3& r_sphere_contact) {
- float d=p_normal.dot(p_sphere_pos)-p_normal.dot(p_triangle[0]);
+ real_t d=p_normal.dot(p_sphere_pos)-p_normal.dot(p_triangle[0]);
if (d > p_sphere_radius || d < -p_sphere_radius) // not touching the plane of the face, return
return false;
@@ -629,7 +657,7 @@ public:
Vector3 axis =n1.cross(n2).cross(n1);
axis.normalize(); // ugh
- float ad=axis.dot(n2);
+ real_t ad=axis.dot(n2);
if (ABS(ad)>p_sphere_radius) {
// no chance with this edge, too far away
@@ -639,7 +667,7 @@ public:
// check point within edge capsule cylinder
/** 4th TEST INSIDE EDGE POINTS **/
- float sphere_at = n1.dot(n2);
+ real_t sphere_at = n1.dot(n2);
if (sphere_at>=0 && sphere_at<n1.dot(n1)) {
@@ -650,7 +678,7 @@ public:
return true;
}
- float r2=p_sphere_radius*p_sphere_radius;
+ real_t r2=p_sphere_radius*p_sphere_radius;
if (n2.length_squared()<r2) {
@@ -726,8 +754,8 @@ public:
int outside_count = 0;
for (int a = 0; a < polygon.size(); a++) {
- //float p_plane.d = (*this) * polygon[a];
- float dist = p_plane.distance_to(polygon[a]);
+ //real_t p_plane.d = (*this) * polygon[a];
+ real_t dist = p_plane.distance_to(polygon[a]);
if (dist <-CMP_POINT_IN_PLANE_EPSILON) {
location_cache[a] = LOC_INSIDE;
inside_count++;
@@ -750,9 +778,7 @@ public:
return Vector<Vector3>(); //empty
}
-// long count = 0;
long previous = polygon.size() - 1;
-
Vector<Vector3> clipped;
for (int index = 0; index < polygon.size(); index++) {
@@ -763,8 +789,8 @@ public:
const Vector3& v2 = polygon[index];
Vector3 segment= v1 - v2;
- double den=p_plane.normal.dot( segment );
- double dist=p_plane.distance_to( v1 ) / den;
+ real_t den=p_plane.normal.dot( segment );
+ real_t dist=p_plane.distance_to( v1 ) / den;
dist=-dist;
clipped.push_back( v1 + segment * dist );
}
@@ -773,8 +799,8 @@ public:
if ((loc == LOC_INSIDE) && (location_cache[previous] == LOC_OUTSIDE)) {
const Vector3& v2 = polygon[previous];
Vector3 segment= v1 - v2;
- double den=p_plane.normal.dot( segment );
- double dist=p_plane.distance_to( v1 ) / den;
+ real_t den=p_plane.normal.dot( segment );
+ real_t dist=p_plane.distance_to( v1 ) / den;
dist=-dist;
clipped.push_back( v1 + segment * dist );
}
@@ -810,7 +836,7 @@ public:
static PoolVector< PoolVector< Face3 > > separate_objects( PoolVector< Face3 > p_array );
- static PoolVector< Face3 > wrap_geometry( PoolVector< Face3 > p_array, float *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
+ static PoolVector< Face3 > wrap_geometry( PoolVector< Face3 > p_array, real_t *p_error=NULL ); ///< create a "wrap" that encloses the given geometry
struct MeshData {
@@ -886,9 +912,9 @@ public:
}
- static double vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B)
+ static real_t vec2_cross(const Point2 &O, const Point2 &A, const Point2 &B)
{
- return (double)(A.x - O.x) * (B.y - O.y) - (double)(A.y - O.y) * (B.x - O.x);
+ return (real_t)(A.x - O.x) * (B.y - O.y) - (real_t)(A.y - O.y) * (B.x - O.x);
}
// Returns a list of points on the convex hull in counter-clockwise order.
@@ -920,10 +946,10 @@ public:
}
static MeshData build_convex_mesh(const PoolVector<Plane> &p_planes);
- static PoolVector<Plane> build_sphere_planes(float p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static PoolVector<Plane> build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis=Vector3::AXIS_Z);
static PoolVector<Plane> build_box_planes(const Vector3& p_extents);
- static PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
- static PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static PoolVector<Plane> build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
+ static PoolVector<Plane> build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
static void make_atlas(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size);
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index c6860ba2e8..76eeece688 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -239,10 +239,10 @@ Vector2 Vector2::cubic_interpolate(const Vector2& p_b,const Vector2& p_pre_a, co
real_t t3 = t2 * t;
Vector2 out;
- out = 0.5f * ( ( p1 * 2.0f) +
+ out = 0.5 * ( ( p1 * 2.0) +
( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ ( 2.0 * p0 - 5.0 * p1 + 4 * p2 - p3 ) * t2 +
+ ( -p0 + 3.0 * p1 - 3.0 * p2 + p3 ) * t3 );
return out;
/*
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 7896299c24..a24c4266ee 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -154,7 +154,7 @@ struct Vector2 {
Vector2 floor() const;
Vector2 snapped(const Vector2& p_by) const;
- real_t get_aspect() const { return width/height; }
+ real_t aspect() const { return width/height; }
operator String() const { return String::num(x)+", "+String::num(y); }
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 8353aa0ebe..c730b4fa30 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -27,12 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "math_funcs.h"
-
#include "core/os/os.h"
-#include "float.h"
-uint32_t Math::default_seed=1;
-
+pcg32_random_t Math::default_pcg = {1, PCG_DEFAULT_INC_64};
#define PHI 0x9e3779b9
@@ -40,59 +37,30 @@ uint32_t Math::default_seed=1;
static uint32_t Q[4096];
#endif
-uint32_t Math::rand_from_seed(uint32_t *seed) {
- // Xorshift31 PRNG
- if ( *seed == 0 ) *seed = Math::RANDOM_MAX;
- (*seed) ^= (*seed) << 13;
- (*seed) ^= (*seed) >> 17;
- (*seed) ^= (*seed) << 5;
- return (*seed) & Math::RANDOM_MAX;
+// TODO: we should eventually expose pcg.inc too
+uint32_t Math::rand_from_seed(uint64_t *seed) {
+ pcg32_random_t pcg = {*seed, PCG_DEFAULT_INC_64};
+ uint32_t r = pcg32_random_r(&pcg);
+ *seed = pcg.state;
+ return r;
}
-void Math::seed(uint32_t x) {
- default_seed=x;
+void Math::seed(uint64_t x) {
+ default_pcg.state=x;
}
void Math::randomize() {
OS::Time time = OS::get_singleton()->get_time();
- seed(OS::get_singleton()->get_ticks_usec()*(time.hour+1)*(time.min+1)*(time.sec+1)*rand()); /* *OS::get_singleton()->get_time().sec); // windows doesn't have get_time(), returns always 0 */
+ seed(OS::get_singleton()->get_ticks_usec()*(time.hour+1)*(time.min+1)*(time.sec+1)*rand()); // TODO: can be simplified.
}
uint32_t Math::rand() {
-
- return rand_from_seed(&default_seed);
-}
-
-double Math::randf() {
-
- return (double)rand() / (double)Math::RANDOM_MAX;
-}
-
-
-double Math::round(double p_val) {
-
- if (p_val>=0) {
- return ::floor(p_val+0.5);
- } else {
- p_val=-p_val;
- return -::floor(p_val+0.5);
- }
-}
-
-double Math::dectime(double p_value,double p_amount, double p_step) {
-
- float sgn = p_value < 0 ? -1.0 : 1.0;
- float val = absf(p_value);
- val-=p_amount*p_step;
- if (val<0.0)
- val=0.0;
- return val*sgn;
+ return pcg32_random_r(&default_pcg);
}
int Math::step_decimals(double p_step) {
-
static const int maxn=9;
static const double sd[maxn]={
0.9999, // somehow compensate for floating point error
@@ -106,7 +74,7 @@ int Math::step_decimals(double p_step) {
0.000000009999
};
- double as=absf(p_step);
+ double as=Math::abs(p_step);
for(int i=0;i<maxn;i++) {
if (as>=sd[i]) {
return i;
@@ -116,8 +84,16 @@ int Math::step_decimals(double p_step) {
return maxn;
}
-double Math::ease(double p_x, double p_c) {
+double Math::dectime(double p_value,double p_amount, double p_step) {
+ double sgn = p_value < 0 ? -1.0 : 1.0;
+ double val = Math::abs(p_value);
+ val-=p_amount*p_step;
+ if (val<0.0)
+ val=0.0;
+ return val*sgn;
+}
+double Math::ease(double p_x, double p_c) {
if (p_x<0)
p_x=0;
else if (p_x>1.0)
@@ -138,20 +114,16 @@ double Math::ease(double p_x, double p_c) {
}
} else
return 0; // no ease (raw)
-
}
double Math::stepify(double p_value,double p_step) {
-
if (p_step!=0) {
-
- p_value=floor( p_value / p_step + 0.5 ) * p_step;
+ p_value=Math::floor( p_value / p_step + 0.5 ) * p_step;
}
return p_value;
}
-
uint32_t Math::larger_prime(uint32_t p_val) {
static const uint32_t primes[] = {
@@ -200,22 +172,15 @@ uint32_t Math::larger_prime(uint32_t p_val) {
}
double Math::random(double from, double to) {
-
unsigned int r = Math::rand();
double ret = (double)r/(double)RANDOM_MAX;
return (ret)*(to-from) + from;
}
-double Math::pow(double x, double y) {
-
- return ::pow(x,y);
+float Math::random(float from, float to) {
+ unsigned int r = Math::rand();
+ float ret = (float)r/(float)RANDOM_MAX;
+ return (ret)*(to-from) + from;
}
-double Math::log(double x) {
-
- return ::log(x);
-}
-double Math::exp(double x) {
- return ::exp(x);
-}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 8ce59224ff..ae461eda2e 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -31,169 +31,145 @@
#include "typedefs.h"
#include "math_defs.h"
+#include "pcg.h"
-#ifndef NO_MATH_H
#include <math.h>
-#endif
-
+#include <float.h>
+
#define Math_PI 3.14159265358979323846
#define Math_SQRT12 0.7071067811865475244008443621048490
+#define Math_LN2 0.693147180559945309417
+#define Math_INF INFINITY
+#define Math_NAN NAN
class Math {
+ static pcg32_random_t default_pcg;
- static uint32_t default_seed;
public:
Math() {} // useless to instance
enum {
- RANDOM_MAX=2147483647L
+ RANDOM_MAX=4294967295L
};
- static _ALWAYS_INLINE_ double sin(double p_x) {
-
- return ::sin(p_x);
-
- }
-
- static _ALWAYS_INLINE_ double cos(double p_x) {
-
- return ::cos(p_x);
-
- }
-
- static _ALWAYS_INLINE_ double tan(double p_x) {
-
- return ::tan(p_x);
-
- }
- static _ALWAYS_INLINE_ double sinh(double p_x) {
-
- return ::sinh(p_x);
- }
-
- static _ALWAYS_INLINE_ double cosh(double p_x) {
-
- return ::cosh(p_x);
- }
-
- static _ALWAYS_INLINE_ double tanh(double p_x) {
-
- return ::tanh(p_x);
- }
+ static _ALWAYS_INLINE_ double sin(double p_x) { return ::sin(p_x); }
+ static _ALWAYS_INLINE_ float sin(float p_x) { return ::sinf(p_x); }
+ static _ALWAYS_INLINE_ double cos(double p_x) { return ::cos(p_x); }
+ static _ALWAYS_INLINE_ float cos(float p_x) { return ::cosf(p_x); }
- static _ALWAYS_INLINE_ double asin(double p_x) {
+ static _ALWAYS_INLINE_ double tan(double p_x) { return ::tan(p_x); }
+ static _ALWAYS_INLINE_ float tan(float p_x) { return ::tanf(p_x); }
- return ::asin(p_x);
+ static _ALWAYS_INLINE_ double sinh(double p_x) { return ::sinh(p_x); }
+ static _ALWAYS_INLINE_ float sinh(float p_x) { return ::sinhf(p_x); }
- }
+ static _ALWAYS_INLINE_ double cosh(double p_x) { return ::cosh(p_x); }
+ static _ALWAYS_INLINE_ float cosh(float p_x) { return ::coshf(p_x); }
- static _ALWAYS_INLINE_ double acos(double p_x) {
+ static _ALWAYS_INLINE_ double tanh(double p_x) { return ::tanh(p_x); }
+ static _ALWAYS_INLINE_ float tanh(float p_x) { return ::tanhf(p_x); }
- return ::acos(p_x);
- }
+ static _ALWAYS_INLINE_ double asin(double p_x) { return ::asin(p_x); }
+ static _ALWAYS_INLINE_ float asin(float p_x) { return ::asinf(p_x); }
- static _ALWAYS_INLINE_ double atan(double p_x) {
+ static _ALWAYS_INLINE_ double acos(double p_x) { return ::acos(p_x); }
+ static _ALWAYS_INLINE_ float acos(float p_x) { return ::acosf(p_x); }
- return ::atan(p_x);
- }
+ static _ALWAYS_INLINE_ double atan(double p_x) { return ::atan(p_x); }
+ static _ALWAYS_INLINE_ float atan(float p_x) { return ::atanf(p_x); }
- static _ALWAYS_INLINE_ double atan2(double p_y, double p_x) {
+ static _ALWAYS_INLINE_ double atan2(double p_y, double p_x) { return ::atan2(p_y,p_x); }
+ static _ALWAYS_INLINE_ float atan2(float p_y, float p_x) { return ::atan2f(p_y,p_x); }
- return ::atan2(p_y,p_x);
+ static _ALWAYS_INLINE_ double sqrt(double p_x) { return ::sqrt(p_x); }
+ static _ALWAYS_INLINE_ float sqrt(float p_x) { return ::sqrtf(p_x); }
- }
+ static _ALWAYS_INLINE_ double fmod(double p_x,double p_y) { return ::fmod(p_x,p_y); }
+ static _ALWAYS_INLINE_ float fmod(float p_x,float p_y) { return ::fmodf(p_x,p_y); }
- static _ALWAYS_INLINE_ double deg2rad(double p_y) {
+ static _ALWAYS_INLINE_ double floor(double p_x) { return ::floor(p_x); }
+ static _ALWAYS_INLINE_ float floor(float p_x) { return ::floorf(p_x); }
- return p_y*Math_PI/180.0;
- }
+ static _ALWAYS_INLINE_ double ceil(double p_x) { return ::ceil(p_x); }
+ static _ALWAYS_INLINE_ float ceil(float p_x) { return ::ceilf(p_x); }
- static _ALWAYS_INLINE_ double rad2deg(double p_y) {
+ static _ALWAYS_INLINE_ double pow(double p_x, double p_y) { return ::pow(p_x,p_y); }
+ static _ALWAYS_INLINE_ float pow(float p_x, float p_y) { return ::powf(p_x,p_y); }
- return p_y*180.0/Math_PI;
- }
+ static _ALWAYS_INLINE_ double log(double p_x) { return ::log(p_x); }
+ static _ALWAYS_INLINE_ float log(float p_x) { return ::logf(p_x); }
+ static _ALWAYS_INLINE_ double exp(double p_x) { return ::exp(p_x); }
+ static _ALWAYS_INLINE_ float exp(float p_x) { return ::expf(p_x); }
- static _ALWAYS_INLINE_ double sqrt(double p_x) {
+ static _ALWAYS_INLINE_ bool is_nan(double p_val) { return (p_val!=p_val); }
+ static _ALWAYS_INLINE_ bool is_nan(float p_val) { return (p_val!=p_val); }
- return ::sqrt(p_x);
+ static _ALWAYS_INLINE_ bool is_inf(double p_val) {
+ #ifdef _MSC_VER
+ return !_finite(p_val);
+ #else
+ return isinf(p_val);
+ #endif
}
-
- static _ALWAYS_INLINE_ double fmod(double p_x,double p_y) {
-
- return ::fmod(p_x,p_y);
+
+ static _ALWAYS_INLINE_ bool is_inf(float p_val) {
+ #ifdef _MSC_VER
+ return !_finite(p_val);
+ #else
+ return isinf(p_val);
+ #endif
}
+
+ static _ALWAYS_INLINE_ double abs(double g) { return absd(g); }
+ static _ALWAYS_INLINE_ float abs(float g) { return absf(g); }
+ static _ALWAYS_INLINE_ int abs(int g) { return g > 0 ? g : -g; }
- static _ALWAYS_INLINE_ double fposmod(double p_x,double p_y) {
-
- if (p_x>=0) {
-
- return fmod(p_x,p_y);
+ static _ALWAYS_INLINE_ double fposmod(double p_x,double p_y) { return (p_x>=0) ? Math::fmod(p_x,p_y) : p_y-Math::fmod(-p_x,p_y); }
+ static _ALWAYS_INLINE_ float fposmod(float p_x,float p_y) { return (p_x>=0) ? Math::fmod(p_x,p_y) : p_y-Math::fmod(-p_x,p_y); }
- } else {
+ static _ALWAYS_INLINE_ double deg2rad(double p_y) { return p_y*Math_PI/180.0; }
+ static _ALWAYS_INLINE_ float deg2rad(float p_y) { return p_y*Math_PI/180.0; }
- return p_y-fmod(-p_x,p_y);
- }
-
- }
- static _ALWAYS_INLINE_ double floor(double p_x) {
+ static _ALWAYS_INLINE_ double rad2deg(double p_y) { return p_y*180.0/Math_PI; }
+ static _ALWAYS_INLINE_ float rad2deg(float p_y) { return p_y*180.0/Math_PI; }
- return ::floor(p_x);
- }
-
- static _ALWAYS_INLINE_ double ceil(double p_x) {
+ static _ALWAYS_INLINE_ double lerp(double a, double b, double c) { return a+(b-a)*c; }
+ static _ALWAYS_INLINE_ float lerp(float a, float b, float c) { return a+(b-a)*c; }
- return ::ceil(p_x);
- }
+ static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log( p_linear ) * 8.6858896380650365530225783783321; }
+ static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log( p_linear ) * 8.6858896380650365530225783783321; }
+ static _ALWAYS_INLINE_ double db2linear(double p_db) { return Math::exp( p_db * 0.11512925464970228420089957273422 ); }
+ static _ALWAYS_INLINE_ float db2linear(float p_db) { return Math::exp( p_db * 0.11512925464970228420089957273422 ); }
- static uint32_t rand_from_seed(uint32_t *seed);
+ static _ALWAYS_INLINE_ double round(double p_val) { return (p_val>=0) ? Math::floor(p_val+0.5) : -Math::floor(-p_val+0.5); }
+ static _ALWAYS_INLINE_ float round(float p_val) { return (p_val>=0) ? Math::floor(p_val+0.5) : -Math::floor(-p_val+0.5); }
+ // double only, as these functions are mainly used by the editor and not performance-critical,
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
static double stepify(double p_value,double p_step);
- static void seed(uint32_t x=0);
- static void randomize();
- static uint32_t larger_prime(uint32_t p_val);
static double dectime(double p_value,double p_amount, double p_step);
+ static uint32_t larger_prime(uint32_t p_val);
- static inline double linear2db(double p_linear) {
-
- return Math::log( p_linear ) * 8.6858896380650365530225783783321;
- }
-
- static inline double db2linear(double p_db) {
-
- return Math::exp( p_db * 0.11512925464970228420089957273422 );
- }
-
- static _ALWAYS_INLINE_ bool is_nan(double p_val) {
-
- return (p_val!=p_val);
- }
-
- static _ALWAYS_INLINE_ bool is_inf(double p_val) {
-
- #ifdef _MSC_VER
- return !_finite(p_val);
- #else
- return isinf(p_val);
- #endif
-
- }
-
+ static void seed(uint64_t x=0);
+ static void randomize();
+ static uint32_t rand_from_seed(uint64_t *seed);
static uint32_t rand();
- static double randf();
-
- static double round(double p_val);
+ static _ALWAYS_INLINE_ double randf() { return (double)rand() / (double)Math::RANDOM_MAX; }
+ static _ALWAYS_INLINE_ float randd() { return (float)rand() / (float)Math::RANDOM_MAX; }
static double random(double from, double to);
+ static float random(float from, float to);
+ static real_t random(int from, int to) { return (real_t)random((real_t)from, (real_t)to); }
- static _FORCE_INLINE_ bool isequal_approx(real_t a, real_t b) {
+
+ static _ALWAYS_INLINE_ bool isequal_approx(real_t a, real_t b) {
// TODO: Comparing floats for approximate-equality is non-trivial.
// Using epsilon should cover the typical cases in Godot (where a == b is used to compare two reals), such as matrix and vector comparison operators.
// A proper implementation in terms of ULPs should eventually replace the contents of this function.
@@ -203,18 +179,7 @@ public:
}
- static _FORCE_INLINE_ real_t abs(real_t g) {
-
-#ifdef REAL_T_IS_DOUBLE
-
- return absd(g);
-#else
-
- return absf(g);
-#endif
- }
-
- static _FORCE_INLINE_ float absf(float g) {
+ static _ALWAYS_INLINE_ float absf(float g) {
union {
float f;
@@ -226,7 +191,7 @@ public:
return u.f;
}
- static _FORCE_INLINE_ double absd(double g) {
+ static _ALWAYS_INLINE_ double absd(double g) {
union {
double d;
@@ -238,12 +203,12 @@ public:
}
//this function should be as fast as possible and rounding mode should not matter
- static _FORCE_INLINE_ int fast_ftoi(float a) {
+ static _ALWAYS_INLINE_ int fast_ftoi(float a) {
static int b;
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone?
- b = (int)((a>0.0f) ? (a + 0.5f):(a -0.5f));
+ b = (int)((a>0.0) ? (a + 0.5):(a -0.5));
#elif defined(_MSC_VER) && _MSC_VER < 1800
__asm fld a
@@ -266,23 +231,16 @@ public:
#if defined(__GNUC__)
- static _FORCE_INLINE_ int64_t dtoll(double p_double) { return (int64_t)p_double; } ///@TODO OPTIMIZE
+ static _ALWAYS_INLINE_ int64_t dtoll(double p_double) { return (int64_t)p_double; } ///@TODO OPTIMIZE
+ static _ALWAYS_INLINE_ int64_t dtoll(float p_float) { return (int64_t)p_float; } ///@TODO OPTIMIZE and rename
#else
- static _FORCE_INLINE_ int64_t dtoll(double p_double) { return (int64_t)p_double; } ///@TODO OPTIMIZE
+ static _ALWAYS_INLINE_ int64_t dtoll(double p_double) { return (int64_t)p_double; } ///@TODO OPTIMIZE
+ static _ALWAYS_INLINE_ int64_t dtoll(float p_float) { return (int64_t)p_float; } ///@TODO OPTIMIZE and rename
#endif
- static _FORCE_INLINE_ float lerp(float a, float b, float c) {
-
- return a+(b-a)*c;
- }
-
- static double pow(double x, double y);
- static double log(double x);
- static double exp(double x);
-
- static _FORCE_INLINE_ uint32_t halfbits_to_floatbits(uint16_t h)
+ static _ALWAYS_INLINE_ uint32_t halfbits_to_floatbits(uint16_t h)
{
uint16_t h_exp, h_sig;
uint32_t f_sgn, f_exp, f_sig;
@@ -314,7 +272,7 @@ public:
}
}
- static _FORCE_INLINE_ float halfptr_to_float(const uint16_t *h) {
+ static _ALWAYS_INLINE_ float halfptr_to_float(const uint16_t *h) {
union {
uint32_t u32;
@@ -325,7 +283,7 @@ public:
return u.f32;
}
- static _FORCE_INLINE_ uint16_t make_half_float(float f) {
+ static _ALWAYS_INLINE_ uint16_t make_half_float(float f) {
union {
float fv;
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index e9c3442582..1fabfbbd4c 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -504,9 +504,9 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
ERR_FAIL_COND(is_rotation() == false);
- double angle,x,y,z; // variables for result
- double epsilon = 0.01; // margin to allow for rounding errors
- double epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees
+ real_t angle,x,y,z; // variables for result
+ real_t epsilon = 0.01; // margin to allow for rounding errors
+ real_t epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees
if ( (Math::abs(elements[1][0]-elements[0][1])< epsilon)
&& (Math::abs(elements[2][0]-elements[0][2])< epsilon)
@@ -525,12 +525,12 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
}
// otherwise this singularity is angle = 180
angle = Math_PI;
- double xx = (elements[0][0]+1)/2;
- double yy = (elements[1][1]+1)/2;
- double zz = (elements[2][2]+1)/2;
- double xy = (elements[1][0]+elements[0][1])/4;
- double xz = (elements[2][0]+elements[0][2])/4;
- double yz = (elements[2][1]+elements[1][2])/4;
+ real_t xx = (elements[0][0]+1)/2;
+ real_t yy = (elements[1][1]+1)/2;
+ real_t zz = (elements[2][2]+1)/2;
+ real_t xy = (elements[1][0]+elements[0][1])/4;
+ real_t xz = (elements[2][0]+elements[0][2])/4;
+ real_t yz = (elements[2][1]+elements[1][2])/4;
if ((xx > yy) && (xx > zz)) { // elements[0][0] is the largest diagonal term
if (xx< epsilon) {
x = 0;
@@ -567,7 +567,7 @@ void Basis::get_axis_and_angle(Vector3 &r_axis,real_t& r_angle) const {
return;
}
// as we have reached here there are no singularities so we can handle normally
- double s = Math::sqrt((elements[1][2] - elements[2][1])*(elements[1][2] - elements[2][1])
+ real_t s = Math::sqrt((elements[1][2] - elements[2][1])*(elements[1][2] - elements[2][1])
+(elements[2][0] - elements[0][2])*(elements[2][0] - elements[0][2])
+(elements[0][1] - elements[1][0])*(elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise
diff --git a/core/math/octree.h b/core/math/octree.h
index 1a41413a76..e566df6a4f 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -30,7 +30,7 @@
#define OCTREE_H
#include "vector3.h"
-#include "aabb.h"
+#include "rect3.h"
#include "list.h"
#include "variant.h"
#include "map.h"
@@ -130,8 +130,10 @@ private:
~Octant() {
- //for (int i=0;i<8;i++)
- // memdelete_notnull(children[i]);
+ /*
+ for (int i=0;i<8;i++)
+ memdelete_notnull(children[i]);
+ */
}
};
@@ -250,8 +252,10 @@ private:
E->get().eA=p_A->pair_list.push_back(&E->get());
E->get().eB=p_B->pair_list.push_back(&E->get());
-// if (pair_callback)
-// pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata);
+ /*
+ if (pair_callback)
+ pair_callback(pair_callback_userdata,p_A->userdata,p_B->userdata);
+ */
} else {
E->get().refcount++;
@@ -431,7 +435,7 @@ int Octree<T,use_pairs,AL>::get_subindex(OctreeElementID p_id) const {
template<class T,bool use_pairs,class AL>
void Octree<T,use_pairs,AL>::_insert_element(Element *p_element,Octant *p_octant) {
- float element_size = p_element->aabb.get_longest_axis_size() * 1.01; // avoid precision issues
+ real_t element_size = p_element->aabb.get_longest_axis_size() * 1.01; // avoid precision issues
if (p_octant->aabb.size.x/OCTREE_DIVISOR < element_size) {
//if (p_octant->aabb.size.x*0.5 < element_size) {
@@ -970,8 +974,10 @@ void Octree<T,use_pairs,AL>::move(OctreeElementID p_id, const Rect3& p_aabb) {
Octant *o=E->get().octant;
typename List<typename Element::OctantOwner,AL>::Element *N=E->next();
-// if (!use_pairs)
-// o->elements.erase( E->get().E );
+ /*
+ if (!use_pairs)
+ o->elements.erase( E->get().E );
+ */
if (use_pairs && e.pairable)
o->pairable_elements.erase( E->get().E );
diff --git a/core/math/pcg.cpp b/core/math/pcg.cpp
new file mode 100644
index 0000000000..eac3b36d36
--- /dev/null
+++ b/core/math/pcg.cpp
@@ -0,0 +1,15 @@
+// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
+// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
+
+#include "pcg.h"
+
+uint32_t pcg32_random_r(pcg32_random_t* rng)
+{
+ uint64_t oldstate = rng->state;
+ // Advance internal state
+ rng->state = oldstate * 6364136223846793005ULL + (rng->inc|1);
+ // Calculate output function (XSH RR), uses old state for max ILP
+ uint32_t xorshifted = ((oldstate >> 18u) ^ oldstate) >> 27u;
+ uint32_t rot = oldstate >> 59u;
+ return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
+}
diff --git a/core/math/pcg.h b/core/math/pcg.h
new file mode 100644
index 0000000000..81f4c9770e
--- /dev/null
+++ b/core/math/pcg.h
@@ -0,0 +1,14 @@
+// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-random.org
+// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
+
+#ifndef RANDOM_H
+#define RANDOM_H
+
+#include "typedefs.h"
+
+#define PCG_DEFAULT_INC_64 1442695040888963407ULL
+
+typedef struct { uint64_t state; uint64_t inc; } pcg32_random_t;
+uint32_t pcg32_random_r(pcg32_random_t* rng);
+
+#endif // RANDOM_H
diff --git a/core/math/plane.h b/core/math/plane.h
index f746ea2067..8235c59135 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -99,7 +99,7 @@ real_t Plane::distance_to(const Vector3 &p_point) const {
bool Plane::has_point(const Vector3 &p_point,real_t _epsilon) const {
- float dist=normal.dot(p_point) - d;
+ real_t dist=normal.dot(p_point) - d;
dist=ABS(dist);
return ( dist <= _epsilon);
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 055e2b7c35..4085f9b84a 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -124,8 +124,8 @@ Quat Quat::slerp(const Quat& q, const real_t& t) const {
// Standard case (slerp)
real_t sine = Math::sqrt(1 - cosine*cosine);
real_t angle = Math::atan2(sine, cosine);
- real_t inv_sine = 1.0f / sine;
- real_t coeff_0 = Math::sin((1.0f - t) * angle) * inv_sine;
+ real_t inv_sine = 1.0 / sine;
+ real_t coeff_0 = Math::sin((1.0 - t) * angle) * inv_sine;
real_t coeff_1 = Math::sin(t * angle) * inv_sine;
Quat ret= src * coeff_0 + dst * coeff_1;
@@ -137,7 +137,7 @@ Quat Quat::slerp(const Quat& q, const real_t& t) const {
// 2. "rkP" and "q" are almost invedste of each other (cosine ~= -1), there
// are an infinite number of possibilities interpolation. but we haven't
// have method to fix this case, so just use linear interpolation here.
- Quat ret = src * (1.0f - t) + dst *t;
+ Quat ret = src * (1.0 - t) + dst *t;
// taking the complement requires renormalisation
ret.normalize();
return ret;
@@ -194,14 +194,14 @@ Quat Quat::slerpni(const Quat& q, const real_t& t) const {
const Quat &from = *this;
- float dot = from.dot(q);
+ real_t dot = from.dot(q);
- if (Math::absf(dot) > 0.9999f) return from;
+ if (Math::absf(dot) > 0.9999) return from;
- float theta = Math::acos(dot),
- sinT = 1.0f / Math::sin(theta),
+ real_t theta = Math::acos(dot),
+ sinT = 1.0 / Math::sin(theta),
newFactor = Math::sin(t * theta) * sinT,
- invFactor = Math::sin((1.0f - t) * theta) * sinT;
+ invFactor = Math::sin((1.0 - t) * theta) * sinT;
return Quat(invFactor * from.x + newFactor * q.x,
invFactor * from.y + newFactor * q.y,
@@ -259,7 +259,7 @@ Quat Quat::slerpni(const Quat& q, const real_t& t) const {
Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const real_t& t) const {
//the only way to do slerp :|
- float t2 = (1.0-t)*t*2;
+ real_t t2 = (1.0-t)*t*2;
Quat sp = this->slerp(q,t);
Quat sq = prep.slerpni(postq,t);
return sp.slerpni(sq,t2);
diff --git a/core/math/quat.h b/core/math/quat.h
index 43c2cab9e6..d3a50343a3 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -119,8 +119,8 @@ public:
w=0;
} else {
- real_t s = Math::sqrt((1.0f + d) * 2.0f);
- real_t rs = 1.0f / s;
+ real_t s = Math::sqrt((1.0 + d) * 2.0);
+ real_t rs = 1.0 / s;
x=c.x*rs;
y=c.y*rs;
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index ab81a068d4..32fc0e01e8 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -86,7 +86,7 @@ Error QuickHull::build(const Vector<Vector3>& p_points, Geometry::MeshData &r_me
if (!valid_points[i])
continue;
- float d = p_points[i][longest_axis];
+ real_t d = p_points[i][longest_axis];
if (i==0 || d < min) {
simplex[0]=i;
@@ -105,7 +105,7 @@ Error QuickHull::build(const Vector<Vector3>& p_points, Geometry::MeshData &r_me
{
- float maxd;
+ real_t maxd;
Vector3 rel12 = p_points[simplex[0]] - p_points[simplex[1]];
for(int i=0;i<p_points.size();i++) {
@@ -127,7 +127,7 @@ Error QuickHull::build(const Vector<Vector3>& p_points, Geometry::MeshData &r_me
//fourth vertex is the one most further away from the plane
{
- float maxd;
+ real_t maxd;
Plane p(p_points[simplex[0]],p_points[simplex[1]],p_points[simplex[2]]);
for(int i=0;i<p_points.size();i++) {
@@ -483,7 +483,7 @@ Error QuickHull::build(const Vector<Vector3>& p_points, Geometry::MeshData &r_me
//fill mesh
r_mesh.faces.clear();
r_mesh.faces.resize(ret_faces.size());
-// print_line("FACECOUNT: "+itos(r_mesh.faces.size()));
+ //print_line("FACECOUNT: "+itos(r_mesh.faces.size()));
int idx=0;
for (List<Geometry::MeshData::Face>::Element *E=ret_faces.front();E;E=E->next()) {
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 04d25fef18..7bd23d31f2 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -29,7 +29,7 @@
#ifndef QUICK_HULL_H
#define QUICK_HULL_H
-#include "aabb.h"
+#include "rect3.h"
#include "set.h"
#include "list.h"
#include "geometry.h"
diff --git a/core/math/aabb.cpp b/core/math/rect3.cpp
index 3518eea7ac..d3f95b89e8 100644
--- a/core/math/aabb.cpp
+++ b/core/math/rect3.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* aabb.cpp */
+/* rect3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,11 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "aabb.h"
+#include "rect3.h"
#include "print_string.h"
-float Rect3::get_area() const {
+real_t Rect3::get_area() const {
return size.x*size.y*size.z;
@@ -114,8 +114,8 @@ bool Rect3::intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3*
Vector3 c1, c2;
Vector3 end = pos+size;
- float near=-1e20;
- float far=1e20;
+ real_t near=-1e20;
+ real_t far=1e20;
int axis=0;
for (int i=0;i<3;i++){
@@ -159,7 +159,7 @@ bool Rect3::intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector
real_t min=0,max=1;
int axis=0;
- float sign=0;
+ real_t sign=0;
for(int i=0;i<3;i++) {
real_t seg_from=p_from[i];
@@ -167,7 +167,7 @@ bool Rect3::intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector
real_t box_begin=pos[i];
real_t box_end=box_begin+size[i];
real_t cmin,cmax;
- float csign;
+ real_t csign;
if (seg_from < seg_to) {
diff --git a/core/math/aabb.h b/core/math/rect3.h
index 2816d1f012..902592b02c 100644
--- a/core/math/aabb.h
+++ b/core/math/rect3.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* aabb.h */
+/* rect3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,6 +33,8 @@
#include "vector3.h"
#include "plane.h"
+#include "math_defs.h"
+
/**
* AABB / AABB (Axis Aligned Bounding Box)
* This is implemented by a point (pos) and the box size
@@ -45,7 +47,7 @@ public:
Vector3 pos;
Vector3 size;
- float get_area() const; /// get area
+ real_t get_area() const; /// get area
_FORCE_INLINE_ bool has_no_area() const {
return (size.x<=CMP_EPSILON || size.y<=CMP_EPSILON || size.z<=CMP_EPSILON);
@@ -74,7 +76,7 @@ public:
Rect3 intersection(const Rect3& p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const;
bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const;
- _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, float t0, float t1) const;
+ _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, real_t t0, real_t t1) const;
_FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const;
bool intersects_plane(const Plane &p_plane) const;
@@ -98,7 +100,7 @@ public:
_FORCE_INLINE_ Vector3 get_endpoint(int p_point) const;
Rect3 expand(const Vector3& p_vector) const;
- _FORCE_INLINE_ void project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const;
+ _FORCE_INLINE_ void project_range_in_plane(const Plane& p_plane,real_t &r_min,real_t& r_max) const;
_FORCE_INLINE_ void expand_to(const Vector3& p_vector); /** expand to contain a point if necesary */
operator String() const;
@@ -293,13 +295,13 @@ inline void Rect3::expand_to(const Vector3& p_vector) {
size=end-begin;
}
-void Rect3::project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const {
+void Rect3::project_range_in_plane(const Plane& p_plane,real_t &r_min,real_t& r_max) const {
Vector3 half_extents( size.x * 0.5, size.y * 0.5, size.z * 0.5 );
Vector3 center( pos.x + half_extents.x, pos.y + half_extents.y, pos.z + half_extents.z );
- float length = p_plane.normal.abs().dot(half_extents);
- float distance = p_plane.distance_to( center );
+ real_t length = p_plane.normal.abs().dot(half_extents);
+ real_t distance = p_plane.distance_to( center );
r_min = distance - length;
r_max = distance + length;
}
@@ -334,14 +336,14 @@ inline real_t Rect3::get_shortest_axis_size() const {
return max_size;
}
-bool Rect3::smits_intersect_ray(const Vector3 &from,const Vector3& dir, float t0, float t1) const {
+bool Rect3::smits_intersect_ray(const Vector3 &from,const Vector3& dir, real_t t0, real_t t1) const {
- float divx=1.0/dir.x;
- float divy=1.0/dir.y;
- float divz=1.0/dir.z;
+ real_t divx=1.0/dir.x;
+ real_t divy=1.0/dir.y;
+ real_t divz=1.0/dir.z;
Vector3 upbound=pos+size;
- float tmin, tmax, tymin, tymax, tzmin, tzmax;
+ real_t tmin, tmax, tymin, tymax, tzmin, tzmax;
if (dir.x >= 0) {
tmin = (pos.x - from.x) * divx;
tmax = (upbound.x - from.x) * divx;
diff --git a/core/math/transform.h b/core/math/transform.h
index d65e87cc6a..45d7b2a12c 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -31,7 +31,7 @@
#include "matrix3.h"
#include "plane.h"
-#include "aabb.h"
+#include "rect3.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index fc5f55066b..247cb90a48 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -236,21 +236,22 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const {
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -258,8 +259,8 @@ Vector3 TriangleMesh::get_area_normal(const Rect3& p_aabb) const {
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}
@@ -320,7 +321,7 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
bool valid = b.aabb.intersects_segment(p_begin,p_end);
-// bool valid = b.aabb.intersects(ray_aabb);
+ //bool valid = b.aabb.intersects(ray_aabb);
if (!valid) {
@@ -339,7 +340,7 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
if (f3.intersects_segment(p_begin,p_end,&res)) {
- float nd = n.dot(res);
+ real_t nd = n.dot(res);
if (nd<d) {
d=nd;
@@ -357,21 +358,22 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -379,8 +381,8 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}
@@ -460,7 +462,7 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
if (f3.intersects_ray(p_begin,p_dir,&res)) {
- float nd = n.dot(res);
+ real_t nd = n.dot(res);
if (nd<d) {
d=nd;
@@ -478,21 +480,22 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
stack[level]=(VISIT_LEFT_BIT<<VISITED_BIT_SHIFT)|node;
}
}
-
- } continue;
+ continue;
+ }
case VISIT_LEFT_BIT: {
stack[level]=(VISIT_RIGHT_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.left|TEST_AABB_BIT;
level++;
-
- } continue;
+ continue;
+ }
case VISIT_RIGHT_BIT: {
stack[level]=(VISIT_DONE_BIT<<VISITED_BIT_SHIFT)|node;
stack[level+1]=b.right|TEST_AABB_BIT;
level++;
- } continue;
+ continue;
+ }
case VISIT_DONE_BIT: {
if (level==0) {
@@ -500,8 +503,8 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec
break;
} else
level--;
-
- } continue;
+ continue;
+ }
}
diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp
index 82b49be7f3..128b6ca331 100644
--- a/core/math/triangulate.cpp
+++ b/core/math/triangulate.cpp
@@ -28,19 +28,19 @@
/*************************************************************************/
#include "triangulate.h"
-float Triangulate::get_area(const Vector<Vector2> &contour)
+real_t Triangulate::get_area(const Vector<Vector2> &contour)
{
int n = contour.size();
const Vector2 *c=&contour[0];
- float A=0.0f;
+ real_t A=0.0;
for(int p=n-1,q=0; q<n; p=q++)
{
A+= c[p].cross(c[q]);
}
- return A*0.5f;
+ return A*0.5;
}
/*
@@ -48,14 +48,14 @@ float Triangulate::get_area(const Vector<Vector2> &contour)
defined by A, B, C.
*/
-bool Triangulate::is_inside_triangle(float Ax, float Ay,
- float Bx, float By,
- float Cx, float Cy,
- float Px, float Py)
+bool Triangulate::is_inside_triangle(real_t Ax, real_t Ay,
+ real_t Bx, real_t By,
+ real_t Cx, real_t Cy,
+ real_t Px, real_t Py)
{
- float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
- float cCROSSap, bCROSScp, aCROSSbp;
+ real_t ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
+ real_t cCROSSap, bCROSScp, aCROSSbp;
ax = Cx - Bx; ay = Cy - By;
bx = Ax - Cx; by = Ay - Cy;
@@ -68,13 +68,13 @@ bool Triangulate::is_inside_triangle(float Ax, float Ay,
cCROSSap = cx*apy - cy*apx;
bCROSScp = bx*cpy - by*cpx;
- return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
+ return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0));
};
bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V)
{
int p;
- float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
+ real_t Ax, Ay, Bx, By, Cx, Cy, Px, Py;
const Vector2 *contour=&p_contour[0];
Ax = contour[V[u]].x;
@@ -112,7 +112,7 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
/* we want a counter-clockwise polygon in V */
- if ( 0.0f < get_area(contour) )
+ if ( 0.0 < get_area(contour) )
for (int v=0; v<n; v++) V[v] = v;
else
for(int v=0; v<n; v++) V[v] = (n-1)-v;
diff --git a/core/math/triangulate.h b/core/math/triangulate.h
index d22677a8b8..ce77334519 100644
--- a/core/math/triangulate.h
+++ b/core/math/triangulate.h
@@ -45,14 +45,14 @@ public:
static bool triangulate(const Vector< Vector2 > &contour, Vector<int> &result);
// compute area of a contour/polygon
- static float get_area(const Vector< Vector2 > &contour);
+ static real_t get_area(const Vector< Vector2 > &contour);
// decide if point Px/Py is inside triangle defined by
// (Ax,Ay) (Bx,By) (Cx,Cy)
- static bool is_inside_triangle(float Ax, float Ay,
- float Bx, float By,
- float Cx, float Cy,
- float Px, float Py);
+ static bool is_inside_triangle(real_t Ax, real_t Ay,
+ real_t Bx, real_t By,
+ real_t Cx, real_t Cy,
+ real_t Px, real_t Py);
private:
diff --git a/core/math/triangulator.cpp b/core/math/triangulator.cpp
index 8f82d76823..75b2b064c4 100644
--- a/core/math/triangulator.cpp
+++ b/core/math/triangulator.cpp
@@ -1128,7 +1128,7 @@ int TriangulatorPartition::MonotonePartition(List<TriangulatorPoly> *inpolys, Li
//this makes deleting existing edges much faster
Set<ScanLineEdge>::Element **edgeTreeIterators,*edgeIter;
edgeTreeIterators = new Set<ScanLineEdge>::Element*[maxnumvertices];
-// Pair<Set<ScanLineEdge>::Element*,bool> edgeTreeRet;
+ //Pair<Set<ScanLineEdge>::Element*,bool> edgeTreeRet;
for(i = 0; i<numvertices; i++) edgeTreeIterators[i] = NULL;
//for each vertex
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 3eb978333d..2ab5fa0465 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -30,12 +30,12 @@
#include "matrix3.h"
-void Vector3::rotate(const Vector3& p_axis,float p_phi) {
+void Vector3::rotate(const Vector3& p_axis,real_t p_phi) {
*this=Basis(p_axis,p_phi).xform(*this);
}
-Vector3 Vector3::rotated(const Vector3& p_axis,float p_phi) const {
+Vector3 Vector3::rotated(const Vector3& p_axis,real_t p_phi) const {
Vector3 r = *this;
r.rotate(p_axis,p_phi);
@@ -63,13 +63,13 @@ int Vector3::max_axis() const {
}
-void Vector3::snap(float p_val) {
+void Vector3::snap(real_t p_val) {
x=Math::stepify(x,p_val);
y=Math::stepify(y,p_val);
z=Math::stepify(z,p_val);
}
-Vector3 Vector3::snapped(float p_val) const {
+Vector3 Vector3::snapped(real_t p_val) const {
Vector3 v=*this;
v.snap(p_val);
@@ -77,7 +77,7 @@ Vector3 Vector3::snapped(float p_val) const {
}
-Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
@@ -87,9 +87,9 @@ Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, c
{
//normalize
- float ab = p0.distance_to(p1);
- float bc = p1.distance_to(p2);
- float cd = p2.distance_to(p3);
+ real_t ab = p0.distance_to(p1);
+ real_t bc = p1.distance_to(p2);
+ real_t cd = p2.distance_to(p3);
if (ab>0)
p0 = p1+(p0-p1)*(bc/ab);
@@ -98,41 +98,41 @@ Vector3 Vector3::cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, c
}
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
+ out = 0.5 * ( ( p1 * 2.0) +
( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ ( 2.0 * p0 - 5.0 * p1 + 4 * p2 - p3 ) * t2 +
+ ( -p0 + 3.0 * p1 - 3.0 * p2 + p3 ) * t3 );
return out;
}
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
Vector3 p2=p_b;
Vector3 p3=p_post_b;
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out = 0.5f * ( ( p1 * 2.0f) +
+ out = 0.5 * ( ( p1 * 2.0) +
( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
+ ( 2.0 * p0 - 5.0 * p1 + 4 * p2 - p3 ) * t2 +
+ ( -p0 + 3.0 * p1 - 3.0 * p2 + p3 ) * t3 );
return out;
}
#if 0
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
Vector3 p0=p_pre_a;
Vector3 p1=*this;
@@ -141,9 +141,9 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
if (true) {
- float ab = p0.distance_to(p1);
- float bc = p1.distance_to(p2);
- float cd = p2.distance_to(p3);
+ real_t ab = p0.distance_to(p1);
+ real_t bc = p1.distance_to(p2);
+ real_t cd = p2.distance_to(p3);
//if (ab>bc) {
if (ab>0)
@@ -156,23 +156,23 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co
//}
}
- float t = p_t;
- float t2 = t * t;
- float t3 = t2 * t;
+ real_t t = p_t;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
Vector3 out;
- out.x = 0.5f * ( ( 2.0f * p1.x ) +
+ out.x = 0.5 * ( ( 2.0 * p1.x ) +
( -p0.x + p2.x ) * t +
- ( 2.0f * p0.x - 5.0f * p1.x + 4 * p2.x - p3.x ) * t2 +
- ( -p0.x + 3.0f * p1.x - 3.0f * p2.x + p3.x ) * t3 );
- out.y = 0.5f * ( ( 2.0f * p1.y ) +
+ ( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 +
+ ( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 );
+ out.y = 0.5 * ( ( 2.0 * p1.y ) +
( -p0.y + p2.y ) * t +
- ( 2.0f * p0.y - 5.0f * p1.y + 4 * p2.y - p3.y ) * t2 +
- ( -p0.y + 3.0f * p1.y - 3.0f * p2.y + p3.y ) * t3 );
- out.z = 0.5f * ( ( 2.0f * p1.z ) +
+ ( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 +
+ ( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 );
+ out.z = 0.5 * ( ( 2.0 * p1.z ) +
( -p0.z + p2.z ) * t +
- ( 2.0f * p0.z - 5.0f * p1.z + 4 * p2.z - p3.z ) * t2 +
- ( -p0.z + 3.0f * p1.z - 3.0f * p2.z + p3.z ) * t3 );
+ ( 2.0 * p0.z - 5.0 * p1.z + 4 * p2.z - p3.z ) * t2 +
+ ( -p0.z + 3.0 * p1.z - 3.0 * p2.z + p3.z ) * t3 );
return out;
}
# endif
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 9ae9b69dfa..a289f9bf4c 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -79,17 +79,17 @@ struct Vector3 {
_FORCE_INLINE_ void zero();
- void snap(float p_val);
- Vector3 snapped(float p_val) const;
+ void snap(real_t p_val);
+ Vector3 snapped(real_t p_val) const;
- void rotate(const Vector3& p_axis,float p_phi);
- Vector3 rotated(const Vector3& p_axis,float p_phi) const;
+ void rotate(const Vector3& p_axis,real_t p_phi);
+ Vector3 rotated(const Vector3& p_axis,real_t p_phi) const;
/* Static Methods between 2 vector3s */
- _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,float p_t) const;
- Vector3 cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const;
- Vector3 cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const;
+ _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,real_t p_t) const;
+ Vector3 cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const;
+ Vector3 cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const;
_FORCE_INLINE_ Vector3 cross(const Vector3& p_b) const;
_FORCE_INLINE_ real_t dot(const Vector3& p_b) const;
@@ -195,7 +195,7 @@ Vector3 Vector3::ceil() const {
return Vector3( Math::ceil(x), Math::ceil(y), Math::ceil(z) );
}
-Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const {
+Vector3 Vector3::linear_interpolate(const Vector3& p_b,real_t p_t) const {
return Vector3(
x+(p_t * (p_b.x-x)),
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index fe46e1671c..50b52e4970 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -27,8 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "message_queue.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "script_language.h"
+
MessageQueue *MessageQueue::singleton=NULL;
MessageQueue *MessageQueue::get_singleton() {
diff --git a/core/method_bind.cpp b/core/method_bind.cpp
index f323f3bc24..3465edff63 100644
--- a/core/method_bind.cpp
+++ b/core/method_bind.cpp
@@ -26,7 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+// object.h needs to be the first include *before* method_bind.h
+// FIXME: Find out why and fix potential cyclical dependencies.
#include "object.h"
+
#include "method_bind.h"
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 36b42c84f3..a35e44b66c 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -74,7 +74,7 @@ MAKE_PTRARG(Vector3);
MAKE_PTRARG(Transform2D);
MAKE_PTRARG(Plane);
MAKE_PTRARG(Quat);
-MAKE_PTRARG(AABB);
+MAKE_PTRARG(Rect3);
MAKE_PTRARG(Basis);
MAKE_PTRARG(Transform);
MAKE_PTRARG(Color);
@@ -84,13 +84,13 @@ MAKE_PTRARG(RID);
MAKE_PTRARG(InputEvent);
MAKE_PTRARG(Dictionary);
MAKE_PTRARG(Array);
-MAKE_PTRARG(ByteArray);
-MAKE_PTRARG(IntArray);
-MAKE_PTRARG(RealArray);
-MAKE_PTRARG(StringArray);
-MAKE_PTRARG(Vector2Array);
-MAKE_PTRARG(Vector3Array);
-MAKE_PTRARG(ColorArray);
+MAKE_PTRARG(PoolByteArray);
+MAKE_PTRARG(PoolIntArray);
+MAKE_PTRARG(PoolRealArray);
+MAKE_PTRARG(PoolStringArray);
+MAKE_PTRARG(PoolVector2Array);
+MAKE_PTRARG(PoolVector3Array);
+MAKE_PTRARG(PoolColorArray);
MAKE_PTRARG(Variant);
diff --git a/core/object.cpp b/core/object.cpp
index 3bb917bd38..79905a6be6 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -27,8 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "object.h"
+
#include "print_string.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "script_language.h"
#include "message_queue.h"
#include "core_string_names.h"
@@ -369,8 +370,10 @@ void Object::set(const String& p_name, const Variant& p_value) {
_setv(p_name,p_value);
- //if (!_use_builtin_script())
-// return;
+ /*
+ if (!_use_builtin_script())
+ return;
+ */
bool success;
ClassDB::set_property(this,p_name,p_value,success);
@@ -380,7 +383,7 @@ void Object::set(const String& p_name, const Variant& p_value) {
if (p_name=="__meta__") {
metadata=p_value;
- } else if (p_name=="script/script") {
+ } else if (p_name=="script") {
set_script(p_value);
} else if (script_instance) {
script_instance->set(p_name,p_value);
@@ -410,8 +413,10 @@ void Object::set(const StringName& p_name, const Variant& p_value, bool *r_valid
//try built-in setgetter
{
if (ClassDB::set_property(this,p_name,p_value,r_valid)) {
- //if (r_valid)
- // *r_valid=true;
+ /*
+ if (r_valid)
+ *r_valid=true;
+ */
return;
}
}
@@ -511,7 +516,7 @@ Variant Object::get(const String& p_name) const {
if (p_name=="__meta__")
return metadata;
- else if (p_name=="script/script")
+ else if (p_name=="script")
return script;
if (script_instance) {
@@ -534,7 +539,7 @@ void Object::get_property_list(List<PropertyInfo> *p_list,bool p_reversed) const
if (!is_class("Script")) // can still be set, but this is for userfriendlyness
- p_list->push_back( PropertyInfo( Variant::OBJECT, "script/script", PROPERTY_HINT_RESOURCE_TYPE, "Script",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NONZERO));
+ p_list->push_back( PropertyInfo( Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NONZERO));
if (!metadata.empty())
p_list->push_back( PropertyInfo( Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_STORE_IF_NONZERO));
if (script_instance && !p_reversed) {
@@ -1036,7 +1041,7 @@ void Object::set_script(const RefPtr& p_script) {
}
- _change_notify("script/script");
+ _change_notify("script");
emit_signal(CoreStringNames::get_singleton()->script_changed);
}
@@ -1670,31 +1675,31 @@ void Object::clear_internal_resource_paths() {
void Object::_bind_methods() {
- ClassDB::bind_method(_MD("get_class"),&Object::get_class);
- ClassDB::bind_method(_MD("is_class","type"),&Object::is_class);
- ClassDB::bind_method(_MD("set","property","value"),&Object::_set_bind);
- ClassDB::bind_method(_MD("get","property"),&Object::_get_bind);
- ClassDB::bind_method(_MD("get_property_list"),&Object::_get_property_list_bind);
- ClassDB::bind_method(_MD("get_method_list"),&Object::_get_method_list_bind);
- ClassDB::bind_method(_MD("notification","what","reversed"),&Object::notification,DEFVAL(false));
- ClassDB::bind_method(_MD("get_instance_ID"),&Object::get_instance_ID);
+ ClassDB::bind_method(D_METHOD("get_class"),&Object::get_class);
+ ClassDB::bind_method(D_METHOD("is_class","type"),&Object::is_class);
+ ClassDB::bind_method(D_METHOD("set","property","value"),&Object::_set_bind);
+ ClassDB::bind_method(D_METHOD("get","property"),&Object::_get_bind);
+ ClassDB::bind_method(D_METHOD("get_property_list"),&Object::_get_property_list_bind);
+ ClassDB::bind_method(D_METHOD("get_method_list"),&Object::_get_method_list_bind);
+ ClassDB::bind_method(D_METHOD("notification","what","reversed"),&Object::notification,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_instance_ID"),&Object::get_instance_ID);
- ClassDB::bind_method(_MD("set_script","script:Script"),&Object::set_script);
- ClassDB::bind_method(_MD("get_script:Script"),&Object::get_script);
+ ClassDB::bind_method(D_METHOD("set_script","script:Script"),&Object::set_script);
+ ClassDB::bind_method(D_METHOD("get_script:Script"),&Object::get_script);
- ClassDB::bind_method(_MD("set_meta","name","value"),&Object::set_meta);
- ClassDB::bind_method(_MD("get_meta","name","value"),&Object::get_meta);
- ClassDB::bind_method(_MD("has_meta","name"),&Object::has_meta);
- ClassDB::bind_method(_MD("get_meta_list"),&Object::_get_meta_list_bind);
+ 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("has_meta","name"),&Object::has_meta);
+ ClassDB::bind_method(D_METHOD("get_meta_list"),&Object::_get_meta_list_bind);
//todo reimplement this per language so all 5 arguments can be called
-// ClassDB::bind_method(_MD("call","method","arg1","arg2","arg3","arg4"),&Object::_call_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
-// ClassDB::bind_method(_MD("call_deferred","method","arg1","arg2","arg3","arg4"),&Object::_call_deferred_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
+ //ClassDB::bind_method(D_METHOD("call","method","arg1","arg2","arg3","arg4"),&Object::_call_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
+ //ClassDB::bind_method(D_METHOD("call_deferred","method","arg1","arg2","arg3","arg4"),&Object::_call_deferred_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("add_user_signal","signal","arguments"),&Object::_add_user_signal,DEFVAL(Array()));
- ClassDB::bind_method(_MD("has_user_signal","signal"),&Object::_has_user_signal);
-// ClassDB::bind_method(_MD("emit_signal","signal","arguments"),&Object::_emit_signal,DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("add_user_signal","signal","arguments"),&Object::_add_user_signal,DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("has_user_signal","signal"),&Object::_has_user_signal);
+ //ClassDB::bind_method(D_METHOD("emit_signal","signal","arguments"),&Object::_emit_signal,DEFVAL(Array()));
{
@@ -1723,27 +1728,27 @@ void Object::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_deferred",&Object::_call_deferred_bind,mi);
}
- ClassDB::bind_method(_MD("callv:Variant","method","arg_array"),&Object::callv);
+ ClassDB::bind_method(D_METHOD("callv:Variant","method","arg_array"),&Object::callv);
- ClassDB::bind_method(_MD("has_method","method"),&Object::has_method);
+ ClassDB::bind_method(D_METHOD("has_method","method"),&Object::has_method);
- ClassDB::bind_method(_MD("get_signal_list"),&Object::_get_signal_list);
- ClassDB::bind_method(_MD("get_signal_connection_list","signal"),&Object::_get_signal_connection_list);
+ ClassDB::bind_method(D_METHOD("get_signal_list"),&Object::_get_signal_list);
+ ClassDB::bind_method(D_METHOD("get_signal_connection_list","signal"),&Object::_get_signal_connection_list);
- ClassDB::bind_method(_MD("connect","signal","target:Object","method","binds","flags"),&Object::connect,DEFVAL(Array()),DEFVAL(0));
- ClassDB::bind_method(_MD("disconnect","signal","target:Object","method"),&Object::disconnect);
- ClassDB::bind_method(_MD("is_connected","signal","target:Object","method"),&Object::is_connected);
+ ClassDB::bind_method(D_METHOD("connect","signal","target:Object","method","binds","flags"),&Object::connect,DEFVAL(Array()),DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("disconnect","signal","target:Object","method"),&Object::disconnect);
+ ClassDB::bind_method(D_METHOD("is_connected","signal","target:Object","method"),&Object::is_connected);
- ClassDB::bind_method(_MD("set_block_signals","enable"),&Object::set_block_signals);
- ClassDB::bind_method(_MD("is_blocking_signals"),&Object::is_blocking_signals);
- ClassDB::bind_method(_MD("set_message_translation","enable"),&Object::set_message_translation);
- ClassDB::bind_method(_MD("can_translate_messages"),&Object::can_translate_messages);
- ClassDB::bind_method(_MD("property_list_changed_notify"),&Object::property_list_changed_notify);
+ ClassDB::bind_method(D_METHOD("set_block_signals","enable"),&Object::set_block_signals);
+ ClassDB::bind_method(D_METHOD("is_blocking_signals"),&Object::is_blocking_signals);
+ ClassDB::bind_method(D_METHOD("set_message_translation","enable"),&Object::set_message_translation);
+ ClassDB::bind_method(D_METHOD("can_translate_messages"),&Object::can_translate_messages);
+ ClassDB::bind_method(D_METHOD("property_list_changed_notify"),&Object::property_list_changed_notify);
- ClassDB::bind_method(_MD("XL_MESSAGE","message"),&Object::XL_MESSAGE);
- ClassDB::bind_method(_MD("tr","message"),&Object::tr);
+ ClassDB::bind_method(D_METHOD("XL_MESSAGE","message"),&Object::XL_MESSAGE);
+ ClassDB::bind_method(D_METHOD("tr","message"),&Object::tr);
- ClassDB::bind_method(_MD("is_queued_for_deletion"),&Object::is_queued_for_deletion);
+ ClassDB::bind_method(D_METHOD("is_queued_for_deletion"),&Object::is_queued_for_deletion);
ClassDB::add_virtual_method("Object",MethodInfo("free"),false);
diff --git a/core/object.h b/core/object.h
index a54693eab6..3fe31bee6b 100644
--- a/core/object.h
+++ b/core/object.h
@@ -103,6 +103,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_SCRIPT_VARIABLE=8192,
PROPERTY_USAGE_STORE_IF_NULL=16384,
PROPERTY_USAGE_ANIMATE_AS_TRIGGER=32768,
+ PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED=65536,
PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED,
@@ -113,12 +114,12 @@ enum PropertyUsageFlags {
#define ADD_SIGNAL( m_signal ) ClassDB::add_signal( get_class_static(), m_signal )
-#define ADD_PROPERTY( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), m_property, m_setter, m_getter )
-#define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), m_property, m_setter, m_getter, m_index )
-#define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter )
-#define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter, m_index )
-#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter )
-#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter, m_index )
+#define ADD_PROPERTY( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter) )
+#define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter), m_index )
+#define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), _scs_create(m_setter), _scs_create(m_getter) )
+#define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), _scs_create(m_setter), _scs_create(m_getter), m_index )
+#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), _scs_create(m_setter), _scs_create(m_getter) )
+#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ClassDB::add_property( get_class_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), _scs_create(m_setter), _scs_create(m_getter), m_index )
#define ADD_GROUP( m_name, m_prefix ) ClassDB::add_property_group( get_class_static(), m_name, m_prefix )
struct PropertyInfo {
@@ -579,8 +580,8 @@ public:
}
/* IAPI */
-// void set(const String& p_name, const Variant& p_value);
-// Variant get(const String& p_name) const;
+ //void set(const String& p_name, const Variant& p_value);
+ //Variant get(const String& p_name) const;
void set(const StringName& p_name, const Variant& p_value, bool *r_valid=NULL);
Variant get(const StringName& p_name, bool *r_valid=NULL) const;
@@ -679,7 +680,7 @@ class ObjectDB {
unsigned long i;
} u;
u.p=p_obj;
- return HashMapHahserDefault::hash((uint64_t)u.i);
+ return HashMapHasherDefault::hash((uint64_t)u.i);
}
};
@@ -721,6 +722,6 @@ public:
};
//needed by macros
-#include "object_type_db.h"
+#include "class_db.h"
#endif
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 804fe15c39..974225a3e8 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -30,7 +30,7 @@
#include "os/file_access.h"
#include "os/memory.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
String DirAccess::_get_root_path() const {
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index f824b5f319..7c173fc780 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -72,7 +72,7 @@ protected:
public:
- virtual bool list_dir_begin()=0; ///< This starts dir listing
+ virtual Error list_dir_begin()=0; ///< This starts dir listing
virtual String get_next(bool* p_is_dir); // compatibility
virtual String get_next()=0;
virtual bool current_is_dir() const=0;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 06723c5131..ae592720e8 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
#include "core/io/marshalls.h"
#include "io/md5.h"
diff --git a/core/os/input.cpp b/core/os/input.cpp
index d2bd433ed9..34883e63ba 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -29,7 +29,7 @@
#include "input.h"
#include "input_map.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
Input *Input::singleton=NULL;
Input *Input::get_singleton() {
@@ -38,7 +38,7 @@ Input *Input::get_singleton() {
}
void Input::set_mouse_mode(MouseMode p_mode) {
- ERR_FAIL_INDEX(p_mode,3);
+ ERR_FAIL_INDEX(p_mode,4);
OS::get_singleton()->set_mouse_mode((OS::MouseMode)p_mode);
}
@@ -49,43 +49,45 @@ Input::MouseMode Input::get_mouse_mode() const {
void Input::_bind_methods() {
- ClassDB::bind_method(_MD("is_key_pressed","scancode"),&Input::is_key_pressed);
- ClassDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed);
- ClassDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
- ClassDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed);
- ClassDB::bind_method(_MD("is_action_just_pressed","action"),&Input::is_action_just_pressed);
- ClassDB::bind_method(_MD("is_action_just_released","action"),&Input::is_action_just_released);
- ClassDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false));
- ClassDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping);
- ClassDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known);
- ClassDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis);
- ClassDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name);
- ClassDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid);
- ClassDB::bind_method(_MD("get_connected_joypads"),&Input::get_connected_joypads);
- ClassDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
- ClassDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
- ClassDB::bind_method(_MD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
- ClassDB::bind_method(_MD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
- ClassDB::bind_method(_MD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
- ClassDB::bind_method(_MD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
- ClassDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
- ClassDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
- ClassDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
- ClassDB::bind_method(_MD("get_magnetometer"),&Input::get_magnetometer);
- ClassDB::bind_method(_MD("get_gyroscope"),&Input::get_gyroscope);
- //ClassDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want
- ClassDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed);
- ClassDB::bind_method(_MD("get_mouse_button_mask"),&Input::get_mouse_button_mask);
- ClassDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode);
- ClassDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode);
- ClassDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos);
- ClassDB::bind_method(_MD("action_press","action"),&Input::action_press);
- ClassDB::bind_method(_MD("action_release","action"),&Input::action_release);
- ClassDB::bind_method(_MD("set_custom_mouse_cursor","image:Texture","hotspot"),&Input::set_custom_mouse_cursor,DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("is_key_pressed","scancode"),&Input::is_key_pressed);
+ ClassDB::bind_method(D_METHOD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed);
+ ClassDB::bind_method(D_METHOD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_pressed","action"),&Input::is_action_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_just_pressed","action"),&Input::is_action_just_pressed);
+ ClassDB::bind_method(D_METHOD("is_action_just_released","action"),&Input::is_action_just_released);
+ ClassDB::bind_method(D_METHOD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("remove_joy_mapping","guid"),&Input::remove_joy_mapping);
+ ClassDB::bind_method(D_METHOD("is_joy_known","device"),&Input::is_joy_known);
+ ClassDB::bind_method(D_METHOD("get_joy_axis","device","axis"),&Input::get_joy_axis);
+ ClassDB::bind_method(D_METHOD("get_joy_name","device"),&Input::get_joy_name);
+ ClassDB::bind_method(D_METHOD("get_joy_guid","device"),&Input::get_joy_guid);
+ ClassDB::bind_method(D_METHOD("get_connected_joypads"),&Input::get_connected_joypads);
+ ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
+ ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
+ ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
+ ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
+ ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
+ ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
+ ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
+ ClassDB::bind_method(D_METHOD("get_gravity"),&Input::get_gravity);
+ ClassDB::bind_method(D_METHOD("get_accelerometer"),&Input::get_accelerometer);
+ ClassDB::bind_method(D_METHOD("get_magnetometer"),&Input::get_magnetometer);
+ ClassDB::bind_method(D_METHOD("get_gyroscope"),&Input::get_gyroscope);
+ //ClassDB::bind_method(D_METHOD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want
+ ClassDB::bind_method(D_METHOD("get_last_mouse_speed"),&Input::get_last_mouse_speed);
+ ClassDB::bind_method(D_METHOD("get_mouse_button_mask"),&Input::get_mouse_button_mask);
+ ClassDB::bind_method(D_METHOD("set_mouse_mode","mode"),&Input::set_mouse_mode);
+ ClassDB::bind_method(D_METHOD("get_mouse_mode"),&Input::get_mouse_mode);
+ ClassDB::bind_method(D_METHOD("warp_mouse_pos","to"),&Input::warp_mouse_pos);
+ 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()));
BIND_CONSTANT( MOUSE_MODE_VISIBLE );
BIND_CONSTANT( MOUSE_MODE_HIDDEN );
BIND_CONSTANT( MOUSE_MODE_CAPTURED );
+ BIND_CONSTANT( MOUSE_MODE_CONFINED );
ADD_SIGNAL( MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "connected")) );
}
diff --git a/core/os/input.h b/core/os/input.h
index c365894f46..2cea154a50 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -47,7 +47,8 @@ public:
enum MouseMode {
MOUSE_MODE_VISIBLE,
MOUSE_MODE_HIDDEN,
- MOUSE_MODE_CAPTURED
+ MOUSE_MODE_CAPTURED,
+ MOUSE_MODE_CONFINED
};
void set_mouse_mode(MouseMode p_mode);
@@ -77,11 +78,12 @@ public:
virtual void stop_joy_vibration(int p_device)=0;
virtual Point2 get_mouse_pos() const=0;
- virtual Point2 get_mouse_speed() const=0;
+ virtual Point2 get_last_mouse_speed() const=0;
virtual int get_mouse_button_mask() const=0;
virtual void warp_mouse_pos(const Vector2& p_to)=0;
+ virtual Vector3 get_gravity() const=0;
virtual Vector3 get_accelerometer() const=0;
virtual Vector3 get_magnetometer() const=0;
virtual Vector3 get_gyroscope() const=0;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 3cc595208f..4ef99558ad 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -39,6 +39,8 @@ bool InputEvent::operator==(const InputEvent &p_event) const {
}
switch(type) {
+ /** Current clang-format style doesn't play well with the aligned return values of that switch. */
+ /* clang-format off */
case NONE:
return true;
case KEY:
@@ -80,6 +82,7 @@ bool InputEvent::operator==(const InputEvent &p_event) const {
case ACTION:
return action.action == p_event.action.action
&& action.pressed == p_event.action.pressed;
+ /* clang-format on */
default:
ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen.");
}
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 309348ea31..40fa86d09f 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -36,6 +36,7 @@ struct _KeyCodeText {
static const _KeyCodeText _keycodes[]={
+ /* clang-format off */
{KEY_ESCAPE ,"Escape"},
{KEY_TAB ,"Tab"},
{KEY_BACKTAB ,"BackTab"},
@@ -281,7 +282,8 @@ static const _KeyCodeText _keycodes[]={
{KEY_DIVISION ,"Division"},
{KEY_YDIAERESIS ,"Ydiaeresis"},
- {0 ,0}
+ {0 ,0}
+ /* clang-format on */
};
bool keycode_has_unicode(uint32_t p_keycode) {
@@ -299,7 +301,8 @@ bool keycode_has_unicode(uint32_t p_keycode) {
case KEY_MEDIAPREVIOUS: case KEY_MEDIANEXT: case KEY_MEDIARECORD: case KEY_HOMEPAGE: case KEY_FAVORITES: case KEY_SEARCH: case KEY_STANDBY:
case KEY_OPENURL: case KEY_LAUNCHMAIL: case KEY_LAUNCHMEDIA: case KEY_LAUNCH0: case KEY_LAUNCH1: case KEY_LAUNCH2: case KEY_LAUNCH3: case KEY_LAUNCH4:
case KEY_LAUNCH5: case KEY_LAUNCH6: case KEY_LAUNCH7: case KEY_LAUNCH8: case KEY_LAUNCH9: case KEY_LAUNCHA: case KEY_LAUNCHB: case KEY_LAUNCHC: case KEY_LAUNCHD:
- case KEY_LAUNCHE: case KEY_LAUNCHF: return false;
+ case KEY_LAUNCHE: case KEY_LAUNCHF:
+ return false;
}
return true;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 11396666d2..dcda8e8952 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -31,12 +31,12 @@
void MainLoop::_bind_methods() {
- ClassDB::bind_method(_MD("input_event","ev"),&MainLoop::input_event);
- ClassDB::bind_method(_MD("input_text","text"),&MainLoop::input_text);
- ClassDB::bind_method(_MD("init"),&MainLoop::init);
- ClassDB::bind_method(_MD("iteration","delta"),&MainLoop::iteration);
- ClassDB::bind_method(_MD("idle","delta"),&MainLoop::idle);
- ClassDB::bind_method(_MD("finish"),&MainLoop::finish);
+ ClassDB::bind_method(D_METHOD("input_event","ev"),&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);
+ ClassDB::bind_method(D_METHOD("idle","delta"),&MainLoop::idle);
+ ClassDB::bind_method(D_METHOD("finish"),&MainLoop::finish);
BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
BIND_VMETHOD( MethodInfo("_input_text",PropertyInfo(Variant::STRING,"text")) );
diff --git a/core/os/memory.h b/core/os/memory.h
index 0e6dea48d3..49424037ff 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -97,8 +97,8 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
#define memnew(m_class) _post_initialize(new("") m_class)
_ALWAYS_INLINE_ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_description) {
-// void *failptr=0;
-// ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */
+ //void *failptr=0;
+ //ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */
return p_pointer;
}
diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp
index f5f7f757c3..acdcb492d9 100644
--- a/core/os/mutex.cpp
+++ b/core/os/mutex.cpp
@@ -47,7 +47,7 @@ Mutex::~Mutex() {
}
-Mutex *_global_mutex=NULL;;
+Mutex *_global_mutex=NULL;
void _global_lock() {
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 677bf63e69..912f7f0b0f 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -27,13 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os.h"
-#include "os/file_access.h"
-#include <stdarg.h>
+
#include "dir_access.h"
-#include "globals.h"
+#include "global_config.h"
#include "input.h"
-// For get_engine_version, could be removed if it's moved to a new Engine singleton
-#include "version.h"
+#include "os/file_access.h"
+
+#include <stdarg.h>
OS* OS::singleton=NULL;
@@ -98,23 +98,6 @@ void OS::printerr(const char* p_format, ...) {
};
-void OS::set_iterations_per_second(int p_ips) {
-
- ips=p_ips;
-}
-int OS::get_iterations_per_second() const {
-
- return ips;
-}
-
-void OS::set_target_fps(int p_fps) {
- _target_fps=p_fps>0? p_fps : 0;
-}
-
-float OS::get_target_fps() const {
- return _target_fps;
-}
-
void OS::set_keep_screen_on(bool p_enabled) {
_keep_screen_on=p_enabled;
}
@@ -152,10 +135,6 @@ int OS::get_process_ID() const {
return -1;
};
-uint64_t OS::get_frames_drawn() {
-
- return frames_drawn;
-}
bool OS::is_stdout_verbose() const {
@@ -187,7 +166,7 @@ const char *OS::get_last_error() const {
void OS::dump_memory_to_file(const char* p_file) {
-// Memory::dump_static_mem_to_file(p_file);
+ //Memory::dump_static_mem_to_file(p_file);
}
static FileAccess *_OSPRF=NULL;
@@ -261,15 +240,7 @@ void OS::clear_last_error() {
memfree(last_error);
last_error=NULL;
}
-void OS::set_frame_delay(uint32_t p_msec) {
- _frame_delay=p_msec;
-}
-
-uint32_t OS::get_frame_delay() const {
-
- return _frame_delay;
-}
void OS::set_no_window_mode(bool p_enable) {
@@ -513,20 +484,13 @@ OS::MouseMode OS::get_mouse_mode() const{
return MOUSE_MODE_VISIBLE;
}
-void OS::set_time_scale(float p_scale) {
-
- _time_scale=p_scale;
-}
OS::LatinKeyboardVariant OS::get_latin_keyboard_variant() const {
return LATIN_KEYBOARD_QWERTY;
}
-float OS::get_time_scale() const {
- return _time_scale;
-}
bool OS::is_joy_known(int p_device) {
return true;
@@ -548,49 +512,21 @@ bool OS::is_vsync_enabled() const{
return true;
}
-Dictionary OS::get_engine_version() const {
-
- Dictionary dict;
- dict["major"] = _MKSTR(VERSION_MAJOR);
- dict["minor"] = _MKSTR(VERSION_MINOR);
-#ifdef VERSION_PATCH
- dict["patch"] = _MKSTR(VERSION_PATCH);
-#else
- dict["patch"] = "";
-#endif
- dict["status"] = _MKSTR(VERSION_STATUS);
- dict["revision"] = _MKSTR(VERSION_REVISION);
-
- String stringver = String(dict["major"]) + "." + String(dict["minor"]);
- if (dict["patch"] != "")
- stringver += "." + String(dict["patch"]);
- stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
- dict["string"] = stringver;
-
- return dict;
-}
OS::OS() {
last_error=NULL;
- frames_drawn=0;
singleton=this;
- ips=60;
_keep_screen_on=true; // set default value to true, because this had been true before godot 2.0.
low_processor_usage_mode=false;
_verbose_stdout=false;
- _frame_delay=0;
_no_window=false;
_exit_code=0;
_orientation=SCREEN_LANDSCAPE;
- _fps=1;
- _target_fps=0;
+
_render_thread_mode=RENDER_THREAD_SAFE;
- _time_scale=1.0;
- _pixel_snap=false;
+
+
_allow_hidpi=true;
- _fixed_frames=0;
- _idle_frames=0;
- _in_fixed=false;
Math::seed(1234567);
}
diff --git a/core/os/os.h b/core/os/os.h
index 5ea3216f24..e179b82dae 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -32,6 +32,7 @@
#include "ustring.h"
#include "list.h"
#include "vector.h"
+#include "engine.h"
#include "os/main_loop.h"
#include <stdarg.h>
@@ -43,28 +44,17 @@ class OS {
static OS* singleton;
String _execpath;
- String _custom_level;
List<String> _cmdline;
- int ips;
bool _keep_screen_on;
bool low_processor_usage_mode;
bool _verbose_stdout;
String _local_clipboard;
- uint64_t frames_drawn;
- uint32_t _frame_delay;
uint64_t _msec_splash;
bool _no_window;
int _exit_code;
int _orientation;
- float _fps;
- int _target_fps;
- float _time_scale;
- bool _pixel_snap;
bool _allow_hidpi;
- uint64_t _fixed_frames;
- uint64_t _idle_frames;
- bool _in_fixed;
char *last_error;
@@ -141,7 +131,8 @@ public:
enum MouseMode {
MOUSE_MODE_VISIBLE,
MOUSE_MODE_HIDDEN,
- MOUSE_MODE_CAPTURED
+ MOUSE_MODE_CAPTURED,
+ MOUSE_MODE_CONFINED
};
virtual void set_mouse_mode(MouseMode p_mode);
@@ -185,15 +176,6 @@ public:
virtual bool get_borderless_window() { return 0; }
-
- virtual void set_iterations_per_second(int p_ips);
- virtual int get_iterations_per_second() const;
-
- virtual void set_target_fps(int p_fps);
- virtual float get_target_fps() const;
-
- virtual float get_frames_per_second() const { return _fps; }
-
virtual void set_keep_screen_on(bool p_enabled);
virtual bool is_keep_screen_on() const;
virtual void set_low_processor_usage_mode(bool p_enabled);
@@ -217,7 +199,6 @@ public:
virtual MainLoop *get_main_loop() const=0;
- String get_custom_level() const { return _custom_level; }
virtual void yield();
@@ -280,17 +261,9 @@ public:
uint32_t get_ticks_msec() const;
uint64_t get_splash_tick_msec() const;
- void set_frame_delay(uint32_t p_msec);
- uint32_t get_frame_delay() const;
virtual bool can_draw() const = 0;
- uint64_t get_frames_drawn();
-
- 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; }
-
bool is_stdout_verbose() const;
enum CursorShape {
@@ -416,10 +389,6 @@ public:
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
- void set_time_scale(float p_scale);
- float get_time_scale() const;
-
- _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
virtual bool is_joy_known(int p_device);
virtual String get_joy_guid(int p_device)const;
@@ -434,7 +403,7 @@ public:
virtual void set_use_vsync(bool p_enable);
virtual bool is_vsync_enabled() const;
- Dictionary get_engine_version() const;
+ virtual bool check_feature_support(const String& p_feature)=0;
bool is_hidpi_allowed() const { return _allow_hidpi; }
OS();
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 5f3b877822..803a217fca 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -27,11 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "packed_data_container.h"
+
#include "io/marshalls.h"
#include "core_string_names.h"
-
Variant PackedDataContainer::getvar(const Variant& p_key, bool *r_valid) const {
bool err=false;
@@ -382,15 +382,15 @@ Variant PackedDataContainer::_iter_get(const Variant& p_iter){
void PackedDataContainer::_bind_methods() {
- ClassDB::bind_method(_MD("_set_data"),&PackedDataContainer::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&PackedDataContainer::_get_data);
- ClassDB::bind_method(_MD("_iter_init"),&PackedDataContainer::_iter_init);
- ClassDB::bind_method(_MD("_iter_get"),&PackedDataContainer::_iter_get);
- ClassDB::bind_method(_MD("_iter_next"),&PackedDataContainer::_iter_next);
- ClassDB::bind_method(_MD("pack:Error","value"),&PackedDataContainer::pack);
- ClassDB::bind_method(_MD("size"),&PackedDataContainer::size);
+ ClassDB::bind_method(D_METHOD("_set_data"),&PackedDataContainer::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&PackedDataContainer::_get_data);
+ ClassDB::bind_method(D_METHOD("_iter_init"),&PackedDataContainer::_iter_init);
+ ClassDB::bind_method(D_METHOD("_iter_get"),&PackedDataContainer::_iter_get);
+ ClassDB::bind_method(D_METHOD("_iter_next"),&PackedDataContainer::_iter_next);
+ ClassDB::bind_method(D_METHOD("pack:Error","value"),&PackedDataContainer::pack);
+ ClassDB::bind_method(D_METHOD("size"),&PackedDataContainer::size);
- ADD_PROPERTY( PropertyInfo(Variant::POOL_BYTE_ARRAY,"__data__"),_SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_BYTE_ARRAY,"__data__"),"_set_data","_get_data");
}
@@ -426,11 +426,11 @@ bool PackedDataContainerRef::_is_dictionary() const {
void PackedDataContainerRef::_bind_methods() {
- ClassDB::bind_method(_MD("size"),&PackedDataContainerRef::size);
- ClassDB::bind_method(_MD("_iter_init"),&PackedDataContainerRef::_iter_init);
- ClassDB::bind_method(_MD("_iter_get"),&PackedDataContainerRef::_iter_get);
- ClassDB::bind_method(_MD("_iter_next"),&PackedDataContainerRef::_iter_next);
- ClassDB::bind_method(_MD("_is_dictionary"),&PackedDataContainerRef::_is_dictionary);
+ ClassDB::bind_method(D_METHOD("size"),&PackedDataContainerRef::size);
+ ClassDB::bind_method(D_METHOD("_iter_init"),&PackedDataContainerRef::_iter_init);
+ ClassDB::bind_method(D_METHOD("_iter_get"),&PackedDataContainerRef::_iter_get);
+ ClassDB::bind_method(D_METHOD("_iter_next"),&PackedDataContainerRef::_iter_next);
+ ClassDB::bind_method(D_METHOD("_is_dictionary"),&PackedDataContainerRef::_is_dictionary);
}
diff --git a/core/pair.h b/core/pair.h
index d75cbed642..174ffb3883 100644
--- a/core/pair.h
+++ b/core/pair.h
@@ -39,4 +39,13 @@ struct Pair {
Pair( F p_first, S p_second) { first=p_first; second=p_second; }
};
+template<class F,class S>
+struct PairSort {
+
+ bool operator()(const Pair<F,S>& A, const Pair<F,S>& B) const {
+ return A.first < B.first;
+ }
+};
+
+
#endif // PAIR_H
diff --git a/core/path_db.cpp b/core/path_db.cpp
index 25f62ed951..679372898c 100644
--- a/core/path_db.cpp
+++ b/core/path_db.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path_db.h"
-#include "print_string.h"
+#include "print_string.h"
uint32_t NodePath::hash() const {
@@ -334,7 +334,7 @@ NodePath::NodePath(const String& p_path) {
StringName property;
Vector<StringName> subpath;
- int absolute=(path[0]=='/')?1:0;;
+ int absolute=(path[0]=='/')?1:0;
bool last_is_slash=true;
int slices=0;
int subpath_pos=path.find(":");
diff --git a/core/path_remap.cpp b/core/path_remap.cpp
index fd5b38fa79..bbaba71bba 100644
--- a/core/path_remap.cpp
+++ b/core/path_remap.cpp
@@ -27,177 +27,4 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path_remap.h"
-#include "globals.h"
-#include "os/os.h"
-#include "translation.h"
-PathRemap* PathRemap::singleton=NULL;
-PathRemap* PathRemap::get_singleton() {
-
- return singleton;
-}
-
-void PathRemap::add_remap(const String& p_from, const String& p_to,const String& p_locale) {
-
- if (!remap.has(p_from)) {
- remap[p_from]=RemapData();
- }
-
- if (p_locale==String())
- remap[p_from].always=p_to;
- else
- remap[p_from].locale[p_locale]=p_to;
-}
-
-
-String PathRemap::get_remap(const String& p_from) const {
-
- const RemapData *ptr=remap.getptr(p_from);
- if (!ptr) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_line("remap failed: "+p_from);
- return p_from;
- } else {
-
- const RemapData *ptr2=NULL;
-
- String locale = TranslationServer::get_singleton()->get_locale();
-
- if (ptr->locale.has(locale)) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
-
- ptr2=remap.getptr(ptr->locale[locale]);
-
- if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
- return ptr2->always;
- else
- return ptr->locale[locale];
- }
-
- int p = locale.find("_");
- if (p!=-1) {
- locale=locale.substr(0,p);
- if (ptr->locale.has(locale)) {
- if (OS::get_singleton()->is_stdout_verbose())
- print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
-
- ptr2=remap.getptr(ptr->locale[locale]);
-
- if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
- return ptr2->always;
- else
- return ptr->locale[locale];
-
- }
- }
-
- if (ptr->always!=String()) {
- if (OS::get_singleton()->is_stdout_verbose()) {
- print_line("remap found: "+p_from+" -> "+ptr->always);
- }
- return ptr->always;
- }
-
- if (OS::get_singleton()->is_stdout_verbose())
- print_line("remap failed: "+p_from);
-
- return p_from;
- }
-}
-bool PathRemap::has_remap(const String& p_from) const{
-
- return remap.has(p_from);
-}
-
-void PathRemap::erase_remap(const String& p_from){
-
- ERR_FAIL_COND(!remap.has(p_from));
- remap.erase(p_from);
-}
-
-void PathRemap::clear_remaps() {
-
- remap.clear();
-}
-
-void PathRemap::load_remaps() {
-
- // default remaps first
- PoolVector<String> remaps = GlobalConfig::get_singleton()->get("remap/all");
-
- {
- int rlen = remaps.size();
-
- ERR_FAIL_COND( rlen%2 );
- PoolVector<String>::Read r = remaps.read();
- for(int i=0;i<rlen/2;i++) {
-
- String from = r[i*2+0];
- String to = r[i*2+1];
- add_remap(from,to);
- }
- }
-
-
- // platform remaps second, so override
- remaps = GlobalConfig::get_singleton()->get("remap/"+OS::get_singleton()->get_name());
-// remaps = Globals::get_singleton()->get("remap/PSP");
- {
- int rlen = remaps.size();
-
- ERR_FAIL_COND( rlen%2 );
- PoolVector<String>::Read r = remaps.read();
- for(int i=0;i<rlen/2;i++) {
-
- String from = r[i*2+0];
- String to = r[i*2+1];
-// print_line("add remap: "+from+" -> "+to);
- add_remap(from,to);
- }
- }
-
-
- //locale based remaps
-
- if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) {
-
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
- List<Variant> rk;
- remaps.get_key_list(&rk);
- for(List<Variant>::Element *E=rk.front();E;E=E->next()) {
-
- String source = E->get();
- PoolStringArray sa = remaps[E->get()];
- int sas = sa.size();
- PoolStringArray::Read r = sa.read();
-
- for(int i=0;i<sas;i++) {
-
- String s = r[i];
- int qp = s.find_last(":");
- if (qp!=-1) {
- String path = s.substr(0,qp);
- String locale = s.substr(qp+1,s.length());
- add_remap(source,path,locale);
- }
- }
- }
-
- }
-
-}
-
-void PathRemap::_bind_methods() {
-
- ClassDB::bind_method(_MD("add_remap","from","to","locale"),&PathRemap::add_remap,DEFVAL(String()));
- ClassDB::bind_method(_MD("has_remap","path"),&PathRemap::has_remap);
- ClassDB::bind_method(_MD("get_remap","path"),&PathRemap::get_remap);
- ClassDB::bind_method(_MD("erase_remap","path"),&PathRemap::erase_remap);
- ClassDB::bind_method(_MD("clear_remaps"),&PathRemap::clear_remaps);
-}
-
-PathRemap::PathRemap() {
-
- singleton=this;
-}
diff --git a/core/path_remap.h b/core/path_remap.h
index a106030f95..966bb10ea5 100644
--- a/core/path_remap.h
+++ b/core/path_remap.h
@@ -29,39 +29,4 @@
#ifndef PATH_REMAP_H
#define PATH_REMAP_H
-#include "hash_map.h"
-#include "ustring.h"
-#include "object.h"
-
-
-class PathRemap : public Object {
-
- GDCLASS(PathRemap,Object);
-
- static PathRemap* singleton;
- struct RemapData {
- String always;
- Map<String,String> locale;
- };
-
- HashMap<String,RemapData> remap;
-protected:
-
- static void _bind_methods();
-public:
-
- void add_remap(const String& p_from, const String& p_to,const String& p_locale=String());
- bool has_remap(const String& p_from) const;
- //_FORCE_INLINE_ String get_remap(const String& p_from) const { const String *ptr=remap.getptr(p_from); if (!ptr) return p_from; else return *ptr; }
- String get_remap(const String& p_from) const;
- void erase_remap(const String& p_from);
- void clear_remaps();
-
- void load_remaps();
-
- static PathRemap* get_singleton();
-
- PathRemap();
-};
-
#endif // PATH_REMAP_H
diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp
index e425218060..3260225ac3 100644
--- a/core/pool_allocator.cpp
+++ b/core/pool_allocator.cpp
@@ -27,12 +27,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "pool_allocator.h"
+
#include "error_macros.h"
#include "core/os/os.h"
#include "os/memory.h"
#include "os/copymem.h"
#include "print_string.h"
+
#include <assert.h>
+
#define COMPACT_CHUNK( m_entry , m_to_pos ) \
do { \
void *_dst=&((unsigned char*)pool)[m_to_pos]; \
@@ -501,7 +504,7 @@ const void *PoolAllocator::get(ID p_mem) const {
return NULL;
}
- if (e->pos<0 || (int)e->pos>=pool_size) {
+ if ((int)e->pos>=pool_size) {
mt_unlock();
ERR_PRINT("e->pos<0 || e->pos>=pool_size");
@@ -543,7 +546,7 @@ void *PoolAllocator::get(ID p_mem) {
return NULL;
}
- if (e->pos<0 || (int)e->pos>=pool_size) {
+ if ((int)e->pos>=pool_size) {
mt_unlock();
ERR_PRINT("e->pos<0 || e->pos>=pool_size");
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 3faed62bb4..36316af619 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -27,7 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "print_string.h"
+
#include "os/os.h"
+
#include <stdio.h>
static PrintHandlerList *print_handler_list=NULL;
diff --git a/core/profile_clock.cpp b/core/profile_clock.cpp
deleted file mode 100644
index 0806275463..0000000000
--- a/core/profile_clock.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "profile_clock.h"
-
-
diff --git a/core/profile_clock.h b/core/profile_clock.h
deleted file mode 100644
index e254580249..0000000000
--- a/core/profile_clock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef PROFILE_CLOCK_H
-#define PROFILE_CLOCK_H
-
-
-
-
-#endif // PROFILE_CLOCK_H
diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp
index e781bae496..29ffe974d2 100644
--- a/core/ref_ptr.cpp
+++ b/core/ref_ptr.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "ref_ptr.h"
+
#include "reference.h"
#include "resource.h"
diff --git a/core/reference.cpp b/core/reference.cpp
index 69e053cc1a..5e8244d2ca 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "reference.h"
+
#include "script_language.h"
@@ -54,9 +55,9 @@ bool Reference::init_ref() {
void Reference::_bind_methods() {
- ClassDB::bind_method(_MD("init_ref"),&Reference::init_ref);
- ClassDB::bind_method(_MD("reference"),&Reference::reference);
- ClassDB::bind_method(_MD("unreference"),&Reference::unreference);
+ ClassDB::bind_method(D_METHOD("init_ref"),&Reference::init_ref);
+ ClassDB::bind_method(D_METHOD("reference"),&Reference::reference);
+ ClassDB::bind_method(D_METHOD("unreference"),&Reference::unreference);
}
int Reference::reference_get_count() const {
@@ -126,7 +127,7 @@ WeakRef::WeakRef() {
void WeakRef::_bind_methods() {
- ClassDB::bind_method(_MD("get_ref:Object"),&WeakRef::get_ref);
+ ClassDB::bind_method(D_METHOD("get_ref:Object"),&WeakRef::get_ref);
}
#if 0
diff --git a/core/reference.h b/core/reference.h
index ce196801bb..e130b4c2b4 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -32,7 +32,7 @@
#include "object.h"
#include "safe_refcount.h"
#include "ref_ptr.h"
-#include "object_type_db.h"
+#include "class_db.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index fe88d1d13d..00f6f8662f 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -35,8 +35,8 @@
#include "io/packet_peer.h"
#include "math/a_star.h"
#include "math/triangle_mesh.h"
-#include "globals.h"
-#include "object_type_db.h"
+#include "global_config.h"
+#include "class_db.h"
#include "geometry.h"
#include "bind/core_bind.h"
#include "core_string_names.h"
@@ -45,6 +45,7 @@
#include "compressed_translation.h"
#include "io/translation_loader_po.h"
#include "io/resource_format_binary.h"
+#include "io/resource_import.h"
#include "io/stream_peer_ssl.h"
#include "os/input.h"
#include "core/io/xml_parser.h"
@@ -57,11 +58,12 @@
static ResourceFormatSaverBinary *resource_saver_binary=NULL;
static ResourceFormatLoaderBinary *resource_loader_binary=NULL;
-
+static ResourceFormatImporter *resource_format_importer=NULL;
static _ResourceLoader *_resource_loader=NULL;
static _ResourceSaver *_resource_saver=NULL;
static _OS *_os=NULL;
+static _Engine *_engine=NULL;
static _ClassDB *_classdb=NULL;
static _Marshalls *_marshalls = NULL;
static TranslationLoaderPO *resource_format_po=NULL;
@@ -104,12 +106,14 @@ void register_core_types() {
resource_loader_binary = memnew( ResourceFormatLoaderBinary );
ResourceLoader::add_resource_format_loader(resource_loader_binary);
+ resource_format_importer = memnew( ResourceFormatImporter );
+ ResourceLoader::add_resource_format_loader(resource_format_importer);
+
ClassDB::register_class<Object>();
ClassDB::register_class<Reference>();
ClassDB::register_class<WeakRef>();
- ClassDB::register_class<ResourceImportMetadata>();
ClassDB::register_class<Resource>();
ClassDB::register_class<FuncRef>();
ClassDB::register_virtual_class<StreamPeer>();
@@ -122,7 +126,7 @@ void register_core_types() {
ClassDB::register_virtual_class<PacketPeer>();
ClassDB::register_class<PacketPeerStream>();
ClassDB::register_class<MainLoop>();
-// ClassDB::register_type<OptimizedSaver>();
+ //ClassDB::register_type<OptimizedSaver>();
ClassDB::register_class<Translation>();
ClassDB::register_class<PHashTranslation>();
ClassDB::register_class<UndoRedo>();
@@ -156,6 +160,7 @@ void register_core_types() {
_resource_loader=memnew(_ResourceLoader);
_resource_saver=memnew(_ResourceSaver);
_os=memnew(_OS);
+ _engine=memnew(_Engine);
_classdb=memnew(_ClassDB);
_marshalls = memnew(_Marshalls);
@@ -177,12 +182,11 @@ void register_core_singletons() {
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("PathRemap",PathRemap::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("TS",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() ) );
@@ -196,6 +200,7 @@ void unregister_core_types() {
memdelete( _resource_loader );
memdelete( _resource_saver );
memdelete( _os);
+ memdelete( _engine );
memdelete( _classdb );
memdelete( _marshalls );
@@ -205,6 +210,8 @@ void unregister_core_types() {
memdelete(resource_saver_binary);
if (resource_loader_binary)
memdelete(resource_loader_binary);
+ if (resource_format_importer)
+ memdelete(resource_format_importer);
memdelete( resource_format_po );
diff --git a/core/resource.cpp b/core/resource.cpp
index db4d2ec0db..fe3cb2df92 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -27,124 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource.h"
+
#include "core_string_names.h"
-#include <stdio.h>
#include "os/file_access.h"
#include "io/resource_loader.h"
#include "script_language.h"
-void ResourceImportMetadata::set_editor(const String& p_editor) {
-
- editor=p_editor;
-}
-
-String ResourceImportMetadata::get_editor() const{
-
- return editor;
-}
-
-void ResourceImportMetadata::add_source(const String& p_path,const String& p_md5) {
-
- Source s;
- s.md5=p_md5;
- s.path=p_path;
- sources.push_back(s);
-}
-
-String ResourceImportMetadata::get_source_path(int p_idx) const{
- ERR_FAIL_INDEX_V(p_idx,sources.size(),String());
- return sources[p_idx].path;
-}
-String ResourceImportMetadata::get_source_md5(int p_idx) const{
- ERR_FAIL_INDEX_V(p_idx,sources.size(),String());
- return sources[p_idx].md5;
-}
-
-void ResourceImportMetadata::set_source_md5(int p_idx,const String& p_md5) {
-
- ERR_FAIL_INDEX(p_idx,sources.size());
- sources[p_idx].md5=p_md5;
-
-}
-
-void ResourceImportMetadata::remove_source(int p_idx){
-
- ERR_FAIL_INDEX(p_idx,sources.size());
- sources.remove(p_idx);
-
-}
-
-int ResourceImportMetadata::get_source_count() const {
-
- return sources.size();
-}
-void ResourceImportMetadata::set_option(const String& p_key, const Variant& p_value) {
-
- if (p_value.get_type()==Variant::NIL) {
- options.erase(p_key);
- return;
- }
-
- ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT);
- ERR_FAIL_COND(p_value.get_type() == Variant::_RID);
-
- options[p_key]=p_value;
-
-}
-
-bool ResourceImportMetadata::has_option(const String& p_key) const {
-
- return options.has(p_key);
-}
-
-Variant ResourceImportMetadata::get_option(const String& p_key) const {
-
- ERR_FAIL_COND_V(!options.has(p_key),Variant());
-
- return options[p_key];
-}
-
-void ResourceImportMetadata::get_options(List<String> *r_options) const {
-
- for(Map<String,Variant>::Element *E=options.front();E;E=E->next()) {
-
- r_options->push_back(E->key());
- }
-
-}
-
-PoolStringArray ResourceImportMetadata::_get_options() const {
-
- PoolStringArray option_names;
- option_names.resize(options.size());
- int i=0;
- for(Map<String,Variant>::Element *E=options.front();E;E=E->next()) {
-
- option_names.set(i++,E->key());
- }
-
- return option_names;
-}
-
-void ResourceImportMetadata::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_editor","name"),&ResourceImportMetadata::set_editor);
- ClassDB::bind_method(_MD("get_editor"),&ResourceImportMetadata::get_editor);
- ClassDB::bind_method(_MD("add_source","path","md5"),&ResourceImportMetadata::add_source, "");
- ClassDB::bind_method(_MD("get_source_path","idx"),&ResourceImportMetadata::get_source_path);
- ClassDB::bind_method(_MD("get_source_md5","idx"),&ResourceImportMetadata::get_source_md5);
- ClassDB::bind_method(_MD("set_source_md5","idx", "md5"),&ResourceImportMetadata::set_source_md5);
- ClassDB::bind_method(_MD("remove_source","idx"),&ResourceImportMetadata::remove_source);
- ClassDB::bind_method(_MD("get_source_count"),&ResourceImportMetadata::get_source_count);
- ClassDB::bind_method(_MD("set_option","key","value"),&ResourceImportMetadata::set_option);
- ClassDB::bind_method(_MD("get_option","key"),&ResourceImportMetadata::get_option);
- ClassDB::bind_method(_MD("get_options"),&ResourceImportMetadata::_get_options);
-}
-
-ResourceImportMetadata::ResourceImportMetadata() {
-
-
-}
+#include <stdio.h>
void Resource::emit_changed() {
@@ -198,7 +87,7 @@ void Resource::set_path(const String& p_path, bool p_take_over) {
if (path_cache!="") {
ResourceCache::lock->write_lock();
- ResourceCache::resources[path_cache]=this;;
+ ResourceCache::resources[path_cache]=this;
ResourceCache::lock->write_unlock();
}
@@ -379,21 +268,6 @@ void Resource::notify_change_to_owners() {
}
}
-void Resource::set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata) {
-#ifdef TOOLS_ENABLED
- import_metadata=p_metadata;
-#endif
-}
-
-Ref<ResourceImportMetadata> Resource::get_import_metadata() const {
-
-#ifdef TOOLS_ENABLED
- return import_metadata;
-#else
- return Ref<ResourceImportMetadata>();
-#endif
-
-}
#ifdef TOOLS_ENABLED
@@ -453,25 +327,23 @@ Node* (*Resource::_get_local_scene_func)()=NULL;
void Resource::_bind_methods() {
- ClassDB::bind_method(_MD("set_path","path"),&Resource::_set_path);
- ClassDB::bind_method(_MD("take_over_path","path"),&Resource::_take_over_path);
- ClassDB::bind_method(_MD("get_path"),&Resource::get_path);
- ClassDB::bind_method(_MD("set_name","name"),&Resource::set_name);
- ClassDB::bind_method(_MD("get_name"),&Resource::get_name);
- ClassDB::bind_method(_MD("get_rid"),&Resource::get_rid);
- ClassDB::bind_method(_MD("set_import_metadata","metadata"),&Resource::set_import_metadata);
- ClassDB::bind_method(_MD("get_import_metadata"),&Resource::get_import_metadata);
- ClassDB::bind_method(_MD("set_local_to_scene","enable"),&Resource::set_local_to_scene);
- ClassDB::bind_method(_MD("is_local_to_scene"),&Resource::is_local_to_scene);
- ClassDB::bind_method(_MD("get_local_scene:Node"),&Resource::get_local_scene);
- ClassDB::bind_method(_MD("setup_local_to_scene"),&Resource::setup_local_to_scene);
-
- ClassDB::bind_method(_MD("duplicate","subresources"),&Resource::duplicate,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_path","path"),&Resource::_set_path);
+ ClassDB::bind_method(D_METHOD("take_over_path","path"),&Resource::_take_over_path);
+ ClassDB::bind_method(D_METHOD("get_path"),&Resource::get_path);
+ ClassDB::bind_method(D_METHOD("set_name","name"),&Resource::set_name);
+ ClassDB::bind_method(D_METHOD("get_name"),&Resource::get_name);
+ ClassDB::bind_method(D_METHOD("get_rid"),&Resource::get_rid);
+ ClassDB::bind_method(D_METHOD("set_local_to_scene","enable"),&Resource::set_local_to_scene);
+ ClassDB::bind_method(D_METHOD("is_local_to_scene"),&Resource::is_local_to_scene);
+ 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));
ADD_SIGNAL( MethodInfo("changed") );
ADD_GROUP("Resource","resource_");
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"resource_local_to_scene" ), _SCS("set_local_to_scene"),_SCS("is_local_to_scene"));
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"resource_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ), _SCS("set_path"),_SCS("get_path"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"resource_name"), _SCS("set_name"),_SCS("get_name"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"resource_local_to_scene" ), "set_local_to_scene","is_local_to_scene");
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"resource_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ), "set_path","get_path");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"resource_name"), "set_name","get_name");
BIND_VMETHOD( MethodInfo("_setup_local_to_scene") );
@@ -481,9 +353,11 @@ Resource::Resource() {
#ifdef TOOLS_ENABLED
last_modified_time=0;
+ import_last_modified_time=0;
#endif
subindex=0;
+ local_to_scene=false;
local_scene=NULL;
}
@@ -522,18 +396,19 @@ void ResourceCache::clear() {
void ResourceCache::reload_externals() {
- //const String *K=NULL;
- //while ((K=resources.next(K))) {
-// resources[*K]->reload_external_data();
-// }
-
+ /*
+ const String *K=NULL;
+ while ((K=resources.next(K))) {
+ resources[*K]->reload_external_data();
+ }
+ */
}
bool ResourceCache::has(const String& p_path) {
- lock->read_lock();;
+ lock->read_lock();
bool b = resources.has(p_path);
- lock->read_unlock();;
+ lock->read_unlock();
return b;
diff --git a/core/resource.h b/core/resource.h
index 284c59e1a8..b29077a3b8 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -33,7 +33,7 @@
#include "safe_refcount.h"
#include "ref_ptr.h"
#include "reference.h"
-#include "object_type_db.h"
+#include "class_db.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -46,47 +46,6 @@ virtual String get_base_extension() const { return m_ext; }\
private:
-class ResourceImportMetadata : public Reference {
-
- GDCLASS( ResourceImportMetadata, Reference );
-
- struct Source {
- String path;
- String md5;
- };
-
- Vector<Source> sources;
- String editor;
-
- Map<String,Variant> options;
-
- PoolStringArray _get_options() const;
-
-protected:
-
- static void _bind_methods();
-public:
-
- void set_editor(const String& p_editor);
- String get_editor() const;
-
- void add_source(const String& p_path,const String& p_md5="");
- String get_source_path(int p_idx) const;
- String get_source_md5(int p_idx) const;
- void set_source_md5(int p_idx,const String& p_md5);
- void remove_source(int p_idx);
- int get_source_count() const;
-
- void set_option(const String& p_key, const Variant& p_value);
- Variant get_option(const String& p_key) const;
- bool has_option(const String& p_key) const;
-
- void get_options(List<String> *r_options) const;
-
-
- ResourceImportMetadata();
-};
-
class Resource : public Reference {
@@ -106,8 +65,9 @@ friend class ResourceCache;
virtual bool _use_builtin_script() const { return true; }
#ifdef TOOLS_ENABLED
- Ref<ResourceImportMetadata> import_metadata;
uint64_t last_modified_time;
+ uint64_t import_last_modified_time;
+ String import_path;
#endif
bool local_to_scene;
@@ -147,10 +107,6 @@ public:
Ref<Resource> duplicate(bool p_subresources=false);
Ref<Resource> duplicate_for_local_scene(Node *p_scene,Map<Ref<Resource>,Ref<Resource> >& remap_cache);
-
- void set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata);
- Ref<ResourceImportMetadata> get_import_metadata() const;
-
void set_local_to_scene(bool p_enable);
bool is_local_to_scene() const;
virtual void setup_local_to_scene();
@@ -164,6 +120,12 @@ public:
virtual void set_last_modified_time(uint64_t p_time) { last_modified_time=p_time; }
uint64_t get_last_modified_time() const { return last_modified_time; }
+ virtual void set_import_last_modified_time(uint64_t p_time) { import_last_modified_time=p_time; }
+ uint64_t get_import_last_modified_time() const { return import_last_modified_time; }
+
+ void set_import_path(const String& p_path) { import_path=p_path; }
+ String get_import_path() const { return import_path; }
+
#endif
virtual RID get_rid() const; // some resources may offer conversion to RID
diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp
index ede37bbe8a..50617f2062 100644
--- a/core/safe_refcount.cpp
+++ b/core/safe_refcount.cpp
@@ -44,6 +44,14 @@ uint32_t atomic_conditional_increment( register uint32_t * pw ) {
return *pw;
}
+uint32_t atomic_increment( register uint32_t * pw ) {
+
+ (*pw)++;
+
+ return *pw;
+
+}
+
uint32_t atomic_decrement( register uint32_t * pw ) {
(*pw)--;
diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp
index a8d77668f5..22aceac4c5 100644
--- a/core/script_debugger_local.cpp
+++ b/core/script_debugger_local.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_debugger_local.h"
+
#include "os/os.h"
void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) {
@@ -286,7 +287,7 @@ void ScriptDebuggerLocal::profiling_end() {
for(int i=0;i<ofs;i++) {
print_line(itos(i)+":"+pinfo[i].signature);
- float tt=USEC_TO_SEC(pinfo[i].total_time);;
+ float tt=USEC_TO_SEC(pinfo[i].total_time);
float st=USEC_TO_SEC(pinfo[i].self_time);
print_line("\ttotal_ms: "+rtos(tt)+"\tself_ms: "+rtos(st)+"total%: "+itos(tt*100/total_time)+"\tself%: "+itos(st*100/total_time)+"\tcalls: "+itos(pinfo[i].call_count));
}
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 62fcd5247f..b14eb51b6c 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -27,10 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_debugger_remote.h"
+
#include "os/os.h"
#include "io/ip.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/input.h"
+
void ScriptDebuggerRemote::_send_video_memory() {
List<ResourceUsage> usage;
@@ -66,7 +68,7 @@ Error ScriptDebuggerRemote::connect_to_host(const String& p_host,uint16_t p_port
int port = p_port;
int tries = 3;
- tcp_client->connect(ip, port);
+ tcp_client->connect_to_host(ip, port);
while (tries--) {
@@ -129,7 +131,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
//or when execution is paused from editor
- if (!tcp_client->is_connected()) {
+ if (!tcp_client->is_connected_to_host()) {
ERR_EXPLAIN("Script Debugger failed to connect, but being used anyway.");
ERR_FAIL();
}
@@ -446,7 +448,7 @@ void ScriptDebuggerRemote::_err_handler(void* ud,const char* p_func,const char*p
sdr->mutex->lock();
- if (!sdr->locking && sdr->tcp_client->is_connected()) {
+ if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) {
sdr->errors.push_back(oe);
}
@@ -778,7 +780,7 @@ void ScriptDebuggerRemote::_send_profiling_data(bool p_for_frame) {
}
- packet_peer_stream->put_var(OS::get_singleton()->get_frames_drawn()); //total frame time
+ packet_peer_stream->put_var(Engine::get_singleton()->get_frames_drawn()); //total frame time
packet_peer_stream->put_var(frame_time); //total frame time
packet_peer_stream->put_var(idle_time); //idle frame time
packet_peer_stream->put_var(fixed_time); //fixed frame time
@@ -887,7 +889,7 @@ void ScriptDebuggerRemote::idle_poll() {
void ScriptDebuggerRemote::send_message(const String& p_message, const Array &p_args) {
mutex->lock();
- if (!locking && tcp_client->is_connected()) {
+ if (!locking && tcp_client->is_connected_to_host()) {
Message msg;
msg.message=p_message;
@@ -928,7 +930,7 @@ void ScriptDebuggerRemote::_print_handler(void *p_this,const String& p_string) {
}
sdr->mutex->lock();
- if (!sdr->locking && sdr->tcp_client->is_connected()) {
+ if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) {
sdr->output_strings.push_back(s);
}
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 52ae181c32..32db35d018 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -46,13 +46,13 @@ void Script::_notification( int p_what) {
void Script::_bind_methods() {
- ClassDB::bind_method(_MD("can_instance"),&Script::can_instance);
- //ClassDB::bind_method(_MD("instance_create","base_object"),&Script::instance_create);
- ClassDB::bind_method(_MD("instance_has","base_object"),&Script::instance_has);
- ClassDB::bind_method(_MD("has_source_code"),&Script::has_source_code);
- ClassDB::bind_method(_MD("get_source_code"),&Script::get_source_code);
- ClassDB::bind_method(_MD("set_source_code","source"),&Script::set_source_code);
- ClassDB::bind_method(_MD("reload","keep_state"),&Script::reload,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("can_instance"),&Script::can_instance);
+ //ClassDB::bind_method(D_METHOD("instance_create","base_object"),&Script::instance_create);
+ ClassDB::bind_method(D_METHOD("instance_has","base_object"),&Script::instance_has);
+ ClassDB::bind_method(D_METHOD("has_source_code"),&Script::has_source_code);
+ ClassDB::bind_method(D_METHOD("get_source_code"),&Script::get_source_code);
+ ClassDB::bind_method(D_METHOD("set_source_code","source"),&Script::set_source_code);
+ ClassDB::bind_method(D_METHOD("reload","keep_state"),&Script::reload,DEFVAL(false));
}
diff --git a/core/set.h b/core/set.h
index 9da2887671..a921fc661f 100644
--- a/core/set.h
+++ b/core/set.h
@@ -141,7 +141,7 @@ private:
#ifdef GLOBALNIL_DISABLED
memdelete_allocator<Element,A>(_nil);
#endif
-// memdelete_allocator<Element,A>(_root);
+ //memdelete_allocator<Element,A>(_root);
}
};
@@ -307,7 +307,7 @@ private:
new_node->right=_data._nil;
new_node->left=_data._nil;
new_node->value=p_value;
-// new_node->data=_data;
+ //new_node->data=_data;
if (new_parent==_data._root || less(p_value,new_parent->value)) {
new_parent->left=new_node;
@@ -416,7 +416,7 @@ private:
Element *aux=node->parent->left;
if (aux->color==RED) {
_set_color(aux,BLACK);
- _set_color(node->parent,RED);;
+ _set_color(node->parent,RED);
_rotate_right(node->parent);
aux=node->parent->left;
}
diff --git a/core/string_db.cpp b/core/string_db.cpp
index be35a44ed1..004b07b9e5 100644
--- a/core/string_db.cpp
+++ b/core/string_db.cpp
@@ -27,8 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "string_db.h"
+
#include "print_string.h"
#include "os/os.h"
+
StaticCString StaticCString::create(const char *p_ptr) {
StaticCString scs; scs.ptr=p_ptr; return scs;
}
diff --git a/core/string_db.h b/core/string_db.h
index a14cdbc7ba..2c5262adaa 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -155,7 +155,4 @@ struct StringNameHasher {
StringName _scs_create(const char *p_chr);
-//#define _SCS(m_cstr) (m_cstr[0]?StringName(StaticCString::create(m_cstr)):StringName())
-#define _SCS(m_cstr) _scs_create(m_cstr)
-
#endif
diff --git a/core/translation.cpp b/core/translation.cpp
index 5215e5f6d1..d9d4fe7784 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -27,7 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "translation.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
@@ -669,6 +670,7 @@ static const char* locale_names[]={
"Sanskrit (India)",
"Santali (India)",
"Sardinian (Italy)",
+"Scots (Scotland)",
"Sindhi (India)",
"Northern Sami (Norway)",
"Samogitian (Lithuania)",
@@ -750,6 +752,20 @@ static const char* locale_names[]={
0
};
+bool TranslationServer::is_locale_valid(const String& p_locale) {
+
+ const char **ptr=locale_list;
+
+ while (*ptr) {
+
+ if (*ptr==p_locale)
+ return true;
+ ptr++;
+ }
+
+ return false;
+
+}
Vector<String> TranslationServer::get_all_locales() {
@@ -899,18 +915,18 @@ int Translation::get_message_count() const {
void Translation::_bind_methods() {
- ClassDB::bind_method(_MD("set_locale","locale"),&Translation::set_locale);
- ClassDB::bind_method(_MD("get_locale"),&Translation::get_locale);
- ClassDB::bind_method(_MD("add_message","src_message","xlated_message"),&Translation::add_message);
- ClassDB::bind_method(_MD("get_message","src_message"),&Translation::get_message);
- ClassDB::bind_method(_MD("erase_message","src_message"),&Translation::erase_message);
- ClassDB::bind_method(_MD("get_message_list"),&Translation::_get_message_list);
- ClassDB::bind_method(_MD("get_message_count"),&Translation::get_message_count);
- ClassDB::bind_method(_MD("_set_messages"),&Translation::_set_messages);
- ClassDB::bind_method(_MD("_get_messages"),&Translation::_get_messages);
-
- ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY,"messages",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_messages"), _SCS("_get_messages") );
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"locale"), _SCS("set_locale"), _SCS("get_locale") );
+ ClassDB::bind_method(D_METHOD("set_locale","locale"),&Translation::set_locale);
+ ClassDB::bind_method(D_METHOD("get_locale"),&Translation::get_locale);
+ ClassDB::bind_method(D_METHOD("add_message","src_message","xlated_message"),&Translation::add_message);
+ ClassDB::bind_method(D_METHOD("get_message","src_message"),&Translation::get_message);
+ ClassDB::bind_method(D_METHOD("erase_message","src_message"),&Translation::erase_message);
+ ClassDB::bind_method(D_METHOD("get_message_list"),&Translation::_get_message_list);
+ ClassDB::bind_method(D_METHOD("get_message_count"),&Translation::get_message_count);
+ ClassDB::bind_method(D_METHOD("_set_messages"),&Translation::_set_messages);
+ ClassDB::bind_method(D_METHOD("_get_messages"),&Translation::_get_messages);
+
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY,"messages",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_messages", "_get_messages") ;
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"locale"), "set_locale", "get_locale") ;
}
Translation::Translation() {
@@ -1121,15 +1137,15 @@ StringName TranslationServer::tool_translate(const StringName& p_message) const
void TranslationServer::_bind_methods() {
- ClassDB::bind_method(_MD("set_locale","locale"),&TranslationServer::set_locale);
- ClassDB::bind_method(_MD("get_locale"),&TranslationServer::get_locale);
+ ClassDB::bind_method(D_METHOD("set_locale","locale"),&TranslationServer::set_locale);
+ ClassDB::bind_method(D_METHOD("get_locale"),&TranslationServer::get_locale);
- ClassDB::bind_method(_MD("translate","message"),&TranslationServer::translate);
+ ClassDB::bind_method(D_METHOD("translate","message"),&TranslationServer::translate);
- ClassDB::bind_method(_MD("add_translation","translation:Translation"),&TranslationServer::add_translation);
- ClassDB::bind_method(_MD("remove_translation","translation:Translation"),&TranslationServer::remove_translation);
+ ClassDB::bind_method(D_METHOD("add_translation","translation:Translation"),&TranslationServer::add_translation);
+ ClassDB::bind_method(D_METHOD("remove_translation","translation:Translation"),&TranslationServer::remove_translation);
- ClassDB::bind_method(_MD("clear"),&TranslationServer::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&TranslationServer::clear);
}
diff --git a/core/translation.h b/core/translation.h
index 85ab4a229d..feed352549 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -102,6 +102,7 @@ public:
static Vector<String> get_all_locales();
static Vector<String> get_all_locale_names();
+ static bool is_locale_valid(const String& p_locale);
void set_tool_translation(const Ref<Translation>& p_translation);
StringName tool_translate(const StringName& p_message) const;
diff --git a/core/typedefs.h b/core/typedefs.h
index 176c77570d..c630887924 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -40,41 +40,39 @@
#define _STR(m_x) #m_x
#define _MKSTR(m_x) _STR(m_x)
#endif
-// have to include version.h for this to work, include it in the .cpp not the .h
+
+/**
+ * Version macros - it is necessary to include "version.h" for those to work.
+ * Include it in the .cpp file, not the header.
+ */
#ifdef VERSION_PATCH
-#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_PATCH)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION)
#else
-#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION)
#endif // VERSION_PATCH
-#define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v" VERSION_MKSTRING
+#define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING
#ifndef _ALWAYS_INLINE_
#if defined(__GNUC__) && (__GNUC__ >= 4 )
-# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
+#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
#elif defined(__llvm__)
-# define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
+#define _ALWAYS_INLINE_ __attribute__((always_inline)) inline
#elif defined(_MSC_VER)
-# define _ALWAYS_INLINE_ __forceinline
+#define _ALWAYS_INLINE_ __forceinline
#else
-# define _ALWAYS_INLINE_ inline
+#define _ALWAYS_INLINE_ inline
#endif
#endif
#ifndef _FORCE_INLINE_
-
#ifdef DEBUG_ENABLED
-
#define _FORCE_INLINE_ inline
-
#else
-
#define _FORCE_INLINE_ _ALWAYS_INLINE_
-
#endif
-
#endif
@@ -97,16 +95,16 @@ T *_nullptr() { T*t=NULL; return t; }
*/
#ifdef _WIN32
-# undef min // override standard definition
-# undef max // override standard definition
-# undef ERROR // override (really stupid) wingdi.h standard definition
-# undef DELETE // override (another really stupid) winnt.h standard definition
-# undef MessageBox // override winuser.h standard definition
-# undef MIN // override standard definition
-# undef MAX // override standard definition
-# undef CLAMP // override standard definition
-# undef Error
-# undef OK
+#undef min // override standard definition
+#undef max // override standard definition
+#undef ERROR // override (really stupid) wingdi.h standard definition
+#undef DELETE // override (another really stupid) winnt.h standard definition
+#undef MessageBox // override winuser.h standard definition
+#undef MIN // override standard definition
+#undef MAX // override standard definition
+#undef CLAMP // override standard definition
+#undef Error
+#undef OK
#endif
#include "error_macros.h"
@@ -150,30 +148,30 @@ inline void __swap_tmpl(T &x, T &y ) {
#endif //swap
-#define HEX2CHR( m_hex ) ( (m_hex>='0' && m_hex<='9')?(m_hex-'0'):\
- ((m_hex>='A' && m_hex<='F')?(10+m_hex-'A'):\
- ((m_hex>='a' && m_hex<='f')?(10+m_hex-'a'):0)))
+/* clang-format off */
+#define HEX2CHR(m_hex) \
+ ((m_hex >= '0' && m_hex <= '9') ? (m_hex - '0') : \
+ ((m_hex >= 'A' && m_hex <= 'F') ? (10 + m_hex - 'A') : \
+ ((m_hex >= 'a' && m_hex <= 'f') ? (10 + m_hex - 'a') : 0)))
+/* clang-format on */
// Macro to check whether we are compiled by clang
// and we have a specific builtin
#if defined(__llvm__) && defined(__has_builtin)
- #define _llvm_has_builtin(x) __has_builtin(x)
+#define _llvm_has_builtin(x) __has_builtin(x)
#else
- #define _llvm_has_builtin(x) 0
+#define _llvm_has_builtin(x) 0
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_mul_overflow)
-# define _mul_overflow __builtin_mul_overflow
+#define _mul_overflow __builtin_mul_overflow
#endif
#if (defined(__GNUC__) && (__GNUC__ >= 5)) || _llvm_has_builtin(__builtin_add_overflow)
-# define _add_overflow __builtin_add_overflow
+#define _add_overflow __builtin_add_overflow
#endif
-
-
-
/** Function to find the nearest (bigger) power of 2 to an integer */
static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) {
@@ -276,14 +274,11 @@ struct _GlobalLock {
};
#define GLOBAL_LOCK_FUNCTION _GlobalLock _global_lock_;
-#ifdef NO_SAFE_CAST
+#ifdef NO_SAFE_CAST
#define SAFE_CAST static_cast
-
#else
-
#define SAFE_CAST dynamic_cast
-
#endif
#define MT_SAFE
@@ -291,7 +286,4 @@ struct _GlobalLock {
#define __STRX(m_index) #m_index
#define __STR(m_index) __STRX(m_index)
-
-
#endif /* typedefs.h */
-
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index acb262d400..f91f1aa14b 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "undo_redo.h"
+
#include "os/os.h"
void UndoRedo::_discard_redo() {
@@ -484,11 +485,11 @@ Variant UndoRedo::_add_undo_method(const Variant** p_args, int p_argcount, Varia
void UndoRedo::_bind_methods() {
- ClassDB::bind_method(_MD("create_action","name","merge_mode"),&UndoRedo::create_action, DEFVAL(MERGE_DISABLE) );
- ClassDB::bind_method(_MD("commit_action"),&UndoRedo::commit_action);
+ ClassDB::bind_method(D_METHOD("create_action","name","merge_mode"),&UndoRedo::create_action, DEFVAL(MERGE_DISABLE) );
+ ClassDB::bind_method(D_METHOD("commit_action"),&UndoRedo::commit_action);
- //ClassDB::bind_method(_MD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method);
- //ClassDB::bind_method(_MD("add_undo_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_undo_method);
+ //ClassDB::bind_method(D_METHOD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method);
+ //ClassDB::bind_method(D_METHOD("add_undo_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_undo_method);
{
MethodInfo mi;
@@ -510,13 +511,13 @@ void UndoRedo::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"add_undo_method",&UndoRedo::_add_undo_method,mi);
}
- ClassDB::bind_method(_MD("add_do_property","object", "property", "value:Variant"),&UndoRedo::add_do_property);
- ClassDB::bind_method(_MD("add_undo_property","object", "property", "value:Variant"),&UndoRedo::add_undo_property);
- ClassDB::bind_method(_MD("add_do_reference","object"),&UndoRedo::add_do_reference);
- ClassDB::bind_method(_MD("add_undo_reference","object"),&UndoRedo::add_undo_reference);
- ClassDB::bind_method(_MD("clear_history"),&UndoRedo::clear_history);
- ClassDB::bind_method(_MD("get_current_action_name"),&UndoRedo::get_current_action_name);
- ClassDB::bind_method(_MD("get_version"),&UndoRedo::get_version);
+ ClassDB::bind_method(D_METHOD("add_do_property","object", "property", "value:Variant"),&UndoRedo::add_do_property);
+ ClassDB::bind_method(D_METHOD("add_undo_property","object", "property", "value:Variant"),&UndoRedo::add_undo_property);
+ ClassDB::bind_method(D_METHOD("add_do_reference","object"),&UndoRedo::add_do_reference);
+ ClassDB::bind_method(D_METHOD("add_undo_reference","object"),&UndoRedo::add_undo_reference);
+ ClassDB::bind_method(D_METHOD("clear_history"),&UndoRedo::clear_history);
+ ClassDB::bind_method(D_METHOD("get_current_action_name"),&UndoRedo::get_current_action_name);
+ ClassDB::bind_method(D_METHOD("get_version"),&UndoRedo::get_version);
BIND_CONSTANT(MERGE_DISABLE);
BIND_CONSTANT(MERGE_ENDS);
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 27bb8eac72..7d88989d04 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include <wchar.h>
#include "ustring.h"
+
#include "os/memory.h"
#include "print_string.h"
#include "math_funcs.h"
@@ -36,10 +36,8 @@
#include "ucaps.h"
#include "color.h"
#include "variant.h"
-#define MAX_DIGITS 6
-#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c))
-#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c))
+#include <wchar.h>
#ifndef NO_USE_STDLIB
#include <stdlib.h>
@@ -50,8 +48,44 @@
#define snprintf _snprintf
#endif
+#define MAX_DIGITS 6
+#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c))
+#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c))
+
+
+
+
/** STRING **/
+bool CharString::operator<(const CharString& p_right) const {
+
+ if (length()==0) {
+ return p_right.length()!=0;
+ }
+
+
+ const char *this_str=get_data();
+ const char *that_str=get_data();
+ while (true) {
+
+ if (*that_str==0 && *this_str==0)
+ return false; //this can't be equal, sadly
+ else if (*this_str==0)
+ return true; //if this is empty, and the other one is not, then we're less.. I think?
+ else if (*that_str==0)
+ return false; //otherwise the other one is smaller..
+ else if (*this_str < *that_str ) //more than
+ return true;
+ else if (*this_str > *that_str ) //less than
+ return false;
+
+ this_str++;
+ that_str++;
+ }
+
+ return false; //should never reach here anyway
+}
+
const char *CharString::get_data() const {
if (size())
@@ -560,7 +594,7 @@ String String::get_slice(String p_splitter, int p_slice) const {
int pos=0;
int prev_pos=0;
-// int slices=1;
+ //int slices=1;
if (p_slice<0)
return "";
if (find(p_splitter)==-1)
@@ -574,7 +608,7 @@ String String::get_slice(String p_splitter, int p_slice) const {
pos=length(); //reached end
int from=prev_pos;
- // int to=pos;
+ //int to=pos;
if (p_slice==i) {
@@ -1255,7 +1289,7 @@ _FORCE_INLINE static int parse_utf8_char(const char *p_utf8,unsigned int *p_ucs4
unichar=*p_utf8;
else {
- unichar=(0xFF >> (len +1)) & *p_utf8;;
+ unichar=(0xFF >> (len +1)) & *p_utf8;
for (int i=1;i<len;i++) {
@@ -1404,7 +1438,7 @@ bool String::parse_utf8(const char* p_utf8,int p_len) {
unichar=*p_utf8;
else {
- unichar=(0xFF >> (len +1)) & *p_utf8;;
+ unichar=(0xFF >> (len +1)) & *p_utf8;
for (int i=1;i<len;i++) {
@@ -1420,7 +1454,7 @@ bool String::parse_utf8(const char* p_utf8,int p_len) {
}
}
-// printf("char %i, len %i\n",unichar,len);
+ //printf("char %i, len %i\n",unichar,len);
if (sizeof(wchar_t)==2 && unichar>0xFFFF) {
unichar=' '; //too long for windows
@@ -2951,6 +2985,78 @@ bool String::matchn(const String& p_wildcard) const {
}
+String String::format(const Variant& values,String placeholder) const {
+
+ String new_string = String( this->ptr() );
+
+ if( values.get_type() == Variant::ARRAY ) {
+ Array values_arr = values;
+
+ for(int i=0;i<values_arr.size();i++) {
+ String i_as_str = String::num_int64( i );
+
+ if( values_arr[i].get_type() == Variant::ARRAY ) {//Array in Array structure [["name","RobotGuy"],[0,"godot"],["strength",9000.91]]
+ Array value_arr = values_arr[i];
+
+ if( value_arr.size()==2 ) {
+ Variant v_key = value_arr[0];
+ String key;
+
+ key = v_key.get_construct_string();
+ if( key.left(1)=="\"" && key.right(key.length()-1)=="\"" ) {
+ key = key.substr(1,key.length()-2);
+ }
+
+ Variant v_val = value_arr[1];
+ String val;
+ val = v_val.get_construct_string();
+
+ if( val.left(1)=="\"" && val.right(val.length()-1)=="\"" ) {
+ val = val.substr(1,val.length()-2);
+ }
+
+ new_string = new_string.replacen( placeholder.replace("_", key ), val );
+ }else {
+ ERR_PRINT(String("STRING.format Inner Array size != 2 ").ascii().get_data());
+ }
+ } else {//Array structure ["RobotGuy","Logis","rookie"]
+ Variant v_val = values_arr[i];
+ String val;
+ val = v_val.get_construct_string();
+
+ if( val.left(1)=="\"" && val.right(val.length()-1)=="\"" ) {
+ val = val.substr(1,val.length()-2);
+ }
+
+ new_string = new_string.replacen( placeholder.replace("_", i_as_str ), val );
+ }
+ }
+ }else if( values.get_type() == Variant::DICTIONARY ) {
+ Dictionary d = values;
+ List<Variant> keys;
+ d.get_key_list(&keys);
+
+ for (List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ String key = E->get().get_construct_string();
+ String val = d[E->get()].get_construct_string();
+
+ if( key.left(1)=="\"" && key.right(key.length()-1)=="\"" ) {
+ key = key.substr(1,key.length()-2);
+ }
+
+ if( val.left(1)=="\"" && val.right(val.length()-1)=="\"" ) {
+ val = val.substr(1,val.length()-2);
+ }
+
+ new_string = new_string.replacen( placeholder.replace("_", key ), val );
+ }
+ }else{
+ ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data());
+ }
+
+ return new_string;
+}
+
String String::replace(String p_key,String p_with) const {
String new_string;
@@ -3336,8 +3442,17 @@ String String::c_escape() const {
escaped=escaped.replace("\t","\\t");
escaped=escaped.replace("\v","\\v");
escaped=escaped.replace("\'","\\'");
- escaped=escaped.replace("\"","\\\"");
escaped=escaped.replace("\?","\\?");
+ escaped=escaped.replace("\"","\\\"");
+
+ return escaped;
+}
+
+String String::c_escape_multiline() const {
+
+ String escaped=*this;
+ escaped=escaped.replace("\\","\\\\");
+ escaped=escaped.replace("\"","\\\"");
return escaped;
}
@@ -3812,7 +3927,7 @@ String String::get_file() const {
return substr(sep+1,length());
}
-String String::extension() const {
+String String::get_extension() const {
int pos = find_last(".");
if (pos<0)
@@ -3822,11 +3937,11 @@ String String::extension() const {
}
String String::plus_file(const String& p_file) const {
-
- if (length()>0 && operator [](length()-1)=='/')
+ if (empty())
+ return p_file;
+ if (operator [](length()-1)=='/' || (p_file.size()>0 && p_file.operator [](0)=='/'))
return *this+p_file;
- else
- return *this+"/"+p_file;
+ return *this+"/"+p_file;
}
String String::percent_encode() const {
@@ -3891,7 +4006,7 @@ String String::percent_decode() const {
return String::utf8(pe.ptr());
}
-String String::basename() const {
+String String::get_basename() const {
int pos = find_last(".");
if (pos<0)
@@ -3986,12 +4101,8 @@ String String::sprintf(const Array& values, bool* error) const {
case 'X': base = 16; capitalize = true; break;
}
// Get basic number.
- String str = String::num_int64(value, base, capitalize);
-
- // Sign.
- if (show_sign && value >= 0) {
- str = str.insert(0, "+");
- }
+ String str = String::num_int64(ABS(value), base, capitalize);
+ int number_len = str.length();
// Padding.
String pad_char = pad_with_zeroes ? String("0") : String(" ");
@@ -4001,6 +4112,13 @@ String String::sprintf(const Array& values, bool* error) const {
str = str.lpad(min_chars, pad_char);
}
+ // Sign.
+ if (show_sign && value >= 0) {
+ str = str.insert(pad_with_zeroes?0:str.length()-number_len, "+");
+ } else if (value < 0) {
+ str = str.insert(pad_with_zeroes?0:str.length()-number_len, "-");
+ }
+
formatted += str;
++value_index;
in_format = false;
@@ -4211,4 +4329,3 @@ String RTR(const String& p_text) {
return p_text;
}
-
diff --git a/core/ustring.h b/core/ustring.h
index 9a145143d0..87289f9e16 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -41,6 +41,8 @@
class CharString : public Vector<char> {
public:
+
+ bool operator<(const CharString& p_right) const;
int length() const { return size() ? size()-1 : 0; }
const char *get_data() const;
operator const char*() {return get_data();};
@@ -125,6 +127,7 @@ public:
bool is_subsequence_ofi(const String& p_string) const;
Vector<String> bigrams() const;
float similarity(const String& p_string) const;
+ String format(const Variant& values,String placeholder="{_}") const;
String replace_first(String p_key,String p_with) const;
String replace(String p_key,String p_with) const;
String replacen(String p_key,String p_with) const;
@@ -176,8 +179,8 @@ public:
String right(int p_pos) const;
String strip_edges(bool left = true, bool right = true) const;
String strip_escapes() const;
- String extension() const;
- String basename() const;
+ String get_extension() const;
+ String get_basename() const;
String plus_file(const String& p_file) const;
CharType ord_at(int p_idx) const;
@@ -217,6 +220,7 @@ public:
String http_escape() const;
String http_unescape() const;
String c_escape() const;
+ String c_escape_multiline() const;
String c_unescape() const;
String json_escape() const;
String word_wrap(int p_chars_per_line) const;
diff --git a/core/variant.cpp b/core/variant.cpp
index 5a670a2786..f45c3fd55d 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -27,6 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "variant.h"
+
+#include "math_funcs.h"
#include "resource.h"
#include "print_string.h"
#include "scene/main/node.h"
@@ -1764,7 +1766,7 @@ Variant::operator Transform() const {
if (type==TRANSFORM2D) {
return *_data._transform2d;
} else if (type==TRANSFORM) {
- const Transform& t = *_data._transform;;
+ const Transform& t = *_data._transform;
Transform2D m;
m.elements[0][0]=t.basis.elements[0][0];
m.elements[0][1]=t.basis.elements[1][0];
@@ -2673,14 +2675,10 @@ uint32_t Variant::hash() const {
case INT: {
return _data._int;
-
} break;
case REAL: {
- MarshallFloat mf;
- mf.f=_data._real;
- return mf.i;
-
+ return hash_djb2_one_float(_data._real);
} break;
case STRING: {
@@ -2920,6 +2918,186 @@ uint32_t Variant::hash() const {
}
+#define hash_compare_scalar(p_lhs, p_rhs)\
+ ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) == Math::is_nan(p_rhs))
+
+#define hash_compare_vector2(p_lhs, p_rhs)\
+ (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
+ (hash_compare_scalar((p_lhs).y, (p_rhs).y))
+
+#define hash_compare_vector3(p_lhs, p_rhs)\
+ (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
+ (hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
+ (hash_compare_scalar((p_lhs).z, (p_rhs).z))
+
+#define hash_compare_quat(p_lhs, p_rhs)\
+ (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \
+ (hash_compare_scalar((p_lhs).y, (p_rhs).y)) && \
+ (hash_compare_scalar((p_lhs).z, (p_rhs).z)) && \
+ (hash_compare_scalar((p_lhs).w, (p_rhs).w))
+
+#define hash_compare_color(p_lhs, p_rhs)\
+ (hash_compare_scalar((p_lhs).r, (p_rhs).r)) && \
+ (hash_compare_scalar((p_lhs).g, (p_rhs).g)) && \
+ (hash_compare_scalar((p_lhs).b, (p_rhs).b)) && \
+ (hash_compare_scalar((p_lhs).a, (p_rhs).a))
+
+#define hash_compare_pool_array(p_lhs, p_rhs, p_type, p_compare_func)\
+ const PoolVector<p_type>& l = *reinterpret_cast<const PoolVector<p_type>*>(p_lhs);\
+ const PoolVector<p_type>& r = *reinterpret_cast<const PoolVector<p_type>*>(p_rhs);\
+ \
+ if(l.size() != r.size()) \
+ return false; \
+ \
+ PoolVector<p_type>::Read lr = l.read(); \
+ PoolVector<p_type>::Read rr = r.read(); \
+ \
+ for(int i = 0; i < l.size(); ++i) { \
+ if(! p_compare_func((lr[i]), (rr[i]))) \
+ return false; \
+ }\
+ \
+ return true
+
+bool Variant::hash_compare(const Variant& p_variant) const {
+ if (type != p_variant.type)
+ return false;
+
+ switch( type ) {
+ case REAL: {
+ return hash_compare_scalar(_data._real, p_variant._data._real);
+ } break;
+
+ case VECTOR2: {
+ const Vector2* l = reinterpret_cast<const Vector2*>(_data._mem);
+ const Vector2* r = reinterpret_cast<const Vector2*>(p_variant._data._mem);
+
+ return hash_compare_vector2(*l, *r);
+ } break;
+
+ case RECT2: {
+ const Rect2* l = reinterpret_cast<const Rect2*>(_data._mem);
+ const Rect2* r = reinterpret_cast<const Rect2*>(p_variant._data._mem);
+
+ return (hash_compare_vector2(l->pos, r->pos)) &&
+ (hash_compare_vector2(l->size, r->size));
+ } break;
+
+ case TRANSFORM2D: {
+ Transform2D* l = _data._transform2d;
+ Transform2D* r = p_variant._data._transform2d;
+
+ for(int i=0;i<3;i++) {
+ if (! (hash_compare_vector2(l->elements[i], r->elements[i])))
+ return false;
+ }
+
+ return true;
+ } break;
+
+ case VECTOR3: {
+ const Vector3* l = reinterpret_cast<const Vector3*>(_data._mem);
+ const Vector3* r = reinterpret_cast<const Vector3*>(p_variant._data._mem);
+
+ return hash_compare_vector3(*l, *r);
+ } break;
+
+ case PLANE: {
+ const Plane* l = reinterpret_cast<const Plane*>(_data._mem);
+ const Plane* r = reinterpret_cast<const Plane*>(p_variant._data._mem);
+
+ return (hash_compare_vector3(l->normal, r->normal)) &&
+ (hash_compare_scalar(l->d, r->d));
+ } break;
+
+ case RECT3: {
+ const Rect3* l = _data._rect3;
+ const Rect3* r = p_variant._data._rect3;
+
+ return (hash_compare_vector3(l->pos, r->pos) &&
+ (hash_compare_vector3(l->size, r->size)));
+
+ } break;
+
+ case QUAT: {
+ const Quat* l = reinterpret_cast<const Quat*>(_data._mem);
+ const Quat* r = reinterpret_cast<const Quat*>(p_variant._data._mem);
+
+ return hash_compare_quat(*l, *r);
+ } break;
+
+ case BASIS: {
+ const Basis* l = _data._basis;
+ const Basis* r = p_variant._data._basis;
+
+ for(int i=0;i<3;i++) {
+ if (! (hash_compare_vector3(l->elements[i], r->elements[i])))
+ return false;
+ }
+
+ return true;
+ } break;
+
+ case TRANSFORM: {
+ const Transform* l = _data._transform;
+ const Transform* r = p_variant._data._transform;
+
+ for(int i=0;i<3;i++) {
+ if (! (hash_compare_vector3(l->basis.elements[i], r->basis.elements[i])))
+ return false;
+ }
+
+ return hash_compare_vector3(l->origin, r->origin);
+ } break;
+
+ case COLOR: {
+ const Color* l = reinterpret_cast<const Color*>(_data._mem);
+ const Color* r = reinterpret_cast<const Color*>(p_variant._data._mem);
+
+ return hash_compare_color(*l, *r);
+ } break;
+
+ case ARRAY: {
+ const Array& l = *(reinterpret_cast<const Array*>(_data._mem));
+ const Array& r = *(reinterpret_cast<const Array*>(p_variant._data._mem));
+
+ if(l.size() != r.size())
+ return false;
+
+ for(int i = 0; i < l.size(); ++i) {
+ if(! l[i].hash_compare(r[i]))
+ return false;
+ }
+
+ return true;
+ } break;
+
+ case POOL_REAL_ARRAY: {
+ hash_compare_pool_array(_data._mem, p_variant._data._mem, real_t, hash_compare_scalar);
+ } break;
+
+ case POOL_VECTOR2_ARRAY: {
+ hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector2, hash_compare_vector2);
+ } break;
+
+ case POOL_VECTOR3_ARRAY: {
+ hash_compare_pool_array(_data._mem, p_variant._data._mem, Vector3, hash_compare_vector3);
+ } break;
+
+ case POOL_COLOR_ARRAY: {
+ hash_compare_pool_array(_data._mem, p_variant._data._mem, Color, hash_compare_color);
+ } break;
+
+ default:
+ bool v;
+ Variant r;
+ evaluate(OP_EQUAL,*this,p_variant,r,v);
+ return r;
+ }
+
+ return false;
+}
+
bool Variant::is_ref() const {
diff --git a/core/variant.h b/core/variant.h
index 9d29fd64c3..f9ceca1ca0 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -33,7 +33,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-#include "aabb.h"
+#include "rect3.h"
#include "ustring.h"
#include "vector3.h"
#include "plane.h"
@@ -421,6 +421,7 @@ public:
bool operator<(const Variant& p_variant) const;
uint32_t hash() const;
+ bool hash_compare(const Variant& p_variant) const;
bool booleanize(bool &valid) const;
void static_assign(const Variant& p_variant);
@@ -459,6 +460,10 @@ struct VariantHasher {
static _FORCE_INLINE_ uint32_t hash(const Variant &p_variant) { return p_variant.hash(); }
};
+struct VariantComparator {
+
+ static _FORCE_INLINE_ bool compare(const Variant &p_lhs, const Variant &p_rhs) { return p_lhs.hash_compare(p_rhs); }
+};
Variant::ObjData& Variant::_get_obj() {
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 0c8b40539d..376e646fc2 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "variant.h"
+
#include "object.h"
#include "os/os.h"
#include "core_string_names.h"
@@ -146,7 +147,7 @@ struct _VariantCall {
Arg(Variant::Type p_type,const StringName &p_name) { name=p_name; type=p_type; }
};
-// void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func);
+ //void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func);
static void make_func_return_variant(Variant::Type p_type,const StringName& p_name) {
@@ -261,6 +262,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(String,is_subsequence_ofi);
VCALL_LOCALMEM0R(String,bigrams);
VCALL_LOCALMEM1R(String,similarity);
+ VCALL_LOCALMEM2R(String,format);
VCALL_LOCALMEM2R(String,replace);
VCALL_LOCALMEM2R(String,replacen);
VCALL_LOCALMEM2R(String,insert);
@@ -272,8 +274,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(String,left);
VCALL_LOCALMEM1R(String,right);
VCALL_LOCALMEM2R(String,strip_edges);
- VCALL_LOCALMEM0R(String,extension);
- VCALL_LOCALMEM0R(String,basename);
+ VCALL_LOCALMEM0R(String,get_extension);
+ VCALL_LOCALMEM0R(String,get_basename);
VCALL_LOCALMEM1R(String,plus_file);
VCALL_LOCALMEM1R(String,ord_at);
VCALL_LOCALMEM2(String,erase);
@@ -349,12 +351,12 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Vector2,tangent);
VCALL_LOCALMEM0R(Vector2,floor);
VCALL_LOCALMEM1R(Vector2,snapped);
- VCALL_LOCALMEM0R(Vector2,get_aspect);
+ VCALL_LOCALMEM0R(Vector2,aspect);
VCALL_LOCALMEM1R(Vector2,dot);
VCALL_LOCALMEM1R(Vector2,slide);
VCALL_LOCALMEM1R(Vector2,reflect);
VCALL_LOCALMEM0R(Vector2,angle);
-// VCALL_LOCALMEM1R(Vector2,cross);
+ //VCALL_LOCALMEM1R(Vector2,cross);
VCALL_LOCALMEM0R(Vector2,abs);
VCALL_LOCALMEM1R(Vector2,clamped);
@@ -562,6 +564,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(PoolStringArray,append);
VCALL_LOCALMEM1(PoolStringArray,append_array);
VCALL_LOCALMEM0(PoolStringArray,invert);
+ VCALL_LOCALMEM1R(PoolStringArray,join);
VCALL_LOCALMEM0R(PoolVector2Array,size);
VCALL_LOCALMEM2(PoolVector2Array,set);
@@ -1051,32 +1054,32 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i
// math types
- case VECTOR2: return Vector2(); // 5
+ case VECTOR2: return Vector2(); // 5
case RECT2: return Rect2();
case VECTOR3: return Vector3();
case TRANSFORM2D: return Transform2D();
case PLANE: return Plane();
case QUAT: return Quat();
- case RECT3: return Rect3(); //sorry naming convention fail :( not like it's used often // 10
+ case RECT3: return Rect3(); // 10
case BASIS: return Basis();
case TRANSFORM: return Transform();
// misc types
case COLOR: return Color();
- case IMAGE: return Image();;
- case NODE_PATH: return NodePath();; // 15
- case _RID: return RID();;
+ case IMAGE: return Image();
+ case NODE_PATH: return NodePath(); // 15
+ case _RID: return RID();
case OBJECT: return (Object*)NULL;
- case INPUT_EVENT: return InputEvent();;
- case DICTIONARY: return Dictionary();;
- case ARRAY: return Array();; // 20
- case POOL_BYTE_ARRAY: return PoolByteArray();;
- case POOL_INT_ARRAY: return PoolIntArray();;
- case POOL_REAL_ARRAY: return PoolRealArray();;
- case POOL_STRING_ARRAY: return PoolStringArray();;
- case POOL_VECTOR2_ARRAY: return PoolVector2Array();; // 25
- case POOL_VECTOR3_ARRAY: return PoolVector3Array();; // 25
- case POOL_COLOR_ARRAY: return PoolColorArray();;
+ case INPUT_EVENT: return InputEvent();
+ case DICTIONARY: return Dictionary();
+ case ARRAY: return Array(); // 20
+ case POOL_BYTE_ARRAY: return PoolByteArray();
+ case POOL_INT_ARRAY: return PoolIntArray();
+ case POOL_REAL_ARRAY: return PoolRealArray();
+ case POOL_STRING_ARRAY: return PoolStringArray();
+ case POOL_VECTOR2_ARRAY: return PoolVector2Array(); // 25
+ case POOL_VECTOR3_ARRAY: return PoolVector3Array();
+ case POOL_COLOR_ARRAY: return PoolColorArray();
default: return Variant();
}
@@ -1125,27 +1128,27 @@ Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, i
case VECTOR3: return (Vector3(*p_args[0]));
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (Quat(*p_args[0]));
- case RECT3: return (Rect3(*p_args[0])); //sorry naming convention fail :( not like it's used often // 10
+ case RECT3: return (Rect3(*p_args[0])); // 10
case BASIS: return (Basis(p_args[0]->operator Basis()));
case TRANSFORM: return (Transform(p_args[0]->operator Transform()));
// misc types
case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]);
case IMAGE: return (Image(*p_args[0]));
- case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15
+ case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15
case _RID: return (RID(*p_args[0]));
case OBJECT: return ((Object*)(p_args[0]->operator Object *()));
case INPUT_EVENT: return (InputEvent(*p_args[0]));
case DICTIONARY: return p_args[0]->operator Dictionary();
- case ARRAY: return p_args[0]->operator Array();
+ case ARRAY: return p_args[0]->operator Array(); // 20
// arrays
case POOL_BYTE_ARRAY: return (PoolByteArray(*p_args[0]));
case POOL_INT_ARRAY: return (PoolIntArray(*p_args[0]));
case POOL_REAL_ARRAY: return (PoolRealArray(*p_args[0]));
case POOL_STRING_ARRAY: return (PoolStringArray(*p_args[0]));
- case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25
- case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0])); // 25
+ case POOL_VECTOR2_ARRAY: return (PoolVector2Array(*p_args[0])); // 25
+ case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0]));
case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0]));
default: return Variant();
}
@@ -1360,15 +1363,15 @@ void register_variant_methods() {
_VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
#define ADDFUNC0(m_vtype,m_ret,m_class,m_method,m_defarg)\
-_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg);
+_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCALL(m_class,m_method),m_defarg);
#define ADDFUNC1(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_defarg)\
-_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)) );
+_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_scs_create(m_argname1)) );
#define ADDFUNC2(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_arg2,m_argname2,m_defarg)\
-_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)));
+_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_scs_create(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_scs_create(m_argname2)));
#define ADDFUNC3(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_arg2,m_argname2,m_arg3,m_argname3,m_defarg)\
-_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_SCS(m_argname3)));
+_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_scs_create(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_scs_create(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_scs_create(m_argname3)));
#define ADDFUNC4(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_arg2,m_argname2,m_arg3,m_argname3,m_arg4,m_argname4,m_defarg)\
-_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_SCS(m_argname3)),_VariantCall::Arg(Variant::m_arg4,_SCS(m_argname4)));
+_VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_scs_create(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_scs_create(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_scs_create(m_argname3)),_VariantCall::Arg(Variant::m_arg4,_scs_create(m_argname4)));
/* STRING */
@@ -1392,6 +1395,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(STRING,POOL_STRING_ARRAY,String,bigrams,varray());
ADDFUNC1(STRING,REAL,String,similarity,STRING,"text",varray());
+ ADDFUNC2(STRING,STRING,String,format,NIL,"values",STRING,"placeholder",varray("{_}"));
ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray());
ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray());
ADDFUNC2(STRING,STRING,String,insert,INT,"pos",STRING,"what",varray());
@@ -1405,8 +1409,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING,STRING,String,left,INT,"pos",varray());
ADDFUNC1(STRING,STRING,String,right,INT,"pos",varray());
ADDFUNC2(STRING,STRING,String,strip_edges,BOOL,"left",BOOL,"right",varray(true,true));
- ADDFUNC0(STRING,STRING,String,extension,varray());
- ADDFUNC0(STRING,STRING,String,basename,varray());
+ ADDFUNC0(STRING,STRING,String,get_extension,varray());
+ ADDFUNC0(STRING,STRING,String,get_basename,varray());
ADDFUNC1(STRING,STRING,String,plus_file,STRING,"file",varray());
ADDFUNC1(STRING,INT,String,ord_at,INT,"at",varray());
ADDFUNC2(STRING,NIL,String,erase,INT,"pos",INT,"chars", varray());
@@ -1457,7 +1461,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(VECTOR2,VECTOR2,Vector2,tangent,varray());
ADDFUNC0(VECTOR2,VECTOR2,Vector2,floor,varray());
ADDFUNC1(VECTOR2,VECTOR2,Vector2,snapped,VECTOR2,"by",varray());
- ADDFUNC0(VECTOR2,REAL,Vector2,get_aspect,varray());
+ ADDFUNC0(VECTOR2,REAL,Vector2,aspect,varray());
ADDFUNC1(VECTOR2,REAL,Vector2,dot,VECTOR2,"with",varray());
ADDFUNC1(VECTOR2,VECTOR2,Vector2,slide,VECTOR2,"vec",varray());
ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray());
@@ -1634,6 +1638,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC2(POOL_STRING_ARRAY,INT,PoolStringArray,insert,INT,"idx",STRING,"string",varray());
ADDFUNC1(POOL_STRING_ARRAY,NIL,PoolStringArray,resize,INT,"idx",varray());
ADDFUNC0(POOL_STRING_ARRAY,NIL,PoolStringArray,invert,varray());
+ ADDFUNC1(POOL_STRING_ARRAY,STRING,PoolStringArray,join,STRING,"string",varray());
ADDFUNC0(POOL_VECTOR2_ARRAY,INT,PoolVector2Array,size,varray());
ADDFUNC2(POOL_VECTOR2_ARRAY,NIL,PoolVector2Array,set,INT,"idx",VECTOR2,"vector2",varray());
diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp
index 8db756aa79..56aa9891fb 100644
--- a/core/variant_construct_string.cpp
+++ b/core/variant_construct_string.cpp
@@ -169,7 +169,7 @@ Error VariantConstruct::_get_token(const CharType *p_str, int &idx, int p_len, T
case 'r': res=13; break;
case '\"': res='\"'; break;
case '\\': res='\\'; break;
- case '/': res='/'; break; //wtf
+ case '/': res='/'; break;
case 'u': {
//hexnumbarh - oct is deprecated
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 50f0b96715..28e804b5bf 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -27,9 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "variant.h"
+
#include "object.h"
#include "script_language.h"
#include "core_string_names.h"
+
Variant::operator bool() const {
bool b;
@@ -1391,7 +1393,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
v->basis.set_axis(index,p_value);
return;
}
- } if (p_index.get_type()==Variant::STRING) {
+ } else if (p_index.get_type()==Variant::STRING) {
Transform *v=_data._transform;
const String *str=reinterpret_cast<const String*>(p_index._data._mem);
@@ -2148,7 +2150,7 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
valid=true;
return index==3?v->origin:v->basis.get_axis(index);
}
- } if (p_index.get_type()==Variant::STRING) {
+ } else if (p_index.get_type()==Variant::STRING) {
const Transform *v=_data._transform;
const String *str=reinterpret_cast<const String*>(p_index._data._mem);
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 402c8d41da..a2ecb1516d 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -27,11 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "variant_parser.h"
+
#include "io/resource_loader.h"
#include "os/keyboard.h"
-
CharType VariantParser::StreamFile::get_char() {
return f->get_8();
@@ -430,7 +430,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String>& strings,
Token token;
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
- r_err_str="Expected '(' in old-style engine.cfg construct";
+ r_err_str="Expected '(' in old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
@@ -442,7 +442,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String>& strings,
CharType c=p_stream->get_char();
if (p_stream->is_eof()) {
- r_err_str="Unexpected EOF while parsing old-style engine.cfg construct";
+ r_err_str="Unexpected EOF while parsing old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
@@ -1328,7 +1328,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=arr;
return OK;
- } else if (id=="key") { // compatibility with engine.cfg
+ } else if (id=="key") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1364,7 +1364,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="mbutton") { // compatibility with engine.cfg
+ } else if (id=="mbutton") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1379,7 +1379,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="jbutton") { // compatibility with engine.cfg
+ } else if (id=="jbutton") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1394,7 +1394,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value=ie;
return OK;
- } else if (id=="jaxis") { // compatibility with engine.cfg
+ } else if (id=="jaxis") { // compatibility with godot.cfg
Vector<String> params;
Error err = _parse_enginecfg(p_stream,params,line,r_err_str);
@@ -1412,19 +1412,19 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
value= ie;
return OK;
- } else if (id=="img") { // compatibility with engine.cfg
+ } else if (id=="img") { // compatibility with godot.cfg
- Token token;
+ Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token.
get_token(p_stream,token,line,r_err_str);
if (token.type!=TK_PARENTHESIS_OPEN) {
- r_err_str="Expected '(' in old-style engine.cfg construct";
+ r_err_str="Expected '(' in old-style godot.cfg construct";
return ERR_PARSE_ERROR;
}
while(true) {
CharType c = p_stream->get_char();
if (p_stream->is_eof()) {
- r_err_str="Unexpected EOF in old style engine.cfg img()";
+ r_err_str="Unexpected EOF in old style godot.cfg img()";
return ERR_PARSE_ERROR;
}
if (c==')')
@@ -1873,7 +1873,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
String str=p_variant;
- str="\""+str.c_escape()+"\"";
+ str="\""+str.c_escape_multiline()+"\"";
p_store_string_func(p_store_string_ud, str );
} break;
case Variant::VECTOR2: {
@@ -1989,7 +1989,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<uint8_t> data = img.get_data();
int len = data.size();
PoolVector<uint8_t>::Read r = data.read();
- const uint8_t *ptr=r.ptr();;
+ const uint8_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
if (i>0)
@@ -2091,20 +2091,22 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
dict.get_key_list(&keys);
keys.sort();
- p_store_string_func(p_store_string_ud,"{ ");
+ p_store_string_func(p_store_string_ud,"{\n");
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
- //if (!_check_type(dict[E->get()]))
- // continue;
+ /*
+ if (!_check_type(dict[E->get()]))
+ continue;
+ */
write(E->get(),p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
- p_store_string_func(p_store_string_ud,":");
+ p_store_string_func(p_store_string_ud,": ");
write(dict[E->get()],p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
if (E->next())
- p_store_string_func(p_store_string_ud,", ");
+ p_store_string_func(p_store_string_ud,",\n");
}
- p_store_string_func(p_store_string_ud," }");
+ p_store_string_func(p_store_string_ud,"\n}");
} break;
@@ -2131,7 +2133,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<uint8_t> data = p_variant;
int len = data.size();
PoolVector<uint8_t>::Read r = data.read();
- const uint8_t *ptr=r.ptr();;
+ const uint8_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
if (i>0)
@@ -2150,7 +2152,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<int> data = p_variant;
int len = data.size();
PoolVector<int>::Read r = data.read();
- const int *ptr=r.ptr();;
+ const int *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2170,7 +2172,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<real_t> data = p_variant;
int len = data.size();
PoolVector<real_t>::Read r = data.read();
- const real_t *ptr=r.ptr();;
+ const real_t *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2188,7 +2190,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<String> data = p_variant;
int len = data.size();
PoolVector<String>::Read r = data.read();
- const String *ptr=r.ptr();;
+ const String *ptr=r.ptr();
String s;
//write_string("\n");
@@ -2211,7 +2213,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Vector2> data = p_variant;
int len = data.size();
PoolVector<Vector2>::Read r = data.read();
- const Vector2 *ptr=r.ptr();;
+ const Vector2 *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2229,7 +2231,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Vector3> data = p_variant;
int len = data.size();
PoolVector<Vector3>::Read r = data.read();
- const Vector3 *ptr=r.ptr();;
+ const Vector3 *ptr=r.ptr();
for (int i=0;i<len;i++) {
@@ -2248,7 +2250,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
PoolVector<Color> data = p_variant;
int len = data.size();
PoolVector<Color>::Read r = data.read();
- const Color *ptr=r.ptr();;
+ const Color *ptr=r.ptr();
for (int i=0;i<len;i++) {
diff --git a/core/vector.h b/core/vector.h
index 3119657cbb..1cb3fee256 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -81,7 +81,7 @@ class Vector {
size_t p;
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
*out = nearest_power_of_2(o);
- if (_add_overflow(o, 32, &p)) return false; //no longer allocated here
+ if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
#else
// Speed is more important than correctness here, do the operations unchecked
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 04bf8f677e..17f45c64a2 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -463,7 +463,7 @@
<argument index="1" name="to" type="float">
</argument>
<description>
- Random range, any floating point value between 'from' and 'to'
+ Random range, any floating point value between 'from' and 'to'.
</description>
</method>
<method name="rand_seed">
@@ -472,28 +472,28 @@
<argument index="0" name="seed" type="int">
</argument>
<description>
- Random from seed, pass a seed and an array with both number and new seed is returned.
+ Random from seed: pass a seed, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
</description>
</method>
<method name="randf">
<return type="float">
</return>
<description>
- Random value (0 to 1 float).
+ Return a random floating point value between 0 and 1.
</description>
</method>
<method name="randi">
<return type="int">
</return>
<description>
- Random 32 bits value (integer). To obtain a value from 0 to N, you can use remainder, like (for random from 0 to 19): randi() % 20.
+ Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use remainder. For example, to get a random integer between 0 and 19 inclusive, you can use randi() % 20.
</description>
</method>
<method name="randomize">
<return type="Nil">
</return>
<description>
- Reset the seed of the random number generator with a new, different one.
+ Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
</description>
</method>
<method name="range">
@@ -667,7 +667,7 @@
</methods>
<constants>
<constant name="PI" value="3.141593">
- Constant that represents how many times the diameter of a circumference fits around it's perimeter.
+ Constant that represents how many times the diameter of a circumference fits around its perimeter.
</constant>
</constants>
</class>
@@ -8025,7 +8025,7 @@
Circular Shape for 2D Physics.
</brief_description>
<description>
- Circular Shape for 2D Physics. This shape is useful for modeling balls or small characters and it's collision detection with everything else is very fast.
+ Circular Shape for 2D Physics. This shape is useful for modeling balls or small characters and its collision detection with everything else is very fast.
</description>
<methods>
<method name="get_radius" qualifiers="const">
@@ -8816,7 +8816,7 @@
<constants>
</constants>
</class>
-<class name="ColorFrame" inherits="Control" category="Core">
+<class name="ColorRect" inherits="Control" category="Core">
<brief_description>
</brief_description>
<description>
@@ -11258,7 +11258,7 @@
This function is called for each file exported and depending from the return value one of many things might happen.
1) If returned value is null, the file is exported as is.
2) If the returned value is a RawAray (array of bytes), the content of that array becomes the new file being exported.
- 3) If the file must also change it's name when exported, then a [Dictionary] must be returned with two fields: 'name' with the new filename and 'data' with a [RawArray] containing the raw contents of the file. Even if the name is changed, the run-time will redirect the old file to the new file automatically when accessed.
+ 3) If the file must also change its name when exported, then a [Dictionary] must be returned with two fields: 'name' with the new filename and 'data' with a [RawArray] containing the raw contents of the file. Even if the name is changed, the run-time will redirect the old file to the new file automatically when accessed.
</description>
</method>
</methods>
@@ -11706,7 +11706,7 @@
</class>
<class name="EditorPlugin" inherits="Node" category="Core">
<brief_description>
- Used by the editor to extend it's functionality.
+ Used by the editor to extend its functionality.
</brief_description>
<description>
Plugins are used by the editor to extend functionality. The most common types of plugins are those which edit a given node or resource type, import plugins and export plugins.
@@ -12005,7 +12005,7 @@
</method>
<method name="save_external_data" qualifiers="virtual">
<description>
- This method is called after the editor save the project or when the it's closed. It asks the plugin to save edited external scenes/resources.
+ 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_state" qualifiers="virtual">
@@ -14300,7 +14300,7 @@
Contains global variables accessible from everywhere.
</brief_description>
<description>
- Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in engine.cfg are also loaded into globals, making this object very useful for reading custom game configuration options.
+ Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in godot.cfg are also loaded into globals, making this object very useful for reading custom game configuration options.
</description>
<methods>
<method name="add_property_info">
@@ -15970,7 +15970,7 @@
Request does not have a response(yet).
</constant>
<constant name="RESULT_BODY_SIZE_LIMIT_EXCEEDED" value="7">
- Request exceded it's maximum size limit, see [method set_body_size_limit].
+ Request exceded its maximum size limit, see [method set_body_size_limit].
</constant>
<constant name="RESULT_REQUEST_FAILED" value="8">
Request failed. (unused)
@@ -15982,7 +15982,7 @@
HTTPRequest couldn't write to the download file.
</constant>
<constant name="RESULT_REDIRECT_LIMIT_REACHED" value="11">
- Request reached it's maximum redirect limit, see [method set_max_redirects].
+ Request reached its maximum redirect limit, see [method set_max_redirects].
</constant>
</constants>
</class>
@@ -16088,7 +16088,7 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Return the status of hostname queued for resolving, given it's queue ID. Returned status can be any of the RESOLVER_STATUS_* enumeration.
+ Return the status of hostname queued for resolving, given its queue ID. Returned status can be any of the RESOLVER_STATUS_* enumeration.
</description>
</method>
<method name="resolve_hostname">
@@ -22660,7 +22660,7 @@
Nodes can also process input events. When set, the [method _input] function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the [method _unhandled_input] function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI [Control] nodes), ensuring that the node only receives the events that were meant for it.
To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with [method set_owner]. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though.
Finally, when a node is freed with [method free] or [method queue_free], it will also free all its children.
- [b]Networking with nodes:[/b] After connecting to a server (or making one, see [NetworkedMultiplayerENet]) it is possible to use the built-in RPC (remote procedure call) system to easily communicate over the network. By calling [method rpc] with a method name, it will be called locally, and in all connected peers (peers = clients and the server that accepts connections), with behaviour varying depending on the network mode ([method set_network_mode]) on the receiving peer. To identify which [Node] receives the RPC call Godot will use it's [NodePath] (make sure node names are the same on all peers).
+ [b]Networking with nodes:[/b] After connecting to a server (or making one, see [NetworkedMultiplayerENet]) it is possible to use the built-in RPC (remote procedure call) system to easily communicate over the network. By calling [method rpc] with a method name, it will be called locally, and in all connected peers (peers = clients and the server that accepts connections), with behaviour varying depending on the network mode ([method set_network_mode]) on the receiving peer. To identify which [Node] receives the RPC call Godot will use its [NodePath] (make sure node names are the same on all peers).
</description>
<methods>
<method name="_enter_tree" qualifiers="virtual">
@@ -25394,10 +25394,15 @@
</return>
<argument index="0" name="port" type="int">
</argument>
- <argument index="1" name="recv_buf_size" type="int" default="65536">
+ <argument index="1" name="bind_address" type="String" default="*">
+ </argument>
+ <argument index="2" name="recv_buf_size" type="int" default="65536">
</argument>
<description>
- Make this [PacketPeerUDP] listen on the "port" with a buffer size "recv_buf_size". Listens on all available addresses.
+ Make this [PacketPeerUDP] listen on the "port" binding to "bind_address" with a buffer size "recv_buf_size".
+ If "bind_address" is set as "*" (default), the peer will listen on all available addresses (both IPv4 and IPv6).
+ If "bind_address" is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the peer will listen on all available addresses matching that IP type.
+ If "bind_address" is set to any valid address (e.g. "192.168.1.101", "::1", etc), the peer will only listen on the interface with that addresses (or fail if no interface with the given address exists).
</description>
</method>
<method name="set_send_address">
@@ -26354,7 +26359,7 @@
</constant>
</constants>
</class>
-<class name="Patch9Frame" inherits="Control" category="Core">
+<class name="Patch9Rect" inherits="Control" category="Core">
<brief_description>
</brief_description>
<description>
@@ -32557,7 +32562,7 @@
<constants>
</constants>
</class>
-<class name="ReferenceFrame" inherits="Control" category="Core">
+<class name="ReferenceRect" inherits="Control" category="Core">
<brief_description>
Reference frame for GUI.
</brief_description>
@@ -33832,7 +33837,7 @@
</signal>
<signal name="sleeping_state_changed">
<description>
- Emitted when the body changes it's sleeping state. Either by sleeping or waking up.
+ Emitted when the body changes its sleeping state. Either by sleeping or waking up.
</description>
</signal>
</signals>
@@ -34227,7 +34232,7 @@
</signal>
<signal name="sleeping_state_changed">
<description>
- Emitted when the body changes it's sleeping state. Either by sleeping or waking up.
+ Emitted when the body changes its sleeping state. Either by sleeping or waking up.
</description>
</signal>
</signals>
@@ -35446,6 +35451,13 @@
Returns true if this SceneTree's [NetworkedMultiplayerPeer] is in server mode (listening for connections).
</description>
</method>
+ <method name="has_network_peer" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ Returns true if there is a [NetworkedMultiplayerPeer] set (with [method SceneTree.set_network_peer]).
+ </description>
+ </method>
<method name="is_paused" qualifiers="const">
<return type="bool">
</return>
@@ -35889,7 +35901,7 @@
<return type="Error">
</return>
<description>
- Tries to wait for the [Semaphore], if it's value is zero, blocks until non-zero.
+ Tries to wait for the [Semaphore], if its value is zero, blocks until non-zero.
</description>
</method>
</methods>
@@ -40576,10 +40588,13 @@
</return>
<argument index="0" name="port" type="int">
</argument>
- <argument index="1" name="accepted_hosts" type="StringArray" default="StringArray([])">
+ <argument index="1" name="bind_address" type="String" default="*">
</argument>
<description>
- Listen on a port using protocol, alternatively give a white-list of accepted hosts.
+ Listen on the "port" binding to "bind_address".
+ If "bind_address" is set as "*" (default), the server will listen on all available addresses (both IPv4 and IPv6).
+ If "bind_address" is set as "0.0.0.0" (for IPv4) or "::" (for IPv6), the server will listen on all available addresses matching that IP type.
+ If "bind_address" is set to any valid address (e.g. "192.168.1.101", "::1", etc), the server will only listen on the interface with that addresses (or fail if no interface with the given address exists).
</description>
</method>
<method name="stop">
@@ -41638,7 +41653,7 @@
<constants>
</constants>
</class>
-<class name="TextureFrame" inherits="Control" category="Core">
+<class name="TextureRect" inherits="Control" category="Core">
<brief_description>
Control Frame that draws a texture.
</brief_description>
@@ -44205,7 +44220,7 @@
</argument>
<argument index="4" name="target_method" type="String">
</argument>
- <argument index="5" name="times_in_sec" type="float">
+ <argument index="5" name="duration" type="float">
</argument>
<argument index="6" name="trans_type" type="int">
</argument>
@@ -44214,7 +44229,7 @@
<argument index="8" name="delay" type="float" default="0">
</argument>
<description>
- Follow [code]method[/code] of [code]object[/code] and apply the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] later. Methods are animated by calling them with consequitive values.
+ Follow [code]method[/code] of [code]object[/code] and apply the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are animated by calling them with consequitive values.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
@@ -44231,7 +44246,7 @@
</argument>
<argument index="4" name="target_property" type="String">
</argument>
- <argument index="5" name="times_in_sec" type="float">
+ <argument index="5" name="duration" type="float">
</argument>
<argument index="6" name="trans_type" type="int">
</argument>
@@ -44240,7 +44255,7 @@
<argument index="8" name="delay" type="float" default="0">
</argument>
<description>
- Follow [code]property[/code] of [code]object[/code] and apply it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] seconds later. Note that [code]target:target_property[/code] would equal [code]object:property[/code] at the end of the tween.
+ Follow [code]property[/code] of [code]object[/code] and apply it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Note that [code]target:target_property[/code] would equal [code]object:property[/code] at the end of the tween.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
@@ -44270,7 +44285,7 @@
</return>
<argument index="0" name="object" type="Object">
</argument>
- <argument index="1" name="times_in_sec" type="float">
+ <argument index="1" name="duration" type="float">
</argument>
<argument index="2" name="callback" type="String">
</argument>
@@ -44285,7 +44300,7 @@
<argument index="7" name="arg5" type="Variant" default="NULL">
</argument>
<description>
- Call [code]callback[/code] of [code]object[/code] after [code]times_in_sec[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
+ Call [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
</description>
</method>
<method name="interpolate_deferred_callback">
@@ -44293,7 +44308,7 @@
</return>
<argument index="0" name="object" type="Object">
</argument>
- <argument index="1" name="times_in_sec" type="float">
+ <argument index="1" name="duration" type="float">
</argument>
<argument index="2" name="callback" type="String">
</argument>
@@ -44308,7 +44323,7 @@
<argument index="7" name="arg5" type="Variant" default="NULL">
</argument>
<description>
- Call [code]callback[/code] of [code]object[/code] after [code]times_in_sec[/code] on the main thread (similar to [methog Object.call_deferred). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
+ Call [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [methog Object.call_deferred). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback.
</description>
</method>
<method name="interpolate_method">
@@ -44322,7 +44337,7 @@
</argument>
<argument index="3" name="final_val" type="Variant">
</argument>
- <argument index="4" name="times_in_sec" type="float">
+ <argument index="4" name="duration" type="float">
</argument>
<argument index="5" name="trans_type" type="int">
</argument>
@@ -44331,7 +44346,7 @@
<argument index="7" name="delay" type="float" default="0">
</argument>
<description>
- Animate [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecuitive values.
+ Animate [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecuitive values.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
@@ -44346,7 +44361,7 @@
</argument>
<argument index="3" name="final_val" type="Variant">
</argument>
- <argument index="4" name="times_in_sec" type="float">
+ <argument index="4" name="duration" type="float">
</argument>
<argument index="5" name="trans_type" type="int">
</argument>
@@ -44355,7 +44370,7 @@
<argument index="7" name="delay" type="float" default="0">
</argument>
<description>
- Animate [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] seconds later.
+ Animate [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
@@ -44502,7 +44517,7 @@
</argument>
<argument index="4" name="final_val" type="Variant">
</argument>
- <argument index="5" name="times_in_sec" type="float">
+ <argument index="5" name="duration" type="float">
</argument>
<argument index="6" name="trans_type" type="int">
</argument>
@@ -44511,7 +44526,7 @@
<argument index="8" name="delay" type="float" default="0">
</argument>
<description>
- Animate [code]method[/code] of [code]object[/code] from the value returned by [code]initial.initial_method[/code] to [code]final_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecuitive values.
+ Animate [code]method[/code] of [code]object[/code] from the value returned by [code]initial.initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecuitive values.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
@@ -44528,7 +44543,7 @@
</argument>
<argument index="4" name="final_val" type="Variant">
</argument>
- <argument index="5" name="times_in_sec" type="float">
+ <argument index="5" name="duration" type="float">
</argument>
<argument index="6" name="trans_type" type="int">
</argument>
@@ -44537,7 +44552,7 @@
<argument index="8" name="delay" type="float" default="0">
</argument>
<description>
- Animate [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]times_in_sec[/code] seconds, [code]delay[/code] seconds later.
+ Animate [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later.
[code]trans_type[/code] accepts TRANS_* constants, and is the way the animation is interpolated, while [code]ease_type[/code] accepts EASE_* constants, and controls the place of the interpolation (the begining, the end, or both). You can read more about them in the class description.
</description>
</method>
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index b026241579..f2616b11b8 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -30,11 +30,9 @@
#ifdef ALSA_ENABLED
-#include <errno.h>
-#include "globals.h"
-
-
+#include "global_config.h"
+#include <errno.h>
Error AudioDriverALSA::init() {
@@ -46,7 +44,7 @@ Error AudioDriverALSA::init() {
samples_out = NULL;
mix_rate = GLOBAL_DEF("audio/mix_rate",44100);
- output_format = OUTPUT_STEREO;
+ speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
@@ -205,16 +203,18 @@ int AudioDriverALSA::get_mix_rate() const {
return mix_rate;
};
-AudioDriverSW::OutputFormat AudioDriverALSA::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
};
+
void AudioDriverALSA::lock() {
if (!thread || !mutex)
return;
mutex->lock();
};
+
void AudioDriverALSA::unlock() {
if (!thread || !mutex)
diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h
index df28294f56..6ab98312b2 100644
--- a/drivers/alsa/audio_driver_alsa.h
+++ b/drivers/alsa/audio_driver_alsa.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#ifdef ALSA_ENABLED
@@ -35,7 +35,7 @@
#include <alsa/asoundlib.h>
-class AudioDriverALSA : public AudioDriverSW {
+class AudioDriverALSA : public AudioDriver {
Thread* thread;
Mutex* mutex;
@@ -48,7 +48,7 @@ class AudioDriverALSA : public AudioDriverSW {
static void thread_func(void* p_udata);
unsigned int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
snd_pcm_uframes_t buffer_size;
snd_pcm_uframes_t period_size;
@@ -68,7 +68,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/drivers/convex_decomp/b2Glue.h b/drivers/convex_decomp/b2Glue.h
index 7ec6d7f181..425486356e 100644
--- a/drivers/convex_decomp/b2Glue.h
+++ b/drivers/convex_decomp/b2Glue.h
@@ -134,11 +134,13 @@ struct b2Vec2
return length;
}
- ///// Does this vector contain finite coordinates?
- //bool IsValid() const
- //{
- // return b2IsValid(x) && b2IsValid(y);
- //}
+ /*
+ /// Does this vector contain finite coordinates?
+ bool IsValid() const
+ {
+ return b2IsValid(x) && b2IsValid(y);
+ }
+ */
float32 x, y;
};
diff --git a/drivers/convex_decomp/b2Polygon.cpp b/drivers/convex_decomp/b2Polygon.cpp
index 73955d3573..b6ead62c63 100644
--- a/drivers/convex_decomp/b2Polygon.cpp
+++ b/drivers/convex_decomp/b2Polygon.cpp
@@ -189,7 +189,7 @@ void b2Polygon::MergeParallelEdges(float32 tolerance) {
x = newx;
y = newy;
nVertices = newNVertices;
-// printf("%d \n", newNVertices);
+ //printf("%d \n", newNVertices);
}
/*
@@ -353,7 +353,7 @@ bool b2Polygon::IsUsable(bool printErrors){
b2Vec2 centroid = PolyCentroid(vertices,nVertices);
b2Vec2 n1 = normals[iminus];
b2Vec2 n2 = normals[i];
- b2Vec2 v = vertices[i] - centroid;;
+ b2Vec2 v = vertices[i] - centroid;
b2Vec2 d;
d.x = b2Dot(n1, v) - toiSlop;
@@ -436,7 +436,6 @@ bool b2Polygon::IsSimple() {
* For internal use.
*/
b2Polygon* b2Polygon::Add(b2Triangle& t) {
-// float32 equalTol = .001f;
// First, find vertices that connect
int32 firstP = -1;
int32 firstT = -1;
@@ -963,7 +962,7 @@ int32 DecomposeConvex(b2Polygon* p, b2Polygon* results, int32 maxPolys) {
tempP.Set(*p);
ReversePolygon(tempP.x, tempP.y, tempP.nVertices);
nTri = TriangulatePolygon(tempP.x, tempP.y, tempP.nVertices, triangulated);
-// ReversePolygon(p->x, p->y, p->nVertices); //reset orientation
+ //ReversePolygon(p->x, p->y, p->nVertices); //reset orientation
} else {
//printf("It is not ccw \n");
nTri = TriangulatePolygon(p->x, p->y, p->nVertices, triangulated);
@@ -997,7 +996,7 @@ void DecomposeConvexAndAddTo(b2Polygon* p, b2Body* bd, b2FixtureDef* prototype)
if (p->nVertices < 3) return;
b2Polygon* decomposed = new b2Polygon[p->nVertices - 2]; //maximum number of polys
int32 nPolys = DecomposeConvex(p, decomposed, p->nVertices - 2);
-// printf("npolys: %d",nPolys);
+ //printf("npolys: %d",nPolys);
b2FixtureDef* pdarray = new b2FixtureDef[2*p->nVertices];//extra space in case of splits
int32 extra = 0;
for (int32 i = 0; i < nPolys; ++i) {
@@ -1362,14 +1361,15 @@ b2Polygon TraceEdge(b2Polygon* p){
//printf("knode %d on node %d now has %d connections\n",k,j,knode->nConnected);
//printf("Found duplicate point.\n");
}
- //printf("Orphaning node at address %d\n",(int)jnode);
- //for (int32 k=0; k<njConn; ++k) {
- // if (jnode->connected[k]->IsConnectedTo(*jnode)) printf("Problem!!!\n");
- //}
/*
+ printf("Orphaning node at address %d\n",(int)jnode);
+ for (int32 k=0; k<njConn; ++k) {
+ if (jnode->connected[k]->IsConnectedTo(*jnode)) printf("Problem!!!\n");
+ }
for (int32 k=0; k < njConn; ++k){
jnode->RemoveConnectionByIndex(k);
- }*/
+ }
+ */
jnode->nConnected = 0;
}
}
diff --git a/drivers/convex_decomp/b2Polygon.h b/drivers/convex_decomp/b2Polygon.h
index 36af2fd9d0..c466e28f7e 100644
--- a/drivers/convex_decomp/b2Polygon.h
+++ b/drivers/convex_decomp/b2Polygon.h
@@ -74,9 +74,11 @@ public:
void print(){
printFormatted();
-// for (int32 i=0; i<nVertices; ++i){
-// printf("i: %d, x:%f, y:%f\n",i,x[i],y[i]);
-// }
+ /*
+ for (int32 i=0; i<nVertices; ++i){
+ printf("i: %d, x:%f, y:%f\n",i,x[i],y[i]);
+ }
+ */
}
void printFormatted(){
diff --git a/drivers/convex_decomp/b2d_decompose.cpp b/drivers/convex_decomp/b2d_decompose.cpp
index 82eade5b69..f84faaf586 100644
--- a/drivers/convex_decomp/b2d_decompose.cpp
+++ b/drivers/convex_decomp/b2d_decompose.cpp
@@ -144,7 +144,7 @@ static Vector< Vector<Vector2> > _b2d_decompose(const Vector<Vector2>& p_polygon
Skip:
;
}
-// delete[] pdarray;
+ //delete[] pdarray;
delete[] decomposed;
delete p;
return res;// pdarray; //needs to be deleted after body is created
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 2673c79232..94c5ecdec1 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -30,7 +30,7 @@
#include "rasterizer_gles2.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include <stdio.h>
#include "servers/visual/shader_language.h"
#include "servers/visual/particle_system_sw.h"
@@ -915,7 +915,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I
if (scale_textures) {
texture->alloc_width = po2_width;
texture->alloc_height = po2_height;
- // print_line("scale because npo2: "+itos(npo2_textures_available)+" mm: "+itos(p_format&VS::TEXTURE_FLAG_MIPMAPS)+" "+itos(p_mipmap_count) );
+ //print_line("scale because npo2: "+itos(npo2_textures_available)+" mm: "+itos(p_format&VS::TEXTURE_FLAG_MIPMAPS)+" "+itos(p_mipmap_count) );
} else {
texture->alloc_width = texture->width;
@@ -1910,7 +1910,7 @@ void RasterizerGLES2::mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,
use_VBO=false;
}
-// surface->packed=pack_arrays && use_VBO;
+ //surface->packed=pack_arrays && use_VBO;
int total_elem_size=0;
@@ -3259,7 +3259,7 @@ void RasterizerGLES2::particles_set_emitting(RID p_particles, bool p_emitting) {
Particles* particles = particles_owner.get( p_particles );
ERR_FAIL_COND(!particles);
- particles->data.emitting=p_emitting;;
+ particles->data.emitting=p_emitting;
}
bool RasterizerGLES2::particles_is_emitting(RID p_particles) const {
@@ -3468,7 +3468,7 @@ void RasterizerGLES2::particles_set_attractor_pos(RID p_particles, int p_attract
Particles* particles = particles_owner.get( p_particles );
ERR_FAIL_COND(!particles);
ERR_FAIL_INDEX(p_attractor,particles->data.attractor_count);
- particles->data.attractors[p_attractor].pos=p_pos;;
+ particles->data.attractors[p_attractor].pos=p_pos;
}
Vector3 RasterizerGLES2::particles_get_attractor_pos(RID p_particles,int p_attractor) const {
@@ -3917,7 +3917,7 @@ void RasterizerGLES2::light_instance_set_shadow_transform(RID p_light_instance,
ERR_FAIL_COND(!lighti);
ERR_FAIL_COND(lighti->base->type!=VS::LIGHT_DIRECTIONAL);
-// ERR_FAIL_INDEX(p_index,1);
+ //ERR_FAIL_INDEX(p_index,1);
lighti->custom_projection[p_index]=p_camera;
lighti->custom_transform[p_index]=p_transform;
@@ -4043,8 +4043,10 @@ RID RasterizerGLES2::viewport_data_create() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0,
- // GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ /*
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ */
glTexImage2D(GL_TEXTURE_2D, 0, format_luminance, 1, 1, 0,
format_luminance_components, format_luminance_type, NULL);
@@ -4295,11 +4297,11 @@ void RasterizerGLES2::begin_frame() {
draw_next_frame=false;
-// material_shader.set_uniform_default(MaterialShaderGLES2::SCREENZ_SCALE, Math::fmod(time, 3600.0));
+ //material_shader.set_uniform_default(MaterialShaderGLES2::SCREENZ_SCALE, Math::fmod(time, 3600.0));
/* nehe ?*/
-// glClearColor(0,0,1,1);
-// glClear(GL_COLOR_BUFFER_BIT); //should not clear if anything else cleared..
+ //glClearColor(0,0,1,1);
+ //glClear(GL_COLOR_BUFFER_BIT); //should not clear if anything else cleared..
}
void RasterizerGLES2::capture_viewport(Image* r_capture) {
@@ -4329,7 +4331,7 @@ void RasterizerGLES2::capture_viewport(Image* r_capture) {
PoolVector<uint8_t>::Write w = pixels.write();
glPixelStorei(GL_PACK_ALIGNMENT, 4);
-// uint64_t time = OS::get_singleton()->get_ticks_usec();
+ //uint64_t time = OS::get_singleton()->get_ticks_usec();
if (current_rt) {
#ifdef GLEW_ENABLED
@@ -4456,7 +4458,7 @@ void RasterizerGLES2::begin_shadow_map( RID p_light_instance, int p_shadow_pass
opaque_render_list.clear();
alpha_render_list.clear();
-// pre_zpass_render_list.clear();
+ //pre_zpass_render_list.clear();
light_instance_count=0;
glCullFace(GL_FRONT);
@@ -4614,7 +4616,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
//print_line("compiled fragment: "+fragment_code);
- // ("compiled fragment globals: "+fragment_globals);
+ //("compiled fragment globals: "+fragment_globals);
//print_line("UCF: "+itos(p_shader->uniforms.size()));
@@ -5128,9 +5130,11 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
ud.value=E->value().default_value;
old_inuse=false; //if reverted to default, obviously did not work
- //print_line("NEW: "+String(E->key())+" because: hasold-"+itos(old_mparams.has(E->key())));
- //if (old_mparams.has(E->key()))
- // print_line(" told "+Variant::get_type_name(old_mparams[E->key()].value.get_type())+" tnew "+Variant::get_type_name(E->value().default_value.get_type()));
+ /*
+ print_line("NEW: "+String(E->key())+" because: hasold-"+itos(old_mparams.has(E->key())));
+ if (old_mparams.has(E->key()))
+ print_line(" told "+Variant::get_type_name(old_mparams[E->key()].value.get_type())+" tnew "+Variant::get_type_name(E->value().default_value.get_type()));
+ */
}
@@ -5216,12 +5220,14 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
if (p_material->shader_cache && p_material->shader_cache->valid) {
- // // reduce amount of conditional compilations
- // for(int i=0;i<_tex_version_count;i++)
- // material_shader.set_conditional((MaterialShaderGLES2::Conditionals)_tex_version[i],false);
+ /*
+ // reduce amount of conditional compilations
+ for(int i=0;i<_tex_version_count;i++)
+ material_shader.set_conditional((MaterialShaderGLES2::Conditionals)_tex_version[i],false);
+ */
- // material_shader.set_custom_shader(p_material->shader_cache->custom_code_id);
+ //material_shader.set_custom_shader(p_material->shader_cache->custom_code_id);
if (p_material->shader_version!=p_material->shader_cache->version) {
//shader changed somehow, must update uniforms
@@ -5241,7 +5247,7 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
if (E->get().index<0)
continue;
-// print_line(String(E->key())+": "+E->get().value);
+ //print_line(String(E->key())+": "+E->get().value);
if (E->get().istexture) {
//clearly a texture..
RID rid = E->get().value;
@@ -5418,13 +5424,7 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
if (li->near_shadow_buffer) {
glActiveTexture(GL_TEXTURE0+max_texture_units-1);
- //if (read_depth_supported) {
-
- glBindTexture(GL_TEXTURE_2D,li->near_shadow_buffer->depth);
- //} else {
-
-
- //}
+ glBindTexture(GL_TEXTURE_2D,li->near_shadow_buffer->depth);
material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX,li->shadow_projection[0]);
material_shader.set_uniform(MaterialShaderGLES2::SHADOW_TEXEL_SIZE,Vector2(1.0,1.0)/li->near_shadow_buffer->size);
@@ -5944,8 +5944,10 @@ Error RasterizerGLES2::_setup_geometry(const Geometry *p_geometry, const Materia
const Surface::ArrayData& ad=surf->array[i];
-// if (!gl_texcoord_shader[i])
-// continue;
+ /*
+ if (!gl_texcoord_shader[i])
+ continue;
+ */
if (ad.size==0 || ! ad.bind) {
glDisableVertexAttribArray(i);
@@ -5957,7 +5959,7 @@ Error RasterizerGLES2::_setup_geometry(const Geometry *p_geometry, const Materia
}
glEnableVertexAttribArray(i);
-// print_line("set: "+itos(i)+" - count: "+itos(ad.count)+" datatype: "+itos(ad.datatype)+" ofs: "+itos(ad.ofs)+" stride: "+itos(stride)+" total len: "+itos(surf->array_len));
+ //print_line("set: "+itos(i)+" - count: "+itos(ad.count)+" datatype: "+itos(ad.datatype)+" ofs: "+itos(ad.ofs)+" stride: "+itos(stride)+" total len: "+itos(surf->array_len));
glVertexAttribPointer(i, ad.count, ad.datatype, ad.normalize, stride, &base[ad.ofs]);
}
@@ -6015,7 +6017,7 @@ void RasterizerGLES2::_render(const Geometry *p_geometry,const Material *p_mater
glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len>(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, s->index_array_local);
} else {
- // print_line("indices: "+itos(s->index_array_local) );
+ //print_line("indices: "+itos(s->index_array_local) );
//print_line("VBO F: "+itos(s->format)+" C: "+itos(s->index_array_len)+" VC: "+itos(s->array_len));
@@ -6405,7 +6407,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_conditional(MaterialShaderGLES2::SHADELESS,false);
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE,false);
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
-// material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_TEXTURE,false);
+ //material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_TEXTURE,false);
}
@@ -6956,7 +6958,7 @@ void RasterizerGLES2::_process_glow_bloom() {
glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::HDR_SOURCE),2);
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::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_SCALE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]));
@@ -7040,7 +7042,7 @@ void RasterizerGLES2::_process_hdr() {
_copy_screen_quad();
copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_COPY,false);
-// int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES];
+ //int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES];
copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_REDUCE,true);
copy_shader.bind();
@@ -7345,7 +7347,7 @@ void RasterizerGLES2::end_scene() {
print_line(String("setting camera to ")+camera_transform_inverse);
*/
-// material_shader.set_uniform_default(MaterialShaderGLES2::CAMERA_INVERSE, camera_transform_inverse);
+ //material_shader.set_uniform_default(MaterialShaderGLES2::CAMERA_INVERSE, camera_transform_inverse);
current_depth_test=true;
@@ -7391,7 +7393,7 @@ void RasterizerGLES2::end_scene() {
_render_list_forward(&alpha_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting,true);
glColorMask(1,1,1,1);
-// material_shader.set_conditional( MaterialShaderGLES2::USE_FOG,false);
+ //material_shader.set_conditional( MaterialShaderGLES2::USE_FOG,false);
DEBUG_TEST_ERROR("Drawing Scene");
@@ -7534,8 +7536,8 @@ void RasterizerGLES2::end_scene() {
if (GLOBAL_DEF("rasterizer/debug_shadow_maps",false)) {
_debug_shadows();
}
-// _debug_luminances();
-// _debug_samplers();
+ //_debug_luminances();
+ //_debug_samplers();
if (using_canvas_bg) {
using_canvas_bg=false;
@@ -7853,7 +7855,7 @@ void RasterizerGLES2::_debug_draw_shadow(GLuint tex, const Rect2& p_rect) {
- Matrix32 modelview;
+ Transform2D modelview;
modelview.translate(p_rect.pos.x, p_rect.pos.y);
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, modelview);
glBindTexture(GL_TEXTURE_2D,tex);
@@ -7884,7 +7886,7 @@ void RasterizerGLES2::_debug_draw_shadows_type(Vector<ShadowBuffer>& p_shadows,P
Size2 debug_size(128,128);
-// Size2 debug_size(512,512);
+ //Size2 debug_size(512,512);
int useblur=shadow_filter==SHADOW_FILTER_ESM?1:0;
@@ -7989,7 +7991,7 @@ void RasterizerGLES2::_debug_shadows() {
_debug_draw_shadows_type(near_shadow_buffers,ofs);
-// _debug_draw_shadows_type(far_shadow_buffers,ofs);
+ //_debug_draw_shadows_type(far_shadow_buffers,ofs);
}
@@ -8071,8 +8073,8 @@ void RasterizerGLES2::canvas_begin() {
canvas_transform.scale( Vector3( 2.0f / viewport.width, csy * -2.0f / viewport.height, 1.0f ) );
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
- canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,Matrix32());
- canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
+ canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,Transform2D());
+ canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Transform2D());
canvas_opacity=1.0;
canvas_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
@@ -8136,11 +8138,11 @@ void RasterizerGLES2::canvas_set_blend_mode(VS::MaterialBlendMode p_mode) {
}
-void RasterizerGLES2::canvas_begin_rect(const Matrix32& p_transform) {
+void RasterizerGLES2::canvas_begin_rect(const Transform2D& p_transform) {
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,p_transform);
- canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
+ canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Transform2D());
}
@@ -8668,7 +8670,7 @@ void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int* p_indic
};
-void RasterizerGLES2::canvas_set_transform(const Matrix32& p_transform) {
+void RasterizerGLES2::canvas_set_transform(const Transform2D& p_transform) {
canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,p_transform);
@@ -8841,11 +8843,11 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) {
} else {
// We'll use a RGBA texture into which we pack the depth info
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cls->size, cls->height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Attach the RGBA texture to FBO color attachment point
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, cls->depth, 0);
+ GL_TEXTURE_2D, cls->depth, 0);
cls->rgba=cls->depth;
// Allocate 16-bit depth buffer
@@ -8853,7 +8855,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) {
// Attach the render buffer as depth buffer - will be ignored
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, cls->rbo);
+ GL_RENDERBUFFER, cls->rbo);
}
@@ -8878,7 +8880,7 @@ RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) {
return canvas_light_shadow_owner.make_rid(cls);
}
-void RasterizerGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Matrix32& p_light_xform, int p_light_mask,float p_near, float p_far, CanvasLightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache) {
+void RasterizerGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D& p_light_xform, int p_light_mask,float p_near, float p_far, CanvasLightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache) {
CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_buffer);
ERR_FAIL_COND(!cls);
@@ -8922,7 +8924,7 @@ void RasterizerGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Matr
//light.basis.scale(Vector3(to_light.elements[0].length(),to_light.elements[1].length(),1));
- /// p_near=1;
+ / //p_near=1;
CameraMatrix projection;
{
real_t fov = 90;
@@ -9121,10 +9123,10 @@ void RasterizerGLES2::canvas_debug_viewport_shadows(CanvasLight* p_lights_with_s
//print_line(" debug lights ");
while(light) {
- // print_line("debug light");
+ //print_line("debug light");
if (light->shadow_buffer.is_valid()) {
- // print_line("sb is valid");
+ //print_line("sb is valid");
CanvasLightShadow * sb = canvas_light_shadow_owner.get(light->shadow_buffer);
if (sb) {
glActiveTexture(GL_TEXTURE0);
@@ -9172,7 +9174,7 @@ void RasterizerGLES2::_canvas_item_render_commands(CanvasItem *p_item,CanvasItem
case CanvasItem::Command::TYPE_RECT: {
CanvasItem::CommandRect* rect = static_cast<CanvasItem::CommandRect*>(c);
-// canvas_draw_rect(rect->rect,rect->region,rect->source,rect->flags&CanvasItem::CommandRect::FLAG_TILE,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V,rect->texture,rect->modulate);
+ //canvas_draw_rect(rect->rect,rect->region,rect->source,rect->flags&CanvasItem::CommandRect::FLAG_TILE,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V,rect->texture,rect->modulate);
#if 0
int flags=0;
@@ -9344,9 +9346,6 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(CanvasItemMaterial *mater
} else {
glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height);
}
-// if (current_clip) {
-// // print_line(" a clip ");
-// }
canvas_texscreen_used=true;
}
@@ -9603,7 +9602,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
- canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
+ canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Transform2D());
bool reclip=false;
@@ -9716,7 +9715,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
}
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
- canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
+ canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Transform2D());
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
if (canvas_use_modulate)
canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE,canvas_modulate);
@@ -9783,7 +9782,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
}
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
- canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
+ canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Transform2D());
if (canvas_use_modulate)
canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE,canvas_modulate);
@@ -9925,8 +9924,8 @@ RID RasterizerGLES2::sampled_light_dp_create(int p_width,int p_height) {
glGenTextures(1,&slight->texture);
glBindTexture(GL_TEXTURE_2D, slight->texture);
// for debug, but glitchy
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -10046,7 +10045,7 @@ void RasterizerGLES2::free(const RID& p_rid) {
// delete the texture
Texture *texture = texture_owner.get(p_rid);
-// glDeleteTextures( 1,&texture->tex_id );
+ //glDeleteTextures( 1,&texture->tex_id );
_rinfo.texture_mem-=texture->total_data_size;
texture_owner.free(p_rid);
memdelete(texture);
@@ -10232,9 +10231,11 @@ void RasterizerGLES2::free(const RID& p_rid) {
glDeleteFramebuffers(1,&cls->fbo);
glDeleteRenderbuffers(1,&cls->rbo);
glDeleteTextures(1,&cls->depth);
- //if (!read_depth_supported) {
- // glDeleteTextures(1,&cls->rgba);
- //}
+ /*
+ if (!read_depth_supported) {
+ glDeleteTextures(1,&cls->rgba);
+ }
+ */
canvas_light_shadow_owner.free(p_rid);
memdelete(cls);
@@ -10286,18 +10287,18 @@ bool RasterizerGLES2::ShadowBuffer::init(int p_size,bool p_use_depth) {
} else {
// We'll use a RGBA texture into which we pack the depth info
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Attach the RGBA texture to FBO color attachment point
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, depth, 0);
+ GL_TEXTURE_2D, depth, 0);
// Allocate 16-bit depth buffer
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size,size);
// Attach the render buffer as depth buffer - will be ignored
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, rbo);
+ GL_RENDERBUFFER, rbo);
}
@@ -10332,8 +10333,8 @@ bool RasterizerGLES2::ShadowBuffer::init(int p_size,bool p_use_depth) {
} else {
-// glGenRenderbuffers(1, &rbo);
-// glBindRenderbuffer(GL_RENDERBUFFER, rbo);
+ //glGenRenderbuffers(1, &rbo);
+ //glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glGenTextures(1, &depth);
glBindTexture(GL_TEXTURE_2D, depth);
@@ -10383,20 +10384,21 @@ bool RasterizerGLES2::ShadowBuffer::init(int p_size,bool p_use_depth) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, size, size, 0,
-// GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, NULL);
+ //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, size, size, 0,
+ //GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, NULL);
- // Attach the RGBA texture to FBO color attachment point
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, blur, 0);
+ // Attach the RGBA texture to FBO color attachment point
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, blur, 0);
- // Allocate 16-bit depth buffer
- /* glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size, size);
+ // Allocate 16-bit depth buffer
+ /*
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size, size);
- // Attach the render buffer as depth buffer - will be ignored
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, rbo_blur);
-*/
+ // Attach the render buffer as depth buffer - will be ignored
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
+ GL_RENDERBUFFER, rbo_blur);
+ */
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
OS::get_singleton()->print("Status: %x\n",status);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -10502,7 +10504,7 @@ void RasterizerGLES2::_update_framebuffer() {
#endif
//color
-// GLuint format_rgba = use_fp16_fb?_GL_RGBA16F_EXT:GL_RGBA;
+ //GLuint format_rgba = use_fp16_fb?_GL_RGBA16F_EXT:GL_RGBA;
GLuint format_rgba = GL_RGBA;
GLuint format_type = use_fp16_fb?_GL_HALF_FLOAT_OES:GL_UNSIGNED_BYTE;
GLuint format_internal=GL_RGBA;
@@ -10528,8 +10530,8 @@ void RasterizerGLES2::_update_framebuffer() {
glTexImage2D(GL_TEXTURE_2D, 0, format_rgba, framebuffer.width, framebuffer.height, 0, format_internal, format_type, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.color, 0);
@@ -10562,8 +10564,8 @@ void RasterizerGLES2::_update_framebuffer() {
glTexImage2D(GL_TEXTURE_2D, 0, format_rgba, framebuffer.width, framebuffer.height, 0, format_internal, format_type, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.sample_color, 0);
@@ -10730,9 +10732,9 @@ void RasterizerGLES2::_update_blur_buffer() {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, framebuffer.blur[i].color, 0);
+ GL_TEXTURE_2D, framebuffer.blur[i].color, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -10915,9 +10917,9 @@ void RasterizerGLES2::init() {
framebuffer.fbo=0;
framebuffer.width=0;
framebuffer.height=0;
-// framebuffer.buff16=false;
-// framebuffer.blur[0].fbo=false;
-// framebuffer.blur[1].fbo=false;
+ //framebuffer.buff16=false;
+ //framebuffer.blur[0].fbo=false;
+ //framebuffer.blur[1].fbo=false;
framebuffer.active=false;
@@ -10945,8 +10947,8 @@ void RasterizerGLES2::init() {
use_depth24 =true;
s3tc_supported = true;
atitc_supported = false;
-// use_texture_instancing=false;
-// use_attribute_instancing=true;
+ //use_texture_instancing=false;
+ //use_attribute_instancing=true;
use_texture_instancing=false;
use_attribute_instancing=true;
full_float_fb_supported=true;
@@ -11017,8 +11019,10 @@ void RasterizerGLES2::init() {
use_hw_skeleton_xform=vtf>0 && float_supported;
float_linear_supported = extensions.has("GL_OES_texture_float_linear");
- //if (extensions.has("GL_QCOM_tiled_rendering"))
- // use_hw_skeleton_xform=false;
+ /*
+ if (extensions.has("GL_QCOM_tiled_rendering"))
+ use_hw_skeleton_xform=false;
+ */
GLint mva;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS,&mva);
if (vtf==0 && mva>8) {
@@ -11195,7 +11199,7 @@ void RasterizerGLES2::set_extensions(const char *p_strings) {
for(int i=0;i<strings.size();i++) {
extensions.insert(strings[i]);
-// print_line(strings[i]);
+ //print_line(strings[i]);
}
}
diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h
index c6057bfd88..ddcd97ec4a 100644
--- a/drivers/gles2/rasterizer_gles2.h
+++ b/drivers/gles2/rasterizer_gles2.h
@@ -1429,7 +1429,7 @@ public:
virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color);
virtual RID multimesh_get_mesh(RID p_multimesh) const;
- virtual AABB multimesh_get_aabb(RID p_multimesh) const;;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const;
virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const;
virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const;
@@ -1630,7 +1630,7 @@ public:
virtual void canvas_set_opacity(float p_opacity);
virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode);
- virtual void canvas_begin_rect(const Matrix32& p_transform);
+ virtual void canvas_begin_rect(const Transform2D& p_transform);
virtual void canvas_set_clip(bool p_clip, const Rect2& p_rect);
virtual void canvas_end_rect();
virtual void canvas_draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width,bool p_antialiased);
@@ -1638,7 +1638,7 @@ public:
virtual void canvas_draw_style_box(const Rect2& p_rect, const Rect2& p_src_region, RID p_texture,const float *p_margins, bool p_draw_center=true,const Color& p_modulate=Color(1,1,1));
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width);
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
- virtual void canvas_set_transform(const Matrix32& p_transform);
+ virtual void canvas_set_transform(const Transform2D& p_transform);
virtual void canvas_render_items(CanvasItem *p_item_list,int p_z,const Color& p_modulate,CanvasLight *p_light);
virtual void canvas_debug_viewport_shadows(CanvasLight* p_lights_with_shadow);
@@ -1647,7 +1647,7 @@ public:
//buffer
virtual RID canvas_light_shadow_buffer_create(int p_width);
- virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Matrix32& p_light_xform, int p_light_mask,float p_near, float p_far, CanvasLightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache);
+ virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D& p_light_xform, int p_light_mask,float p_near, float p_far, CanvasLightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache);
//occluder
virtual RID canvas_light_occluder_create();
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index adb9fe0e83..a5aa570e33 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -435,13 +435,14 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
//create the call to sample the screen, and clamp it
uses_texpos=true;
code="get_texpos("+dump_node_code(onode->arguments[1],p_level)+"";
-// code="get_texpos(gl_ProjectionMatrixInverse * texture2D( depth_texture, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy,vec2(0.0),vec2(1.0))*gl_LightSource[5].specular.zw+gl_LightSource[5].specular.xy)";
+ //code="get_texpos(gl_ProjectionMatrixInverse * texture2D( depth_texture, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy,vec2(0.0),vec2(1.0))*gl_LightSource[5].specular.zw+gl_LightSource[5].specular.xy)";
//code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb";
break;
} else if (custom_h && callfunc=="cosh_custom") {
if (!cosh_used) {
- global_code= "float cosh_custom(float val)\n"\
+ global_code=
+ "float cosh_custom(float val)\n"\
"{\n"\
" float tmp = exp(val);\n"\
" float cosH = (tmp + 1.0 / tmp) / 2.0;\n"\
@@ -453,7 +454,8 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
} else if (custom_h && callfunc=="sinh_custom") {
if (!sinh_used) {
- global_code= "float sinh_custom(float val)\n"\
+ global_code=
+ "float sinh_custom(float val)\n"\
"{\n"\
" float tmp = exp(val);\n"\
" float sinH = (tmp - 1.0 / tmp) / 2.0;\n"\
@@ -465,7 +467,8 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
} else if (custom_h && callfunc=="tanh_custom") {
if (!tanh_used) {
- global_code= "float tanh_custom(float val)\n"\
+ global_code=
+ "float tanh_custom(float val)\n"\
"{\n"\
" float tmp = exp(val);\n"\
" float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n"\
@@ -571,12 +574,13 @@ Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) {
global_code+=uline;
if (uniforms) {
- //if (uniforms->has(E->key())) {
- // //repeated uniform, error
- // ERR_EXPLAIN("Uniform already exists from other shader: "+String(E->key()));
- // ERR_FAIL_COND_V(uniforms->has(E->key()),ERR_ALREADY_EXISTS);
-//
-// }
+ /*
+ if (uniforms->has(E->key())) {
+ //repeated uniform, error
+ ERR_EXPLAIN("Uniform already exists from other shader: "+String(E->key()));
+ ERR_FAIL_COND_V(uniforms->has(E->key()),ERR_ALREADY_EXISTS);
+ }
+ */
SL::Uniform u = E->get();
u.order+=ubase;
uniforms->insert(E->key(),u);
@@ -812,8 +816,8 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"]="var1_interp";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"]="var2_interp";
-// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS";
-// mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE";
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS";
+ //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"]="instance_id";
mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"]="time";
diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp
index 2ee89e9895..97c31dfc1c 100644
--- a/drivers/gles2/shader_gles2.cpp
+++ b/drivers/gles2/shader_gles2.cpp
@@ -561,7 +561,7 @@ ShaderGLES2::Version* ShaderGLES2::get_current_version() {
v.uniform_location[j]=glGetUniformLocation(v.id,uniform_names[j]);
- // print_line("uniform "+String(uniform_names[j])+" location "+itos(v.uniform_location[j]));
+ //print_line("uniform "+String(uniform_names[j])+" location "+itos(v.uniform_location[j]));
}
// set texture uniforms
diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h
index ea9958741a..004d636c1e 100644
--- a/drivers/gles2/shader_gles2.h
+++ b/drivers/gles2/shader_gles2.h
@@ -134,7 +134,7 @@ private:
struct VersionKeyHash {
- static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHahserDefault::hash(p_key.key); };
+ static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHasherDefault::hash(p_key.key); };
};
//this should use a way more cachefriendly version..
@@ -213,7 +213,7 @@ private:
case Variant::MATRIX32: {
- Matrix32 tr=p_value;
+ Transform2D tr=p_value;
GLfloat matrix[16]={ /* build a 16x16 matrix */
tr.elements[0][0],
tr.elements[0][1],
diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl
index eeab42ee64..4bcebbd69d 100644
--- a/drivers/gles2/shaders/canvas.glsl
+++ b/drivers/gles2/shaders/canvas.glsl
@@ -392,7 +392,7 @@ LIGHT_SHADER_CODE
//use lighting
#endif
-// color.rgb*=color.a;
+ //color.rgb*=color.a;
gl_FragColor = color;
diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl
index e5be25757d..704a22c5d1 100644
--- a/drivers/gles2/shaders/material.glsl
+++ b/drivers/gles2/shaders/material.glsl
@@ -820,7 +820,7 @@ void main() {
vec3 binormal = normalize(binormal_interp)*side;
vec3 tangent = normalize(tangent_interp)*side;
#endif
-// vec3 normal = abs(normalize(normal_interp))*side;
+ //vec3 normal = abs(normalize(normal_interp))*side;
vec3 normal = normalize(normal_interp)*side;
#if defined(ENABLE_SCREEN_UV)
vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult;
@@ -989,7 +989,7 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_USE_PSSM
-// if (vertex_interp.z > light_pssm_split) {
+ //if (vertex_interp.z > light_pssm_split) {
#if 0
highp vec3 splane = vec3(0.0,0.0,0.0);
@@ -1261,12 +1261,12 @@ LIGHT_SHADER_CODE
vec3 ambient = const_light_mult*ambient_light*diffuse.rgb;
# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT)
-// ambient*=diffuse_interp.a; //attenuation affects ambient too
+ //ambient*=diffuse_interp.a; //attenuation affects ambient too
# endif
-// diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient;
-// diffuse.rgb+=emission * const_light_mult;
+ //diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient;
+ //diffuse.rgb+=emission * const_light_mult;
diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient;
diffuse.rgb+=emission * const_light_mult;
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 3c3768be67..9f44d05580 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1,6 +1,10 @@
#include "rasterizer_canvas_gles3.h"
#include "os/os.h"
+#ifndef GLES_OVER_GL
+#define glClearDepth glClearDepthf
+#endif
+
static _FORCE_INLINE_ void store_transform2d(const Transform2D& p_mtx, float* p_array) {
p_array[ 0]=p_mtx.elements[0][0];
@@ -87,7 +91,7 @@ void RasterizerCanvasGLES3::light_internal_update(RID p_rid, Light* p_light) {
if (p_light->radius_cache==0)
li->ubo_data.shadow_gradient=0;
else
- li->ubo_data.shadow_gradient=p_light->shadow_gradient_length/(p_light->radius_cache*1.1);;
+ li->ubo_data.shadow_gradient=p_light->shadow_gradient_length/(p_light->radius_cache*1.1);
li->ubo_data.shadow_distance_mult=(p_light->radius_cache*1.1);
@@ -147,7 +151,7 @@ void RasterizerCanvasGLES3::canvas_begin(){
-// state.canvas_shader.set_uniform(CanvasShaderGLES3::PROJECTION_MATRIX,state.vp);
+ //state.canvas_shader.set_uniform(CanvasShaderGLES3::PROJECTION_MATRIX,state.vp);
//state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX,Transform());
//state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX,Transform());
@@ -378,7 +382,7 @@ void RasterizerCanvasGLES3::_draw_gui_primitive(int p_points, const Vector2 *p_v
}
- float b[(2+2+4)];
+ float b[(2+2+4)*4];
for(int i=0;i<p_points;i++) {
@@ -642,7 +646,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item,Item *curr
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE,texpixel_size);
}
- _draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1);
+ //_draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1);
} break;
case Item::Command::TYPE_CIRCLE: {
@@ -662,7 +666,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item,Item *curr
indices[i*3+1]=(i+1)%numpoints;
indices[i*3+2]=numpoints;
}
- _draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true);
+ //_draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true);
//canvas_draw_circle(circle->indices.size(),circle->indices.ptr(),circle->points.ptr(),circle->uvs.ptr(),circle->colors.ptr(),circle->texture,circle->colors.size()==1);
} break;
case Item::Command::TYPE_TRANSFORM: {
@@ -743,9 +747,6 @@ void RasterizerGLES2::_canvas_item_setup_shader_params(CanvasItemMaterial *mater
} else {
glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height);
}
-// if (current_clip) {
-// // print_line(" a clip ");
-// }
canvas_texscreen_used=true;
}
@@ -1009,7 +1010,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list,int p_z,const
if (unshaded || (state.canvas_item_modulate.a>0.001 && (!shader_cache || shader_cache->canvas_item.light_mode!=RasterizerStorageGLES3::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !ci->light_masked ))
_canvas_item_render_commands(ci,current_clip,reclip);
- if ((blend_mode==RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX || RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA) && p_light && !unshaded) {
+ if ((blend_mode==RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_MIX || blend_mode==RasterizerStorageGLES3::Shader::CanvasItem::BLEND_MODE_PMALPHA) && p_light && !unshaded) {
Light *light = p_light;
bool light_used=false;
@@ -1141,7 +1142,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list,int p_z,const
state.canvas_shader.set_uniform(CanvasShaderGLES3::MODELVIEW_MATRIX,state.final_transform);
- state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX,Matrix32());
+ state.canvas_shader.set_uniform(CanvasShaderGLES3::EXTRA_MATRIX,Transform2D());
state.canvas_shader.set_uniform(CanvasShaderGLES3::FINAL_MODULATE,state.canvas_item_modulate);
glBlendEquation(GL_FUNC_ADD);
@@ -1193,10 +1194,10 @@ void RasterizerCanvasGLES3::canvas_debug_viewport_shadows(Light* p_lights_with_s
while(light) {
- // print_line("debug light");
+ //print_line("debug light");
if (light->shadow_buffer.is_valid()) {
- // print_line("sb is valid");
+ //print_line("sb is valid");
RasterizerStorageGLES3::CanvasLightShadow * sb = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
if (sb) {
glBindTexture(GL_TEXTURE_2D,sb->distance);
@@ -1253,7 +1254,7 @@ void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, cons
//light.basis.scale(Vector3(to_light.elements[0].length(),to_light.elements[1].length(),1));
- /// p_near=1;
+ //p_near=1;
CameraMatrix projection;
{
real_t fov = 90;
@@ -1458,7 +1459,7 @@ void RasterizerCanvasGLES3::initialize() {
glGenBuffers(1,&data.primitive_quad_buffer);
glBindBuffer(GL_ARRAY_BUFFER,data.primitive_quad_buffer);
- glBufferData(GL_ARRAY_BUFFER,sizeof(float)*2+sizeof(float)*2+sizeof(float)*4,NULL,GL_DYNAMIC_DRAW); //allocate max size
+ glBufferData(GL_ARRAY_BUFFER,(2+2+4)*4*sizeof(float),NULL,GL_DYNAMIC_DRAW); //allocate max size
glBindBuffer(GL_ARRAY_BUFFER,0);
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index efad6c7e55..aea4642d88 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -1,6 +1,6 @@
#include "rasterizer_gles3.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "gl_context/context_gl.h"
#include <string.h>
RasterizerStorage *RasterizerGLES3::get_storage() {
@@ -185,12 +185,8 @@ void RasterizerGLES3::begin_frame(){
storage->frame.prev_tick=tick;
+ storage->update_dirty_resources();
- storage->update_dirty_multimeshes();
- storage->update_dirty_skeletons();
- storage->update_dirty_shaders();
- storage->update_dirty_materials();
- storage->update_particles();
storage->info.render_object_count=0;
storage->info.render_material_switch_count=0;
@@ -237,7 +233,7 @@ void RasterizerGLES3::set_current_render_target(RID p_render_target){
storage->frame.current_rt=NULL;
storage->frame.clear_request=false;
glViewport(0,0,OS::get_singleton()->get_window_size().width,OS::get_singleton()->get_window_size().height);
- glBindFramebuffer(GL_FRAMEBUFFER,storage->config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER,RasterizerStorageGLES3::system_fbo);
}
}
@@ -268,7 +264,7 @@ void RasterizerGLES3::blit_render_target_to_screen(RID p_render_target,const Rec
canvas->canvas_begin();
glDisable(GL_BLEND);
- glBindFramebuffer(GL_FRAMEBUFFER,storage->config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER,RasterizerStorageGLES3::system_fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,rt->color);
canvas->draw_generic_textured_rect(p_screen_rect,Rect2(0,0,1,-1));
@@ -300,9 +296,9 @@ void RasterizerGLES3::end_frame(){
glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, 0, vtx );
-// glBindBuffer(GL_ARRAY_BUFFER,canvas->data.canvas_quad_vertices);
-// glEnableVertexAttribArray(VS::ARRAY_VERTEX);
-// glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, 0, 0 );
+ //glBindBuffer(GL_ARRAY_BUFFER,canvas->data.canvas_quad_vertices);
+ //glEnableVertexAttribArray(VS::ARRAY_VERTEX);
+ //glVertexAttribPointer( VS::ARRAY_VERTEX, 2 ,GL_FLOAT, false, 0, 0 );
glBindVertexArray(canvas->data.canvas_quad_array);
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 5e0f439e3e..03a5834ca7 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1,8 +1,12 @@
#include "rasterizer_scene_gles3.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
#include "rasterizer_canvas_gles3.h"
+#ifndef GLES_OVER_GL
+#define glClearDepth glClearDepthf
+#endif
+
static const GLenum _cube_side_enum[6]={
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
@@ -129,7 +133,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas,int p_size){
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &shadow_atlas->depth);
glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadow_atlas->size, shadow_atlas->size, 0,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, shadow_atlas->size, shadow_atlas->size, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -141,9 +145,12 @@ void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas,int p_size){
GL_TEXTURE_2D, shadow_atlas->depth, 0);
glViewport(0,0,shadow_atlas->size,shadow_atlas->size);
- glClearDepth(0);
+ glClearDepth(0.0f);
glClear(GL_DEPTH_BUFFER_BIT);
+ glBindFramebuffer(GL_FRAMEBUFFER,0);
+
+
}
}
@@ -161,7 +168,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_quadrant_subdivision(RID p_atlas,int
subdiv<<=1;
}
- subdiv=int(Math::sqrt(subdiv));
+ subdiv=int(Math::sqrt((float)subdiv));
//obtain the number that will be x*x
@@ -553,6 +560,8 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas,int p_size)
}
+
+
void RasterizerSceneGLES3::reflection_atlas_set_subdivision(RID p_ref_atlas,int p_subdiv) {
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas);
@@ -563,7 +572,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_subdivision(RID p_ref_atlas,int
subdiv<<=1;
}
- subdiv=int(Math::sqrt(subdiv));
+ subdiv=int(Math::sqrt((float)subdiv));
if (reflection_atlas->subdiv==subdiv)
return;
@@ -1077,6 +1086,18 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
state.current_line_width=p_material->line_width;
}
+ if (state.current_depth_test!=(!p_material->shader->spatial.ontop)) {
+ if (p_material->shader->spatial.ontop) {
+ glDisable(GL_DEPTH_TEST);
+
+ } else {
+ glEnable(GL_DEPTH_TEST);
+
+ }
+
+ state.current_depth_test=!p_material->shader->spatial.ontop;
+ }
+
if (state.current_depth_draw!=p_material->shader->spatial.depth_draw_mode) {
switch(p_material->shader->spatial.depth_draw_mode) {
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS:
@@ -1102,10 +1123,10 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
- */
- //if (p_material->line_width)
- // glLineWidth(p_material->line_width);
+ if (p_material->line_width)
+ glLineWidth(p_material->line_width);
+ */
#if 0
//blend mode
@@ -1200,6 +1221,11 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
} else {
+#ifdef TOOLS_ENABLED
+ if (t->detect_3d) {
+ t->detect_3d(t->detect_3d_ud);
+ }
+#endif
if (storage->config.srgb_decode_supported) {
//if SRGB decode extension is present, simply switch the texture to whathever is needed
bool must_srgb=false;
@@ -1212,9 +1238,8 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
if (must_srgb) {
glTexParameteri(t->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
#ifdef TOOLS_ENABLED
- if (!(t->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) {
- t->flags|=VS::TEXTURE_FLAG_CONVERT_TO_LINEAR;
- //notify that texture must be set to linear beforehand, so it works in other platforms when exported
+ if (t->detect_srgb) {
+ t->detect_srgb(t->detect_srgb_ud);
}
#endif
@@ -1361,6 +1386,8 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
int amount = MAX(multi_mesh->size,multi_mesh->visible_instances);
+
+
if (s->index_array_len>0) {
glDrawElementsInstanced(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0,amount);
@@ -1584,6 +1611,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e,const Transform&
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_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) {
@@ -1596,6 +1624,7 @@ 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_BLEND_AMBIENT2, gipi2->probe?!gipi2->probe->interior:false);
state.scene_shader.set_uniform(SceneShaderGLES3::GI_PROBE2_ENABLED, true );
} else {
@@ -1710,6 +1739,9 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
state.cull_front=false;
glCullFace(GL_BACK);
+ state.current_depth_test=true;
+ glEnable(GL_DEPTH_TEST);
+
state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON,false);
state.current_blend_mode=-1;
@@ -1718,6 +1750,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
RasterizerStorageGLES3::Material* prev_material=NULL;
RasterizerStorageGLES3::Geometry* prev_geometry=NULL;
+ RasterizerStorageGLES3::GeometryOwner* prev_owner=NULL;
VS::InstanceType prev_base_type = VS::INSTANCE_MAX;
int current_blend_mode=-1;
@@ -1737,6 +1770,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
RasterizerStorageGLES3::Material* material= e->material;
RID skeleton = e->instance->skeleton;
+
bool rebind=first;
int shading = (e->sort_key>>RenderList::SORT_KEY_SHADING_SHIFT)&RenderList::SORT_KEY_SHADING_MASK;
@@ -1906,7 +1940,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
}
- if (prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) {
+ if (e->owner != prev_owner || prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) {
+
_setup_geometry(e);
storage->info.render_surface_switch_count++;
@@ -1924,6 +1959,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
prev_material=material;
prev_base_type=e->instance->base_type;
prev_geometry=e->geometry;
+ prev_owner=e->owner;
prev_shading=shading;
prev_skeleton=skeleton;
first=false;
@@ -2067,8 +2103,10 @@ void RasterizerSceneGLES3::_add_geometry( RasterizerStorageGLES3::Geometry* p_g
}
}
- //if (e->geometry->type==RasterizerStorageGLES3::Geometry::GEOMETRY_MULTISURFACE)
- // e->sort_flags|=RenderList::SORT_FLAG_INSTANCING;
+ /*
+ if (e->geometry->type==RasterizerStorageGLES3::Geometry::GEOMETRY_MULTISURFACE)
+ e->sort_flags|=RenderList::SORT_FLAG_INSTANCING;
+ */
if (mirror) {
@@ -2268,9 +2306,9 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index,const Transform&
float sign = li->light_ptr->negative?-1:1;
Color linear_col = li->light_ptr->color.to_linear();
- ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
+ ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
ubo_data.light_color_energy[3]=0;
//omni, keep at 0
@@ -2291,10 +2329,10 @@ void RasterizerSceneGLES3::_setup_directional_light(int p_index,const Transform&
ubo_data.light_params[3]=0;
Color shadow_color = li->light_ptr->shadow_color.to_linear();
- ubo_data.light_shadow_color[0]=shadow_color.r;
- ubo_data.light_shadow_color[1]=shadow_color.g;
- ubo_data.light_shadow_color[2]=shadow_color.b;
- ubo_data.light_shadow_color[3]=1.0;
+ ubo_data.light_shadow_color_contact[0]=shadow_color.r;
+ ubo_data.light_shadow_color_contact[1]=shadow_color.g;
+ ubo_data.light_shadow_color_contact[2]=shadow_color.b;
+ ubo_data.light_shadow_color_contact[3]=li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE];
if (p_use_shadows && li->light_ptr->shadow) {
@@ -2425,9 +2463,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
float sign = li->light_ptr->negative?-1:1;
Color linear_col = li->light_ptr->color.to_linear();
- ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
+ ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
ubo_data.light_color_energy[3]=0;
@@ -2450,10 +2488,10 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
ubo_data.light_params[3]=0;
Color shadow_color = li->light_ptr->shadow_color.to_linear();
- ubo_data.light_shadow_color[0]=shadow_color.r;
- ubo_data.light_shadow_color[1]=shadow_color.g;
- ubo_data.light_shadow_color[2]=shadow_color.b;
- ubo_data.light_shadow_color[3]=1.0;
+ ubo_data.light_shadow_color_contact[0]=shadow_color.r;
+ ubo_data.light_shadow_color_contact[1]=shadow_color.g;
+ ubo_data.light_shadow_color_contact[2]=shadow_color.b;
+ ubo_data.light_shadow_color_contact[3]=li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE];
if (li->light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(li->self)) {
// fill in the shadow information
@@ -2518,9 +2556,9 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
float sign = li->light_ptr->negative?-1:1;
Color linear_col = li->light_ptr->color.to_linear();
- ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
- ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];;
+ ubo_data.light_color_energy[0]=linear_col.r*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[1]=linear_col.g*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
+ ubo_data.light_color_energy[2]=linear_col.b*sign*li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
ubo_data.light_color_energy[3]=0;
Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin);
@@ -2543,10 +2581,10 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
ubo_data.light_params[3]=0;
Color shadow_color = li->light_ptr->shadow_color.to_linear();
- ubo_data.light_shadow_color[0]=shadow_color.r;
- ubo_data.light_shadow_color[1]=shadow_color.g;
- ubo_data.light_shadow_color[2]=shadow_color.b;
- ubo_data.light_shadow_color[3]=1.0;
+ ubo_data.light_shadow_color_contact[0]=shadow_color.r;
+ ubo_data.light_shadow_color_contact[1]=shadow_color.g;
+ ubo_data.light_shadow_color_contact[2]=shadow_color.b;
+ ubo_data.light_shadow_color_contact[3]=li->light_ptr->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE];
if (li->light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(li->self)) {
// fill in the shadow information
@@ -2624,19 +2662,19 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
glBindBuffer(GL_UNIFORM_BUFFER, state.omni_array_ubo);
glBufferSubData(GL_UNIFORM_BUFFER, 0, state.omni_light_count*state.ubo_light_size, state.omni_array_tmp);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
-
- glBindBufferBase(GL_UNIFORM_BUFFER,4,state.omni_array_ubo);
}
+ glBindBufferBase(GL_UNIFORM_BUFFER,4,state.omni_array_ubo);
+
if (state.spot_light_count) {
glBindBuffer(GL_UNIFORM_BUFFER, state.spot_array_ubo);
glBufferSubData(GL_UNIFORM_BUFFER, 0, state.spot_light_count*state.ubo_light_size, state.spot_array_tmp);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
- glBindBufferBase(GL_UNIFORM_BUFFER,5,state.spot_array_ubo);
}
+ glBindBufferBase(GL_UNIFORM_BUFFER,5,state.spot_array_ubo);
}
@@ -2732,9 +2770,10 @@ void RasterizerSceneGLES3::_setup_reflections(RID *p_reflection_probe_cull_resul
glBufferSubData(GL_UNIFORM_BUFFER, 0, state.reflection_probe_count*sizeof(ReflectionProbeDataUBO), state.reflection_array_tmp);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
- glBindBufferBase(GL_UNIFORM_BUFFER,6,state.reflection_array_ubo);
}
+ glBindBufferBase(GL_UNIFORM_BUFFER,6,state.reflection_array_ubo);
+
}
@@ -2767,6 +2806,7 @@ void RasterizerSceneGLES3::_copy_to_front_buffer(Environment *env) {
//no environment, simply convert from linear to srgb
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB,true);
} else {
+ /* FIXME: Why are both statements equal? */
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB,true);
}
@@ -2847,6 +2887,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase** p_cull_result,int p_
RasterizerStorageGLES3::MultiMesh *multi_mesh = storage->multimesh_owner.getptr(inst->base);
ERR_CONTINUE(!multi_mesh);
+
if (multi_mesh->size==0 || multi_mesh->visible_instances==0)
continue;
@@ -2862,6 +2903,7 @@ void RasterizerSceneGLES3::_fill_render_list(InstanceBase** p_cull_result,int p_
_add_geometry(s,inst,multi_mesh,-1,p_shadow);
}
+
} break;
case VS::INSTANCE_IMMEDIATE: {
@@ -3730,14 +3772,20 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
state.ubo_data.shadow_dual_paraboloid_render_side=0;
state.ubo_data.shadow_dual_paraboloid_render_zfar=0;
+ if (storage->frame.current_rt) {
+ state.ubo_data.screen_pixel_size[0]=1.0/storage->frame.current_rt->width;
+ state.ubo_data.screen_pixel_size[1]=1.0/storage->frame.current_rt->height;
+ }
+
_setup_environment(env,p_cam_projection,p_cam_transform);
bool fb_cleared=false;
glDepthFunc(GL_LEQUAL);
+ state.used_contact_shadows=true;
- if (storage->frame.current_rt && true) {
+ if ( storage->frame.current_rt && true) { //detect with state.used_contact_shadows too
//pre z pass
@@ -3751,8 +3799,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
glViewport(0,0,storage->frame.current_rt->width,storage->frame.current_rt->height);
glColorMask(0,0,0,0);
-
- glClearDepth(1.0);
+ glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
@@ -3765,6 +3812,19 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
glColorMask(1,1,1,1);
+ if (state.used_contact_shadows) {
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->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_DEPTH_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ //bind depth for read
+ glActiveTexture(GL_TEXTURE0+storage->config.max_texture_image_units-8);
+ glBindTexture(GL_TEXTURE_2D,storage->frame.current_rt->depth);
+ }
+
fb_cleared=true;
render_pass++;
}
@@ -3864,7 +3924,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
}
if (!fb_cleared) {
- glClearDepth(1.0);
+ glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
}
@@ -3949,9 +4009,10 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
if (env && env->bg_mode==VS::ENV_BG_SKYBOX) {
- //if (use_mrt) {
- // glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo); //switch to alpha fbo for skybox, only diffuse/ambient matters
- //
+ /*
+ if (use_mrt) {
+ glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo); //switch to alpha fbo for skybox, only diffuse/ambient matters
+ */
_draw_skybox(skybox,p_cam_projection,p_cam_transform,storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP],env->skybox_scale);
}
@@ -3963,14 +4024,13 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
//_render_list_forward(&alpha_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting,true);
//glColorMask(1,1,1,1);
-// state.scene_shader.set_conditional( SceneShaderGLES3::USE_FOG,false);
+ //state.scene_shader.set_conditional( SceneShaderGLES3::USE_FOG,false);
if (use_mrt) {
_render_mrts(env,p_cam_projection);
}
- glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glEnable(GL_BLEND);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
@@ -4016,7 +4076,7 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
storage->canvas->canvas_begin();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,exposure_shrink[4].color);
-// glBindTexture(GL_TEXTURE_2D,storage->frame.current_rt->exposure.color);
+ //glBindTexture(GL_TEXTURE_2D,storage->frame.current_rt->exposure.color);
storage->canvas->draw_generic_textured_rect(Rect2(0,0,storage->frame.current_rt->width/16,storage->frame.current_rt->height/16),Rect2(0,0,1,1));
}
@@ -4044,11 +4104,11 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
if (false && env_radiance_tex) {
- //_copy_texture_to_front_buffer(shadow_atlas->depth);
- storage->canvas->canvas_begin();
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D,env_radiance_tex);
- 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));
+ //_copy_texture_to_front_buffer(shadow_atlas->depth);
+ storage->canvas->canvas_begin();
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D,env_radiance_tex);
+ 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));
}
@@ -4189,8 +4249,8 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,const C
if (GLOBAL_DEF("rasterizer/debug_shadow_maps",false)) {
_debug_shadows();
}
-// _debug_luminances();
-// _debug_samplers();
+ //_debug_luminances();
+ //_debug_samplers();
if (using_canvas_bg) {
using_canvas_bg=false;
@@ -4398,25 +4458,25 @@ void RasterizerSceneGLES3::render_shadow(RID p_light,RID p_shadow_atlas,int p_pa
render_list.sort_by_depth(false); //shadow is front to back for performance
- glDepthMask(true);
- glColorMask(1,1,1,1);
glDisable(GL_BLEND);
glDisable(GL_DITHER);
glEnable(GL_DEPTH_TEST);
glBindFramebuffer(GL_FRAMEBUFFER,fbo);
+ glDepthMask(true);
+ glColorMask(0,0,0,0);
+
if (custom_vp_size) {
glViewport(0,0,custom_vp_size,custom_vp_size);
glScissor(0,0,custom_vp_size,custom_vp_size);
-
} else {
glViewport(x,y,width,height);
glScissor(x,y,width,height);
}
glEnable(GL_SCISSOR_TEST);
- glClearDepth(1.0);
+ glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
@@ -4429,7 +4489,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light,RID p_shadow_atlas,int p_pa
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH,true);
- _render_list(render_list.elements,render_list.element_count,light_transform,light_projection,0,!flip_facing,false,true,false,false);
+ _render_list(render_list.elements,render_list.element_count,light_transform,light_projection,0,flip_facing,false,true,false,false);
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH,false);
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH_DUAL_PARABOLOID,false);
@@ -4469,7 +4529,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light,RID p_shadow_atlas,int p_pa
glViewport(local_x,local_y,local_width,local_height);
glScissor(local_x,local_y,local_width,local_height);
glEnable(GL_SCISSOR_TEST);
- glClearDepth(1.0);
+ glClearDepth(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
//glDisable(GL_DEPTH_TEST);
@@ -4561,7 +4621,7 @@ static _FORCE_INLINE_ Vector3 ImportanceSampleGGX(Vector2 Xi, float Roughness, V
// Compute distribution direction
float Phi = 2.0f * Math_PI * Xi.x;
- float CosTheta = Math::sqrt((1.0f - Xi.y) / (1.0f + (a*a - 1.0f) * Xi.y));
+ float CosTheta = Math::sqrt((float)(1.0f - Xi.y) / (1.0f + (a*a - 1.0f) * Xi.y));
float SinTheta = Math::sqrt((float)Math::abs(1.0f - CosTheta * CosTheta));
// Convert to spherical direction
@@ -4609,7 +4669,7 @@ void RasterizerSceneGLES3::_generate_brdf() {
float NoV = float(i+1)/(brdf_size); //avoid storing nov0
Vector3 V;
- V.x = Math::sqrt( 1.0 - NoV * NoV );
+ V.x = Math::sqrt( 1.0f - NoV * NoV );
V.y = 0.0;
V.z = NoV;
@@ -4746,7 +4806,7 @@ void RasterizerSceneGLES3::initialize() {
//gen cubemap first
for(int i=0;i<6;i++) {
- glTexImage2D(_cube_side_enum[i], 0, GL_DEPTH_COMPONENT, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
+ glTexImage2D(_cube_side_enum[i], 0, GL_DEPTH_COMPONENT24, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -4780,7 +4840,7 @@ void RasterizerSceneGLES3::initialize() {
glBindFramebuffer(GL_FRAMEBUFFER,directional_shadow.fbo);
glGenTextures(1,&directional_shadow.depth);
glBindTexture(GL_TEXTURE_2D,directional_shadow.depth);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -4870,7 +4930,7 @@ void RasterizerSceneGLES3::initialize() {
glGenTextures(1,&cube.depth);
glBindTexture(GL_TEXTURE_2D,cube.depth);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, cube.size, cube.size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -4988,12 +5048,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/gles3/subsurface_scattering/follow_surface");
- subsurface_scatter_quality=SubSurfaceScatterQuality(int(GlobalConfig::get_singleton()->get("rendering/gles3/subsurface_scattering/quality")));
- subsurface_scatter_size=GlobalConfig::get_singleton()->get("rendering/gles3/subsurface_scattering/max_size");
+ 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");
- state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH,GlobalConfig::get_singleton()->get("rendering/gles3/high_quality_vct_gi"));
+ state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH,GlobalConfig::get_singleton()->get("rendering/reflections/high_quality_vct_gi"));
}
void RasterizerSceneGLES3::finalize(){
@@ -5004,5 +5064,4 @@ void RasterizerSceneGLES3::finalize(){
RasterizerSceneGLES3::RasterizerSceneGLES3()
{
-
}
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index 7838345e59..81dfa1bf46 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -61,6 +61,7 @@ public:
int current_blend_mode;
float current_line_width;
int current_depth_draw;
+ bool current_depth_test;
GLuint current_main_tex;
SceneShaderGLES3 scene_shader;
@@ -90,6 +91,7 @@ public:
float shadow_slope_scale;
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
+ float screen_pixel_size[2];
float shadow_atlas_pixel_size[2];
float shadow_directional_pixel_size[2];
float reflection_multiplier;
@@ -135,6 +137,7 @@ public:
int max_ubo_reflections;
int max_skeleton_bones;
+ bool used_contact_shadows;
int spot_light_count;
@@ -209,7 +212,6 @@ public:
bool _shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow);
bool shadow_atlas_update_light(RID p_atlas,RID p_light_intance,float p_coverage,uint64_t p_light_version);
-
struct DirectionalShadow {
GLuint fbo;
GLuint depth;
@@ -467,7 +469,7 @@ public:
float light_color_energy[4];
float light_params[4]; //spot attenuation, spot angle, specular, shadow enabled
float light_clamp[4];
- float light_shadow_color[4];
+ float light_shadow_color_contact[4];
float shadow_matrix1[16]; //up to here for spot and omni, rest is for directional
float shadow_matrix2[16];
float shadow_matrix3[16];
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index f096719988..cec41aa251 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1,7 +1,7 @@
#include "rasterizer_storage_gles3.h"
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
-#include "globals.h"
+#include "global_config.h"
/* TEXTURE API */
@@ -78,6 +78,8 @@
#define _EXT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
#define _EXT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
+GLuint RasterizerStorageGLES3::system_fbo = 0;
+
Image RasterizerStorageGLES3::_get_gl_image_and_format(const 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) {
@@ -91,16 +93,26 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima
switch(p_format) {
case Image::FORMAT_L8: {
+#ifdef GLES_OVER_GL
r_gl_internal_format=GL_R8;
r_gl_format=GL_RED;
r_gl_type=GL_UNSIGNED_BYTE;
-
+#else
+ r_gl_internal_format=GL_LUMINANCE;
+ r_gl_format=GL_LUMINANCE;
+ r_gl_type=GL_UNSIGNED_BYTE;
+#endif
} break;
case Image::FORMAT_LA8: {
-
+#ifdef GLES_OVER_GL
r_gl_internal_format=GL_RG8;
r_gl_format=GL_RG;
r_gl_type=GL_UNSIGNED_BYTE;
+#else
+ r_gl_internal_format=GL_LUMINANCE_ALPHA;
+ r_gl_format=GL_LUMINANCE_ALPHA;
+ r_gl_type=GL_UNSIGNED_BYTE;
+#endif
} break;
case Image::FORMAT_R8: {
@@ -133,8 +145,12 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima
} break;
case Image::FORMAT_RGB565: {
+#ifndef GLES_OVER_GL
+ r_gl_internal_format=GL_RGB565;
+#else
//#warning TODO: Convert tod 555 if 565 is not supported (GLES3.3-)
r_gl_internal_format=GL_RGB5;
+#endif
//r_gl_internal_format=GL_RGB565;
r_gl_format=GL_RGB;
r_gl_type=GL_UNSIGNED_SHORT_5_6_5;
@@ -212,7 +228,7 @@ Image RasterizerStorageGLES3::_get_gl_image_and_format(const Image& p_image, Ima
if (config.s3tc_supported) {
- r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ r_gl_internal_format=(config.srgb_decode_supported || p_flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)?_EXT_COMPRESSED_SRGB_S3TC_DXT1_NV:_EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT;
r_gl_format=GL_RGBA;
r_gl_type=GL_UNSIGNED_BYTE;
r_compressed=true;
@@ -728,6 +744,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
}
//set swizle for older format compatibility
+#ifdef GLES_OVER_GL
switch(texture->format) {
case Image::FORMAT_L8: {
@@ -753,6 +770,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
} break;
}
+#endif
if (config.use_anisotropic_filter) {
if (texture->flags&VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) {
@@ -779,7 +797,7 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
if (texture->compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glCompressedTexImage2D( blit_target, i, format,w,h,0,size,&read[ofs] );
+ glCompressedTexImage2D( blit_target, i, internal_format,w,h,0,size,&read[ofs] );
} else {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -808,6 +826,10 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && mipmaps==1 && !texture->ignore_mipmaps && (!(texture->flags&VS::TEXTURE_FLAG_CUBEMAP) || texture->stored_cube_sides==(1<<6)-1)) {
//generate mipmaps if they were requested and the image does not contain them
glGenerateMipmap(texture->target);
+ } else if (mipmaps>1) {
+ glTexParameteri(texture->target, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameteri(texture->target, GL_TEXTURE_MAX_LEVEL, mipmaps-1);
+
}
texture->mipmaps=mipmaps;
@@ -1060,13 +1082,33 @@ void RasterizerStorageGLES3::textures_keep_original(bool p_enable) {
config.keep_original_textures=p_enable;
}
+void RasterizerStorageGLES3::texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata) {
+
+ Texture * texture = texture_owner.get(p_texture);
+ ERR_FAIL_COND(!texture);
+
+ texture->detect_3d=p_callback;
+ texture->detect_3d_ud=p_userdata;
+}
+
+void RasterizerStorageGLES3::texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata){
+ Texture * texture = texture_owner.get(p_texture);
+ ERR_FAIL_COND(!texture);
+
+ texture->detect_srgb=p_callback;
+ texture->detect_srgb_ud=p_userdata;
+
+}
+
+
+
RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_resolution) const {
Texture * texture = texture_owner.get(p_source);
ERR_FAIL_COND_V(!texture,RID());
ERR_FAIL_COND_V(!(texture->flags&VS::TEXTURE_FLAG_CUBEMAP),RID());
- bool use_float=true;
+ bool use_float=config.hdr_supported;
if (p_resolution<0) {
p_resolution=texture->width;
@@ -1186,7 +1228,7 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_r
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
glDeleteFramebuffers(1, &tmp_fb);
Texture * ctex = memnew( Texture );
@@ -1286,7 +1328,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in
int mm_level=mipmaps;
- bool use_float=true;
+ bool use_float=config.hdr_supported;
GLenum internal_format = use_float?GL_RGBA16F:GL_RGB10_A2;
GLenum format = GL_RGBA;
@@ -1351,7 +1393,7 @@ void RasterizerStorageGLES3::skybox_set_texture(RID p_skybox, RID p_cube_map, in
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, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
glDeleteFramebuffers(1, &tmp_fb);
}
@@ -1509,12 +1551,12 @@ void RasterizerStorageGLES3::_update_shader(Shader* p_shader) const {
actions->uniforms=&p_shader->uniforms;
- }
+ } break;
case VS::SHADER_PARTICLES: {
actions=&shaders.actions_particles;
actions->uniforms=&p_shader->uniforms;
- }
+ } break;
}
@@ -2290,6 +2332,7 @@ void RasterizerStorageGLES3::_update_material(Material* material) {
bool is_animated = false;
if (material->shader && material->shader->mode==VS::SHADER_SPATIAL) {
+
if (!material->shader->spatial.uses_alpha && material->shader->spatial.blend_mode==Shader::Spatial::BLEND_MODE_MIX) {
can_cast_shadow=true;
}
@@ -2302,20 +2345,19 @@ void RasterizerStorageGLES3::_update_material(Material* material) {
is_animated=true;
}
- }
+ if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) {
+ material->can_cast_shadow_cache=can_cast_shadow;
+ material->is_animated_cache=is_animated;
- if (can_cast_shadow!=material->can_cast_shadow_cache || is_animated!=material->is_animated_cache) {
- material->can_cast_shadow_cache=can_cast_shadow;
- material->is_animated_cache=is_animated;
+ for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) {
+ E->key()->material_changed_notify();
+ }
- for(Map<Geometry*,int>::Element *E=material->geometry_owners.front();E;E=E->next()) {
- E->key()->material_changed_notify();
- }
+ for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) {
+ E->key()->base_material_changed();
+ }
- for(Map<RasterizerScene::InstanceBase*,int>::Element *E=material->instance_owners.front();E;E=E->next()) {
- E->key()->base_material_changed();
}
-
}
}
@@ -2465,6 +2507,7 @@ RID RasterizerStorageGLES3::mesh_create(){
void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes,const Vector<Rect3>& p_bone_aabbs){
+
PoolVector<uint8_t> array = p_array;
Mesh *mesh = mesh_owner.getornull(p_mesh);
@@ -2663,8 +2706,6 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh,uint32_t p_format,VS::P
int array_size = stride * p_vertex_count;
int index_array_size=0;
-
- print_line("desired size: "+itos(array_size)+" vcount "+itos(p_vertex_count)+" should be: "+itos(array.size()+p_vertex_count*2)+" but is "+itos(array.size()));
if (array.size()!=array_size && array.size()+p_vertex_count*2 == array_size) {
//old format, convert
array = PoolVector<uint8_t>();
@@ -3590,8 +3631,23 @@ void RasterizerStorageGLES3::multimesh_set_mesh(RID p_multimesh,RID p_mesh){
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
ERR_FAIL_COND(!multimesh);
+ if (multimesh->mesh.is_valid()) {
+ Mesh *mesh = mesh_owner.getornull(multimesh->mesh);
+ if (mesh) {
+ mesh->multimeshes.remove(&multimesh->mesh_list);
+ }
+ }
+
multimesh->mesh=p_mesh;
+
+ if (multimesh->mesh.is_valid()) {
+ Mesh *mesh = mesh_owner.getornull(multimesh->mesh);
+ if (mesh) {
+ mesh->multimeshes.add(&multimesh->mesh_list);
+ }
+ }
+
multimesh->dirty_aabb=true;
if (!multimesh->update_list.in_list()) {
@@ -4261,6 +4317,7 @@ RID RasterizerStorageGLES3::light_create(VS::LightType p_type){
light->param[VS::LIGHT_PARAM_SPECULAR]=0.5;
light->param[VS::LIGHT_PARAM_RANGE]=1.0;
light->param[VS::LIGHT_PARAM_SPOT_ANGLE]=45;
+ light->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE]=45;
light->param[VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE]=0;
light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET]=0.1;
light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET]=0.3;
@@ -4747,6 +4804,8 @@ RID RasterizerStorageGLES3::gi_probe_create() {
gip->bounds=Rect3(Vector3(),Vector3(1,1,1));
gip->dynamic_range=1.0;
gip->energy=1.0;
+ gip->propagation=1.0;
+ gip->bias=0.4;
gip->interior=false;
gip->compress=false;
gip->version=1;
@@ -4852,6 +4911,25 @@ void RasterizerStorageGLES3::gi_probe_set_energy(RID p_probe,float p_range){
}
+
+void RasterizerStorageGLES3::gi_probe_set_bias(RID p_probe,float p_range){
+
+ GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND(!gip);
+
+ gip->bias=p_range;
+
+}
+
+void RasterizerStorageGLES3::gi_probe_set_propagation(RID p_probe,float p_range){
+
+ GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND(!gip);
+
+ gip->propagation=p_range;
+
+}
+
void RasterizerStorageGLES3::gi_probe_set_interior(RID p_probe,bool p_enable) {
GIProbe *gip = gi_probe_owner.getornull(p_probe);
@@ -4896,6 +4974,25 @@ float RasterizerStorageGLES3::gi_probe_get_energy(RID p_probe) const{
return gip->energy;
}
+float RasterizerStorageGLES3::gi_probe_get_bias(RID p_probe) const{
+
+ const GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND_V(!gip,0);
+
+ return gip->bias;
+}
+
+
+float RasterizerStorageGLES3::gi_probe_get_propagation(RID p_probe) const{
+
+ const GIProbe *gip = gi_probe_owner.getornull(p_probe);
+ ERR_FAIL_COND_V(!gip,0);
+
+ return gip->propagation;
+}
+
+
+
uint32_t RasterizerStorageGLES3::gi_probe_get_version(RID p_probe) {
@@ -5250,7 +5347,7 @@ void RasterizerStorageGLES3::update_particles() {
shaders.particles.set_uniform(ParticlesShaderGLES3::ORIGIN,particles->origin);
- float new_phase = Math::fmod(particles->phase+(frame.delta/particles->lifetime),1.0);
+ float new_phase = Math::fmod((float)particles->phase+(frame.delta/particles->lifetime),(float)1.0);
shaders.particles.set_uniform(ParticlesShaderGLES3::SYSTEM_PHASE,new_phase);
shaders.particles.set_uniform(ParticlesShaderGLES3::PREV_SYSTEM_PHASE,particles->phase);
@@ -5397,12 +5494,14 @@ void RasterizerStorageGLES3::instance_remove_dependency(RID p_base,RasterizerSce
void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
+
if (rt->fbo) {
glDeleteFramebuffers(1,&rt->fbo);
glDeleteTextures(1,&rt->color);
rt->fbo=0;
}
+
if (rt->buffers.fbo) {
glDeleteFramebuffers(1,&rt->buffers.fbo);
glDeleteRenderbuffers(1,&rt->buffers.depth);
@@ -5416,11 +5515,13 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->buffers.fbo=0;
}
+
if (rt->depth) {
glDeleteTextures(1,&rt->depth);
rt->depth=0;
}
+
if (rt->effects.ssao.blur_fbo[0]) {
glDeleteFramebuffers(1,&rt->effects.ssao.blur_fbo[0]);
glDeleteTextures(1,&rt->effects.ssao.blur_red[0]);
@@ -5433,11 +5534,16 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->effects.ssao.depth_mipmap_fbos.clear();
glDeleteTextures(1,&rt->effects.ssao.linear_depth);
+
+ rt->effects.ssao.blur_fbo[0]=0;
+ rt->effects.ssao.blur_fbo[1]=0;
}
+
if (rt->exposure.fbo) {
glDeleteFramebuffers(1,&rt->exposure.fbo);
glDeleteTextures(1,&rt->exposure.color);
+ rt->exposure.fbo=0;
}
Texture *tex = texture_owner.get(rt->texture);
tex->alloc_height=0;
@@ -5445,6 +5551,7 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
tex->width=0;
tex->height=0;
+
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);
@@ -5454,6 +5561,8 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
rt->effects.mip_maps[i].sizes.clear();
rt->effects.mip_maps[i].levels=0;
}
+
+
/*
if (rt->effects.screen_space_depth) {
glDeleteTextures(1,&rt->effects.screen_space_depth);
@@ -5468,15 +5577,15 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
if (rt->width<=0 || rt->height<=0)
return;
-
GLuint color_internal_format;
GLuint color_format;
GLuint color_type;
Image::Format image_format;
+ bool hdr = rt->flags[RENDER_TARGET_HDR] && config.hdr_supported;
+ hdr=false;
-
- if (!rt->flags[RENDER_TARGET_HDR] || rt->flags[RENDER_TARGET_NO_3D]) {
+ if (!hdr || rt->flags[RENDER_TARGET_NO_3D]) {
color_internal_format=GL_RGBA8;
color_format=GL_RGBA;
@@ -5501,7 +5610,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
glGenTextures(1, &rt->depth);
glBindTexture(GL_TEXTURE_2D, rt->depth);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, rt->width, rt->height, 0,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, rt->width, rt->height, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -5523,7 +5632,11 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
+
+ if (status != GL_FRAMEBUFFER_COMPLETE) {
+ printf("framebuffer fail, status: %x\n",status);
+ }
ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE );
@@ -5572,7 +5685,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
if (msaa==0)
glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height);
else
- glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,GL_RGBA16F,rt->width,rt->height);
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER,rt->buffers.diffuse);
@@ -5580,7 +5693,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
glBindRenderbuffer(GL_RENDERBUFFER, rt->buffers.specular);
if (msaa==0)
- glRenderbufferStorage(GL_RENDERBUFFER,GL_RGBA16F,rt->width,rt->height);
+ glRenderbufferStorage(GL_RENDERBUFFER,color_internal_format,rt->width,rt->height);
else
glRenderbufferStorageMultisample(GL_RENDERBUFFER,msaa,color_internal_format,rt->width,rt->height);
@@ -5610,7 +5723,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
if (status != GL_FRAMEBUFFER_COMPLETE) {
printf("err status: %x\n",status);
@@ -5643,7 +5756,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE );
}
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
if (status != GL_FRAMEBUFFER_COMPLETE) {
_render_target_clear(rt);
@@ -5712,7 +5825,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
}
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
rt->effects.mip_maps[i].levels=level;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -5941,7 +6054,7 @@ RID RasterizerStorageGLES3::canvas_light_shadow_buffer_create(int p_width) {
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
//printf("errnum: %x\n",status);
- glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES3::system_fbo);
ERR_FAIL_COND_V( status != GL_FRAMEBUFFER_COMPLETE, RID() );
@@ -6204,6 +6317,18 @@ bool RasterizerStorageGLES3::free(RID p_rid){
mesh->instance_remove_deps();
mesh_clear(p_rid);
+ while(mesh->multimeshes.first()) {
+ MultiMesh *multimesh = mesh->multimeshes.first()->self();
+ multimesh->mesh=RID();
+ multimesh->dirty_aabb=true;
+ mesh->multimeshes.remove(mesh->multimeshes.first());
+
+ if (!multimesh->update_list.in_list()) {
+ multimesh_update_list.add(&multimesh->update_list);
+ }
+
+ }
+
mesh_owner.free(p_rid);
memdelete(mesh);
@@ -6213,9 +6338,17 @@ bool RasterizerStorageGLES3::free(RID p_rid){
MultiMesh *multimesh = multimesh_owner.get(p_rid);
multimesh->instance_remove_deps();
+ if (multimesh->mesh.is_valid()) {
+ Mesh *mesh = mesh_owner.getornull(multimesh->mesh);
+ if (mesh) {
+ mesh->multimeshes.remove(&multimesh->mesh_list);
+ }
+ }
+
multimesh_allocate(p_rid,0,VS::MULTIMESH_TRANSFORM_2D,VS::MULTIMESH_COLOR_NONE); //frees multimesh
update_dirty_multimeshes();
+
multimesh_owner.free(p_rid);
memdelete(multimesh);
} else if (immediate_owner.owns(p_rid)) {
@@ -6288,6 +6421,25 @@ bool RasterizerStorageGLES3::free(RID p_rid){
return true;
}
+
+bool RasterizerStorageGLES3::has_os_feature(const String& p_feature) const {
+
+ if (p_feature=="s3tc")
+ return config.s3tc_supported;
+
+ if (p_feature=="etc")
+ return config.etc_supported;
+
+ if (p_feature=="etc2")
+ return config.etc2_supported;
+
+ if (p_feature=="pvrtc")
+ return config.pvrtc_supported;
+
+ return false;
+
+}
+
////////////////////////////////////////////
@@ -6296,7 +6448,7 @@ void RasterizerStorageGLES3::initialize() {
config.render_arch=RENDER_ARCH_DESKTOP;
//config.fbo_deferred=int(Globals::get_singleton()->get("rendering/gles3/lighting_technique"));
- config.system_fbo=0;
+ RasterizerStorageGLES3::system_fbo=0;
//// extensions config
@@ -6325,9 +6477,11 @@ void RasterizerStorageGLES3::initialize() {
config.latc_supported=config.extensions.has("GL_EXT_texture_compression_latc");
config.bptc_supported=config.extensions.has("GL_ARB_texture_compression_bptc");
#ifdef GLES_OVER_GL
+ config.hdr_supported=true;
config.etc2_supported=false;
#else
config.etc2_supported=true;
+ config.hdr_supported=false;
#endif
config.pvrtc_supported=config.extensions.has("GL_IMG_texture_compression_pvrtc");
config.srgb_decode_supported=config.extensions.has("GL_EXT_texture_sRGB_decode");
@@ -6463,7 +6617,7 @@ void RasterizerStorageGLES3::initialize() {
glBufferData(GL_ARRAY_BUFFER,xf_feedback_size*1024,NULL,GL_STREAM_DRAW);
}
- shaders.blend_shapes.init();;
+ shaders.blend_shapes.init();
glGenVertexArrays(1,&resources.transform_feedback_array);
@@ -6488,6 +6642,14 @@ void RasterizerStorageGLES3::finalize() {
}
+void RasterizerStorageGLES3::update_dirty_resources() {
+
+ update_dirty_multimeshes();
+ update_dirty_skeletons();
+ update_dirty_shaders();
+ update_dirty_materials();
+ update_particles();
+}
RasterizerStorageGLES3::RasterizerStorageGLES3()
{
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index f9e440288f..ab5e5612c6 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -24,6 +24,7 @@ public:
RasterizerCanvasGLES3 *canvas;
RasterizerSceneGLES3 *scene;
+ static GLuint system_fbo; //on some devices, such as apple, screen is rendered to yet another fbo.
enum RenderArchitecture {
RENDER_ARCH_MOBILE,
@@ -34,8 +35,6 @@ public:
RenderArchitecture render_arch;
- GLuint system_fbo; //on some devices, such as apple, screen is rendered to yet another fbo.
-
bool shrink_textures_x2;
bool use_fast_texture_filter;
bool use_anisotropic_filter;
@@ -47,6 +46,8 @@ public:
bool etc2_supported;
bool pvrtc_supported;
+ bool hdr_supported;
+
bool srgb_decode_supported;
bool use_rgba_2d_shadows;
@@ -229,6 +230,12 @@ public:
Image images[6];
+ VisualServer::TextureDetectCallback detect_3d;
+ void *detect_3d_ud;
+
+ VisualServer::TextureDetectCallback detect_srgb;
+ void *detect_srgb_ud;
+
Texture() {
using_srgb=false;
@@ -244,6 +251,10 @@ public:
total_data_size=0;
target=GL_TEXTURE_2D;
mipmaps=0;
+ detect_3d=NULL;
+ detect_3d_ud=NULL;
+ detect_srgb=NULL;
+ detect_srgb_ud=NULL;
}
@@ -282,6 +293,10 @@ public:
virtual void textures_keep_original(bool p_enable);
+ virtual void texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata);
+ virtual void texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata);
+
+
/* SKYBOX API */
struct SkyBox : public RID_Data {
@@ -554,6 +569,7 @@ public:
virtual void material_changed_notify() {
mesh->instance_material_change_notify();
+ mesh->update_multimeshes();
}
Surface() {
@@ -578,6 +594,7 @@ public:
}
};
+ class MultiMesh;
struct Mesh : public GeometryOwner {
@@ -587,6 +604,17 @@ public:
VS::BlendShapeMode blend_shape_mode;
Rect3 custom_aabb;
mutable uint64_t last_pass;
+ SelfList<MultiMesh>::List multimeshes;
+
+ _FORCE_INLINE_ void update_multimeshes() {
+
+ SelfList<MultiMesh> *mm = multimeshes.first();
+ while(mm) {
+ mm->self()->instance_material_change_notify();
+ mm=mm->next();
+ }
+ }
+
Mesh() {
blend_shape_mode=VS::BLEND_SHAPE_MODE_NORMALIZED;
blend_shape_count=0;
@@ -646,6 +674,7 @@ public:
Vector<float> data;
Rect3 aabb;
SelfList<MultiMesh> update_list;
+ SelfList<MultiMesh> mesh_list;
GLuint buffer;
int visible_instances;
@@ -655,7 +684,7 @@ public:
bool dirty_aabb;
bool dirty_data;
- MultiMesh() : update_list(this) {
+ MultiMesh() : update_list(this), mesh_list(this) {
dirty_aabb=true;
dirty_data=true;
xform_floats=0;
@@ -908,6 +937,8 @@ public:
int dynamic_range;
float energy;
+ float bias;
+ float propagation;
bool interior;
bool compress;
@@ -940,6 +971,12 @@ public:
virtual void gi_probe_set_energy(RID p_probe,float p_range);
virtual float gi_probe_get_energy(RID p_probe) const;
+ 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_propagation(RID p_probe,float p_range);
+ virtual float gi_probe_get_propagation(RID p_probe) const;
+
virtual void gi_probe_set_interior(RID p_probe,bool p_enable);
virtual bool gi_probe_is_interior(RID p_probe) const;
@@ -1011,7 +1048,7 @@ public:
Particles() : particle_element(this) {
emitting=false;
amount=0;
- lifetime=1.0;;
+ lifetime=1.0;
pre_process_time=0.0;
explosiveness=0.0;
randomness=0.0;
@@ -1161,9 +1198,11 @@ public:
height=0;
depth=0;
fbo=0;
+ exposure.fbo=0;
buffers.fbo=0;
used_in_frame=false;
+
flags[RENDER_TARGET_VFLIP]=false;
flags[RENDER_TARGET_TRANSPARENT]=false;
flags[RENDER_TARGET_NO_3D]=false;
@@ -1238,7 +1277,9 @@ public:
void initialize();
void finalize();
+ virtual bool has_os_feature(const String& p_feature) const;
+ virtual void update_dirty_resources();
RasterizerStorageGLES3();
};
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 26b9aeada4..14764afdba 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -401,6 +401,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
String scode = _dump_node_code(bnode->statements[i],p_level,r_gen_code,p_actions,p_default_actions);
if (bnode->statements[i]->type==SL::Node::TYPE_CONTROL_FLOW || bnode->statements[i]->type==SL::Node::TYPE_CONTROL_FLOW) {
+ // FIXME: if (A || A) ? I am hesitant to delete one of them, could be copy-paste error.
code+=scode; //use directly
} else {
code+=_mktab(p_level)+scode+";\n";
@@ -582,6 +583,7 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String& p_code,
used_name_defines.clear();
used_rmode_defines.clear();
+ used_flag_pointers.clear();
_dump_node_code(parser.get_shader(),1,r_gen_code,*p_actions,actions[p_mode]);
@@ -676,7 +678,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["AO"]="ao";
actions[VS::SHADER_SPATIAL].renames["EMISSION"]="emission";
actions[VS::SHADER_SPATIAL].renames["DISCARD"]="_discard";
-// actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
+ //actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"]=ShaderLanguage::TYPE_VEC2;
actions[VS::SHADER_SPATIAL].renames["POINT_COORD"]="gl_PointCoord";
diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp
index 13b2160ec6..42a9f19671 100644
--- a/drivers/gles3/shader_gles3.cpp
+++ b/drivers/gles3/shader_gles3.cpp
@@ -573,7 +573,7 @@ ShaderGLES3::Version* ShaderGLES3::get_current_version() {
v.uniform_location[j]=glGetUniformLocation(v.id,uniform_names[j]);
- // print_line("uniform "+String(uniform_names[j])+" location "+itos(v.uniform_location[j]));
+ //print_line("uniform "+String(uniform_names[j])+" location "+itos(v.uniform_location[j]));
}
// set texture uniforms
@@ -720,7 +720,7 @@ void ShaderGLES3::setup(const char** p_conditional_defines, int p_conditional_co
} else {
fragment_code3=code3.substr(0,cpos).ascii();
- // print_line("CODE3:\n"+String(fragment_code3.get_data()));
+ //print_line("CODE3:\n"+String(fragment_code3.get_data()));
fragment_code4 = code3.substr(cpos+light_code_tag.length(),code3.length()).ascii();
//print_line("CODE4:\n"+String(fragment_code4.get_data()));
}
diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h
index ee8db2ac8c..c2d283d492 100644
--- a/drivers/gles3/shader_gles3.h
+++ b/drivers/gles3/shader_gles3.h
@@ -149,7 +149,7 @@ private:
struct VersionKeyHash {
- static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHahserDefault::hash(p_key.key); };
+ static _FORCE_INLINE_ uint32_t hash( const VersionKey& p_key) { return HashMapHasherDefault::hash(p_key.key); };
};
//this should use a way more cachefriendly version..
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index cf2e0f776f..e6c72da8f1 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -449,7 +449,7 @@ LIGHT_SHADER_CODE
//use lighting
#endif
-// color.rgb*=color.a;
+ //color.rgb*=color.a;
frag_color = color;
}
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index c5af010c96..a0bf6cd58b 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -71,6 +71,7 @@ layout(std140) uniform SceneData { //ubo:0
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
+ highp vec2 screen_pixel_size;
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;
@@ -91,7 +92,7 @@ layout(std140) uniform DirectionalLightData { //ubo:3
mediump vec4 light_color_energy;
mediump vec4 light_params; //cone attenuation, angle, specular, shadow enabled,
mediump vec4 light_clamp;
- mediump vec4 shadow_color;
+ mediump vec4 shadow_color_contact;
highp mat4 shadow_matrix1;
highp mat4 shadow_matrix2;
highp mat4 shadow_matrix3;
@@ -126,13 +127,6 @@ out vec3 binormal_interp;
#endif
-#if !defined(USE_DEPTH_SHADOWS) && defined(USE_SHADOW_PASS)
-
-varying vec4 position_interp;
-
-#endif
-
-
VERTEX_SHADER_GLOBALS
@@ -161,6 +155,8 @@ layout(std140) uniform SkeletonData { //ubo:7
#endif
+out highp vec4 position_interp;
+
void main() {
highp vec4 vertex = vertex_attrib; // vec4(vertex_attrib.xyz * data_attrib.x,1.0);
@@ -293,7 +289,7 @@ VERTEX_SHADER_CODE
gl_Position = vertex;
#endif
-
+ position_interp=gl_Position;
}
@@ -375,6 +371,8 @@ layout(std140) uniform SceneData {
highp vec4 ambient_light_color;
highp vec4 bg_color;
+
+
float ambient_energy;
float bg_energy;
@@ -383,6 +381,7 @@ layout(std140) uniform SceneData {
float shadow_dual_paraboloid_render_zfar;
float shadow_dual_paraboloid_render_side;
+ highp vec2 screen_pixel_size;
vec2 shadow_atlas_pixel_size;
vec2 directional_shadow_pixel_size;
@@ -403,7 +402,7 @@ layout(std140) uniform DirectionalLightData {
mediump vec4 light_color_energy;
mediump vec4 light_params; //cone attenuation, angle, specular, shadow enabled,
mediump vec4 light_clamp;
- mediump vec4 shadow_color;
+ mediump vec4 shadow_color_contact;
highp mat4 shadow_matrix1;
highp mat4 shadow_matrix2;
highp mat4 shadow_matrix3;
@@ -425,7 +424,7 @@ struct LightData {
mediump vec4 light_color_energy;
mediump vec4 light_params; //cone attenuation, angle, specular, shadow enabled,
mediump vec4 light_clamp;
- mediump vec4 shadow_color;
+ mediump vec4 shadow_color_contact;
highp mat4 shadow_matrix;
};
@@ -493,6 +492,69 @@ layout(location=0) out vec4 frag_color;
#endif
+in highp vec4 position_interp;
+uniform highp sampler2D depth_buffer; //texunit:-8
+
+float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) {
+
+ if (abs(dir.z)>0.99)
+ return 1.0;
+
+ vec3 endpoint = pos+dir*max_distance;
+ vec4 source = position_interp;
+ vec4 dest = projection_matrix * vec4(endpoint, 1.0);
+
+ vec2 from_screen = (source.xy / source.w) * 0.5 + 0.5;
+ vec2 to_screen = (dest.xy / dest.w) * 0.5 + 0.5;
+
+ vec2 screen_rel = to_screen - from_screen;
+
+ /*float pixel_size; //approximate pixel size
+
+ if (screen_rel.x > screen_rel.y) {
+
+ pixel_size = abs((pos.x-endpoint.x)/(screen_rel.x/screen_pixel_size.x));
+ } else {
+ pixel_size = abs((pos.y-endpoint.y)/(screen_rel.y/screen_pixel_size.y));
+
+ }*/
+ vec4 bias = projection_matrix * vec4(pos+vec3(0.0,0.0,0.04), 1.0); //todo un-harcode the 0.04
+
+
+
+ vec2 pixel_incr = normalize(screen_rel)*screen_pixel_size;
+
+ float steps = length(screen_rel) / length(pixel_incr);
+
+ //steps=10.0;
+
+ vec4 incr = (dest - source)/steps;
+ float ratio=0.0;
+ float ratio_incr = 1.0/steps;
+
+ do {
+ source += incr*2.0;
+ bias+=incr*2.0;
+
+ vec3 uv_depth = (source.xyz / source.w) * 0.5 + 0.5;
+ float depth = texture(depth_buffer,uv_depth.xy).r;
+
+ if (depth < uv_depth.z) {
+ if (depth > (bias.z/bias.w) * 0.5 + 0.5) {
+ return min(pow(ratio,4.0),1.0);
+ } else {
+ return 1.0;
+ }
+ }
+
+
+ ratio+=ratio_incr;
+ steps-=1.0;
+ } while (steps>0.0);
+
+ return 1.0;
+}
+
// GGX Specular
// Source: http://www.filmicworlds.com/images/ggx-opt/optimized-ggx.hlsl
@@ -517,6 +579,8 @@ float GTR1(float NdotH, float a)
return (a2-1.0) / (M_PI*log(a2)*t);
}
+
+
void light_compute(vec3 N, vec3 L,vec3 V,vec3 B, vec3 T,vec3 light_color,vec3 diffuse_color, vec3 specular_color, float specular_blob_intensity, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse, inout vec3 specular) {
float dotNL = max(dot(N,L), 0.0 );
@@ -660,7 +724,8 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po
void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 specular, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex;
- float normalized_distance = length( light_rel_vec )*omni_lights[idx].light_pos_inv_radius.w;
+ 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 ));
if (omni_lights[idx].light_params.w>0.5) {
@@ -681,11 +746,13 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
splane.z=1.0 - splane.z;
- //if (clamp_rect.z<clamp_rect.w) {
- // clamp_rect.x+=clamp_rect.z;
- //} else {
- // clamp_rect.y+=clamp_rect.w;
- //}
+ /*
+ if (clamp_rect.z<clamp_rect.w) {
+ clamp_rect.x+=clamp_rect.z;
+ } else {
+ clamp_rect.y+=clamp_rect.w;
+ }
+ */
}
@@ -694,8 +761,15 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
splane.z = shadow_len * omni_lights[idx].light_pos_inv_radius.w;
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);
+ 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);
+
- light_attenuation*=mix(omni_lights[idx].shadow_color.rgb,vec3(1.0),sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,clamp_rect));
+ }
+ 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,specular,omni_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
@@ -705,7 +779,8 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino
void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, vec3 specular, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy, inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex;
- float normalized_distance = length( light_rel_vec )*spot_lights[idx].light_pos_inv_radius.w;
+ 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 spot_dir = spot_lights[idx].light_direction_attenuation.xyz;
float spot_cutoff=spot_lights[idx].light_params.y;
@@ -717,7 +792,17 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi
//there is a shadowmap
highp vec4 splane=(spot_lights[idx].shadow_matrix * vec4(vertex,1.0));
splane.xyz/=splane.w;
- light_attenuation*=mix(spot_lights[idx].shadow_color.rgb,vec3(1.0),sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,spot_lights[idx].light_clamp));
+
+ float shadow = sample_shadow(shadow_atlas,shadow_atlas_pixel_size,splane.xy,splane.z,spot_lights[idx].light_clamp);
+
+ 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);
+
+ }
+
+ 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,specular,spot_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light);
@@ -846,6 +931,7 @@ uniform highp mat4 gi_probe_xform1;
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 bool gi_probe_blend_ambient1;
uniform mediump sampler3D gi_probe2; //texunit:-7
@@ -853,13 +939,14 @@ uniform highp mat4 gi_probe_xform2;
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 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) {
+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 = dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0;
+ 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);
@@ -872,12 +959,14 @@ vec3 voxel_cone_trace(sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, b
dist += diameter * 0.5;
}
- //color.rgb = mix(color.rgb,mix(ambient,color.rgb,alpha),blend_ambient);
+ if (blend_ambient) {
+ color.rgb = mix(ambient,color.rgb,min(1.0,alpha/0.95));
+ }
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, 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, out vec4 out_spec, out vec4 out_diff) {
@@ -938,7 +1027,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
for(int i=0;i<MAX_CONE_DIRS;i++) {
vec3 dir = normalize( (probe_xform * vec4(pos + normal_mtx * cone_dirs[i],1.0)).xyz - probe_pos);
- light+=cone_weights[i] * voxel_cone_trace(probe,cell_size,probe_pos,ambient,blend_ambient,dir,cone_angle_tan,max_distance);
+ light+=cone_weights[i] * voxel_cone_trace(probe,cell_size,probe_pos,ambient,blend_ambient,dir,cone_angle_tan,max_distance,p_bias);
}
@@ -948,7 +1037,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
//irradiance
- vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,max(min_ref_tan,tan(roughness * 0.5 * M_PI)) ,max_distance);
+ vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,max(min_ref_tan,tan(roughness * 0.5 * M_PI)) ,max_distance,p_bias);
irr_light *= multiplier;
//irr_light=vec3(0.0);
@@ -979,11 +1068,11 @@ void gi_probes_compute(vec3 pos, vec3 normal, float roughness, vec3 specular, in
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,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,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,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,spec_accum,diff_accum);
}
if (diff_accum.a>0.0) {
@@ -1266,6 +1355,8 @@ FRAGMENT_SHADER_CODE
}
}
+
+
#endif //LIGHT_USE_PSSM4
#ifdef LIGHT_USE_PSSM2
@@ -1304,16 +1395,26 @@ FRAGMENT_SHADER_CODE
//one one sample
- light_attenuation=mix(shadow_color.rgb,vec3(1.0),sample_shadow(directional_shadow,directional_shadow_pixel_size,pssm_coord.xy,pssm_coord.z,light_clamp));
+ float shadow = sample_shadow(directional_shadow,directional_shadow_pixel_size,pssm_coord.xy,pssm_coord.z,light_clamp);
#if defined(LIGHT_USE_PSSM_BLEND)
+
if (use_blend) {
- vec3 light_attenuation2=mix(shadow_color.rgb,vec3(1.0),sample_shadow(directional_shadow,directional_shadow_pixel_size,pssm_coord2.xy,pssm_coord2.z,light_clamp));
- light_attenuation=mix(light_attenuation,light_attenuation2,pssm_blend);
+ shadow=mix(shadow, sample_shadow(directional_shadow,directional_shadow_pixel_size,pssm_coord2.xy,pssm_coord2.z,light_clamp));
}
#endif
+ 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);
+
+ }
+
+ light_attenuation=mix(shadow_color_contact.rgb,vec3(1.0),shadow);
+
+
}
#endif //LIGHT_DIRECTIONAL_SHADOW
diff --git a/drivers/gles3/shaders/ssao.glsl b/drivers/gles3/shaders/ssao.glsl
index 75f49ef37a..ba29ec52c7 100644
--- a/drivers/gles3/shaders/ssao.glsl
+++ b/drivers/gles3/shaders/ssao.glsl
@@ -29,7 +29,7 @@ void main() {
uniform sampler2D source_depth; //texunit:0
-uniform usampler2D source_depth_mipmaps; //texunit:1
+uniform highp usampler2D source_depth_mipmaps; //texunit:1
uniform sampler2D source_normal; //texunit:2
uniform ivec2 screen_size;
@@ -78,8 +78,8 @@ vec3 reconstructCSFaceNormal(vec3 C) {
/** Returns a unit vector and a screen-space radius for the tap on a unit disk (the caller should scale by the actual disk radius) */
vec2 tapLocation(int sampleNumber, float spinAngle, out float ssR){
// Radius relative to ssR
- float alpha = float(sampleNumber + 0.5) * (1.0 / NUM_SAMPLES);
- float angle = alpha * (NUM_SPIRAL_TURNS * 6.28) + spinAngle;
+ float alpha = (float(sampleNumber) + 0.5) * (1.0 / float(NUM_SAMPLES));
+ float angle = alpha * (float(NUM_SPIRAL_TURNS) * 6.28) + spinAngle;
ssR = alpha;
return vec2(cos(angle), sin(angle));
@@ -193,7 +193,7 @@ void main() {
// Hash function used in the HPG12 AlchemyAO paper
- float randomPatternRotationAngle = (3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10;
+ float randomPatternRotationAngle = float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10);
// Reconstruct normals from positions. These will lead to 1-pixel black lines
// at depth discontinuities, however the blur will wipe those out so they are not visible
@@ -208,12 +208,12 @@ void main() {
sum += sampleAO(ssC, C, n_C, ssDiskRadius, radius,i, randomPatternRotationAngle);
}
- float A = max(0.0, 1.0 - sum * intensity_div_r6 * (5.0 / NUM_SAMPLES));
+ float A = max(0.0, 1.0 - sum * intensity_div_r6 * (5.0 / float(NUM_SAMPLES)));
#ifdef ENABLE_RADIUS2
//go again for radius2
- randomPatternRotationAngle = (5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11;
+ randomPatternRotationAngle = float((5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11);
// Reconstruct normals from positions. These will lead to 1-pixel black lines
// at depth discontinuities, however the blur will wipe those out so they are not visible
@@ -228,15 +228,15 @@ void main() {
sum += sampleAO(ssC, C, n_C, ssDiskRadius,radius2, i, randomPatternRotationAngle);
}
- A= min(A,max(0.0, 1.0 - sum * intensity_div_r62 * (5.0 / NUM_SAMPLES)));
+ A= min(A,max(0.0, 1.0 - sum * intensity_div_r62 * (5.0 / float(NUM_SAMPLES))));
#endif
// Bilateral box-filter over a quad for free, respecting depth edges
// (the difference that this makes is subtle)
if (abs(dFdx(C.z)) < 0.02) {
- A -= dFdx(A) * ((ssC.x & 1) - 0.5);
+ A -= dFdx(A) * (float(ssC.x & 1) - 0.5);
}
if (abs(dFdy(C.z)) < 0.02) {
- A -= dFdy(A) * ((ssC.y & 1) - 0.5);
+ A -= dFdy(A) * (float(ssC.y & 1) - 0.5);
}
visibility = A;
diff --git a/drivers/gles3/shaders/ssao_blur.glsl b/drivers/gles3/shaders/ssao_blur.glsl
index 31f3841a2a..ff852487c0 100644
--- a/drivers/gles3/shaders/ssao_blur.glsl
+++ b/drivers/gles3/shaders/ssao_blur.glsl
@@ -69,9 +69,11 @@ void main() {
depth*=depth_divide;
- //if (depth > camera_z_far*0.999) {
- // discard;//skybox
- //}
+ /*
+ if (depth > camera_z_far*0.999) {
+ discard;//skybox
+ }
+ */
float sum = texelFetch(source_ssao, ssC, 0).r;
diff --git a/drivers/gles3/shaders/ssao_minify.glsl b/drivers/gles3/shaders/ssao_minify.glsl
index df9045c28a..6e46a1842c 100644
--- a/drivers/gles3/shaders/ssao_minify.glsl
+++ b/drivers/gles3/shaders/ssao_minify.glsl
@@ -43,7 +43,7 @@ void main() {
fdepth = fdepth * 2.0 - 1.0;
fdepth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - fdepth * (camera_z_far - camera_z_near));
fdepth /= camera_z_far;
- depth = uint(clamp(fdepth*65535,0.0,65535.0));
+ depth = uint(clamp(fdepth*65535.0,0.0,65535.0));
#else
depth = texelFetch(source_depth, clamp(ssP * 2 + ivec2(ssP.y & 1, ssP.x & 1), ivec2(0), from_size - ivec2(1)), source_mipmap).r;
diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp
index de095c20ac..51429f3416 100644
--- a/drivers/png/image_loader_png.cpp
+++ b/drivers/png/image_loader_png.cpp
@@ -134,7 +134,7 @@ Error ImageLoaderPNG::_load_image(void *rf_up,png_rw_ptr p_func,Image *p_image)
}
if (png_get_valid(png,info,PNG_INFO_tRNS)) {
-// png_set_expand_gray_1_2_4_to_8(png);
+ //png_set_expand_gray_1_2_4_to_8(png);
png_set_tRNS_to_alpha(png);
update_info=true;
}
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index a9a199bb59..f55b089ded 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -29,7 +29,7 @@
#include "resource_saver_png.h"
#include "core/image.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "scene/resources/texture.h"
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 3a1317cbf6..f5268f3ebd 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -32,7 +32,7 @@
#include <pulse/error.h>
-#include "globals.h"
+#include "global_config.h"
Error AudioDriverPulseAudio::init() {
@@ -44,7 +44,7 @@ Error AudioDriverPulseAudio::init() {
samples_out = NULL;
mix_rate = GLOBAL_DEF("audio/mix_rate",44100);
- output_format = OUTPUT_STEREO;
+ speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
pa_sample_spec spec;
@@ -65,15 +65,15 @@ Error AudioDriverPulseAudio::init() {
int error_code;
pulse = pa_simple_new( NULL, // default server
- "Godot", // application name
- PA_STREAM_PLAYBACK,
- NULL, // default device
- "Sound", // stream description
- &spec,
- NULL, // use default channel map
- &attr, // use buffering attributes from above
- &error_code
- );
+ "Godot", // application name
+ PA_STREAM_PLAYBACK,
+ NULL, // default device
+ "Sound", // stream description
+ &spec,
+ NULL, // use default channel map
+ &attr, // use buffering attributes from above
+ &error_code
+ );
if (pulse == NULL) {
fprintf(stderr, "PulseAudio ERR: %s\n", pa_strerror(error_code));\
@@ -103,6 +103,7 @@ float AudioDriverPulseAudio::get_latency() {
void AudioDriverPulseAudio::thread_func(void* p_udata) {
+ print_line("thread");
AudioDriverPulseAudio* ad = (AudioDriverPulseAudio*)p_udata;
while (!ad->exit_thread) {
@@ -121,9 +122,9 @@ void AudioDriverPulseAudio::thread_func(void* p_udata) {
for (unsigned int i=0; i < ad->buffer_size * ad->channels;i ++) {
ad->samples_out[i] = ad->samples_in[i] >> 16;
}
- }
+ }
- // pa_simple_write always consumes the entire buffer
+ // pa_simple_write always consumes the entire buffer
int error_code;
int byte_size = ad->buffer_size * sizeof(int16_t) * ad->channels;
@@ -134,7 +135,7 @@ void AudioDriverPulseAudio::thread_func(void* p_udata) {
ad->exit_thread = true;
break;
}
- }
+ }
ad->thread_exited = true;
}
@@ -149,9 +150,9 @@ int AudioDriverPulseAudio::get_mix_rate() const {
return mix_rate;
}
-AudioDriverSW::OutputFormat AudioDriverPulseAudio::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverPulseAudio::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
}
void AudioDriverPulseAudio::lock() {
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index aa7b7a9188..36ae8c2e53 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#ifdef PULSEAUDIO_ENABLED
@@ -35,7 +35,7 @@
#include <pulse/simple.h>
-class AudioDriverPulseAudio : public AudioDriverSW {
+class AudioDriverPulseAudio : public AudioDriver{
Thread* thread;
Mutex* mutex;
@@ -48,7 +48,7 @@ class AudioDriverPulseAudio : public AudioDriverSW {
static void thread_func(void* p_udata);
unsigned int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
unsigned int buffer_size;
int channels;
@@ -69,7 +69,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp
index a798990449..cc715545bd 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.cpp
+++ b/drivers/rtaudio/audio_driver_rtaudio.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_rtaudio.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
#ifdef RTAUDIO_ENABLED
@@ -71,7 +71,7 @@ int AudioDriverRtAudio::callback( void *outputBuffer, void *inputBuffer, unsigne
self->audio_server_process(nBufferFrames,buffer);
- self->mutex->unlock();;
+ self->mutex->unlock();
return 0;
}
@@ -85,6 +85,8 @@ Error AudioDriverRtAudio::init() {
ERR_EXPLAIN("Cannot initialize RtAudio audio driver: No devices present.")
ERR_FAIL_COND_V( dac->getDeviceCount() < 1, ERR_UNAVAILABLE );
+ // FIXME: Adapt to the OutputFormat -> SpeakerMode change
+ /*
String channels = GLOBAL_DEF("audio/output","stereo");
if (channels=="5.1")
@@ -95,6 +97,7 @@ Error AudioDriverRtAudio::init() {
output_format=OUTPUT_MONO;
else
output_format=OUTPUT_STEREO;
+ */
RtAudio::StreamParameters parameters;
parameters.deviceId = dac->getDefaultOutputDevice();
@@ -104,11 +107,11 @@ Error AudioDriverRtAudio::init() {
unsigned int target_number_of_buffers = 4;
options.numberOfBuffers = target_number_of_buffers;
-// options.
-// RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE). *///
-// unsigned int numberOfBuffers; /*!< Number of stream buffers. */
-// std::string streamName; /*!< A stream name (currently used only in Jack). */
-// int priority; /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */
+ //options.
+ //RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE). *///
+ //unsigned int numberOfBuffers; /*!< Number of stream buffers. */
+ //std::string streamName; /*!< A stream name (currently used only in Jack). */
+ //int priority; /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */
parameters.firstChannel = 0;
mix_rate = GLOBAL_DEF("audio/mix_rate",44100);
@@ -125,11 +128,10 @@ Error AudioDriverRtAudio::init() {
while(true) {
while( true) {
- switch(output_format) {
- case OUTPUT_MONO: parameters.nChannels = 1; break;
- case OUTPUT_STEREO: parameters.nChannels = 2; break;
- case OUTPUT_QUAD: parameters.nChannels = 4; break;
- case OUTPUT_5_1: parameters.nChannels = 6; break;
+ switch(speaker_mode) {
+ case SPEAKER_MODE_STEREO: parameters.nChannels = 2; break;
+ case SPEAKER_SURROUND_51: parameters.nChannels = 6; break;
+ case SPEAKER_SURROUND_71: parameters.nChannels = 8; break;
};
try {
@@ -142,11 +144,10 @@ Error AudioDriverRtAudio::init() {
// try with less channels
ERR_PRINT("Unable to open audio, retrying with fewer channels..");
- switch(output_format) {
- case OUTPUT_MONO: ERR_EXPLAIN("Unable to open audio."); ERR_FAIL_V( ERR_UNAVAILABLE ); break;
- case OUTPUT_STEREO: output_format=OUTPUT_MONO; break;
- case OUTPUT_QUAD: output_format=OUTPUT_STEREO; break;
- case OUTPUT_5_1: output_format=OUTPUT_QUAD; break;
+ switch(speaker_mode) {
+ case SPEAKER_MODE_STEREO: speaker_mode=SPEAKER_MODE_STEREO; break;
+ case SPEAKER_SURROUND_51: speaker_mode=SPEAKER_SURROUND_51; break;
+ case SPEAKER_SURROUND_71: speaker_mode=SPEAKER_SURROUND_71; break;
};
}
}
@@ -189,9 +190,9 @@ int AudioDriverRtAudio::get_mix_rate() const {
return mix_rate;
}
-AudioDriverSW::OutputFormat AudioDriverRtAudio::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverRtAudio::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
}
void AudioDriverRtAudio::start() {
@@ -229,7 +230,7 @@ AudioDriverRtAudio::AudioDriverRtAudio()
mutex=NULL;
mix_rate=44100;
- output_format=OUTPUT_STEREO;
+ speaker_mode=SPEAKER_MODE_STEREO;
}
diff --git a/drivers/rtaudio/audio_driver_rtaudio.h b/drivers/rtaudio/audio_driver_rtaudio.h
index aa7fae038a..3f293db6a6 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.h
+++ b/drivers/rtaudio/audio_driver_rtaudio.h
@@ -31,16 +31,16 @@
#ifdef RTAUDIO_ENABLED
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include <RtAudio.h>
-class AudioDriverRtAudio : public AudioDriverSW {
+class AudioDriverRtAudio : public AudioDriver {
static int callback( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *userData );
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
Mutex *mutex;
RtAudio *dac;
int mix_rate;
@@ -53,7 +53,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const ;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 3bb30700db..a09cf80e6c 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -44,20 +44,20 @@ DirAccess *DirAccessUnix::create_fs() {
return memnew( DirAccessUnix );
}
-bool DirAccessUnix::list_dir_begin() {
+Error DirAccessUnix::list_dir_begin() {
list_dir_end(); //close any previous dir opening!
-// char real_current_dir_name[2048]; //is this enough?!
+ //char real_current_dir_name[2048]; //is this enough?!
//getcwd(real_current_dir_name,2048);
//chdir(curent_path.utf8().get_data());
dir_stream = opendir(current_dir.utf8().get_data());
//chdir(real_current_dir_name);
if (!dir_stream)
- return true; //error!
+ return ERR_CANT_OPEN; //error!
- return false;
+ return OK;
}
bool DirAccessUnix::file_exists(String p_file) {
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index 324d2a379c..f075c48268 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -57,7 +57,7 @@ protected:
public:
- virtual bool list_dir_begin(); ///< This starts dir listing
+ virtual Error list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 283cff0486..fe49501328 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -30,6 +30,7 @@
#ifdef UNIX_ENABLED
+#include "servers/visual_server.h"
#include "thread_posix.h"
#include "semaphore_posix.h"
@@ -60,7 +61,7 @@
#include <poll.h>
#include <errno.h>
#include <assert.h>
-#include "globals.h"
+#include "global_config.h"
extern bool _print_error_enabled;
@@ -116,7 +117,13 @@ int OS_Unix::unix_initialize_audio(int p_audio_driver) {
return 0;
}
-
+// Very simple signal handler to reap processes where ::execute was called with
+// !p_blocking
+void handle_sigchld(int sig) {
+ int saved_errno = errno;
+ while (waitpid((pid_t)(-1), 0, WNOHANG) > 0) {}
+ errno = saved_errno;
+}
void OS_Unix::initialize_core() {
@@ -147,6 +154,14 @@ void OS_Unix::initialize_core() {
ticks_start=0;
ticks_start=get_ticks_usec();
+
+ struct sigaction sa;
+ sa.sa_handler = &handle_sigchld;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+ if (sigaction(SIGCHLD, &sa, 0) == -1) {
+ perror("ERROR sigaction() failed:");
+ }
}
void OS_Unix::finalize_core() {
@@ -478,6 +493,13 @@ String OS_Unix::get_data_dir() const {
}
+bool OS_Unix::check_feature_support(const String& p_feature) {
+
+ return VisualServer::get_singleton()->has_os_feature(p_feature);
+
+}
+
+
String OS_Unix::get_installed_templates_path() const {
String p=get_global_settings_path();
if (p!="")
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index b28adc2ee0..220f818ff6 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -117,6 +117,8 @@ 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/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp
index 4d9ef6cdae..7696a5fcb5 100644
--- a/drivers/unix/packet_peer_udp_posix.cpp
+++ b/drivers/unix/packet_peer_udp_posix.cpp
@@ -96,12 +96,15 @@ Error PacketPeerUDPPosix::get_packet(const uint8_t **r_buffer,int &r_buffer_size
}
Error PacketPeerUDPPosix::put_packet(const uint8_t *p_buffer,int p_buffer_size){
- ERR_FAIL_COND_V(peer_addr == IP_Address(), ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED);
+
+ if (sock_type==IP::TYPE_NONE)
+ sock_type = peer_addr.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
int sock = _get_socket();
ERR_FAIL_COND_V( sock == -1, FAILED );
struct sockaddr_storage addr;
- size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, ip_type);
+ size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, sock_type);
errno = 0;
int err;
@@ -121,16 +124,27 @@ int PacketPeerUDPPosix::get_max_packet_size() const{
return 512; // uhm maybe not
}
-Error PacketPeerUDPPosix::listen(int p_port, int p_recv_buffer_size) {
+Error PacketPeerUDPPosix::listen(int p_port, IP_Address p_bind_address, int p_recv_buffer_size) {
+
+ ERR_FAIL_COND_V(sockfd!=-1,ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(),ERR_INVALID_PARAMETER);
+
+#ifdef __OpenBSD__
+ sock_type = IP::TYPE_IPV4; // OpenBSD does not support dual stacking, fallback to IPv4 only.
+#else
+ sock_type = IP::TYPE_ANY;
+#endif
+
+ if(p_bind_address.is_valid())
+ sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
- close();
int sock = _get_socket();
if (sock == -1 )
return ERR_CANT_CREATE;
sockaddr_storage addr = {0};
- size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, NULL);
+ size_t addr_size = _set_listen_sockaddr(&addr, p_port, sock_type, IP_Address());
if (bind(sock, (struct sockaddr*)&addr, addr_size) == -1 ) {
close();
@@ -145,7 +159,8 @@ void PacketPeerUDPPosix::close(){
if (sockfd != -1)
::close(sockfd);
sockfd=-1;
- rb.resize(8);
+ sock_type = IP::TYPE_NONE;
+ rb.resize(16);
queue_count=0;
}
@@ -157,10 +172,14 @@ Error PacketPeerUDPPosix::wait() {
Error PacketPeerUDPPosix::_poll(bool p_wait) {
+ if (sockfd==-1) {
+ return FAILED;
+ }
+
struct sockaddr_storage from = {0};
socklen_t len = sizeof(struct sockaddr_storage);
int ret;
- while ( (ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) {
+ while ( (ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-24, 0)), p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) {
uint32_t port = 0;
@@ -221,16 +240,18 @@ int PacketPeerUDPPosix::get_packet_port() const{
int PacketPeerUDPPosix::_get_socket() {
+ ERR_FAIL_COND_V(sock_type==IP::TYPE_NONE, -1);
+
if (sockfd != -1)
return sockfd;
- sockfd = _socket_create(ip_type, SOCK_DGRAM, IPPROTO_UDP);
+ sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP);
return sockfd;
}
-void PacketPeerUDPPosix::set_send_address(const IP_Address& p_address,int p_port) {
+void PacketPeerUDPPosix::set_dest_address(const IP_Address& p_address,int p_port) {
peer_addr=p_address;
peer_port=p_port;
@@ -253,7 +274,8 @@ PacketPeerUDPPosix::PacketPeerUDPPosix() {
packet_port=0;
queue_count=0;
peer_port=0;
- ip_type = IP::TYPE_ANY;
+ sock_type = IP::TYPE_NONE;
+ rb.resize(16);
}
PacketPeerUDPPosix::~PacketPeerUDPPosix() {
diff --git a/drivers/unix/packet_peer_udp_posix.h b/drivers/unix/packet_peer_udp_posix.h
index 89b8886cf5..ac68344d78 100644
--- a/drivers/unix/packet_peer_udp_posix.h
+++ b/drivers/unix/packet_peer_udp_posix.h
@@ -48,6 +48,7 @@ class PacketPeerUDPPosix : public PacketPeerUDP {
mutable int packet_port;
mutable int queue_count;
int sockfd;
+ IP::Type sock_type;
IP_Address peer_addr;
int peer_port;
@@ -65,7 +66,7 @@ public:
virtual int get_max_packet_size() const;
- virtual Error listen(int p_port, int p_recv_buffer_size=65536);
+ virtual Error listen(int p_port, IP_Address p_bind_address=IP_Address("*"), int p_recv_buffer_size=65536);
virtual void close();
virtual Error wait();
virtual bool is_listening() const;
@@ -73,7 +74,7 @@ public:
virtual IP_Address get_packet_address() const;
virtual int get_packet_port() const;
- virtual void set_send_address(const IP_Address& p_address,int p_port);
+ virtual void set_dest_address(const IP_Address& p_address,int p_port);
static void make_default();
diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h
index 6d4f7e7519..bb1a866552 100644
--- a/drivers/unix/socket_helpers.h
+++ b/drivers/unix/socket_helpers.h
@@ -16,7 +16,7 @@ static size_t _set_sockaddr(struct sockaddr_storage* p_addr, const IP_Address& p
memset(p_addr, 0, sizeof(struct sockaddr_storage));
- ERR_FAIL_COND_V(p_ip==IP_Address(),0);
+ ERR_FAIL_COND_V(!p_ip.is_valid(),0);
// IPv6 socket
if (p_sock_type == IP::TYPE_IPV6 || p_sock_type == IP::TYPE_ANY) {
@@ -44,21 +44,29 @@ static size_t _set_sockaddr(struct sockaddr_storage* p_addr, const IP_Address& p
};
};
-static size_t _set_listen_sockaddr(struct sockaddr_storage* p_addr, int p_port, IP::Type p_sock_type, const List<String> *p_accepted_hosts) {
+static size_t _set_listen_sockaddr(struct sockaddr_storage* p_addr, int p_port, IP::Type p_sock_type, const IP_Address p_bind_address) {
memset(p_addr, 0, sizeof(struct sockaddr_storage));
if (p_sock_type == IP::TYPE_IPV4) {
struct sockaddr_in* addr4 = (struct sockaddr_in*)p_addr;
addr4->sin_family = AF_INET;
addr4->sin_port = htons(p_port);
- addr4->sin_addr.s_addr = INADDR_ANY; // TODO: use accepted hosts list
+ if(p_bind_address.is_valid()) {
+ copymem(&addr4->sin_addr.s_addr, p_bind_address.get_ipv4(), 4);
+ } else {
+ addr4->sin_addr.s_addr = INADDR_ANY;
+ }
return sizeof(sockaddr_in);
} else {
struct sockaddr_in6* addr6 = (struct sockaddr_in6*)p_addr;
addr6->sin6_family = AF_INET6;
addr6->sin6_port = htons(p_port);
- addr6->sin6_addr = in6addr_any; // TODO: use accepted hosts list
+ if(p_bind_address.is_valid()) {
+ copymem(&addr6->sin6_addr.s6_addr, p_bind_address.get_ipv6(), 16);
+ } else {
+ addr6->sin6_addr = in6addr_any;
+ }
return sizeof(sockaddr_in6);
};
};
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index f2a1417920..08a2954617 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -88,17 +88,12 @@ Error StreamPeerTCPPosix::_block(int p_sockfd, bool p_read, bool p_write) const
return ret < 0 ? FAILED : OK;
};
-Error StreamPeerTCPPosix::_poll_connection(bool p_block) const {
+Error StreamPeerTCPPosix::_poll_connection() const {
ERR_FAIL_COND_V(status != STATUS_CONNECTING || sockfd == -1, FAILED);
- if (p_block) {
-
- _block(sockfd, false, true);
- };
-
struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, ip_type);
+ size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, sock_type);
if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == -1) {
@@ -122,9 +117,9 @@ Error StreamPeerTCPPosix::_poll_connection(bool p_block) const {
return OK;
};
-void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type) {
+void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type) {
- ip_type = p_ip_type;
+ sock_type = p_sock_type;
sockfd = p_sockfd;
#ifndef NO_FCNTL
fcntl(sockfd, F_SETFL, O_NONBLOCK);
@@ -139,14 +134,15 @@ void StreamPeerTCPPosix::set_socket(int p_sockfd, IP_Address p_host, int p_port,
peer_port = p_port;
};
-Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) {
+Error StreamPeerTCPPosix::connect_to_host(const IP_Address& p_host, uint16_t p_port) {
- ERR_FAIL_COND_V( p_host == IP_Address(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V( !p_host.is_valid(), ERR_INVALID_PARAMETER);
- sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
+ sock_type = p_host.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+ sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == -1) {
ERR_PRINT("Socket creation failed!");
- disconnect();
+ disconnect_from_host();
//perror("socket");
return FAILED;
};
@@ -159,13 +155,13 @@ Error StreamPeerTCPPosix::connect(const IP_Address& p_host, uint16_t p_port) {
#endif
struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, ip_type);
+ size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, sock_type);
errno = 0;
if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == -1 && errno != EINPROGRESS) {
ERR_PRINT("Connection to remote host failed!");
- disconnect();
+ disconnect_from_host();
return FAILED;
};
@@ -190,7 +186,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
if (status != STATUS_CONNECTED) {
- if (_poll_connection(p_block) != OK) {
+ if (_poll_connection() != OK) {
return FAILED;
};
@@ -217,7 +213,7 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -243,14 +239,14 @@ Error StreamPeerTCPPosix::write(const uint8_t* p_data,int p_bytes, int &r_sent,
Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block) {
- if (!is_connected()) {
+ if (!is_connected_to_host()) {
return FAILED;
};
if (status == STATUS_CONNECTING) {
- if (_poll_connection(p_block) != OK) {
+ if (_poll_connection() != OK) {
return FAILED;
};
@@ -274,7 +270,7 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b
if (errno != EAGAIN) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -308,12 +304,12 @@ Error StreamPeerTCPPosix::read(uint8_t* p_buffer, int p_bytes,int &r_received, b
void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
- ERR_FAIL_COND(!is_connected());
+ ERR_FAIL_COND(!is_connected_to_host());
int flag=p_enabled?1:0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int));
}
-bool StreamPeerTCPPosix::is_connected() const {
+bool StreamPeerTCPPosix::is_connected_to_host() const {
if (status == STATUS_NONE || status == STATUS_ERROR) {
@@ -329,17 +325,19 @@ bool StreamPeerTCPPosix::is_connected() const {
StreamPeerTCP::Status StreamPeerTCPPosix::get_status() const {
if (status == STATUS_CONNECTING) {
- _poll_connection(false);
+ _poll_connection();
};
return status;
};
-void StreamPeerTCPPosix::disconnect() {
+void StreamPeerTCPPosix::disconnect_from_host() {
if (sockfd != -1)
close(sockfd);
+
+ sock_type = IP::TYPE_NONE;
sockfd=-1;
status = STATUS_NONE;
@@ -390,15 +388,15 @@ uint16_t StreamPeerTCPPosix::get_connected_port() const {
StreamPeerTCPPosix::StreamPeerTCPPosix() {
+ sock_type = IP::TYPE_NONE;
sockfd = -1;
status = STATUS_NONE;
peer_port = 0;
- ip_type = IP::TYPE_ANY;
};
StreamPeerTCPPosix::~StreamPeerTCPPosix() {
- disconnect();
+ disconnect_from_host();
};
#endif
diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h
index 1df509cac4..7f8d90a448 100644
--- a/drivers/unix/stream_peer_tcp_posix.h
+++ b/drivers/unix/stream_peer_tcp_posix.h
@@ -35,19 +35,18 @@
#include "core/io/stream_peer_tcp.h"
#include "error_list.h"
-#include "core/io/ip_address.h"
-
class StreamPeerTCPPosix : public StreamPeerTCP {
protected:
mutable Status status;
+ IP::Type sock_type;
int sockfd;
Error _block(int p_sockfd, bool p_read, bool p_write) const;
- Error _poll_connection(bool p_block) const;
+ Error _poll_connection() const;
IP_Address peer_host;
int peer_port;
@@ -59,7 +58,7 @@ protected:
public:
- virtual Error connect(const IP_Address& p_host, uint16_t p_port);
+ virtual Error connect_to_host(const IP_Address& p_host, uint16_t p_port);
virtual Error put_data(const uint8_t* p_data,int p_bytes);
virtual Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
@@ -69,14 +68,14 @@ public:
virtual int get_available_bytes() const;
- void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type);
+ void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type);
virtual IP_Address get_connected_host() const;
virtual uint16_t get_connected_port() const;
- virtual bool is_connected() const;
+ virtual bool is_connected_to_host() const;
virtual Status get_status() const;
- virtual void disconnect();
+ virtual void disconnect_from_host();
virtual void set_nodelay(bool p_enabled);
diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp
index 0178f08b8c..7e9970453f 100644
--- a/drivers/unix/tcp_server_posix.cpp
+++ b/drivers/unix/tcp_server_posix.cpp
@@ -68,10 +68,23 @@ void TCPServerPosix::make_default() {
TCP_Server::_create = TCPServerPosix::_create;
};
-Error TCPServerPosix::listen(uint16_t p_port,const List<String> *p_accepted_hosts) {
+Error TCPServerPosix::listen(uint16_t p_port,const IP_Address p_bind_address) {
+
+ ERR_FAIL_COND_V(listen_sockfd!=-1,ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
int sockfd;
- sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
+#ifdef __OpenBSD__
+ sock_type = IP::TYPE_IPV4; // OpenBSD does not support dual stacking, fallback to IPv4 only.
+#else
+ sock_type = IP::TYPE_ANY;
+#endif
+
+ // If the bind address is valid use its type as the socket type
+ if (p_bind_address.is_valid())
+ sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+
+ sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
ERR_FAIL_COND_V(sockfd == -1, FAILED);
@@ -88,9 +101,7 @@ Error TCPServerPosix::listen(uint16_t p_port,const List<String> *p_accepted_host
}
struct sockaddr_storage addr;
- size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, p_accepted_hosts);
-
- // automatically fill with my IP TODO: use p_accepted_hosts
+ size_t addr_size = _set_listen_sockaddr(&addr, p_port, sock_type, p_bind_address);
if (bind(sockfd, (struct sockaddr *)&addr, addr_size) != -1) {
@@ -157,7 +168,7 @@ Ref<StreamPeerTCP> TCPServerPosix::take_connection() {
int port;
_set_ip_addr_port(ip, port, &their_addr);
- conn->set_socket(fd, ip, port, ip_type);
+ conn->set_socket(fd, ip, port, sock_type);
return conn;
};
@@ -170,13 +181,14 @@ void TCPServerPosix::stop() {
};
listen_sockfd = -1;
+ sock_type = IP::TYPE_NONE;
};
TCPServerPosix::TCPServerPosix() {
listen_sockfd = -1;
- ip_type = IP::TYPE_ANY;
+ sock_type = IP::TYPE_NONE;
};
TCPServerPosix::~TCPServerPosix() {
diff --git a/drivers/unix/tcp_server_posix.h b/drivers/unix/tcp_server_posix.h
index 6f9fa8cb5b..ea42d0fc0c 100644
--- a/drivers/unix/tcp_server_posix.h
+++ b/drivers/unix/tcp_server_posix.h
@@ -35,12 +35,13 @@
class TCPServerPosix : public TCP_Server {
int listen_sockfd;
+ IP::Type sock_type;
static TCP_Server* _create();
public:
- virtual Error listen(uint16_t p_port,const List<String> *p_accepted_hosts=NULL);
+ virtual Error listen(uint16_t p_port, IP_Address p_bind_address=IP_Address("*"));
virtual bool is_connection_available() const;
virtual Ref<StreamPeerTCP> take_connection();
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index c7082dbc7c..14742aa420 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -59,7 +59,7 @@ struct DirAccessWindowsPrivate {
// CreateFolderAsync
-bool DirAccessWindows::list_dir_begin() {
+Error DirAccessWindows::list_dir_begin() {
_cisdir=false;
_cishidden=false;
@@ -67,7 +67,7 @@ bool DirAccessWindows::list_dir_begin() {
list_dir_end();
p->h = FindFirstFileExW((current_dir+"\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0);
- return (p->h==INVALID_HANDLE_VALUE);
+ return (p->h==INVALID_HANDLE_VALUE) ? ERR_CANT_OPEN : OK;
}
diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h
index 4d9fdd08e2..f4105b7bc9 100644
--- a/drivers/windows/dir_access_windows.h
+++ b/drivers/windows/dir_access_windows.h
@@ -62,7 +62,7 @@ class DirAccessWindows : public DirAccess {
public:
- virtual bool list_dir_begin(); ///< This starts dir listing
+ virtual Error list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 183cec96ec..894b49231b 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -50,7 +50,7 @@ void FileAccessWindows::check_errors() const {
if (feof(f)) {
- last_error=ERR_FILE_EOF;;
+ last_error=ERR_FILE_EOF;
}
}
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index 5be857164c..cd61fefd91 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_xaudio2.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
const char * AudioDriverXAudio2::get_name() const
@@ -46,7 +46,8 @@ Error AudioDriverXAudio2::init() {
mix_rate = 48000;
- output_format = OUTPUT_STEREO;
+ // FIXME: speaker_mode seems unused in the Xaudio2 driver so far
+ speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
@@ -156,9 +157,9 @@ int AudioDriverXAudio2::get_mix_rate() const {
return mix_rate;
};
-AudioDriverSW::OutputFormat AudioDriverXAudio2::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverXAudio2::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
};
float AudioDriverXAudio2::get_latency() {
diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h
index ad880b24d5..afafb84c23 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.h
+++ b/drivers/xaudio2/audio_driver_xaudio2.h
@@ -29,8 +29,7 @@
#ifndef AUDIO_DRIVER_XAUDIO2_H
#define AUDIO_DRIVER_XAUDIO2_H
-#include "servers/audio/audio_server_sw.h"
-
+#include "servers/audio_server.h"
#include "core/os/thread.h"
#include "core/os/mutex.h"
@@ -40,7 +39,7 @@
#include <xaudio2.h>
#include <wrl/client.h>
-class AudioDriverXAudio2 : public AudioDriverSW {
+class AudioDriverXAudio2 : public AudioDriver {
enum {
AUDIO_BUFFERS = 2
@@ -72,7 +71,7 @@ class AudioDriverXAudio2 : public AudioDriverSW {
int buffer_size;
unsigned int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
int channels;
@@ -96,7 +95,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual float get_latency();
virtual void lock();
virtual void unlock();
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 6f27bcdc5a..a9f643c785 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -158,10 +158,10 @@ bool InputDefault::is_action_just_pressed(const StringName& p_action) const {
if (!E)
return false;
- if (OS::get_singleton()->is_in_fixed_frame()) {
- return E->get().pressed && E->get().fixed_frame==OS::get_singleton()->get_fixed_frames();
+ if (Engine::get_singleton()->is_in_fixed_frame()) {
+ return E->get().pressed && E->get().fixed_frame==Engine::get_singleton()->get_fixed_frames();
} else {
- return E->get().pressed && E->get().idle_frame==OS::get_singleton()->get_idle_frames();
+ return E->get().pressed && E->get().idle_frame==Engine::get_singleton()->get_idle_frames();
}
}
@@ -171,10 +171,10 @@ bool InputDefault::is_action_just_released(const StringName& p_action) const{
if (!E)
return false;
- if (OS::get_singleton()->is_in_fixed_frame()) {
- return !E->get().pressed && E->get().fixed_frame==OS::get_singleton()->get_fixed_frames();
+ if (Engine::get_singleton()->is_in_fixed_frame()) {
+ return !E->get().pressed && E->get().fixed_frame==Engine::get_singleton()->get_fixed_frames();
} else {
- return !E->get().pressed && E->get().idle_frame==OS::get_singleton()->get_idle_frames();
+ return !E->get().pressed && E->get().idle_frame==Engine::get_singleton()->get_idle_frames();
}
}
@@ -277,6 +277,12 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_
emit_signal("joy_connection_changed", p_idx, p_connected);
};
+Vector3 InputDefault::get_gravity() const{
+
+ _THREAD_SAFE_METHOD_
+ return gravity;
+}
+
Vector3 InputDefault::get_accelerometer() const{
_THREAD_SAFE_METHOD_
@@ -307,7 +313,7 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if (p_event.key.scancode==0)
break;
- // print_line(p_event);
+ //print_line(p_event);
if (p_event.key.pressed)
keys_pressed.insert(p_event.key.scancode);
@@ -375,15 +381,12 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if (!p_event.is_echo()) {
for (const Map<StringName,InputMap::Action>::Element *E=InputMap::get_singleton()->get_action_map().front();E;E=E->next()) {
- if (InputMap::get_singleton()->event_is_action(p_event,E->key())) {
-
- if(is_action_pressed(E->key()) != p_event.is_pressed()) {
- Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
- action.pressed=p_event.is_pressed();
- action_state[E->key()]=action;
- }
+ if (InputMap::get_singleton()->event_is_action(p_event,E->key()) && is_action_pressed(E->key()) != p_event.is_pressed()) {
+ Action action;
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
+ action.pressed=p_event.is_pressed();
+ action_state[E->key()]=action;
}
}
}
@@ -423,6 +426,14 @@ void InputDefault::stop_joy_vibration(int p_device) {
joy_vibration[p_device] = vibration;
}
+void InputDefault::set_gravity(const Vector3& p_gravity) {
+
+ _THREAD_SAFE_METHOD_
+
+ gravity=p_gravity;
+
+}
+
void InputDefault::set_accelerometer(const Vector3& p_accel) {
_THREAD_SAFE_METHOD_
@@ -465,14 +476,14 @@ Point2 InputDefault::get_mouse_pos() const {
return mouse_pos;
}
-Point2 InputDefault::get_mouse_speed() const {
+Point2 InputDefault::get_last_mouse_speed() const {
return mouse_speed_track.speed;
}
int InputDefault::get_mouse_button_mask() const {
- return OS::get_singleton()->get_mouse_button_state();
+ return mouse_button_mask;// do not trust OS implementaiton, should remove it - OS::get_singleton()->get_mouse_button_state();
}
void InputDefault::warp_mouse_pos(const Vector2& p_to) {
@@ -490,8 +501,8 @@ void InputDefault::action_press(const StringName& p_action) {
Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
action.pressed=true;
action_state[p_action]=action;
@@ -502,8 +513,8 @@ void InputDefault::action_release(const StringName& p_action){
Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
action.pressed=false;
action_state[p_action]=action;
@@ -554,8 +565,7 @@ void InputDefault::set_mouse_in_window(bool p_in_window) {
}
// from github.com/gabomdq/SDL_GameControllerDB
-static const char *s_ControllerMappings [] =
-{
+static const char *s_ControllerMappings [] = {
#ifdef WINDOWS_ENABLED
"00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,",
"00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,",
@@ -1204,6 +1214,15 @@ int InputDefault::get_joy_button_index_from_string(String p_button) {
ERR_FAIL_V(-1);
}
+int InputDefault::get_unused_joy_id() {
+ for (int i=0;i<JOYPADS_MAX;i++) {
+ if (!joy_names.has(i) || !joy_names[i].connected) {
+ return i;
+ }
+ }
+ return -1;
+}
+
String InputDefault::get_joy_axis_string(int p_axis) {
ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "");
return _axes[p_axis];
diff --git a/main/input_default.h b/main/input_default.h
index 33a852ab10..78bc0f4355 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -44,6 +44,7 @@ class InputDefault : public Input {
Set<int> joy_buttons_pressed;
Map<int,float> _joy_axis;
//Map<StringName,int> custom_action_press;
+ Vector3 gravity;
Vector3 accelerometer;
Vector3 magnetometer;
Vector3 gyroscope;
@@ -133,6 +134,11 @@ public:
HAT_LEFT,
HAT_MAX,
};
+
+ enum {
+ JOYPADS_MAX = 16,
+ };
+
struct JoyAxis {
int min;
float value;
@@ -191,18 +197,20 @@ public:
void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = "");
void parse_joypad_mapping(String p_mapping, bool p_update_existing);
+ virtual Vector3 get_gravity() const;
virtual Vector3 get_accelerometer() const;
virtual Vector3 get_magnetometer() const;
virtual Vector3 get_gyroscope() const;
virtual Point2 get_mouse_pos() const;
- virtual Point2 get_mouse_speed() const;
+ virtual Point2 get_last_mouse_speed() const;
virtual int get_mouse_button_mask() const;
virtual void warp_mouse_pos(const Vector2& p_to);
void parse_input_event(const InputEvent& p_event);
+ void set_gravity(const Vector3& p_gravity);
void set_accelerometer(const Vector3& p_accel);
void set_magnetometer(const Vector3& p_magnetometer);
void set_gyroscope(const Vector3& p_gyroscope);
@@ -240,6 +248,8 @@ public:
virtual int get_joy_axis_index_from_string(String p_axis);
virtual int get_joy_button_index_from_string(String p_button);
+ int get_unused_joy_id();
+
bool is_joy_mapped(int p_device);
String get_joy_guid_remapped(int p_device) const;
void set_fallback_mapping(String p_guid);
diff --git a/main/main.cpp b/main/main.cpp
index 16adee4bf6..9be77c31b6 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "main.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "splash.h"
#include "core/register_core_types.h"
#include "scene/register_scene_types.h"
@@ -38,11 +38,11 @@
#include "script_debugger_local.h"
#include "script_debugger_remote.h"
#include "message_queue.h"
-#include "path_remap.h"
+
#include "input_map.h"
#include "io/resource_loader.h"
#include "scene/main/scene_main_loop.h"
-
+#include "servers/audio_server.h"
#include "script_language.h"
#include "io/resource_loader.h"
@@ -54,20 +54,14 @@
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
+#include "tools/editor/doc/doc_data.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/project_manager.h"
-
#endif
#include "io/file_access_network.h"
-#include "tools/doc/doc_data.h"
-
-
-#include "servers/spatial_sound_server.h"
-#include "servers/spatial_sound_2d_server.h"
#include "servers/physics_2d_server.h"
-
#include "core/io/stream_peer_tcp.h"
#include "core/os/thread.h"
#include "core/io/file_access_pack.h"
@@ -79,13 +73,15 @@
#include "performance.h"
static GlobalConfig *globals=NULL;
+static Engine *engine=NULL;
static InputMap *input_map=NULL;
static bool _start_success=false;
static ScriptDebugger *script_debugger=NULL;
+AudioServer *audio_server=NULL;
static MessageQueue *message_queue=NULL;
static Performance *performance = NULL;
-static PathRemap *path_remap;
+
static PackedData *packed_data=NULL;
#ifdef MINIZIP_ENABLED
static ZipArchive *zip_packed_data=NULL;
@@ -130,7 +126,7 @@ void Main::print_help(const char* p_binary) {
OS::get_singleton()->print(VERSION_FULL_NAME" (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n");
OS::get_singleton()->print("Usage: %s [options] [scene]\n",p_binary);
OS::get_singleton()->print("Options:\n");
- OS::get_singleton()->print("\t-path [dir] : Path to a game, containing engine.cfg\n");
+ OS::get_singleton()->print("\t-path [dir] : Path to a game, containing godot.cfg\n");
#ifdef TOOLS_ENABLED
OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n");
#endif
@@ -183,8 +179,6 @@ void Main::print_help(const char* p_binary) {
#ifdef TOOLS_ENABLED
OS::get_singleton()->print("\t-doctool FILE: Dump the whole engine api to FILE in XML format. If FILE exists, it will be merged.\n");
OS::get_singleton()->print("\t-nodocbase: Disallow dump the base types (used with -doctool).\n");
- OS::get_singleton()->print("\t-optimize FILE Save an optimized copy of scene to FILE.\n");
- OS::get_singleton()->print("\t-optimize_preset [preset] Use a given preset for optimization.\n");
OS::get_singleton()->print("\t-export [target] Export the project using given export target.\n");
#endif
}
@@ -195,6 +189,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
RID_OwnerBase::init_rid();
OS::get_singleton()->initialize_core();
+
+ engine = memnew( Engine );
+
ClassDB::init();
MAIN_PRINT("Main: Initialize CORE");
@@ -212,7 +209,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
register_core_settings(); //here globals is present
- path_remap = memnew( PathRemap );
translation_server = memnew( TranslationServer );
performance = memnew( Performance );
globals->add_singleton(GlobalConfig::Singleton("Performance",performance));
@@ -235,7 +231,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
while (I) {
I->get()=unescape_cmdline(I->get().strip_escapes());
-// print_line("CMD: "+I->get());
+ //print_line("CMD: "+I->get());
I=I->next();
}
@@ -499,7 +495,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
if (I->next()) {
- OS::get_singleton()->set_time_scale(I->next()->get().to_double());
+ Engine::get_singleton()->set_time_scale(I->next()->get().to_double());
N=I->next()->next();
} else {
goto error;
@@ -592,6 +588,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
I=N;
}
+ GLOBAL_DEF("memory/multithread/thread_rid_pool_prealloc",60);
GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second",2048);
GLOBAL_DEF("network/debug/remote_port",6007);
@@ -706,8 +703,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
else
input_map->load_from_globals(); //keys for game
- if (video_driver=="") // specified in engine.cfg
- video_driver=_GLOBAL_DEF("display/driver/name",Variant((const char*)OS::get_singleton()->get_video_driver_name(0)));
+ if (video_driver=="") // specified in godot.cfg
+ 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");
@@ -742,7 +739,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
use_vsync = GLOBAL_DEF("display/window/use_vsync", use_vsync);
GLOBAL_DEF("display/window/test_width",0);
GLOBAL_DEF("display/window/test_height",0);
- OS::get_singleton()->_pixel_snap=GLOBAL_DEF("rendering/2d/use_pixel_snap",false);
+ 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);
if (rtm==-1) {
rtm=GLOBAL_DEF("rendering/threads/thread_model",OS::RENDER_THREAD_SAFE);
@@ -762,7 +759,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
/* Determine Video Driver */
- if (audio_driver=="") { // specified in engine.cfg
+ if (audio_driver=="") { // specified in godot.cfg
audio_driver=GLOBAL_DEF("audio/driver",OS::get_singleton()->get_audio_driver_name(0));
}
@@ -819,8 +816,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
}
- OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/fixed_fps",60));
- OS::get_singleton()->set_target_fps(GLOBAL_DEF("debug/fps/force_fps",0));
+ 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));
GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose());
@@ -831,7 +828,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
frame_delay=GLOBAL_DEF("application/frame_delay_msec",0);
}
- OS::get_singleton()->set_frame_delay(frame_delay);
+ Engine::get_singleton()->set_frame_delay(frame_delay);
message_queue = memnew( MessageQueue );
@@ -862,21 +859,23 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
memdelete( translation_server );
if (globals)
memdelete(globals);
+ if (engine)
+ memdelete(engine);
if (script_debugger)
memdelete(script_debugger);
if (packed_data)
memdelete(packed_data);
if (file_access_network_client)
memdelete(file_access_network_client);
- if(path_remap)
- memdelete(path_remap);
// Note 1: *zip_packed_data live into *packed_data
// Note 2: PackedData::~PackedData destroy this.
-//#ifdef MINIZIP_ENABLED
-// if (zip_packed_data)
-// memdelete( zip_packed_data );
-//#endif
+/*
+#ifdef MINIZIP_ENABLED
+ if (zip_packed_data)
+ memdelete( zip_packed_data );
+#endif
+*/
unregister_core_driver_types();
unregister_core_types();
@@ -899,6 +898,11 @@ Error Main::setup2() {
OS::get_singleton()->set_window_position(init_custom_pos);
}
+ //right moment to create and initialize the audio server
+
+ audio_server = memnew( AudioServer );
+ audio_server->init();
+
OS::get_singleton()->set_use_vsync(use_vsync);
register_core_singletons();
@@ -922,8 +926,6 @@ Error Main::setup2() {
}
MAIN_PRINT("Main: Load Remaps");
- path_remap->load_remaps();
-
Color clear = GLOBAL_DEF("rendering/viewport/default_clear_color",Color(0.3,0.3,0.3));
VisualServer::get_singleton()->set_default_clear_color(clear);
@@ -949,7 +951,7 @@ Error Main::setup2() {
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());
+ //GlobalConfig::get_singleton()->set("application/boot_logo",Image());
#endif
} else {
@@ -1003,7 +1005,7 @@ Error Main::setup2() {
//print_line("use custom cursor");
Ref<Texture> cursor=ResourceLoader::load(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
- // print_line("loaded ok");
+ //print_line("loaded ok");
Vector2 hotspot = GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot);
}
@@ -1033,6 +1035,7 @@ Error Main::setup2() {
translation_server->load_translations();
+ audio_server->load_default_bus_layout();
if (use_debug_profiler && script_debugger) {
script_debugger->profiling_start();
@@ -1065,12 +1068,9 @@ bool Main::start() {
String script;
String test;
String screen;
- String optimize;
- String optimize_preset;
String _export_platform;
String _import;
String _import_script;
- String dumpstrings;
bool noquit=false;
bool export_debug=false;
bool project_manager_request = false;
@@ -1096,13 +1096,9 @@ bool Main::start() {
} else if (args[i]=="-script" || args[i]=="-s") {
script=args[i+1];
} else if (args[i]=="-level" || args[i]=="-l") {
- OS::get_singleton()->_custom_level=args[i+1];
+ Engine::get_singleton()->_custom_level=args[i+1];
} else if (args[i]=="-test") {
test=args[i+1];
- } else if (args[i]=="-optimize") {
- optimize=args[i+1];
- } else if (args[i]=="-optimize_preset") {
- optimize_preset=args[i+1];
} else if (args[i]=="-export") {
editor=true; //needs editor
_export_platform=args[i+1];
@@ -1116,9 +1112,6 @@ bool Main::start() {
} else if (args[i]=="-import_script") {
editor=true; //needs editor
_import_script=args[i+1];
- } else if (args[i]=="-dumpstrings") {
- editor=true; //needs editor
- dumpstrings=args[i+1];
} else {
// The parameter does not match anything known, don't skip the next argument
parsed_pair=false;
@@ -1153,10 +1146,6 @@ bool Main::start() {
return false;
}
- if (optimize!="")
- editor=true; //need editor
-
-
#endif
@@ -1365,7 +1354,7 @@ bool Main::start() {
DirAccess *da = DirAccess::open(local_game_path.substr(0,sep));
if (da) {
- local_game_path=da->get_current_dir()+"/"+local_game_path.substr(sep+1,local_game_path.length());;
+ local_game_path=da->get_current_dir()+"/"+local_game_path.substr(sep+1,local_game_path.length());
memdelete(da);
}
}
@@ -1390,22 +1379,7 @@ bool Main::start() {
Error serr = editor_node->load_scene(local_game_path);
- if (serr==OK) {
-
- if (optimize!="") {
-
- editor_node->save_optimized_copy(optimize,optimize_preset);
- if (!noquit)
- sml->quit();
- }
-
- if (dumpstrings!="") {
- editor_node->save_translatable_strings(dumpstrings);
- if (!noquit)
- sml->quit();
- }
- }
}
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
@@ -1513,7 +1487,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/icon","Variant()");
if (iconpath!="") {
Image icon;
if (icon.load(iconpath)==OK)
@@ -1579,11 +1553,12 @@ bool Main::iteration() {
uint64_t ticks_elapsed=ticks-last_ticks;
double step=(double)ticks_elapsed / 1000000.0;
- float frame_slice=1.0/OS::get_singleton()->get_iterations_per_second();
-
-// if (time_accum+step < frame_slice)
-// return false;
+ float frame_slice=1.0/Engine::get_singleton()->get_iterations_per_second();
+ /*
+ if (time_accum+step < frame_slice)
+ return false;
+ */
uint64_t fixed_process_ticks=0;
uint64_t idle_process_ticks=0;
@@ -1597,13 +1572,13 @@ bool Main::iteration() {
time_accum+=step;
- float time_scale = OS::get_singleton()->get_time_scale();
+ float time_scale = Engine::get_singleton()->get_time_scale();
bool exit=false;
int iters = 0;
- OS::get_singleton()->_in_fixed=true;
+ Engine::get_singleton()->_in_fixed=true;
while(time_accum>frame_slice) {
@@ -1629,27 +1604,24 @@ bool Main::iteration() {
time_accum-=frame_slice;
message_queue->flush();
- //if (AudioServer::get_singleton())
- // AudioServer::get_singleton()->update();
+ /*
+ if (AudioServer::get_singleton())
+ AudioServer::get_singleton()->update();
+ */
fixed_process_ticks=MAX(fixed_process_ticks,OS::get_singleton()->get_ticks_usec()-fixed_begin); // keep the largest one for reference
fixed_process_max=MAX(OS::get_singleton()->get_ticks_usec()-fixed_begin,fixed_process_max);
iters++;
- OS::get_singleton()->_fixed_frames++;
+ Engine::get_singleton()->_fixed_frames++;
}
- OS::get_singleton()->_in_fixed=false;
+ Engine::get_singleton()->_in_fixed=false;
uint64_t idle_begin = OS::get_singleton()->get_ticks_usec();
OS::get_singleton()->get_main_loop()->idle( step*time_scale );
message_queue->flush();
- if (SpatialSoundServer::get_singleton())
- SpatialSoundServer::get_singleton()->update( step*time_scale );
- if (SpatialSound2DServer::get_singleton())
- SpatialSound2DServer::get_singleton()->update( step*time_scale );
-
VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames.
@@ -1658,11 +1630,11 @@ bool Main::iteration() {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
if (VisualServer::get_singleton()->has_changed()) {
VisualServer::get_singleton()->draw(); // flush visual commands
- OS::get_singleton()->frames_drawn++;
+ Engine::get_singleton()->frames_drawn++;
}
} else {
VisualServer::get_singleton()->draw(); // flush visual commands
- OS::get_singleton()->frames_drawn++;
+ Engine::get_singleton()->frames_drawn++;
force_redraw_requested = false;
}
}
@@ -1686,9 +1658,9 @@ bool Main::iteration() {
}
- // x11_delay_usec(10000);
+ //x11_delay_usec(10000);
frames++;
- OS::get_singleton()->_idle_frames++;
+ Engine::get_singleton()->_idle_frames++;
if (frame>1000000) {
@@ -1696,7 +1668,7 @@ bool Main::iteration() {
print_line("FPS: "+itos(frames));
};
- OS::get_singleton()->_fps=frames;
+ Engine::get_singleton()->_fps=frames;
performance->set_process_time(USEC_TO_SEC(idle_process_max));
performance->set_fixed_process_time(USEC_TO_SEC(fixed_process_max));
idle_process_max=0;
@@ -1710,12 +1682,12 @@ bool Main::iteration() {
if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max)
else {
- uint32_t frame_delay = OS::get_singleton()->get_frame_delay();
+ uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
if (frame_delay)
- OS::get_singleton()->delay_usec( OS::get_singleton()->get_frame_delay()*1000 );
+ OS::get_singleton()->delay_usec( Engine::get_singleton()->get_frame_delay()*1000 );
}
- int target_fps = OS::get_singleton()->get_target_fps();
+ int target_fps = Engine::get_singleton()->get_target_fps();
if (target_fps>0) {
uint64_t time_step = 1000000L/target_fps;
target_ticks += time_step;
@@ -1752,6 +1724,11 @@ void Main::cleanup() {
OS::get_singleton()->_execpath="";
OS::get_singleton()->_local_clipboard="";
+ if (audio_server) {
+ memdelete(audio_server);
+ }
+
+
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif
@@ -1763,6 +1740,7 @@ void Main::cleanup() {
OS::get_singleton()->finalize();
+
if (packed_data)
memdelete(packed_data);
if (file_access_network_client)
@@ -1773,10 +1751,10 @@ void Main::cleanup() {
memdelete(input_map);
if (translation_server)
memdelete( translation_server );
- if (path_remap)
- memdelete(path_remap);
if (globals)
memdelete(globals);
+ if (engine)
+ memdelete(engine);
diff --git a/main/performance.cpp b/main/performance.cpp
index 2ca73c6d4b..bc5d8c33c4 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -40,7 +40,7 @@ Performance *Performance::singleton=NULL;
void Performance::_bind_methods() {
- ClassDB::bind_method(_MD("get_monitor","monitor"),&Performance::get_monitor);
+ ClassDB::bind_method(D_METHOD("get_monitor","monitor"),&Performance::get_monitor);
BIND_CONSTANT( TIME_FPS );
BIND_CONSTANT( TIME_PROCESS );
@@ -118,7 +118,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
float Performance::get_monitor(Monitor p_monitor) const {
switch(p_monitor) {
- case TIME_FPS: return OS::get_singleton()->get_frames_per_second();
+ case TIME_FPS: return Engine::get_singleton()->get_frames_per_second();
case TIME_PROCESS: return _process_time;
case TIME_FIXED_PROCESS: return _fixed_process_time;
case MEMORY_STATIC: return Memory::get_mem_usage();
@@ -141,9 +141,9 @@ float Performance::get_monitor(Monitor p_monitor) const {
};
case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME);
case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME);
- case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);;
- case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);;
- case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);;
+ case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
+ case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
+ case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED);
case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED);
diff --git a/main/tests/test_containers.cpp b/main/tests/test_containers.cpp
index 4bc297d0ba..2711d107e4 100644
--- a/main/tests/test_containers.cpp
+++ b/main/tests/test_containers.cpp
@@ -55,7 +55,6 @@ MainLoop * test() {
{
-// static const int size = 16;
Image img;
img.create(default_mouse_cursor_xpm);
@@ -78,7 +77,7 @@ MainLoop * test() {
for (int i=0;i<1100;i++) {
int num=i;//(int)Math::random(0,1024);
- // print_line("inserting "+itos(num));
+ //print_line("inserting "+itos(num));
set.insert( num );
}
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index 1ee27ec661..7fdfef5f3c 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -219,7 +219,7 @@ static String _parser_expr(const GDParser::Node *p_expr) {
case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&="+_parser_expr(c_node->arguments[1]); } break;
case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: { txt=_parser_expr(c_node->arguments[0])+"|="+_parser_expr(c_node->arguments[1]); } break;
case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: { txt=_parser_expr(c_node->arguments[0])+"^="+_parser_expr(c_node->arguments[1]); } break;
- case GDParser::OperatorNode::OP_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&"+_parser_expr(c_node->arguments[1]); } break;;
+ case GDParser::OperatorNode::OP_BIT_AND: { txt=_parser_expr(c_node->arguments[0])+"&"+_parser_expr(c_node->arguments[1]); } break;
case GDParser::OperatorNode::OP_BIT_OR: { txt=_parser_expr(c_node->arguments[0])+"|"+_parser_expr(c_node->arguments[1]); } break;
case GDParser::OperatorNode::OP_BIT_XOR: { txt=_parser_expr(c_node->arguments[0])+"^"+_parser_expr(c_node->arguments[1]); } break;
default: {}
@@ -947,7 +947,7 @@ MainLoop* test(TestType p_test) {
if (tk.get_token_line()!=line) {
int from=line+1;
- line = tk.get_token_line();;
+ line = tk.get_token_line();
for(int i=from;i<=line;i++) {
int l=i-1;
@@ -1026,7 +1026,7 @@ MainLoop* test(TestType p_test) {
} else if (p_test==TEST_BYTECODE) {
Vector<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code);
- String dst = test.basename()+".gdc";
+ String dst = test.get_basename()+".gdc";
FileAccess *fw = FileAccess::open(dst,FileAccess::WRITE);
fw->store_buffer(buf.ptr(),buf.size());
memdelete(fw);
diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp
index ab3df3b022..899bdc37b9 100644
--- a/main/tests/test_gui.cpp
+++ b/main/tests/test_gui.cpp
@@ -46,7 +46,7 @@
#include "scene/gui/tab_container.h"
#include "scene/gui/tree.h"
#include "scene/gui/rich_text_label.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "io/image_loader.h"
#include "print_string.h"
#include "scene/2d/sprite.h"
@@ -97,7 +97,7 @@ public:
Sprite *sp = memnew( Sprite );
sp->set_texture( vp->get_render_target_texture() );
-// sp->set_texture( ResourceLoader::load("res://ball.png") );
+ //sp->set_texture( ResourceLoader::load("res://ball.png") );
sp->set_pos(Point2(300,300));
get_root()->add_child(sp);
@@ -353,14 +353,14 @@ public:
label = memnew( Label );
label->set_text("Some Label");
label->set_pos( Point2(20,20) );
- ctl->add_child(label);;
+ ctl->add_child(label);
ctl= memnew( Control );
ctl->set_name("tab 3");
button = memnew( Button );
button->set_text("Some Button");
button->set_pos( Point2(30,50) );
- ctl->add_child(button);;
+ ctl->add_child(button);
tabc->add_child(ctl);
diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp
index 42664e73cd..23459c68d1 100644
--- a/main/tests/test_io.cpp
+++ b/main/tests/test_io.cpp
@@ -39,7 +39,7 @@
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "io/file_access_memory.h"
diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp
index 1f7f2d7dda..763616dd46 100644
--- a/main/tests/test_main.cpp
+++ b/main/tests/test_main.cpp
@@ -104,10 +104,10 @@ MainLoop* test_main(String p_test,const List<String>& p_args) {
}
#endif
- if (p_test=="sound") {
+ //if (p_test=="sound") {
- return TestSound::test();
- }
+ // return TestSound::test();
+ //}
if (p_test=="io") {
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index f3d9ddba87..bbbb903e5f 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -144,11 +144,11 @@ class GetClassAndNamespace {
error_str="Unterminated comment";
error=true;
return TK_ERROR;
- } if (code[idx]=='*' &&code[idx+1]=='/') {
+ } else if (code[idx]=='*' &&code[idx+1]=='/') {
idx+=2;
break;
- } if (code[idx]=='\n') {
+ } else if (code[idx]=='\n') {
line++;
}
@@ -596,7 +596,7 @@ MainLoop* test() {
{
- // print_line("NUM: "+itos(237641278346127));
+ //print_line("NUM: "+itos(237641278346127));
print_line("NUM: "+itos(-128));
return NULL;
diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp
index ea5b1cae85..95ce540b16 100644
--- a/main/tests/test_physics.cpp
+++ b/main/tests/test_physics.cpp
@@ -111,7 +111,7 @@ protected:
PhysicsServer * ps = PhysicsServer::get_singleton();
- RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);;
+ RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);
ps->shape_set_data( plane_shape, p_plane );
RID b = ps->body_create( PhysicsServer::BODY_MODE_STATIC );
@@ -345,11 +345,16 @@ public:
/* CAMERA */
camera = vs->camera_create();
+
RID viewport = vs->viewport_create();
+ Size2i screen_size = OS::get_singleton()->get_window_size();
+ vs->viewport_set_size(viewport,screen_size.x,screen_size.y);
+ vs->viewport_attach_to_screen(viewport,Rect2(Vector2(),screen_size));
+ vs->viewport_set_active(viewport,true);
vs->viewport_attach_camera( viewport, camera );
- vs->viewport_attach_to_screen(viewport);
vs->viewport_set_scenario( viewport, scenario );
+
vs->camera_set_perspective(camera,60,0.1,40.0);
vs->camera_set_transform(camera,Transform( Basis(), Vector3(0,9,12)));
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
@@ -358,9 +363,9 @@ public:
gxf.basis.scale(Vector3(1.4,0.4,1.4));
gxf.origin=Vector3(-2,1,-2);
make_grid(5,5,2.5,1,gxf);
- // create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf);
+ //create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf);
//create_static_plane( Plane( Vector3(0,1,0), -2) );
-// test_joint();
+ //test_joint();
test_fall();
//test_joint();
diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp
index 2074d532b1..d5d4689562 100644
--- a/main/tests/test_physics_2d.cpp
+++ b/main/tests/test_physics_2d.cpp
@@ -63,7 +63,7 @@ class TestPhysics2DMainLoop : public MainLoop {
};
- BodyShapeData body_shape_data[6];
+ BodyShapeData body_shape_data[8];
void _create_body_shape_data() {
@@ -191,7 +191,7 @@ class TestPhysics2DMainLoop : public MainLoop {
Image image(convex_png);
- body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].image=vs->texture_create_from_image(image);
+ body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image=vs->texture_create_from_image(image);
RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON);
@@ -206,7 +206,7 @@ class TestPhysics2DMainLoop : public MainLoop {
arr.push_back(Point2(11,7)-sb);
ps->shape_set_data(convex_polygon_shape,arr);
- body_shape_data[Physics2DServer::SHAPE_CUSTOM+1].shape = convex_polygon_shape;
+ body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape;
}
@@ -218,8 +218,10 @@ class TestPhysics2DMainLoop : public MainLoop {
void _do_ray_query() {
-// Physics2DServer *ps = Physics2DServer::get_singleton();
- // ps->query_intersection_segment(ray_query,ray_from,ray_to);
+ /*
+ Physics2DServer *ps = Physics2DServer::get_singleton();
+ ps->query_intersection_segment(ray_query,ray_from,ray_to);
+ */
}
@@ -273,7 +275,7 @@ protected:
ps->body_set_continuous_collision_detection_mode(body,Physics2DServer::CCD_MODE_CAST_SHAPE);
ps->body_set_state(body,Physics2DServer::BODY_STATE_TRANSFORM,p_xform);
-// print_line("add body with xform: "+p_xform);
+ //print_line("add body with xform: "+p_xform);
RID sprite = vs->canvas_item_create();
vs->canvas_item_set_parent(sprite,canvas);
vs->canvas_item_set_transform(sprite,p_xform);
@@ -281,8 +283,8 @@ protected:
vs->canvas_item_add_texture_rect(sprite,Rect2(-imgsize/2.0,imgsize),body_shape_data[p_shape].image);
ps->body_set_force_integration_callback(body,this,"_body_moved",sprite);
-// RID q = ps->query_create(this,"_body_moved",sprite);
-// ps->query_body_state(q,body);
+ //RID q = ps->query_create(this,"_body_moved",sprite);
+ //ps->query_body_state(q,body);
return body;
}
@@ -354,8 +356,8 @@ protected:
static void _bind_methods() {
- ClassDB::bind_method(_MD("_body_moved"),&TestPhysics2DMainLoop::_body_moved);
- ClassDB::bind_method(_MD("_ray_query_callback"),&TestPhysics2DMainLoop::_ray_query_callback);
+ ClassDB::bind_method(D_METHOD("_body_moved"),&TestPhysics2DMainLoop::_body_moved);
+ ClassDB::bind_method(D_METHOD("_ray_query_callback"),&TestPhysics2DMainLoop::_ray_query_callback);
}
@@ -380,8 +382,13 @@ public:
RID vp = vs->viewport_create();
canvas = vs->canvas_create();
+
+ Size2i screen_size = OS::get_singleton()->get_window_size();
vs->viewport_attach_canvas(vp,canvas);
- vs->viewport_attach_to_screen(vp,Rect2(Vector2(),OS::get_singleton()->get_window_size()));
+ vs->viewport_set_size(vp,screen_size.x,screen_size.y);
+ vs->viewport_attach_to_screen(vp,Rect2(Vector2(),screen_size));
+ vs->viewport_set_active(vp,true);
+
Transform2D smaller;
//smaller.scale(Vector2(0.6,0.6));
//smaller.elements[2]=Vector2(100,0);
@@ -409,10 +416,12 @@ public:
};
Physics2DServer::ShapeType type = types[i%4];
-// type=Physics2DServer::SHAPE_SEGMENT;
+ //type=Physics2DServer::SHAPE_SEGMENT;
_add_body(type,Transform2D(i*0.8,Point2(152+i*40,100-40*i)));
- //if (i==0)
- // ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ /*
+ if (i==0)
+ ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ */
}
//RID b= _add_body(Physics2DServer::SHAPE_CIRCLE,Transform2D(0,Point2(101,140)));
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index 3049ba7d45..7380c1ff6a 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -192,7 +192,6 @@ public:
*/
RID lightaux;
- //*
lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
vs->light_set_color( lightaux, Color(1.0,1.0,1.0) );
@@ -203,17 +202,14 @@ public:
lla.set_look_at(Vector3(),Vector3(-0.000000,-0.836026,-0.548690),Vector3(0,1,0));
vs->instance_set_transform( light, lla );
- // */
- //*
lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
-// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
+ //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
vs->light_set_color( lightaux, Color(1.0,1.0,0.0) );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_RANGE, 4 );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
- // */
ofs=0;
quit=false;
diff --git a/main/tests/test_sound.cpp b/main/tests/test_sound.cpp
index 44cc117e02..6b0cf0a324 100644
--- a/main/tests/test_sound.cpp
+++ b/main/tests/test_sound.cpp
@@ -30,11 +30,13 @@
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
-#include "scene/resources/sample.h"
+
#include "io/resource_loader.h"
#include "print_string.h"
#include "servers/audio_server.h"
#include "os/os.h"
+
+#if 0
namespace TestSound {
@@ -93,3 +95,4 @@ MainLoop* test() {
}
}
+#endif
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index d99ad4476f..518c4503fc 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -252,7 +252,7 @@ bool test_13() {
/* how can i embed UTF in here? */
static const CharType ustr[] = { 0x304A , 0x360F, 0x3088, 0x3046, 0 };
-// static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 };
+ //static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 };
String s=ustr;
OS::get_singleton()->print("\tUnicode: %ls\n",ustr);
@@ -835,7 +835,6 @@ bool test_28() {
bool test_29() {
- bool error = false;
bool state = true;
bool success = false;
diff --git a/tools/dist/docker/Dockerfile b/misc/dist/docker/Dockerfile
index 428de9d1a7..428de9d1a7 100644
--- a/tools/dist/docker/Dockerfile
+++ b/misc/dist/docker/Dockerfile
diff --git a/tools/dist/docker/README.md b/misc/dist/docker/README.md
index 7f10b46ad8..7f10b46ad8 100644
--- a/tools/dist/docker/README.md
+++ b/misc/dist/docker/README.md
diff --git a/tools/dist/docker/scripts/install-android-tools b/misc/dist/docker/scripts/install-android-tools
index 8a617d9942..8a617d9942 100644
--- a/tools/dist/docker/scripts/install-android-tools
+++ b/misc/dist/docker/scripts/install-android-tools
diff --git a/tools/dist/html_fs/godotfs.js b/misc/dist/html_fs/godotfs.js
index 2c59344cf5..2c59344cf5 100644
--- a/tools/dist/html_fs/godotfs.js
+++ b/misc/dist/html_fs/godotfs.js
diff --git a/tools/dist/ios_xcode/godot_xcode/data.pck b/misc/dist/ios_xcode/godot_xcode/data.pck
index e69de29bb2..e69de29bb2 100644
--- a/tools/dist/ios_xcode/godot_xcode/data.pck
+++ b/misc/dist/ios_xcode/godot_xcode/data.pck
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_debug.iphone b/misc/dist/ios_xcode/godot_xcode/godot_debug.iphone
index e69de29bb2..e69de29bb2 100755
--- a/tools/dist/ios_xcode/godot_xcode/godot_debug.iphone
+++ b/misc/dist/ios_xcode/godot_xcode/godot_debug.iphone
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj
index bdba8488c8..bdba8488c8 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.pbxproj
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 3c9ba38bbe..3c9ba38bbe 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png
index 1d5e472665..1d5e472665 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-568h@2x~iphone.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png
index b13a399c83..b13a399c83 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png
index b51598fed0..b51598fed0 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-667h@2x.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png
index 8c44edbccd..8c44edbccd 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png
index 33847ac136..33847ac136 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-736h@3x.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png
index 2a025b745b..2a025b745b 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape-736h.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png
index 7099f3e18d..7099f3e18d 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape@2x~ipad.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png
index 4a761c339a..4a761c339a 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Landscape~ipad.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png
index b09cf21186..b09cf21186 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait@2x~ipad.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png
index fa698eb70c..fa698eb70c 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default-Portrait~ipad.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png
index ddf2861f4d..ddf2861f4d 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default@2x~iphone.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png
index c485a33b03..c485a33b03 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Default~iphone.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json
index a458b67873..a458b67873 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Contents.json
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png
index 165f4423b3..165f4423b3 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-100.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png
index 2e205e920c..2e205e920c 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-114.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png
index 6245f83f48..6245f83f48 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-120.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png
index 7b24e01bc6..7b24e01bc6 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-144.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png
index 344b470fa3..344b470fa3 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-152.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png
index 0dcebbc3f2..0dcebbc3f2 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-180.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png
index 9ae94e9aaf..9ae94e9aaf 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-29.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png
index 569f24df91..569f24df91 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-40.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png
index 9e69ed3121..9e69ed3121 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-50.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png
index b970fa3067..b970fa3067 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-57.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png
index 6097a6c73b..6097a6c73b 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-58.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png
index 21b9622eb6..21b9622eb6 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-60.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png
index 34dea8e6ad..34dea8e6ad 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-72.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png
index f72eb0b345..f72eb0b345 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-76.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png
index 793c9b1f5f..793c9b1f5f 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/Icon-80.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png
index 7cd0e054ab..7cd0e054ab 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-167.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png
index e9b2429754..e9b2429754 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/icon-87.png
Binary files differ
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes
index e328a62cb6..e328a62cb6 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/Images.xcassets/AppIcon.appiconset/sizes
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings b/misc/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings
index 477b28ff8f..477b28ff8f 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/en.lproj/InfoPlist.strings
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist
index f97b0fca36..f97b0fca36 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/godot_ios-Info.plist
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_ios/main.m b/misc/dist/ios_xcode/godot_xcode/godot_ios/main.m
index 88b8e60670..88b8e60670 100644
--- a/tools/dist/ios_xcode/godot_xcode/godot_ios/main.m
+++ b/misc/dist/ios_xcode/godot_xcode/godot_ios/main.m
diff --git a/tools/dist/ios_xcode/godot_xcode/godot_opt.iphone b/misc/dist/ios_xcode/godot_xcode/godot_opt.iphone
index e69de29bb2..e69de29bb2 100755
--- a/tools/dist/ios_xcode/godot_xcode/godot_opt.iphone
+++ b/misc/dist/ios_xcode/godot_xcode/godot_opt.iphone
diff --git a/tools/dist/osx_template.app/Contents/Info.plist b/misc/dist/osx_template.app/Contents/Info.plist
index eee787bdaf..eee787bdaf 100755
--- a/tools/dist/osx_template.app/Contents/Info.plist
+++ b/misc/dist/osx_template.app/Contents/Info.plist
diff --git a/tools/dist/osx_template.app/Contents/PkgInfo b/misc/dist/osx_template.app/Contents/PkgInfo
index 6f749b0f37..6f749b0f37 100644
--- a/tools/dist/osx_template.app/Contents/PkgInfo
+++ b/misc/dist/osx_template.app/Contents/PkgInfo
diff --git a/tools/dist/osx_template.app/Contents/Resources/icon.icns b/misc/dist/osx_template.app/Contents/Resources/icon.icns
index 375f61437d..375f61437d 100644
--- a/tools/dist/osx_template.app/Contents/Resources/icon.icns
+++ b/misc/dist/osx_template.app/Contents/Resources/icon.icns
Binary files differ
diff --git a/tools/dist/osx_tools.app/Contents/Info.plist b/misc/dist/osx_tools.app/Contents/Info.plist
index 4d88e97503..4d88e97503 100755
--- a/tools/dist/osx_tools.app/Contents/Info.plist
+++ b/misc/dist/osx_tools.app/Contents/Info.plist
diff --git a/tools/dist/osx_tools.app/Contents/PkgInfo b/misc/dist/osx_tools.app/Contents/PkgInfo
index 6f749b0f37..6f749b0f37 100644
--- a/tools/dist/osx_tools.app/Contents/PkgInfo
+++ b/misc/dist/osx_tools.app/Contents/PkgInfo
diff --git a/tools/dist/osx_tools.app/Contents/Resources/Godot.icns b/misc/dist/osx_tools.app/Contents/Resources/Godot.icns
index 375f61437d..375f61437d 100644
--- a/tools/dist/osx_tools.app/Contents/Resources/Godot.icns
+++ b/misc/dist/osx_tools.app/Contents/Resources/Godot.icns
Binary files differ
diff --git a/tools/dist/uwp_template/AppxManifest.xml b/misc/dist/uwp_template/AppxManifest.xml
index d5e653708c..d5e653708c 100644
--- a/tools/dist/uwp_template/AppxManifest.xml
+++ b/misc/dist/uwp_template/AppxManifest.xml
diff --git a/tools/dist/uwp_template/Assets/SplashScreen.scale-100.png b/misc/dist/uwp_template/Assets/SplashScreen.scale-100.png
index 540bfb1c01..540bfb1c01 100644
--- a/tools/dist/uwp_template/Assets/SplashScreen.scale-100.png
+++ b/misc/dist/uwp_template/Assets/SplashScreen.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/Square150x150Logo.scale-100.png b/misc/dist/uwp_template/Assets/Square150x150Logo.scale-100.png
index 6cff663eb5..6cff663eb5 100644
--- a/tools/dist/uwp_template/Assets/Square150x150Logo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/Square150x150Logo.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/Square310x310Logo.scale-100.png b/misc/dist/uwp_template/Assets/Square310x310Logo.scale-100.png
index 12ec232c87..12ec232c87 100644
--- a/tools/dist/uwp_template/Assets/Square310x310Logo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/Square310x310Logo.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/Square44x44Logo.scale-100.png b/misc/dist/uwp_template/Assets/Square44x44Logo.scale-100.png
index ad059994ed..ad059994ed 100644
--- a/tools/dist/uwp_template/Assets/Square44x44Logo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/Square44x44Logo.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/Square71x71Logo.scale-100.png b/misc/dist/uwp_template/Assets/Square71x71Logo.scale-100.png
index b1bf331365..b1bf331365 100644
--- a/tools/dist/uwp_template/Assets/Square71x71Logo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/Square71x71Logo.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/StoreLogo.scale-100.png b/misc/dist/uwp_template/Assets/StoreLogo.scale-100.png
index 8d7a625c82..8d7a625c82 100644
--- a/tools/dist/uwp_template/Assets/StoreLogo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/StoreLogo.scale-100.png
Binary files differ
diff --git a/tools/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png b/misc/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png
index b06f1ad50f..b06f1ad50f 100644
--- a/tools/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png
+++ b/misc/dist/uwp_template/Assets/Wide310x150Logo.scale-100.png
Binary files differ
diff --git a/tools/scripts/addheader.py b/misc/scripts/addheader.py
index 056e807c81..056e807c81 100644
--- a/tools/scripts/addheader.py
+++ b/misc/scripts/addheader.py
diff --git a/tools/scripts/file-hex-array.py b/misc/scripts/file-hex-array.py
index a6cdfe541f..a6cdfe541f 100755
--- a/tools/scripts/file-hex-array.py
+++ b/misc/scripts/file-hex-array.py
diff --git a/tools/scripts/make_bmfhdr.py b/misc/scripts/make_bmfhdr.py
index 1d3c40f9c6..1d3c40f9c6 100644
--- a/tools/scripts/make_bmfhdr.py
+++ b/misc/scripts/make_bmfhdr.py
diff --git a/tools/scripts/make_glwrapper.py b/misc/scripts/make_glwrapper.py
index 5694d2327e..5694d2327e 100644
--- a/tools/scripts/make_glwrapper.py
+++ b/misc/scripts/make_glwrapper.py
diff --git a/tools/scripts/make_icons.sh b/misc/scripts/make_icons.sh
index 71037cd1c3..71037cd1c3 100644
--- a/tools/scripts/make_icons.sh
+++ b/misc/scripts/make_icons.sh
diff --git a/tools/scripts/makeargs.py b/misc/scripts/makeargs.py
index 2cd47ae087..2cd47ae087 100644
--- a/tools/scripts/makeargs.py
+++ b/misc/scripts/makeargs.py
diff --git a/tools/scripts/memsort.py b/misc/scripts/memsort.py
index fb636b0f78..fb636b0f78 100644
--- a/tools/scripts/memsort.py
+++ b/misc/scripts/memsort.py
diff --git a/tools/scripts/sort-demos.sh b/misc/scripts/sort-demos.sh
index d4770b337e..2121d78c15 100644
--- a/tools/scripts/sort-demos.sh
+++ b/misc/scripts/sort-demos.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# When scanning for demos, the project manager sorts them based on their
# timestamp, i.e. last modification date. This can make for a pretty
-# messy output, so this script 'touches' each engine.cfg file in reverse
+# messy output, so this script 'touches' each godot.cfg file in reverse
# alphabetical order to ensure a nice listing.
#
# It's good practice to run it once before packaging demos on the build
@@ -17,7 +17,7 @@ if [ -e demos.list ]; then
fi
for dir in 2d 3d gui misc viewport; do
- find "demos/$dir" -name "engine.cfg" |sort >> demos.list
+ find "demos/$dir" -name "godot.cfg" |sort >> demos.list
done
cat demos.list |sort -r > demos_r.list
diff --git a/tools/scripts/svgs_2_pngs.py b/misc/scripts/svgs_2_pngs.py
index b24324dcd7..b24324dcd7 100644
--- a/tools/scripts/svgs_2_pngs.py
+++ b/misc/scripts/svgs_2_pngs.py
diff --git a/modules/chibi/SCsub b/modules/chibi/SCsub
deleted file mode 100644
index dffd966753..0000000000
--- a/modules/chibi/SCsub
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_chibi = env_modules.Clone()
-
-# Godot source files
-env_chibi.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/chibi/cp_config.h b/modules/chibi/cp_config.h
deleted file mode 100644
index 35312b68be..0000000000
--- a/modules/chibi/cp_config.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*************************************************************************/
-/* cp_config.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_CONFIG_H
-#define CP_CONFIG_H
-
-
-#include "typedefs.h"
-#include "error_macros.h"
-#include "math_funcs.h"
-#include "os/memory.h"
-#include "os/copymem.h"
-
-#define CP_PRINTERR(m_err) ERR_PRINT(m_err)
-#define CP_ERR_COND(m_cond) ERR_FAIL_COND(m_cond)
-#define CP_ERR_COND_V(m_cond,m_ret) ERR_FAIL_COND_V(m_cond,m_ret)
-#define CP_FAIL_INDEX(m_index,m_size) ERR_FAIL_INDEX(m_index,m_size)
-#define CP_FAIL_INDEX_V(m_index,m_size,m_ret) ERR_FAIL_INDEX_V(m_index,m_size,m_ret)
-#define cp_intabs(m_val) ABS(m_val)
-
-#define CP_ALLOC(m_mem) memalloc(m_mem)
-#define CP_REALLOC(m_mem,m_size) memrealloc(m_mem,m_size)
-#define CP_FREE(m_mem) memfree(m_mem)
-
-#define cp_memzero(m_mem,m_size) zeromem(m_mem,m_size)
-
-#endif // CP_CONFIG_H
diff --git a/modules/chibi/cp_envelope.cpp b/modules/chibi/cp_envelope.cpp
deleted file mode 100644
index 36259e8d63..0000000000
--- a/modules/chibi/cp_envelope.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/*************************************************************************/
-/* cp_envelope.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_envelope.h"
-
-
-CPEnvelope::CPEnvelope() {
-
-
- reset();
-}
-
-void CPEnvelope::reset() {
-
-
-
- on=false;
- carry=false;
- loop_on=false;
- loop_begin_node=0;
- loop_end_node=0;
- sustain_loop_on=false;
- sustain_loop_begin_node=0;
- sustain_loop_end_node=0;
- node_count=0;
-
-}
-
-int CPEnvelope::get_height_at_pos(int pos) {
-
- if (node_count && pos>node[node_count-1].tick_offset)
- return node[node_count-1].value;
-
- int begin_x,begin_y;
- int end_x,end_y,xdif;
- int count=0;
- int limit=-1;
-
- if (node_count<2) return NO_POINT;
-
- while ((count<node_count) && (limit==-1)) {
-
- if (node[count].tick_offset>=pos) limit=count;
- count++;
- }
-
- if (pos==0) return node[0].value;
-
- if (limit==-1) return NO_POINT;
-
- begin_x=node[limit-1].tick_offset;
- end_x=node[limit].tick_offset;
- begin_y=node[limit-1].value;
- end_y=node[limit].value;
-
- xdif=end_x-begin_x;
- return begin_y+((pos-begin_x)*(end_y-begin_y))/(xdif?xdif:1);
-}
-
-/*
-int CPEnvelope::get_fx_height_at_pos(int pos) {
-
- if (node_count && pos>node[node_count-1].tick_offset)
- return node[node_count-1].value<<FX_HEIGHT_BITS;
-
- int begin_x,begin_y;
- int end_x,end_y,xdif;
- int count=0;
- int limit=-1;
-
- if (node_count<2) return NO_POINT;
-
- while ((count<node_count) && (limit==-1)) {
-
- if (node[count].tick_offset>=pos) limit=count;
- count++;
- }
-
- if (pos==0) return node[0].value<<FX_HEIGHT_BITS;
-
- if (limit==-1) return NO_POINT;
-
- begin_x=node[limit-1].tick_offset;
- end_x=node[limit].tick_offset;
- begin_y=node[limit-1].value;
- end_y=node[limit].value;
-
- xdif=end_x-begin_x;
- return (begin_y<<FX_HEIGHT_BITS)+((pos-begin_x)*(end_y-begin_y)*(int)(1<<FX_HEIGHT_BITS))/(xdif?xdif:1);
-}
-*/
-
-float CPEnvelope::get_interp_height_at_pos(float pos) {
-
- if (node_count && pos>node[node_count-1].tick_offset)
- return node[node_count-1].value;
-
- int begin_x,begin_y;
- int end_x,end_y,xdif;
- int count=0;
- int limit=-1;
-
- if (node_count<2) return NO_POINT;
-
- while ((count<node_count) && (limit==-1)) {
-
- if (node[count].tick_offset>=pos) limit=count;
- count++;
- }
-
- if (pos==0) return node[0].value;
-
- if (limit==-1) return NO_POINT;
-
- begin_x=node[limit-1].tick_offset;
- end_x=node[limit].tick_offset;
- begin_y=node[limit-1].value;
- end_y=node[limit].value;
-
- xdif=end_x-begin_x;
- return begin_y+((pos-begin_x)*(end_y-begin_y))/(xdif?xdif:1);
-}
-
-void CPEnvelope::set_position(int p_node,int p_x,int p_y) {
-
- if (p_node>=node_count) return;
-
-
-
- if (p_node==0) {
-
- p_x=0;
-
- } else if (p_x<=node[p_node-1].tick_offset) {
-
- p_x=node[p_node-1].tick_offset+1;
-
- } else if ((p_node<(node_count-1)) && (p_x>=node[p_node+1].tick_offset)) {
-
- p_x=node[p_node+1].tick_offset-1;
- }
-
- if (p_x>=9999) p_x=9999;
-
- if (p_y>max_value) p_y=max_value;
- if (p_y<min_value) p_y=min_value;
-
-
- node[p_node].tick_offset=p_x;
- node[p_node].value=p_y;
-
-
-
-}
-
-int CPEnvelope::add_position(int p_x,int p_y,bool p_move_loops) {
-
- if (node_count==MAX_POINTS) return -1;
-
-
- int i,new_node;
-
- // if this is assigning an existing node, let's quit.
- for (i=0;i<node_count;i++) if (p_x==node[i].tick_offset) return -1;
-
-
- i=0;
- while ((i<node_count) && (p_x>=node[i].tick_offset)) i++;
-
- new_node=i;
- node_count++;
-
- if (p_move_loops) {
- if (loop_begin_node>=new_node) loop_begin_node++;
- if (loop_end_node>=new_node) loop_end_node++;
- if (sustain_loop_begin_node>=new_node) sustain_loop_begin_node++;
- if (sustain_loop_end_node>=new_node) sustain_loop_end_node++;
- }
- for (i=node_count-1;i>new_node;i--) node[i]=node[i-1];
-
-
-
- set_position(new_node,p_x,p_y);
-
-
-
- return new_node;
-
-}
-
-void CPEnvelope::set_loop_begin(int pos) {
-
- if ((pos<0) || (pos>=node_count)) return;
-
-
-
- loop_begin_node=pos;
-
- if (loop_end_node<loop_begin_node) loop_end_node=loop_begin_node;
-
-
-
-}
-
-void CPEnvelope::set_loop_end(int pos) {
-
- if ((pos<0) || (pos>=node_count)) return;
-
-
-
- loop_end_node=pos;
-
- if (loop_end_node<loop_begin_node) loop_begin_node=loop_end_node;
-
-
-
-
-}
-
-
-void CPEnvelope::set_sustain_loop_begin(int pos) {
-
- if ((pos<0) || (pos>=node_count)) return;
-
-
-
- sustain_loop_begin_node=pos;
-
- if (sustain_loop_end_node<sustain_loop_begin_node) sustain_loop_end_node=sustain_loop_begin_node;
-
-
-
-}
-
-void CPEnvelope::set_sustain_loop_end(int pos) {
-
- if ((pos<0) || (pos>=node_count)) return;
-
-
-
- sustain_loop_end_node=pos;
-
- if (sustain_loop_end_node<sustain_loop_begin_node) sustain_loop_begin_node=sustain_loop_end_node;
-
-
-
-}
-
-void CPEnvelope::set_loop_enabled(bool p_enabled) {
-
- loop_on=p_enabled;
-}
-bool CPEnvelope::is_loop_enabled() {
-
- return loop_on;
-}
-
-
-void CPEnvelope::set_sustain_loop_enabled(bool p_enabled) {
-
- sustain_loop_on=p_enabled;
-}
-bool CPEnvelope::is_sustain_loop_enabled() {
-
- return sustain_loop_on;
-}
-
-void CPEnvelope::del_position(int p_node) {
-
- if ((node_count<3) || (p_node<=0) || (p_node>=node_count)) return;
-
-
-
- int i;
-
- if (loop_begin_node>=p_node) loop_begin_node--;
- if (loop_end_node>=p_node) loop_end_node--;
- if (sustain_loop_begin_node>=p_node) sustain_loop_begin_node--;
- if (sustain_loop_end_node>=p_node) sustain_loop_end_node--;
-
- for (i=p_node;i<node_count-1;i++) node[i]=node[i+1];
-
- node_count--;
-
-
-
-}
-
-uint8_t CPEnvelope::get_loop_begin() {
-
-
- return loop_begin_node;
-}
-uint8_t CPEnvelope::get_loop_end() {
-
- return loop_end_node;
-}
-
-uint8_t CPEnvelope::get_sustain_loop_begin() {
-
-
- return sustain_loop_begin_node;
-}
-uint8_t CPEnvelope::get_sustain_loop_end() {
-
- return sustain_loop_end_node;
-}
-
-
-
-void CPEnvelope::set_enabled(bool p_enabled) {
-
- on=p_enabled;
-}
-
-bool CPEnvelope::is_enabled() {
-
- return on;
-}
-
-void CPEnvelope::set_carry_enabled(bool p_enabled) {
-
- carry=p_enabled;
-}
-bool CPEnvelope::is_carry_enabled() {
-
- return carry;
-}
-
-uint8_t CPEnvelope::get_node_count() {
-
- return node_count;
-}
-
-const CPEnvelope::Point& CPEnvelope::get_node(int p_idx) {
-
- if (p_idx<0 || p_idx>=node_count)
- return node[node_count-1];
-
- return node[p_idx];
-
-}
-
-
diff --git a/modules/chibi/cp_envelope.h b/modules/chibi/cp_envelope.h
deleted file mode 100644
index af27f5f185..0000000000
--- a/modules/chibi/cp_envelope.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*************************************************************************/
-/* cp_envelope.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_ENVELOPE_H
-#define CP_ENVELOPE_H
-
-#include "cp_config.h"
-
-/**envelope?
- *@author Juan Linietsky
- */
-
-/******************************
- envelope.h
- ----------
-
-Proovides an envelope, and basic functions
-for it that can be used for both player
-and interface
-********************************/
-
-
-class CPEnvelope {
- enum {
-
- MAX_POINTS=25
- };
-
- struct Point {
-
- uint16_t tick_offset;
- int16_t value;
- };
-
- Point node[MAX_POINTS];
-
- int8_t node_count;
-
- bool on;
- bool carry;
-
- bool loop_on;
-
- uint8_t loop_begin_node;
- uint8_t loop_end_node;
-
- bool sustain_loop_on;
- uint8_t sustain_loop_begin_node;
- uint8_t sustain_loop_end_node;
-
-
- int8_t max_value;
- int8_t min_value;
-
-
-public:
- enum {
-
- NO_POINT=-5000,
- };
-
- void set_max(int8_t p_max) { max_value=p_max; }
- int8_t get_max() { return max_value; }
- void set_min(int8_t p_min) { min_value=p_min; }
- int8_t get_min() { return min_value; }
-
- uint8_t get_node_count();
- const Point& get_node(int p_idx);
-
- void set_position(int p_node,int p_x,int p_y);
- int add_position(int p_x,int p_y,bool p_move_loops=true);
- void del_position(int p_node);
-
- void set_loop_enabled(bool p_enabled);
- bool is_loop_enabled();
- void set_loop_begin(int pos);
- void set_loop_end(int pos);
- uint8_t get_loop_begin();
- uint8_t get_loop_end();
-
- void set_sustain_loop_enabled(bool p_enabled);
- bool is_sustain_loop_enabled();
- void set_sustain_loop_begin(int pos);
- void set_sustain_loop_end(int pos);
- uint8_t get_sustain_loop_begin();
- uint8_t get_sustain_loop_end();
-
- void set_enabled(bool p_enabled);
- bool is_enabled();
-
- void set_carry_enabled(bool p_enabled);
- bool is_carry_enabled();
-
- void reset();
- int get_height_at_pos(int pos);
- float get_interp_height_at_pos(float pos);
-
-
- CPEnvelope();
-
-};
-
-#endif
diff --git a/modules/chibi/cp_file_access_wrapper.h b/modules/chibi/cp_file_access_wrapper.h
deleted file mode 100644
index ade077c1ef..0000000000
--- a/modules/chibi/cp_file_access_wrapper.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*************************************************************************/
-/* cp_file_access_wrapper.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_FILE_ACCESS_WRAPPER_H
-#define CP_FILE_ACCESS_WRAPPER_H
-
-#include "cp_config.h"
-
-class CPFileAccessWrapper {
-public:
-
- enum ModeFlags {
-
- READ=1,
- WRITE=2,
- READ_WRITE=3,
- };
-
- enum Error {
-
- OK,
- ERROR_FILE_NOT_FOUND,
- ERROR_FILE_BAD_DRIVE,
- ERROR_FILE_BAD_PATH,
- ERROR_FILE_NO_PERMISSION,
- ERROR_ALREADY_IN_USE,
- ERROR_INVALID_PARAMETERS,
- ERROR_OPENING_FILE,
- ERROR_READING_FILE,
- ERROR_WRITING_FILE
- };
-
- virtual Error open(const char *p_filename, int p_mode_flags)=0;
- virtual void close()=0;
-
- virtual void seek(uint32_t p_position)=0;
- virtual void seek_end()=0;
- virtual uint32_t get_pos()=0;
-
- virtual bool eof_reached()=0;
-
- virtual uint8_t get_byte()=0;
- virtual void get_byte_array(uint8_t *p_dest,int p_elements)=0;
- virtual void get_word_array(uint16_t *p_dest,int p_elements)=0;
-
- virtual uint16_t get_word()=0;
- virtual uint32_t get_dword()=0;
-
- // use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
- // It's not about the current CPU type but file formats.
- // this flags get reset to false (little endian) on each open
- virtual void set_endian_conversion(bool p_swap)=0;
- virtual bool is_open()=0;
-
- virtual Error get_error()=0;
-
- virtual void store_byte(uint8_t p_dest)=0;
- virtual void store_byte_array(const uint8_t *p_dest,int p_elements)=0;
-
- virtual void store_word(uint16_t p_dest)=0;
- virtual void store_dword(uint32_t p_dest)=0;
-
-
-
- virtual ~CPFileAccessWrapper(){}
-
-};
-
-
-
-#endif
diff --git a/modules/chibi/cp_instrument.cpp b/modules/chibi/cp_instrument.cpp
deleted file mode 100644
index 606a4217e0..0000000000
--- a/modules/chibi/cp_instrument.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*************************************************************************/
-/* cp_instrument.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_instrument.h"
-#include "cp_song.h"
-#include "cp_note.h"
-
-
-
-const char *CPInstrument::get_name() {
-
- return name;
-
-}
-void CPInstrument::set_name(const char *p_name) {
-
-
- if (p_name==NULL) {
- name[0]=0;
- return;
- }
-
-
- bool done=false;
- for (int i=0;i<MAX_NAME_LEN;i++) {
-
-
- name[i]=done?0:p_name[i];
- if (!done && p_name[i]==0)
- done=true;
- }
-
- name[MAX_NAME_LEN-1]=0; /* just in case */
-
-
-}
-
-void CPInstrument::set_sample_number(uint8_t p_note,uint8_t p_sample_id) {
-
- CP_ERR_COND(p_note>=CPNote::NOTES);
- CP_ERR_COND(p_sample_id>CPSong::MAX_SAMPLES && p_sample_id!=CPNote::EMPTY);
- data.sample_number[p_note]=p_sample_id;
-
-
-}
-uint8_t CPInstrument::get_sample_number(uint8_t p_note) {
-
- CP_ERR_COND_V(p_note>=CPNote::NOTES,0);
- return data.sample_number[p_note];
-}
-
-void CPInstrument::set_note_number(uint8_t p_note,uint8_t p_note_id) {
-
- CP_ERR_COND(p_note>=CPNote::NOTES);
- CP_ERR_COND(p_note_id>=CPNote::NOTES && p_note_id!=CPNote::EMPTY);
- data.note_number[p_note]=p_note_id;
-
-}
-uint8_t CPInstrument::get_note_number(uint8_t p_note) {
-
- CP_ERR_COND_V(p_note>=CPNote::NOTES,0);
- return data.note_number[p_note];
-
-}
-
-void CPInstrument::set_NNA_type(NNA_Type p_NNA_type) {
-
- data.NNA_type=p_NNA_type;
-}
-CPInstrument::NNA_Type CPInstrument::get_NNA_type() {
-
- return data.NNA_type;
-}
-
-void CPInstrument::set_DC_type(DC_Type p_DC_type) {
-
- data.DC_type=p_DC_type;
-}
-CPInstrument::DC_Type CPInstrument::get_DC_type() {
-
- return data.DC_type;
-
-}
-
-void CPInstrument::set_DC_action(DC_Action p_DC_action) {
-
- data.DC_action=p_DC_action;
-}
-CPInstrument::DC_Action CPInstrument::get_DC_action() {
-
- return data.DC_action;
-}
-
-/* Volume */
-
-void CPInstrument::set_volume_global_amount(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_VOLUME);
- data.volume.global_amount=p_amount;
-
-}
-uint8_t CPInstrument::get_volume_global_amount() {
-
- return data.volume.global_amount;
-}
-
-void CPInstrument::set_volume_fadeout(uint16_t p_amount) {
- CP_ERR_COND(p_amount>MAX_FADEOUT);
- data.volume.fadeout=p_amount;
-}
-uint16_t CPInstrument::get_volume_fadeout() {
-
- return data.volume.fadeout;
-}
-void CPInstrument::set_volume_random_variation(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_VOLUME_RANDOM);
- data.volume.random_variation=p_amount;
-}
-uint8_t CPInstrument::get_volume_random_variation() {
-
- return data.volume.random_variation;
-}
-
-/* Panning */
-
-void CPInstrument::set_pan_default_amount(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_PAN);
- data.pan.default_amount=p_amount;
-}
-uint8_t CPInstrument::get_pan_default_amount() {
-
- return data.pan.default_amount;
-}
-
-void CPInstrument::set_pan_default_enabled(bool p_enabled) {
-
- data.pan.use_default=p_enabled;
-}
-bool CPInstrument::is_pan_default_enabled() {
-
- return data.pan.use_default;
-
-}
-
-void CPInstrument::set_pan_pitch_separation(int8_t p_amount) {
-
- CP_ERR_COND(p_amount<-32);
- CP_ERR_COND(p_amount>32);
- data.pan.pitch_separation=p_amount;
-}
-int8_t CPInstrument::get_pan_pitch_separation() {
-
- return data.pan.pitch_separation;
-}
-
-void CPInstrument::set_pan_pitch_center(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>=CPNote::NOTES);
- data.pan.pitch_center=p_amount;
-}
-uint8_t CPInstrument::get_pan_pitch_center() {
-
- return data.pan.pitch_center;
-}
-
-void CPInstrument::set_pan_random_variation(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_PAN_RANDOM);
- data.pan.random_variation=p_amount;
-}
-uint8_t CPInstrument::get_pan_random_variation() {
-
- return data.pan.random_variation;
-}
-
-/* Pitch / Filter */
-
-void CPInstrument::set_pitch_use_as_filter(bool p_enabled) {
-
- data.pitch.use_as_filter=p_enabled;
-}
-bool CPInstrument::is_pitch_use_as_filter() {
-
- return data.pitch.use_as_filter;
-}
-
-void CPInstrument::set_filter_use_default_cutoff(bool p_enabled) {
-
- data.pitch.use_default_cutoff=p_enabled;
-
-}
-bool CPInstrument::filter_use_default_cutoff() {
-
- return data.pitch.use_default_cutoff;
-}
-
-void CPInstrument::set_filter_default_cutoff(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_FILTER_CUTOFF);
- data.pitch.default_cutoff=p_amount;
-}
-uint8_t CPInstrument::get_filter_default_cutoff() {
-
- return data.pitch.default_cutoff;
-}
-
-void CPInstrument::set_filter_use_default_resonance(bool p_enabled) {
-
- data.pitch.use_default_resonance=p_enabled;
-}
-bool CPInstrument::filter_use_default_resonance() {
-
- return data.pitch.use_default_resonance;
-}
-
-void CPInstrument::set_filter_default_resonance(uint8_t p_amount) {
-
- CP_ERR_COND(p_amount>MAX_FILTER_RESONANCE);
- data.pitch.default_resonance=p_amount;
-
-}
-uint8_t CPInstrument::get_filter_default_resonance() {
-
- return data.pitch.default_resonance;
-}
-
-/* Envelopes */
-
-
-CPEnvelope* CPInstrument::get_volume_envelope() {
-
- return &data.volume.envelope;
-}
-CPEnvelope* CPInstrument::get_pan_envelope() {
-
- return &data.pan.envelope;
-}
-CPEnvelope* CPInstrument::get_pitch_filter_envelope() {
-
- return &data.pitch.envelope;
-
-
-}
-
-
-void CPInstrument::reset() {
-
- name[0]=0;
-
- data.NNA_type=NNA_NOTE_CUT;
- data.DC_action=DCA_NOTE_CUT;
- data.DC_type=DCT_DISABLED;
-
- for (int i=0;i<CPNote::NOTES;i++) {
-
- data.sample_number[i]=CPNote::EMPTY;
- data.note_number[i]=i;
- }
-
- data.volume.envelope.reset();
- data.volume.envelope.set_max(64);
- data.volume.envelope.set_min(0);
- data.volume.envelope.add_position(0,64,false);
- data.volume.envelope.add_position(30,64,false);
-
- data.volume.global_amount=MAX_VOLUME;
- data.volume.fadeout=0;
- data.volume.random_variation=0;
-
- data.pan.envelope.reset();
- data.pan.envelope.set_max(32);
- data.pan.envelope.set_min(-32);
- data.pan.envelope.add_position(0,0,false);
- data.pan.envelope.add_position(30,0,false);
-
- data.pan.default_amount=32;
- data.pan.pitch_center=48;
- data.pan.pitch_separation=0;
- data.pan.use_default=false;
- data.pan.random_variation=0;
-
-
- data.pitch.envelope.reset();
- data.pitch.envelope.set_max(32);
- data.pitch.envelope.set_min(-32);
- data.pitch.envelope.add_position(0,0,false);
- data.pitch.envelope.add_position(30,0,false);
- data.pitch.use_as_filter=false;
- data.pitch.use_default_cutoff=false;
- data.pitch.use_default_resonance=false;
- data.pitch.default_cutoff=0;
- data.pitch.default_resonance=0;
-
-}
-
-bool CPInstrument::is_empty() {
-
- bool has_sample=false;
-
- for (int i=0;i<CPNote::NOTES;i++) {
-
- if (data.sample_number[i]!=CPNote::EMPTY) {
-
- has_sample=true;
- break;
- }
- }
-
- return !has_sample;
-}
-
-CPInstrument::CPInstrument() {
-
- reset();
-
-}
-
diff --git a/modules/chibi/cp_instrument.h b/modules/chibi/cp_instrument.h
deleted file mode 100644
index e51612a38d..0000000000
--- a/modules/chibi/cp_instrument.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/*************************************************************************/
-/* cp_instrument.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_INSTRUMENT_H
-#define CP_INSTRUMENT_H
-
-
-#include "cp_config.h"
-#include "cp_note.h"
-#include "cp_envelope.h"
-
-class CPInstrument {
-public:
-
-
- enum NNA_Type {
-
- NNA_NOTE_CUT,
- NNA_NOTE_CONTINUE,
- NNA_NOTE_OFF,
- NNA_NOTE_FADE
- };
-
- enum DC_Type {
-
- DCT_DISABLED,
- DCT_NOTE,
- DCT_SAMPLE,
- DCT_INSTRUMENT
- };
-
- enum DC_Action
- {
-
- DCA_NOTE_CUT,
- DCA_NOTE_OFF,
- DCA_NOTE_FADE,
- };
-
- enum EnvelopeType {
- VOLUME_ENVELOPE,
- PAN_ENVELOPE,
- PITCH_ENVELOPE
- };
-
-
- enum {
- MAX_NAME_LEN=26,
- MAX_ENVELOPE_NODES=25,
- ENVELOPE_FRAC_BITS=8,
- MAX_VOLUME=128,
- MAX_FADEOUT=256,
- MAX_PAN=128,
- MAX_VOLUME_RANDOM=100,
- MAX_PAN_RANDOM=64, //what did this guy have inside his head?
-
- MAX_FILTER_CUTOFF=127,
- MAX_FILTER_RESONANCE=127
-
- };
-
-
- struct Data {
-
-
- uint8_t sample_number[CPNote::NOTES];
- uint8_t note_number[CPNote::NOTES];
-
- NNA_Type NNA_type;
- DC_Type DC_type;
- DC_Action DC_action;
-
- struct Volume {
-
- CPEnvelope envelope;
- uint8_t global_amount;
- uint16_t fadeout;
- uint8_t random_variation;
-
- } volume;
-
- struct Pan {
-
- CPEnvelope envelope;
- bool use_default;
- uint8_t default_amount;
- int8_t pitch_separation;
- uint8_t pitch_center;
- uint8_t random_variation;
-
- } pan;
-
- struct Pitch {
-
- CPEnvelope envelope;
- bool use_as_filter;
- bool use_default_cutoff;
- uint8_t default_cutoff;
- bool use_default_resonance;
- uint8_t default_resonance;
- } pitch;
-
- };
-
-private:
-
-
-
- Data data;
- char name[MAX_NAME_LEN];
-
-public:
-
- /* CPInstrument General */
-
- const char *get_name();
- void set_name(const char *p_name);
-
- void set_sample_number(uint8_t p_note,uint8_t p_sample_id);
- uint8_t get_sample_number(uint8_t p_note);
-
- void set_note_number(uint8_t p_note,uint8_t p_note_id);
- uint8_t get_note_number(uint8_t p_note);
-
- void set_NNA_type(NNA_Type p_NNA_type);
- NNA_Type get_NNA_type();
-
- void set_DC_type(DC_Type p_DC_type);
- DC_Type get_DC_type();
-
- void set_DC_action(DC_Action p_DC_action);
- DC_Action get_DC_action();
-
- /* Volume */
-
- void set_volume_global_amount(uint8_t p_amount);
- uint8_t get_volume_global_amount();
-
- void set_volume_fadeout(uint16_t p_amount);
- uint16_t get_volume_fadeout();
-
- void set_volume_random_variation(uint8_t p_amount);
- uint8_t get_volume_random_variation();
-
- /* Panning */
-
- void set_pan_default_amount(uint8_t p_amount);
- uint8_t get_pan_default_amount();
-
- void set_pan_default_enabled(bool p_enabled);
- bool is_pan_default_enabled();
-
- void set_pan_pitch_separation(int8_t p_amount);
- int8_t get_pan_pitch_separation();
-
- void set_pan_pitch_center(uint8_t p_amount);
- uint8_t get_pan_pitch_center();
-
- void set_pan_random_variation(uint8_t p_amount);
- uint8_t get_pan_random_variation();
-
- /* Pitch / Filter */
-
- void set_pitch_use_as_filter(bool p_enabled);
- bool is_pitch_use_as_filter();
-
- void set_filter_use_default_cutoff(bool p_enabled);
- bool filter_use_default_cutoff();
-
- void set_filter_default_cutoff(uint8_t p_amount);
- uint8_t get_filter_default_cutoff();
-
- void set_filter_use_default_resonance(bool p_enabled);
- bool filter_use_default_resonance();
-
- void set_filter_default_resonance(uint8_t p_amount);
- uint8_t get_filter_default_resonance();
-
- CPEnvelope* get_volume_envelope();
- CPEnvelope* get_pan_envelope();
- CPEnvelope* get_pitch_filter_envelope();
-
- bool is_empty();
-
- void reset();
- CPInstrument();
-
-};
-
-
-
-#endif
-
-
diff --git a/modules/chibi/cp_loader.h b/modules/chibi/cp_loader.h
deleted file mode 100644
index 1630444481..0000000000
--- a/modules/chibi/cp_loader.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************/
-/* cp_loader.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_LOADER_H
-#define CP_LOADER_H
-
-
-#include "cp_song.h"
-#include "cp_file_access_wrapper.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class CPLoader {
-
-public:
-
- enum Error {
- FILE_OK,
- FILE_UNRECOGNIZED,
- FILE_CANNOT_OPEN,
- FILE_CORRUPTED,
- FILE_OUT_OF_MEMORY,
- };
-
-
- virtual bool can_load_song()=0;
- virtual bool can_load_sample()=0;
- virtual bool can_load_instrument()=0;
-
- virtual Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset)=0;
- virtual Error load_sample(const char *p_file,CPSample *p_sample)=0;
- virtual Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx)=0;
-
-
- virtual ~CPLoader() {}
-
-};
-
-#endif
diff --git a/modules/chibi/cp_loader_it.cpp b/modules/chibi/cp_loader_it.cpp
deleted file mode 100644
index bfffd9b509..0000000000
--- a/modules/chibi/cp_loader_it.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_it.h"
-
-bool CPLoader_IT::can_load_song() { return true; }
-bool CPLoader_IT::can_load_sample() { return true; }
-bool CPLoader_IT::can_load_instrument() { return true; }
-
-CPLoader::Error CPLoader_IT::load_song(const char *p_file,CPSong *p_song, bool p_sampleset) {
-
-
- song=p_song;
-
- if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
- return CPLoader::FILE_CANNOT_OPEN;
-
-
- Error err;
-
- char aux_identifier[4];
- file->get_byte_array((uint8_t*)aux_identifier,4);
-
- if ( aux_identifier[0]!='I' ||
- aux_identifier[1]!='M' ||
- aux_identifier[2]!='P' ||
- aux_identifier[3]!='M') {
-
-
- CP_PRINTERR("IT CPLoader CPSong: Failed Identifier");
- return FILE_UNRECOGNIZED;
- }
-
-
- if (p_sampleset) {
-
- song->reset(false,true,true,false);
-
- if ((err=load_header(true))) {
- file->close();
- return err;
- }
-
- if ((err=load_samples())) {
- file->close();
- return err;
- }
-
- if ((err=load_instruments())) {
- file->close();
- return err;
- }
-
- return FILE_OK;
- }
-
- song->reset();
-
- if ((err=load_header(false))) {
- file->close();
- return err;
- }
-
- if ((err=load_orders())) {
- file->close();
- return err;
- }
-
- if ((err=load_patterns())) {
- file->close();
- return err;
- }
-
- if ((err=load_samples())) {
- file->close();
- return err;
- }
-
- if ((err=load_effects())) {
- file->close();
- return err;
- }
-
- if ((err=load_instruments())) {
- file->close();
- return err;
- }
-
- if ((err=load_message())) {
- file->close();
- return err;
- }
-
- file->close();
- return FILE_OK;
-
-}
-
-
-
-
-CPLoader::Error CPLoader_IT::load_sample(const char *p_file,CPSample *p_sample) {
-
- if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
- return CPLoader::FILE_CANNOT_OPEN;
-
- p_sample->reset();
- CPLoader::Error res=load_sample(p_sample);
-
- file->close();
-
- return res;
-}
-CPLoader::Error CPLoader_IT::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) {
-
- CP_FAIL_INDEX_V(p_instr_idx,CPSong::MAX_INSTRUMENTS,CPLoader::FILE_CANNOT_OPEN);
-
- if (file->open( p_file, CPFileAccessWrapper::READ )!=CPFileAccessWrapper::OK)
- return CPLoader::FILE_CANNOT_OPEN;
-
-
- p_song->get_instrument( p_instr_idx )->reset();
-
-
- int samples=0;
- CPLoader::Error res=load_instrument( p_song->get_instrument( p_instr_idx ), &samples );
-
- if (res) {
- file->close();
- return res;
- }
-
-
- char exchange[CPSong::MAX_SAMPLES];
- for (int i=0;i<CPSong::MAX_SAMPLES;i++)
- exchange[i]=0;
-
- for (int i=0;i<samples;i++) {
-
- file->seek( 554+i*80 ); //i think this should work?! seems to.. but i'm not sure
-
- /* find free sample */
-
- int free_idx=-1;
- for (int s=0;s<CPSong::MAX_SAMPLES;s++) {
-
- if (p_song->get_sample( s )->get_sample_data().is_null()) {
- free_idx=s;
- break;
- }
- }
- if (free_idx==-1)
- break; //can't seem to be able to load more samples
-
- exchange[i]=free_idx;
- res=load_sample( p_song->get_sample( free_idx ) );
-
- if (res) {
-
- file->close();
- return res;
- }
- }
-
- for (int i=0;i<CPNote::NOTES;i++) {
-
- int smp=song->get_instrument(p_instr_idx)->get_sample_number(i);
-
- if (smp>=CPSong::MAX_SAMPLES)
- continue;
-
- if (smp<0)
- continue;
-
- smp=exchange[smp];
-
- song->get_instrument(p_instr_idx)->set_sample_number(i,smp);
-
- }
-
- file->close();
-
- return res;
-
-}
-
-CPLoader_IT::CPLoader_IT(CPFileAccessWrapper *p_file) {
-
- file=p_file;
-
-}
diff --git a/modules/chibi/cp_loader_it.h b/modules/chibi/cp_loader_it.h
deleted file mode 100644
index 5ce62a6a49..0000000000
--- a/modules/chibi/cp_loader_it.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_LOADER_IT_H
-#define CP_LOADER_IT_H
-
-#include "cp_loader.h"
-/**
- *@author Juan Linietsky
- */
-
-/******************************
- loader_it.h
- ----------
-Impulse Tracker Module CPLoader!
-It lacks support for old
-instrument files methinks...
-and some other things like
-midi.
-********************************/
-
-class AuxSampleData; //used for internal crap
-
-class CPLoader_IT : public CPLoader {
-
-
-
- CPFileAccessWrapper *file;
- CPSong *song;
-
- struct IT_Header {
- uint8_t blank01[2];
- uint16_t ordnum;
- uint16_t insnum;
- uint16_t smpnum;
- uint16_t patnum;
- uint16_t cwt; /* Created with tracker (y.xx = 0x0yxx) */
- uint16_t cmwt; /* Compatible with tracker ver > than val. */
- uint16_t flags;
- uint16_t special; /* bit 0 set = song message attached */
- uint16_t msglength;
- uint32_t msgoffset;
- bool is_chibi;
- };
-
- /* Variables to store temp data */
- IT_Header header;
-
- /* CPSong Info Methods */
- Error load_header(bool p_dont_set);
- Error load_orders();
- Error load_message();
-
- /* CPPattern Methods */
- Error load_patterns();
-
- /* CPSample Methods */
-
- Error load_samples();
- Error load_sample(CPSample *p_sample);
- CPSample_ID load_sample_data(AuxSampleData& p_sample_data);
-
- // CPSample decompression
-
- uint32_t read_n_bits_from_IT_compressed_block(uint8_t p_bits_to_read);
- bool read_IT_compressed_block (bool p_16bits);
- void free_IT_compressed_block ();
- bool load_sample_8bits_IT_compressed(void *p_dest_buffer,int p_buffsize);
- bool load_sample_16bits_IT_compressed(void *p_dest_buffer,int p_buffsize);
- uint32_t *source_buffer; /* source buffer */
- uint32_t *source_position; /* actual reading position */
- uint8_t source_remaining_bits; /* bits remaining in read dword */
- uint8_t* pat_data;
-
- /* CPInstruments Methods */
- Error load_effects();
- Error load_instruments();
- Error load_instrument(CPInstrument *p_instrument,int *p_samples=0);
- void load_envelope(CPEnvelope *p_envelope,bool*p_has_filter_flag=0);
-
-
-public:
-
-
- bool can_load_song();
- bool can_load_sample();
- bool can_load_instrument();
-
- Error load_song(const char *p_file,CPSong *p_song, bool p_sampleset=false);
- Error load_sample(const char *p_file,CPSample *p_sample);
- Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx);
-
- CPLoader_IT(CPFileAccessWrapper *p_file);
-
-};
-
-
-
-#endif
diff --git a/modules/chibi/cp_loader_it_info.cpp b/modules/chibi/cp_loader_it_info.cpp
deleted file mode 100644
index a474fcd2f9..0000000000
--- a/modules/chibi/cp_loader_it_info.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it_info.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_it.h"
-
-
-
-CPLoader::Error CPLoader_IT::load_header(bool p_dont_set) {
-
-
- char aux_songname[26];
-
- file->get_byte_array((uint8_t*)aux_songname,26);
- if (!p_dont_set)
- song->set_name( aux_songname );
-
- uint8_t aux_hlmin=file->get_byte();
- uint8_t aux_hlmaj=file->get_byte();
-
- if (aux_hlmin==0) aux_hlmin=4;
- if (aux_hlmaj==0) aux_hlmaj=16;
-
- if (!p_dont_set) {
- song->set_row_highlight_minor( aux_hlmin );
- song->set_row_highlight_major( aux_hlmaj );
- }
-
- header.ordnum=file->get_word();
- header.insnum=file->get_word();
- header.smpnum=file->get_word();
- header.patnum=file->get_word();
-
- header.cwt=file->get_word(); /* Created with tracker (y.xx = 0x0yxx) */
- header.cmwt=file->get_word(); /* Compatible with tracker ver > than val. */
- header.flags=file->get_word();
-
- if (!p_dont_set) {
- song->set_stereo( header.flags & 1 );
- song->set_linear_slides( header.flags & 8 );
- song->set_old_effects( header.flags & 16 );
- song->set_compatible_gxx( header.flags & 32 );
- song->set_instruments( header.flags & 4 );
- }
-
-
- header.special=file->get_word();
- if (!p_dont_set) {
-
- song->set_global_volume( file->get_byte() );
- song->set_mixing_volume( file->get_byte() );
- song->set_speed( file->get_byte() );
- song->set_tempo( file->get_byte() );
- song->set_stereo_separation( file->get_byte() );
-
- } else {
-
- file->get_byte(); // skip
- file->get_byte(); // skip
- file->get_byte(); // skip
- file->get_byte(); // skip
- file->get_byte(); // skip
- }
- file->get_byte(); // ZERO Byte
- header.msglength=file->get_word();
- header.msgoffset=file->get_dword();
- char chibi[4];
- file->get_byte_array((uint8_t*)chibi,4);
- header.is_chibi=(chibi[0]=='C' && chibi[1]=='H' && chibi[2]=='B' && chibi[3]=='I');
-
- for (int i=0;i<64;i++) {
-
- uint8_t panbyte=file->get_byte();
-
- uint8_t pan_dst=(panbyte<65) ? panbyte : 32;
- bool surround_dst=(panbyte==100);
- bool mute_dst=(panbyte>=128);
-
- if (!p_dont_set) {
- song->set_channel_pan( i, pan_dst );
- song->set_channel_surround( i, surround_dst );
- song->set_channel_mute( i, mute_dst );
- }
- }
- for (int i=0;i<64;i++) {
- unsigned char cv = file->get_byte();
- if (!p_dont_set)
- song->set_channel_volume( i, cv );
- }
-
- CP_ERR_COND_V( file->eof_reached(),FILE_CORRUPTED );
- CP_ERR_COND_V( file->get_error(),FILE_CORRUPTED );
-
- return FILE_OK;
-}
-
-CPLoader::Error CPLoader_IT::load_effects() {
-
- if (!header.is_chibi)
- return FILE_OK; //no effects, regular IT file
-
- /* GOTO End of IT header */
- file->seek(0xC0+header.ordnum+header.insnum*4+header.smpnum*4+header.patnum*4);
-
-
- if (file->get_byte()>0) //not made with this version, ignore extended info
- return FILE_OK;
-
- /* Chibitracker Extended info */
-
- switch(file->get_byte()) {
-
- case CPSong::REVERB_MODE_ROOM: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_ROOM );
- } break;
- case CPSong::REVERB_MODE_STUDIO_SMALL: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_SMALL );
-
- } break;
- case CPSong::REVERB_MODE_STUDIO_MEDIUM: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_MEDIUM );
-
- } break;
- case CPSong::REVERB_MODE_STUDIO_LARGE: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_STUDIO_LARGE );
-
- } break;
- case CPSong::REVERB_MODE_HALL: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_HALL );
-
- } break;
- case CPSong::REVERB_MODE_SPACE_ECHO: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_SPACE_ECHO );
-
- } break;
-
- case CPSong::REVERB_MODE_ECHO: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_ECHO );
-
- } break;
- case CPSong::REVERB_MODE_DELAY: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_DELAY );
-
- } break;
- case CPSong::REVERB_MODE_HALF_ECHO: {
-
- song->set_reverb_mode( CPSong::REVERB_MODE_HALF_ECHO );
-
- } break;
-
- }
-
- //chorus
- song->set_chorus_speed_hz10( file->get_byte() );
- song->set_chorus_delay_ms( file->get_byte() );
- song->set_chorus_depth_ms10( file->get_byte() );
- song->set_chorus_separation_ms( file->get_byte() );
-
- for (int i=0;i<CPPattern::WIDTH;i++) {
- song->set_channel_reverb(i,file->get_byte());
- }
- for (int i=0;i<CPPattern::WIDTH;i++) {
- song->set_channel_chorus(i,file->get_byte());
- }
-
- return FILE_OK;
-
-}
-
-CPLoader::Error CPLoader_IT::load_message() {
-
-
- if (!(header.special & 1)) {
-
- return FILE_OK;
- }
-
-
- file->seek(header.msgoffset);
-
- //(void*)tmpmsg=malloc(header.msglength+1);
-
- char message[8000];
-
-
- char *tmpmsg = message;
-
- file->get_byte_array((uint8_t*)tmpmsg,header.msglength);
- tmpmsg[header.msglength]=0;
-
- for (int i=0;i<header.msglength;i++) if (tmpmsg[i]=='\r') tmpmsg[i]='\n';
-
- song->set_message(tmpmsg);
-
- return FILE_OK;
-}
-
-CPLoader::Error CPLoader_IT::load_orders() {
-
- file->seek(0xC0);
-
-
- for (int i=0;i<header.ordnum;i++) {
-
- uint8_t aux_order=file->get_byte();
- CPOrder order=CP_ORDER_NONE;
-
-
- if (i>=CPSong::MAX_ORDERS)
- continue;
- if (aux_order==254) {
-
- order=CP_ORDER_BREAK;
-
- } else if (aux_order<200) {
-
- order=aux_order;
- //nothing!
-
- }
- song->set_order(i,order);
-
- }
-
- if (file->eof_reached() || file->get_error()) {
-
-
- return FILE_CORRUPTED;
-
- }
-
- return FILE_OK;
-}
-
-
-
diff --git a/modules/chibi/cp_loader_it_instruments.cpp b/modules/chibi/cp_loader_it_instruments.cpp
deleted file mode 100644
index 446e841c5f..0000000000
--- a/modules/chibi/cp_loader_it_instruments.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it_instruments.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_it.h"
-
-enum EnvFlags {
- ENV_ON=1,
- ENV_LOOP=2,
- ENV_SUSLOOP=4,
- ENV_CARRY=8,
- ENV_FILTER=128
-};
-
-void CPLoader_IT::load_envelope(CPEnvelope *p_envelope,bool*p_has_filter_flag) {
-
- uint8_t flags=file->get_byte();
- uint8_t points=file->get_byte();
- uint8_t begin=file->get_byte();
- uint8_t end=file->get_byte();
- uint8_t susbegin=file->get_byte();
- uint8_t susend=file->get_byte();
-
- p_envelope->reset();
-
- for (int i=0;i<25;i++) {
-
- uint8_t height=file->get_byte();
- int8_t &signed_height=(int8_t&)height;
- uint16_t tick=file->get_word();
-
- if (i>=points)
- continue;
- p_envelope->add_position( tick, signed_height );
-
- }
-
- p_envelope->set_enabled( flags & ENV_ON );
- p_envelope->set_carry_enabled( flags & ENV_CARRY);
-
- p_envelope->set_loop_enabled( flags & ENV_LOOP );
- p_envelope->set_loop_begin( begin );
- p_envelope->set_loop_end( end );
-
- p_envelope->set_sustain_loop_enabled( flags & ENV_SUSLOOP );
- p_envelope->set_sustain_loop_begin( susbegin );
- p_envelope->set_sustain_loop_end( susend );
-
- if (p_has_filter_flag)
- *p_has_filter_flag=flags&ENV_FILTER;
-
- file->get_byte(); //zerobyte
-
- //fill with stuff if the envelope hass less than 2 points
- while(p_envelope->get_node_count()<2) {
-
- p_envelope->add_position( 30*p_envelope->get_node_count(), p_envelope->get_min()==0 ? 64 : 0, false );
- }
-}
-
-
-CPLoader::Error CPLoader_IT::load_instrument(CPInstrument *p_instrument,int *p_samples) {
-
-
-
- char aux_header[4];
-
- file->get_byte_array((uint8_t*)aux_header,4);
-
-
- if ( aux_header[0]!='I' ||
- aux_header[1]!='M' ||
- aux_header[2]!='P' ||
- aux_header[3]!='I') {
- CP_PRINTERR("IT CPLoader CPInstrument: Failed Identifier");
-
- return FILE_UNRECOGNIZED;
- }
-
-
-
- // Ignore deprecated 8.3 filename field
- for (int i=0;i<12;i++) file->get_byte();
-
- //Ignore zerobyte
- file->get_byte(); /* (byte) CPInstrument type (always 0) */
-
- switch( file->get_byte() ) { /* New CPNote Action [0,1,2,3] */
- case 0: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_CUT ) ; break;
- case 1: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_CONTINUE ) ; break;
- case 2: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_OFF ) ; break;
- case 3: p_instrument->set_NNA_type( CPInstrument::NNA_NOTE_FADE ) ; break;
- };
- switch( file->get_byte() ) { // Duplicate Check Type
- case 0: p_instrument->set_DC_type( CPInstrument::DCT_DISABLED ); break ;
- case 1: p_instrument->set_DC_type( CPInstrument::DCT_NOTE ); break ;
- case 2: p_instrument->set_DC_type( CPInstrument::DCT_SAMPLE ); break ;
- case 3: p_instrument->set_DC_type( CPInstrument::DCT_INSTRUMENT ); break ;
- }
- switch( file->get_byte() ) { //Duplicate Check Action
- case 0: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_CUT ); break ;
- case 1: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_OFF ); break ;
- case 2: p_instrument->set_DC_action( CPInstrument::DCA_NOTE_FADE ); break ;
- }
-
- int fade = file->get_word();
- //intf("AFADE: %i\n",fade);
- if (fade>CPInstrument::MAX_FADEOUT) //needs to be clipped because of horrible modplug doings
- fade=CPInstrument::MAX_FADEOUT;
-
- p_instrument->set_volume_fadeout( fade );
- p_instrument->set_pan_pitch_separation( file->get_byte() );
- p_instrument->set_pan_pitch_center( file->get_byte() );
- p_instrument->set_volume_global_amount( file->get_byte() );
- uint8_t pan=file->get_byte();
- p_instrument->set_pan_default_amount(pan&0x7F);
- p_instrument->set_pan_default_enabled( !(pan&0x80) );
- p_instrument->set_volume_random_variation( file->get_byte() );
- p_instrument->set_pan_random_variation( file->get_byte() );
-
-
-
- file->get_word(); //empty (version)
- uint8_t samples=file->get_byte();
- if (p_samples)
- *p_samples=samples;
- file->get_byte(); //empty
- char aux_name[26];
- file->get_byte_array((uint8_t*)aux_name,26);
- p_instrument->set_name(aux_name);
-
- uint8_t cutoff=file->get_byte();
-
- p_instrument->set_filter_default_cutoff(cutoff&0x7F);
- p_instrument->set_filter_use_default_cutoff(cutoff&0x80);
-
- uint8_t resonance=file->get_byte();
-
- p_instrument->set_filter_default_resonance(resonance&0x7F);
- p_instrument->set_filter_use_default_resonance(resonance&0x80);
-
- file->get_dword(); //MIDI, IGNORED!
-
- /* CPNote -> CPSample table */
- for (uint8_t i=0;i<CPNote::NOTES;i++) {
-
-
- uint8_t note=file->get_byte();
- if (note>=CPNote::NOTES)
- note=0;
- p_instrument->set_note_number(i,note);
-
- uint8_t samp=file->get_byte();
- if (samp==0 || samp>99)
- samp=CPNote::EMPTY;
- else
- samp--;
-
-
- p_instrument->set_sample_number(i,samp);
-
-
- }
-
-
- load_envelope( p_instrument->get_volume_envelope() );
- load_envelope( p_instrument->get_pan_envelope() );
- bool use_as_filter;
- load_envelope( p_instrument->get_pitch_filter_envelope(), &use_as_filter );
- p_instrument->set_pitch_use_as_filter( use_as_filter );
-
- return FILE_OK;
-
-}
-
-
-CPLoader::Error CPLoader_IT::load_instruments() {
-
-
- for (int i=0;i<header.insnum;i++) {
-
-
- file->seek(0xC0+header.ordnum+i*4);
- uint32_t final_location=file->get_dword();
- file->seek( final_location );
-
- Error err=load_instrument( song->get_instrument( i ) );
- if (err)
- return err;
-
- }
-
- return FILE_OK;
-
- if (file->eof_reached() || file->get_error())
- return FILE_CORRUPTED;
-}
-
-
diff --git a/modules/chibi/cp_loader_it_patterns.cpp b/modules/chibi/cp_loader_it_patterns.cpp
deleted file mode 100644
index 528d99fff7..0000000000
--- a/modules/chibi/cp_loader_it_patterns.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it_patterns.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_it.h"
-
-
-CPLoader::Error CPLoader_IT::load_patterns() {
-
-
- for (int i=0;i<header.patnum;i++) {
-
- if (i>=CPSong::MAX_PATTERNS)
- break;
-
- /* Position where pattern offsets are stored */
- file->seek(0xC0+header.ordnum+header.insnum*4+header.smpnum*4+i*4);
- uint32_t pattern_offset=file->get_dword();
-
- if (pattern_offset==0) {
-
- continue;
- }
-
- uint16_t pat_size;
- uint16_t pat_length;
-
- int row=0,flag,channel,j;
- uint8_t aux_byte;
- uint32_t reserved;
- uint8_t chan_mask[64]; //mask cache for each
- CPNote last_value[64]; //last value of each
-
- for (j=0;j<64;j++) {
-
- chan_mask[j]=0;
- last_value[j].clear();
- }
-
- file->seek(pattern_offset);
-
- pat_size=file->get_word();
- pat_length=file->get_word();
- reserved=file->get_dword();
-
- song->get_pattern(i)->set_length( pat_length );
-
- do {
-
- aux_byte=file->get_byte();
- flag=aux_byte;
-
- if ( flag==0 ) {
-
- row++;
- } else {
-
- channel=(flag-1) & 63;
-
- if ( flag & 128 ) {
-
- aux_byte=file->get_byte();
- chan_mask[channel]=aux_byte;
- }
-
- CPNote note; //note used for reading
-
- if ( chan_mask[channel]&1 ) { // read note
-
- aux_byte=file->get_byte();
-
- if ( aux_byte<120 )
- note.note=aux_byte;
- else if ( aux_byte==255 )
- note.note=CPNote::OFF;
- else if ( aux_byte==254 )
- note.note=CPNote::CUT;
-
- last_value[channel].note=note.note;
- }
-
-
- if ( chan_mask[channel]&2 ) {
-
- aux_byte=file->get_byte();
- if ( aux_byte<100 )
- note.instrument=aux_byte-1;
-
- last_value[channel].instrument=note.instrument;
- }
- if ( chan_mask[channel]&4 ) {
-
- aux_byte=file->get_byte();
- if ( aux_byte<213 )
- note.volume=aux_byte;
-
- last_value[channel].volume=note.volume;
- }
- if ( chan_mask[channel]&8 ) {
-
- aux_byte=file->get_byte();
- if ( aux_byte>0 )
- note.command=aux_byte-1;
-
-
- last_value[channel].command=note.command;
-
- note.parameter=file->get_byte();
-
- last_value[channel].parameter=note.parameter;
- }
-
- if ( chan_mask[channel]&16 ) {
-
- note.note=last_value[channel].note;
- }
-
- if ( chan_mask[channel]&32 ) {
-
- note.instrument=last_value[channel].instrument;
- }
- if ( chan_mask[channel]&64 ) {
-
- note.volume=last_value[channel].volume;
- }
- if ( chan_mask[channel]&128 ) {
-
- note.command=last_value[channel].command;
- note.parameter=last_value[channel].parameter;
- }
-
- song->get_pattern(i)->set_note(channel,row,note);
- }
-
-
- } while(row<pat_length);
-
- }
-
- return FILE_OK;
-}
-
diff --git a/modules/chibi/cp_loader_it_samples.cpp b/modules/chibi/cp_loader_it_samples.cpp
deleted file mode 100644
index 60db9b7f74..0000000000
--- a/modules/chibi/cp_loader_it_samples.cpp
+++ /dev/null
@@ -1,620 +0,0 @@
-/*************************************************************************/
-/* cp_loader_it_samples.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_it.h"
-#include "cp_sample.h"
-
-struct AuxSampleData {
-
-
- uint32_t fileofs;
- uint32_t c5spd;
- uint32_t length;
- uint32_t loop_begin;
- uint32_t loop_end;
- bool loop_enabled;
- bool pingpong_enabled;
- bool is16bit;
- bool stereo;
- bool exists;
- bool compressed;
-
-};
-
-
-enum IT_Sample_Flags {
-
- IT_SAMPLE_EXISTS=1,
- IT_SAMPLE_16BITS=2,
- IT_SAMPLE_STEREO=4,
- IT_SAMPLE_COMPRESSED=8,
- IT_SAMPLE_LOOPED=16,
- IT_SAMPLE_SUSTAIN_LOOPED=32,
- IT_SAMPLE_LOOP_IS_PINGPONG=64,
- IT_SAMPLE_SUSTAIN_LOOP_IS_PINGPONG=128
-};
-
-
-CPLoader::Error CPLoader_IT::load_sample(CPSample *p_sample) {
-
-
- AuxSampleData aux_sample_data;
-
- char aux_header[4];
-
- file->get_byte_array((uint8_t*)aux_header,4);
-
- if ( aux_header[0]!='I' ||
- aux_header[1]!='M' ||
- aux_header[2]!='P' ||
- aux_header[3]!='S') {
-
- //CP_PRINTERR("IT CPLoader CPSample: Failed Identifier");
- return FILE_UNRECOGNIZED;
- }
-
-
- // Ignore deprecated 8.3 filename
- for (int i=0;i<12;i++) file->get_byte();
-
- file->get_byte(); //ignore zerobyte
-
- p_sample->set_global_volume( file->get_byte() );
-
- /* SAMPLE FLAGS */
- uint8_t flags=file->get_byte();
- aux_sample_data.loop_enabled=flags&IT_SAMPLE_LOOPED;
- aux_sample_data.pingpong_enabled=flags&IT_SAMPLE_LOOP_IS_PINGPONG;
- aux_sample_data.is16bit=flags&IT_SAMPLE_16BITS;
- aux_sample_data.exists=flags&IT_SAMPLE_EXISTS;
- aux_sample_data.stereo=flags&IT_SAMPLE_STEREO;
- aux_sample_data.compressed=flags&IT_SAMPLE_COMPRESSED;
-
- p_sample->set_default_volume(file->get_byte());
- /* SAMPLE NAME */
- char aux_name[26];
- file->get_byte_array((uint8_t*)aux_name,26);
- p_sample->set_name(aux_name);
-
- // ??
- uint8_t convert_flag=file->get_byte();
- // PAN
- uint8_t pan=file->get_byte();
- p_sample->set_pan( pan&0x7F );
- p_sample->set_pan_enabled( pan & 0x80 );
-
- aux_sample_data.length=file->get_dword();
-
-
- aux_sample_data.loop_begin= file->get_dword();
- aux_sample_data.loop_end= file->get_dword();
- aux_sample_data.c5spd=file->get_dword();
- /*p_sample->data.set_sustain_loop_begin=*/file->get_dword();
- /*p_sample->data.sustain_loop_end=*/file->get_dword();
- aux_sample_data.fileofs=file->get_dword();
- p_sample->set_vibrato_speed( file->get_byte() );
- p_sample->set_vibrato_depth( file->get_byte() );
- p_sample->set_vibrato_rate( file->get_byte() );
- switch( file->get_byte() ) {
- /* Vibrato Wave: 0=sine, 1=rampdown, 2=square, 3=random */
- case 0: p_sample->set_vibrato_type( CPSample::VIBRATO_SINE ); break;
- case 1: p_sample->set_vibrato_type( CPSample::VIBRATO_SAW ); break;
- case 2: p_sample->set_vibrato_type( CPSample::VIBRATO_SQUARE ); break;
- case 3: p_sample->set_vibrato_type( CPSample::VIBRATO_RANDOM ); break;
- default: p_sample->set_vibrato_type( CPSample::VIBRATO_SINE ); break;
- }
-
- //printf("Name %s - Flags: fileofs :%i - c5spd %i - len %i 16b %i - data?: %i\n",p_sample->get_name(),aux_sample_data.fileofs,aux_sample_data.c5spd, aux_sample_data.length, aux_sample_data.is16bit,aux_sample_data.exists);
- CPSample_ID samp_id;
-
- if (aux_sample_data.exists) {
- samp_id=load_sample_data(aux_sample_data);
- CPSampleManager::get_singleton()->set_c5_freq(samp_id,aux_sample_data.c5spd);
- CPSampleManager::get_singleton()->set_loop_begin( samp_id,aux_sample_data.loop_begin );
- CPSampleManager::get_singleton()->set_loop_end( samp_id,aux_sample_data.loop_end );
- CPSample_Loop_Type loop_type=aux_sample_data.loop_enabled?( aux_sample_data.pingpong_enabled? CP_LOOP_BIDI: CP_LOOP_FORWARD):CP_LOOP_NONE;
- CPSampleManager::get_singleton()->set_loop_end( samp_id,aux_sample_data.loop_end );
- CPSampleManager::get_singleton()->set_loop_type( samp_id, loop_type);
-
- }
-
- //printf("Loaded id is null?: %i\n",samp_id.is_null());
- p_sample->set_sample_data(samp_id);
- if (!samp_id.is_null()) {
-
- // printf("Loaded ID: stereo: %i len %i 16bit %i\n",CPSampleManager::get_singleton()->is_stereo(samp_id), CPSampleManager::get_singleton()->get_size( samp_id), CPSampleManager::get_singleton()->is_16bits( samp_id) );
- }
-
- CP_ERR_COND_V( file->eof_reached(),FILE_CORRUPTED );
- CP_ERR_COND_V( file->get_error(),FILE_CORRUPTED );
-
- return FILE_OK;
-
-}
-
-CPSample_ID CPLoader_IT::load_sample_data(AuxSampleData& p_sample_data) {
-
-
- int aux_sample_properties = (p_sample_data.is16bit?IT_SAMPLE_16BITS:0)|(p_sample_data.compressed?IT_SAMPLE_COMPRESSED:0)|(p_sample_data.stereo?IT_SAMPLE_STEREO:0);
-
- file->seek(p_sample_data.fileofs);
-
- CPSampleManager *sm=CPSampleManager::get_singleton();
-
- CPSample_ID id;
-
- switch (aux_sample_properties) {
-
- case (0): // 8 bits, mono
- case (IT_SAMPLE_16BITS): // 16 bits mono
- case (IT_SAMPLE_STEREO): // 8 bits stereo
- case (IT_SAMPLE_16BITS|IT_SAMPLE_STEREO): { // 16 bits mono
-
- id=sm->create(p_sample_data.is16bit,p_sample_data.stereo,p_sample_data.length);
- if (id.is_null())
- break;
-
- sm->lock_data(id);
-
- int16_t *ptr16 = (int16_t*)sm->get_data(id);
- int8_t *ptr8=(int8_t*)ptr16;
-
- int chans=p_sample_data.stereo?2:1;
-
- if (p_sample_data.is16bit) {
-
- for (int c=0;c<chans;c++) {
-
- for (int i=0;i<p_sample_data.length;i++) {
-
- ptr16[i*chans+c]=file->get_word();
- }
- }
- } else {
-
- for (int c=0;c<chans;c++) {
-
- for (int i=0;i<p_sample_data.length;i++) {
-
- ptr8[i*chans+c]=file->get_byte();
- }
- }
-
- }
-
- sm->unlock_data(id);
-
- } break;
- case (IT_SAMPLE_COMPRESSED): { // 8 bits compressed
-
-
- id=sm->create(false,false,p_sample_data.length);
- if (id.is_null())
- break;
- sm->lock_data(id);
-
- if ( load_sample_8bits_IT_compressed((void*)sm->get_data( id),p_sample_data.length) ) {
-
- sm->unlock_data(id);
- sm->destroy(id);
-
- break;
- }
-
- sm->unlock_data(id);
-
-
- } break;
- case (IT_SAMPLE_16BITS|IT_SAMPLE_COMPRESSED): { // 16 bits compressed
-
-
- id=sm->create(true,false,p_sample_data.length);
- if (id.is_null())
- break;
- sm->lock_data(id);
-
- if ( load_sample_16bits_IT_compressed((void*)sm->get_data(id),p_sample_data.length) ) {
-
- sm->unlock_data(id);
- sm->destroy(id);
- break;
- }
-
- sm->unlock_data(id);
-
- } break;
- default: {
-
- // I dont know how to handle stereo compressed, does that exist?
- } break;
-
- }
-
-
- return id;
-}
-
-
-CPLoader::Error CPLoader_IT::load_samples() {
-
- for (int i=0;i<header.smpnum;i++) {
-
- //seek to sample
- file->seek(0xC0+header.ordnum+header.insnum*4+i*4);
-
- uint32_t final_location=file->get_dword();
- file->seek( final_location );
-
-
- Error err=load_sample(song->get_sample(i));
- CP_ERR_COND_V(err,err);
-
- }
-
- if (file->eof_reached() || file->get_error())
- return FILE_CORRUPTED;
-
- return FILE_OK;
-}
-/* * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE
-
- -The following sample decompression code is based on xmp's code.(http://xmp.helllabs.org) which is based in openCP code.
-
-* NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE * NOTICE */
-
-uint32_t CPLoader_IT::read_n_bits_from_IT_compressed_block (uint8_t p_bits_to_read) {
-
- uint32_t aux_return_value;
- uint32_t val;
-
- uint8_t *buffer=(uint8_t*)source_position;
- if ( p_bits_to_read <= source_remaining_bits ) {
-
- val=buffer[3];
- val<<=8;
- val|=buffer[2];
- val<<=8;
- val|=buffer[1];
- val<<=8;
- val|=buffer[0];
-
- aux_return_value = val & ((1 << p_bits_to_read) - 1);
- val >>= p_bits_to_read;
- source_remaining_bits -= p_bits_to_read;
-
- buffer[3]=val>>24;
- buffer[2]=(val>>16)&0xFF;
- buffer[1]=(val>>8)&0xFF;
- buffer[0]=(val)&0xFF;
-
- } else {
- aux_return_value=buffer[3];
- aux_return_value<<=8;
- aux_return_value|=buffer[2];
- aux_return_value<<=8;
- aux_return_value|=buffer[1];
- aux_return_value<<=8;
- aux_return_value|=buffer[0];
-
- uint32_t nbits = p_bits_to_read - source_remaining_bits;
- source_position++;
-
- buffer+=4;
- val=buffer[3];
- val<<=8;
- val|=buffer[2];
- val<<=8;
- val|=buffer[1];
- val<<=8;
- val|=buffer[0];
- aux_return_value |= ((val & ((1 << nbits) - 1)) << source_remaining_bits);
- val >>= nbits;
- source_remaining_bits = 32 - nbits;
- buffer[3]=val>>24;
- buffer[2]=(val>>16)&0xFF;
- buffer[1]=(val>>8)&0xFF;
- buffer[0]=(val)&0xFF;
-
- }
-
- return aux_return_value;
-}
-
-bool CPLoader_IT::read_IT_compressed_block (bool p_16bits) {
-
- uint16_t size;
-
- size=file->get_word();
-
- if (file->eof_reached() || file->get_error()) return true;
-
- pat_data = (uint8_t*)CP_ALLOC( 4* ((size >> 2) + 2) );
- if (!pat_data)
- return true;
-
-
- source_buffer=(uint32_t*)pat_data;
- file->get_byte_array((uint8_t*)source_buffer,size);
-
- if (file->eof_reached() || file->get_error()) {
-
- free_IT_compressed_block();
- return true;
- }
-
- source_position = source_buffer;
- source_remaining_bits = 32;
-
- return false;
-}
-
-void CPLoader_IT::free_IT_compressed_block () {
-
-
- if (pat_data) {
- CP_FREE(pat_data);
- pat_data=NULL;
- }
-
-}
-
-bool CPLoader_IT::load_sample_8bits_IT_compressed(void *p_dest_buffer,int p_buffsize) {
-
- int8_t *dest_buffer; /* destination buffer which will be returned */
- uint16_t block_length; /* length of compressed data block in samples */
- uint16_t block_position; /* position in block */
- uint8_t bit_width; /* actual "bit width" */
- uint16_t aux_value; /* value read from file to be processed */
- int8_t d1, d2; /* integrator buffers (d2 for it2.15) */
- int8_t *dest_position; /* position in output buffer */
- int8_t v; /* sample value */
- bool it215; // is this an it215 module?
-
- dest_buffer = (int8_t *) p_dest_buffer;
-
- if (dest_buffer==NULL)
- return true;
-
- for (int i=0;i<p_buffsize;i++)
- dest_buffer[i]=0;
-
-
- dest_position = dest_buffer;
-
- it215=(header.cmwt==0x215);
-
- /* now unpack data till the dest buffer is full */
-
- while (p_buffsize) {
- /* read a new block of compressed data and reset variables */
- if ( read_IT_compressed_block(false) ) {
- CP_PRINTERR("Out of memory decompressing IT CPSample");
- return true;
- }
-
-
- block_length = (p_buffsize < 0x8000) ? p_buffsize : 0x8000;
-
- block_position = 0;
-
- bit_width = 9; /* start with width of 9 bits */
-
- d1 = d2 = 0; /* reset integrator buffers */
-
- /* now uncompress the data block */
- while ( block_position < block_length ) {
-
- aux_value = read_n_bits_from_IT_compressed_block(bit_width); /* read bits */
-
- if ( bit_width < 7 ) { /* method 1 (1-6 bits) */
-
- if ( aux_value == (1 << (bit_width - 1)) ) { /* check for "100..." */
-
- aux_value = read_n_bits_from_IT_compressed_block(3) + 1; /* yes -> read new width; */
- bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1;
- /* and expand it */
- continue; /* ... next value */
- }
-
- } else if ( bit_width < 9 ) { /* method 2 (7-8 bits) */
-
- uint8_t border = (0xFF >> (9 - bit_width)) - 4;
- /* lower border for width chg */
-
- if ( aux_value > border && aux_value <= (border + 8) ) {
-
- aux_value -= border; /* convert width to 1-8 */
- bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1;
- /* and expand it */
- continue; /* ... next value */
- }
-
-
- } else if ( bit_width == 9 ) { /* method 3 (9 bits) */
-
- if ( aux_value & 0x100 ) { /* bit 8 set? */
-
- bit_width = (aux_value + 1) & 0xff; /* new width... */
- continue; /* ... and next value */
- }
-
- } else { /* illegal width, abort */
-
-
- free_IT_compressed_block();
- CP_PRINTERR("CPSample has illegal BitWidth ");
- return true;
- }
-
- /* now expand value to signed byte */
- if ( bit_width < 8 ) {
-
- uint8_t tmp_shift = 8 - bit_width;
-
- v=(aux_value << tmp_shift);
- v>>=tmp_shift;
-
- } else v = (int8_t) aux_value;
-
- /* integrate upon the sample values */
- d1 += v;
- d2 += d1;
-
- /* ... and store it into the buffer */
- *(dest_position++) = it215 ? d2 : d1;
- block_position++;
-
- }
-
- /* now subtract block lenght from total length and go on */
- free_IT_compressed_block();
- p_buffsize -= block_length;
- }
-
-
- return false;
-}
-
-bool CPLoader_IT::load_sample_16bits_IT_compressed(void *p_dest_buffer,int p_buffsize) {
-
- int16_t *dest_buffer; /* destination buffer which will be returned */
- uint16_t block_length; /* length of compressed data block in samples */
- uint16_t block_position; /* position in block */
- uint8_t bit_width; /* actual "bit width" */
- uint32_t aux_value; /* value read from file to be processed */
- int16_t d1, d2; /* integrator buffers (d2 for it2.15) */
- int16_t *dest_position; /* position in output buffer */
- int16_t v; /* sample value */
-
- bool it215; // is this an it215 module?
-
- dest_buffer = (int16_t *) p_dest_buffer;
-
- if (dest_buffer==NULL)
- return true;
-
- for (int i=0;i<p_buffsize;i++)
- dest_buffer[i]=0;
-
- dest_position = dest_buffer;
-
- it215=(header.cmwt==0x215);
-
-
- while (p_buffsize) {
- /* read a new block of compressed data and reset variables */
- if ( read_IT_compressed_block(true) ) {
-
- return true;
- }
-
-
- block_length = (p_buffsize < 0x4000) ? p_buffsize : 0x4000;
-
- block_position = 0;
-
- bit_width = 17; /* start with width of 9 bits */
-
- d1 = d2 = 0; /* reset integrator buffers */
-
- while ( block_position < block_length ) {
-
- aux_value = read_n_bits_from_IT_compressed_block(bit_width); /* read bits */
-
- if ( bit_width < 7 ) { /* method 1 (1-6 bits) */
-
- if ( (signed)aux_value == (1 << (bit_width - 1)) ) { /* check for "100..." */
-
- aux_value = read_n_bits_from_IT_compressed_block(4) + 1; /* yes -> read new width; */
- bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1;
- /* and expand it */
- continue; /* ... next value */
- }
-
- } else if ( bit_width < 17 ) {
-
- uint16_t border = (0xFFFF >> (17 - bit_width)) - 8;
-
- if ( (int)aux_value > (int)border && (int)aux_value <= ((int)border + 16) ) {
-
- aux_value -= border; /* convert width to 1-8 */
- bit_width = (aux_value < bit_width) ? aux_value : aux_value + 1;
- /* and expand it */
- continue; /* ... next value */
- }
-
-
- } else if ( bit_width == 17 ) {
-
- if ( aux_value & 0x10000 ) { /* bit 8 set? */
-
- bit_width = (aux_value + 1) & 0xff; /* new width... */
- continue; /* ... and next value */
- }
-
- } else { /* illegal width, abort */
-
- CP_PRINTERR("CPSample has illegal BitWidth ");
-
- free_IT_compressed_block();
-
- return true;
- }
-
- /* now expand value to signed byte */
- if ( bit_width < 16 ) {
-
- uint8_t tmp_shift = 16 - bit_width;
-
- v=(aux_value << tmp_shift);
- v>>=tmp_shift;
-
- } else v = (int16_t) aux_value;
-
- /* integrate upon the sample values */
- d1 += v;
- d2 += d1;
-
- /* ... and store it into the buffer */
- *(dest_position++) = it215 ? d2 : d1;
- block_position++;
-
- }
-
- /* now subtract block lenght from total length and go on */
- free_IT_compressed_block();
- p_buffsize -= block_length;
- }
-
-
- return false;
-
-}
-
-
-
diff --git a/modules/chibi/cp_loader_mod.cpp b/modules/chibi/cp_loader_mod.cpp
deleted file mode 100644
index 4a47ce5c43..0000000000
--- a/modules/chibi/cp_loader_mod.cpp
+++ /dev/null
@@ -1,482 +0,0 @@
-/*************************************************************************/
-/* cp_loader_mod.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_mod.h"
-
-
-static bool tag_equal_to(const char *p_tag, const char *p_string) {
-
- return( p_tag[0]==p_string[0] &&
- p_tag[1]==p_string[1] &&
- p_tag[2]==p_string[2] &&
- p_tag[3]==p_string[3]);
-}
-/* ProTracker period table */
-uint16_t period_table[6*12] = {
- 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907,
- 856,808,762,720,678,640,604,570,538,508,480,453,
- 428,404,381,360,339,320,302,285,269,254,240,226,
- 214,202,190,180,170,160,151,143,135,127,120,113,
- 107,101,95,90,85,80,75,71,67,63,60,56,
- 53,50,47,45,42,40,37,35,33,31,30,28
-};
-
-
-CPLoader::Error CPLoader_MOD::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) {
-
- if (file->open(p_file,CPFileAccessWrapper::READ)) {
- //printf("Can't open file! %s\n",p_file);
- return FILE_CANNOT_OPEN;
- };
-
- /* FIRST OF ALL, one needs to read the .mod file format tag */
- file->seek( 1080 ); //located at 1080
-
- char format_tag[4];
-
- file->get_byte_array( (uint8_t*)format_tag, 4 );
-
- int channels=-1;
-
- /** THE PAIN!! - COMPARE TAGS */
-
- /* Classic 4-chan */
- if (tag_equal_to(format_tag,"M.K.") )
- channels=4;
- if (tag_equal_to(format_tag,"FLT4") )
- channels=4;
- if (tag_equal_to(format_tag,"M!K!") )
- channels=4;
-
- /* 8 Channel MODS */
-
- if (tag_equal_to(format_tag,"FLT8") )
- channels=2;
-
- if (tag_equal_to(format_tag,"CD81") )
- channels=2;
-
- /* Custom channel MODS */
-
- for (int i=1;i<=32;i++) {
-
- if (i<10) { // up to 9 channels mods
-
- /* Old Take Tracker */
- char old_take_tracker[4]={'T','D','Z',char('0'+i)};
-
- if (tag_equal_to(format_tag,old_take_tracker)) {
-
- channels=i;
- break;
- }
-
- /* Contemplates many XCHN Formats */
- char xchn[4]={char('0'+i),'C','H','N'};
-
- if (tag_equal_to(format_tag,xchn)) {
-
- channels=i;
- break;
- }
- }
-
- /* Fast Tracker */
- char fast_tracker[4]={char('0'+(i/10)),char('0'+(i%10)),'C','H'};
-
- if (tag_equal_to(format_tag,fast_tracker)) {
-
- channels=i;
- break;
- }
-
- }
-
-
- if (channels==-1) {
-
- file->close();
- return FILE_UNRECOGNIZED;
- }
-
-
-
- /** Load CPSong INFO */
-
- file->seek( 0 ); //go to begining of file
-
- file->set_endian_conversion( true );
- p_song->reset();
- p_song->set_instruments( false );
-
- char name[21];
-
- file->get_byte_array( (uint8_t*)name,20);
- name[20]=0;
-
- p_song->set_name(name);
- p_song->set_old_effects( true );
- p_song->set_linear_slides( false );
- p_song->set_compatible_gxx( true );
-
-
-
- CPSampleManager *sm=CPSampleManager::get_singleton();
-
- int instruments=31;
-
- for (int i=0;i<instruments;i++) {
-
- char sample_name[23];
- file->get_byte_array( (uint8_t*)sample_name,22);
- sample_name[22]=0;
-
- uint32_t sample_len=file->get_word();
- sample_len<<=1;
-
- uint8_t fine_nibble=file->get_byte()&0xF;
-
-
- //(int8_t)(fine_nibble & 7) - (int8_t)(fine_nibble & 8); //yesso's genius trick
- // boo, I can't use it :( but i leave it here because of how cool it is
- uint8_t linear_volume=file->get_byte(); //0 .. ?
-
- uint32_t loop_begin=file->get_word(); //0 .. ?
- loop_begin<<=1;
- uint32_t loop_end=file->get_word(); //0 .. ?
- loop_end<<=1;
-
- if (sample_len>0) {
-
- CPSample_ID sid=sm->create( false, false, sample_len );
-
- if (sid.is_null()) {
-
- file->close();
- return FILE_OUT_OF_MEMORY;
- }
-
- if (loop_end>2) {
- sm->set_loop_begin( sid, loop_begin );
- sm->set_loop_end( sid, loop_end+loop_begin );
- sm->set_loop_type( sid,CP_LOOP_FORWARD );
- }
- static const uint16_t fine_to_freq[16]={
- 8363,8413,8463,8529,8581,8651,8723,8757,
- 7895,7941,7985,8046,8107,8169,8232,8280
- };
-
- sm->set_c5_freq( sid, fine_to_freq[fine_nibble] );
- p_song->get_sample(i)->set_sample_data(sid);
- }
-
- p_song->get_sample(i)->set_name(sample_name);
- p_song->get_sample(i)->set_default_volume( linear_volume );
-
-
-
- }
-
- /* pan for MODs */
- for (int i=0;i<channels;i++)
- p_song->set_channel_pan( i, (((i&3)==1) || ((i&3)==2)) ? 0: 64);
-
-
- uint8_t order_count=file->get_byte();
-// uint8_t loop_to=file->get_byte();
-
-
- int pattern_count=0;
-
- for (int i=0;i<128;i++) {
-
- uint8_t order=file->get_byte();
-
-
- if (i<order_count) {
- p_song->set_order(i,order);
-
- /* Determine the amount of patterns */
- if ((order+1)>pattern_count)
- pattern_count=order+1;
- } else
- p_song->set_order( i, CP_ORDER_NONE );
- }
-
- if (instruments==31)
- file->get_dword(); // identiefier, now skip it
-
- for (int i=0;i<pattern_count;i++) {
-
- for(int line=0;line<64;line++) {
-
- for(int column=0;column<channels;column++) {
-
- uint32_t note_w=file->get_dword();
-
- CPNote note;
-
- note.instrument=(note_w>>12)&0xF;
- note.instrument|=(note_w>>24)&0xF0;
-
- if (note.instrument==0)
- note.instrument=CPNote::EMPTY;
- else
- note.instrument--;
-
- note.parameter=note_w&0xFF;
-
- int cmd=(note_w>>8)&0xF;
-
- uint32_t period=(note_w>>16)&0xFFF;
-
- if (period>0 && period<0xFFF) {
-
- //period>>=2;
- //period<<=1;
- for (int n=0; n<6*12; n++) {
-
- if (period >= period_table[n]) {
-
- if ((period!=period_table[n]) && (n))
- {
- uint32_t p1 = period_table[n-1];
- uint32_t p2 = period_table[n];
- if (p1 - period < (period - p2)) {
-
- note.note=n+36;
- break;
- }
- }
- note.note=n+1+36;
- break;
- }
- }
- if (note.note==CPNote::EMPTY)
- note.note=6*12+36;
-
- note.note--;
- }
-
-
- switch(cmd) {
-
- case 0x0: {
-
- if (note.parameter>0)
- note.command='J'-'A';
- } break;
- case 0x1: {
- note.command='F'-'A';
- } break;
- case 0x2: {
-
- note.command='E'-'A';
- } break;
- case 0x3: {
-
- note.command='G'-'A';
- } break;
- case 0x4: {
-
- note.command='H'-'A';
- } break;
- case 0x5: {
- note.command='L'-'A';
- } break;
- case 0x6: {
-
- note.command='K'-'A';
- } break;
- case 0x7: {
- note.command='R'-'A';
- } break;
- case 0x8: {
-
- note.command='X'-'A';
- } break;
- case 0x9: {
-
- note.command='O'-'A';
-
- } break;
- case 0xA: {
-
- note.command='D'-'A';
-
- } break;
- case 0xB: {
-
- note.command='B'-'A';
-
- } break;
- case 0xC: {
-
- note.volume=note.parameter;
- if (note.volume>64)
- note.volume=64;
- note.parameter=0;
-
- } break;
- case 0xD: {
-
- note.command='C'-'A';
- note.parameter=(note.parameter>>4)*10 + (note.parameter&0xF);
-
- } break;
- case 0xE: { //SPECIAL EFFECT!
-
- note.command='S'-'A';
-
- switch(note.parameter>>4) {
-
- case 0x1: {
-
- note.command='F'-'A';
- note.parameter=0xF0|(note.parameter&0xF);
- } break;
- case 0x2: {
-
- note.command='E'-'A';
- note.parameter=0xF0|(note.parameter&0xF);
- } break;
- case 0x4: {
-
- note.command='S'-'A';
- note.parameter=0x30|(note.parameter&0x3);
-
- } break;
- case 0x6: {
-
- note.command='S'-'A';
- note.parameter=0xB0|(note.parameter&0xF);
-
- } break;
- case 0x7: {
- note.command='S'-'A';
- note.parameter=0x40|(note.parameter&0x3);
-
- } break;
- case 0x8: {
-
- note.command='S'-'A'; // wow, it's the same!
-
- } break;
- case 0x9: {
- note.command='Q'-'A';
- note.parameter=(note.parameter&0xF);
-
- } break;
- case 0xA: {
-
- note.command='D'-'A';
- note.parameter=0xF|((note.parameter&0xF)<<4);
-
- } break;
- case 0xB: {
- note.command='D'-'A';
- note.parameter=0xF0|(note.parameter&0xF);
-
- } break;
- case 0xC:
- case 0xD: {
-
- note.command='S'-'A'; //wow, they are the same!
-
- } break;
- case 0xE: {
- note.command='S'-'A';
- note.parameter=0x60|(note.parameter&0xF);
-
- } break;
-
- default: {
-
- note.command=CPNote::EMPTY;
- note.parameter=0;
- } break;
-
- }
- } break;
- case 0xF: {
-
- if (note.parameter<32)
- note.command='A'-'A';
- else
- note.command='T'-'A';
-
- } break;
- }
-
- p_song->get_pattern(i)->set_note( column,line, note );
- }
- }
- }
-
-
-
- for (int i=0;i<instruments;i++) {
-
- CPSample_ID sid=p_song->get_sample(i)->get_sample_data();
- if (sid.is_null()) {
- continue; //empty sample, not stored?
- }
- sm->lock_data(sid);
- uint8_t *dataptr = (uint8_t*)sm->get_data(sid);
-
- int len=sm->get_size(sid);
- for (int s=0;s<len;s++) {
-
- uint8_t d=file->get_byte();
- //d-=128; //convert to signed
- int8_t*ds=(int8_t*)&d;
- dataptr[s]=*ds;
-
- }
- sm->unlock_data(sid);
- }
-
- file->close();
-
- return FILE_OK;
-
-
-}
-
-
-CPLoader_MOD::CPLoader_MOD(CPFileAccessWrapper *p_file) {
-
- file=p_file;
-}
-
-
-CPLoader_MOD::~CPLoader_MOD()
-{
-}
-
-
diff --git a/modules/chibi/cp_loader_mod.h b/modules/chibi/cp_loader_mod.h
deleted file mode 100644
index 57f7128bc0..0000000000
--- a/modules/chibi/cp_loader_mod.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*************************************************************************/
-/* cp_loader_mod.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_LOADER_MOD_H
-#define CP_LOADER_MOD_H
-#include "cp_loader.h"
-/**
- @author Juan Linietsky <reduz@gmail.com>
-*/
-class CPLoader_MOD : public CPLoader {
-
- CPFileAccessWrapper *file;
-public:
-
- bool can_load_song() { return true; }
- bool can_load_sample() { return false; }
- bool can_load_instrument() { return false; }
-
- Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset);
- Error load_sample(const char *p_file,CPSample *p_sample) { return FILE_UNRECOGNIZED; }
- Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) { return FILE_UNRECOGNIZED; }
-
- CPLoader_MOD(CPFileAccessWrapper *p_file);
- ~CPLoader_MOD();
-};
-
-#endif
diff --git a/modules/chibi/cp_loader_s3m.cpp b/modules/chibi/cp_loader_s3m.cpp
deleted file mode 100644
index eb5fad12e1..0000000000
--- a/modules/chibi/cp_loader_s3m.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/*************************************************************************/
-/* cp_loader_s3m.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_s3m.h"
-
-#define BITBOOL(m_exp) ((m_exp)?1:0)
-
-
-CPLoader::Error CPLoader_S3M::load_header() {
-
- int i;
-
-
- file->get_byte_array((uint8_t*)header.songname,28);
- header.t1a=file->get_byte();
- header.type=file->get_byte();
- file->get_byte_array((uint8_t*)header.unused1,2);
- header.ordnum=file->get_word();
- header.insnum=file->get_word();
- header.patnum=file->get_word();
- header.flags=file->get_word();
- header.tracker=file->get_word();
- header.fileformat=file->get_word();
- file->get_byte_array((uint8_t*)header.scrm,4);
- header.scrm[4]=0;
-
- if (header.scrm[0]!='S' || header.scrm[1]!='C' || header.scrm[2]!='R' || header.scrm[3]!='M')
- return FILE_UNRECOGNIZED;
-
- header.mastervol=file->get_byte();
- header.initspeed=file->get_byte();
- header.inittempo=file->get_byte();
- header.mastermult=file->get_byte();
- header.ultraclick=file->get_byte();
- header.pantable=file->get_byte();
- file->get_byte_array((uint8_t*)header.unused2,8);
- header.special=file->get_word();
- file->get_byte_array((uint8_t*)header.channels,32);
-
- file->get_byte_array((uint8_t*)header.orderlist,header.ordnum);
-
- header.scrm[4]=0;
- if (header.scrm[0]!='S' || header.scrm[1]!='C' || header.scrm[2]!='R' || header.scrm[3]!='M') //again?
- return FILE_UNRECOGNIZED;
- //sample parapointers
- for (i=0;i<header.insnum;i++) {
-
- int parapointer;
- parapointer=file->get_word();
- parapointer=(parapointer*16);
- sample_parapointers[i]=parapointer;
- }
- //pattern
- for (i=0;i<header.patnum;i++) {
-
- int parapointer;
- parapointer=file->get_word();
- parapointer=(parapointer*16);
- pattern_parapointers[i]=parapointer;
- }
-
- if (header.pantable==252) {
-
- file->get_byte_array((uint8_t*)header.pannings,32);
- }
-
- return FILE_OK;
-
-
-}
-
-
-void CPLoader_S3M::set_header() {
-
-
-
-
- song->set_name( header.songname );
-// song->variables.filename=
-
- song->set_row_highlight_minor( 4 );
- song->set_row_highlight_major( 16 );
- song->set_mixing_volume( header.mastervol );
- song->set_linear_slides( false );
- song->set_old_effects( !(header.flags&64) );
- song->set_compatible_gxx( true );
-
- song->set_global_volume( header.mastermult );
- song->set_speed( header.initspeed );
- song->set_tempo( header.inittempo );
-
- //[TODO] Set Panning Positions.. ?
-
- for (int i=0;i<header.ordnum;i++) song->set_order(i,header.orderlist[i]);
-
-}
-
-CPLoader::Error CPLoader_S3M::load_sample(CPSample *p_sample) {
-
-
-
- int type=file->get_byte();
-
- char filename[13];
- file->get_byte_array((uint8_t*)filename,12);
- filename[12]=0;
-
-
- uint32_t samplepos=(uint32_t)file->get_byte() << 16;
- samplepos|=file->get_word();
- samplepos*=16;
-// printf("sample at %i\n",samplepos);
- /**/
- int sample_size=file->get_dword();
-
-
- int loop_begin=file->get_dword();
- int loop_end=file->get_dword();
-
- int def_volume=file->get_byte();;
- int dsk=file->get_byte();
- int pack=file->get_byte();
-
- int flags=file->get_byte();
- int c2speed=file->get_dword();
-
- file->get_dword(); //useless crap
- file->get_dword();
- file->get_dword();
-
-
- char name[29];
- file->get_byte_array((uint8_t*)name,28);
- name[28]=0;
-
- p_sample->set_default_volume(def_volume);
- p_sample->set_name(name);
-
- char scrs[5];
- file->get_byte_array((uint8_t*)scrs,4);
- scrs[4]=0;
-
-
-
- bool data_is_16bits=flags&4;
- bool data_is_stereo=flags&2;
-
- if (type==0) {
- //empty sample
- return FILE_OK;
- }
-
-
- if ((type!=1) || scrs[0]!='S' || scrs[1]!='C' || scrs[2]!='R' || scrs[3]!='S' ) {
-// printf("type: %i, %c%c%c%c\n",type,scrs[0],scrs[1],scrs[2],scrs[3]);
- CP_PRINTERR("Not an S3M CPSample!");
- return FILE_CORRUPTED;
- }
-
- //p_sample->data.set_c5_freq(p_sample->c2spd<<1);
-
- file->seek(samplepos);
-
- int real_sample_size=sample_size<<BITBOOL(data_is_16bits);
- real_sample_size<<=BITBOOL(data_is_stereo);
-
- CPSampleManager *sm=CPSampleManager::get_singleton();
-
- CPSample_ID id =sm->create( data_is_16bits, data_is_stereo, sample_size );
-
- if (id.is_null())
- return FILE_OUT_OF_MEMORY;
-
- sm->lock_data(id);
- void *dataptr = sm->get_data(id);
-
- int chans = (data_is_stereo?2:1);
- for (int c=0;c<chans;c++) {
- for (int i=0;i<sample_size;i++) {
-
- if (data_is_16bits) {
-
- uint16_t s=file->get_word();
- s-=32768; //toggle sign
-
- int16_t *v=(int16_t*)&s;
- ((int16_t*)dataptr)[i*chans+c]=*v;
- } else {
-
-
- int8_t *v;
- uint8_t s=file->get_byte();
- s-=128; //toggle sign
- v=(int8_t*)&s;
- ((int8_t*)dataptr)[i*chans+c]=*v;
-
- }
-
- }
-
- }
-
- sm->unlock_data(id);
-
-
- sm->set_loop_begin( id, loop_begin );
- sm->set_loop_end( id, loop_end );
- sm->set_loop_type( id, (flags&1) ? CP_LOOP_FORWARD : CP_LOOP_NONE );
- sm->set_c5_freq( id, c2speed << 1 );
- p_sample->set_sample_data(id);
-
- /* Scream tracker previous to 3.10 seems to be buggy, as in, wont save what is after the sample loop, including the loop end point. Because of this I must fix it by habd */
- if (flags&1) {
-
- for (int c=0;c<(data_is_stereo?2:1);c++) {
- sm->set_data( id, loop_end, sm->get_data( id, loop_begin,c ),c );
-
- }
- }
-
-
- return FILE_OK;
-
-}
-
-
-CPLoader::Error CPLoader_S3M::load_pattern(CPPattern *p_pattern) {
-
- int row=0,flag,ch;
- CPNote n;
- int length,accum=0;
-
- length=file->get_word();
- p_pattern->set_length(64);
-
- /* clear pattern data */
- while((row<64) && (accum<=length) ) {
- flag=file->get_byte();
- accum++;
-
- n.clear();
- if(flag) {
- // ch=remap[flag&31];
-// ch=remap[flag&31];
-// if(ch!=-1)
-// n=s3mbuf[(64U*ch)+row];
-// else
-// n=&dummy;
-
- ch=flag&31;
-
- if(flag&32) {
- n.note=file->get_byte();
- if (n.note==255) {
-
- n.note=CPNote::EMPTY;
- } else if (n.note==254) {
-
- n.note=CPNote::CUT;
- } else {
-
- n.note=((n.note>>4)*12)+(n.note&0xF);
- }
-
- n.instrument=file->get_byte()-1;
- accum+=2;
-
- }
- if(flag&64) {
- n.volume=file->get_byte();
- if (n.volume>64) n.volume=64;
- accum++;
-
- }
- if(flag&128) {
- n.command=file->get_byte()-1;
- n.parameter=file->get_byte();
- accum+=2;
- }
-
- p_pattern->set_note(ch,row,n);
- } else row++;
- }
- return FILE_OK;
-
-
-}
-
-CPLoader::Error CPLoader_S3M::load_sample(const char *p_file,CPSample *p_sample) {
-
- return FILE_UNRECOGNIZED;
-}
-CPLoader::Error CPLoader_S3M::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) {
-
- return FILE_UNRECOGNIZED;
-
-}
-
-
-CPLoader::Error CPLoader_S3M::load_samples() {
-
- int i;
-
- for(i=0;i<header.insnum;i++) {
-
- file->seek(sample_parapointers[i]);
- load_sample(song->get_sample(i));
- sample_count++;
- }
-
- return FILE_OK;
-}
-
-CPLoader::Error CPLoader_S3M::load_patterns() {
-
- int i;
-
- Error err;
- for(i=0;i<header.patnum;i++) {
-
- file->seek(pattern_parapointers[i]);
-
- err=load_pattern(song->get_pattern(i) );
- CP_ERR_COND_V(err,err);
-
-
- pattern_count++;
- }
- return FILE_OK;
-
-}
-
-CPLoader::Error CPLoader_S3M::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) {
-
- song=p_song;
-
- if (file->open(p_file,CPFileAccessWrapper::READ)) {
- //printf("Can't open file! %s\n",p_file);
- return FILE_CANNOT_OPEN;
- };
-
- sample_count=0;
- pattern_count=0;
-
- //printf("LOADING HEADER\n");
- CPLoader::Error err;
- if ((err=load_header())) {
- file->close();
- CP_ERR_COND_V(err,err);
-
- }
-
- song->reset(); //file type recognized, reset song!
-
- set_header();
-
- //printf("LOADING SAMPLES\n");
-
- if ((err=load_samples())) {
- file->close();
-
- CP_ERR_COND_V(err,err);
- }
-
- //printf("LOADING PATTERNS\n");
-
- if ((err=load_patterns())) {
-
- file->close();
- return err;
- }
-
- file->close();
-
- return FILE_OK;
-}
-
-
-
-CPLoader_S3M::CPLoader_S3M(CPFileAccessWrapper *p_file){
-
- file=p_file;
-
-}
-CPLoader_S3M::~CPLoader_S3M(){
-}
-
diff --git a/modules/chibi/cp_loader_s3m.h b/modules/chibi/cp_loader_s3m.h
deleted file mode 100644
index 04ee0b2917..0000000000
--- a/modules/chibi/cp_loader_s3m.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*************************************************************************/
-/* cp_loader_s3m.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_LOADER_S3M_H
-#define CP_LOADER_S3M_H
-
-#include "cp_loader.h"
-
-/**
- *@author Juan Linietsky
- */
-/******************************
- loader_s3m.h
- ----------
-Scream Tracker Module CPLoader!
-It lacks support for
-individual sample loading
-and reorganizing the columns.
-********************************/
-
-
-
-
-class CPLoader_S3M : public CPLoader {
-
- struct S3M_Header {
- char songname[28];
- uint8_t t1a;
- uint8_t type;
- uint8_t unused1[2];
- uint16_t ordnum;
- uint16_t insnum;
- uint16_t patnum;
- uint16_t flags;
- uint16_t tracker;
- uint16_t fileformat;
- char scrm[5];
- uint8_t mastervol;
- uint8_t initspeed;
- uint8_t inittempo;
- uint8_t mastermult;
- uint8_t ultraclick;
- uint8_t pantable;
- uint8_t unused2[8];
- uint16_t special;
- uint8_t channels[32];
- uint8_t pannings[32];
- uint8_t orderlist[300];
- };
-
-
- int sample_parapointers[CPSong::MAX_SAMPLES];
- int pattern_parapointers[CPSong::MAX_PATTERNS];
-
- Error load_header();
- void set_header();
- Error load_sample(CPSample *p_sample);
- Error load_pattern(CPPattern *p_pattern);
- Error load_patterns();
-
- Error load_samples();
-
- S3M_Header header;
- int sample_count;
- int pattern_count;
-
- CPFileAccessWrapper *file;
- CPSong *song;
-public:
-
- bool can_load_song() { return true; }
- bool can_load_sample() { return false; }
- bool can_load_instrument() { return false; }
-
- Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset);
- Error load_sample(const char *p_file,CPSample *p_sample);
- Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx);
-
- CPLoader_S3M(CPFileAccessWrapper *p_file);
- ~CPLoader_S3M();
-};
-
-
-
-#endif
diff --git a/modules/chibi/cp_loader_xm.cpp b/modules/chibi/cp_loader_xm.cpp
deleted file mode 100644
index 65c7bc7ee1..0000000000
--- a/modules/chibi/cp_loader_xm.cpp
+++ /dev/null
@@ -1,752 +0,0 @@
-/*************************************************************************/
-/* cp_loader_xm.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_loader_xm.h"
-#include "cp_tables.h"
-
-#define ABORT_LOAD { file->close(); return FILE_CORRUPTED; }
-
-
-
-
-CPLoader::Error CPLoader_XM::load_song(const char *p_file,CPSong *p_song,bool p_sampleset) {
-
- song=p_song;
-
- if (file->open(p_file,CPFileAccessWrapper::READ)) {
-
- return FILE_CANNOT_OPEN;
- };
-
-
- /**************************************
- LOAD HEADER
- ***************************************/
-
- file->get_byte_array(header.idtext,17);
- header.idtext[17]=0;
-
- file->get_byte_array(header.songname,20);
-
-
-
- header.songname[20]=0;
- header.hex1a=file->get_byte();
- if (header.hex1a!=0x1A) { //XM "magic" byte.. this sucks :)
-
- file->close();
- return FILE_UNRECOGNIZED;
-
- }
-
-
- //magic byte sucks, but can't do much about it..
-
- song->reset(); //must reset the song
-
- song->set_name( (const char*)header.songname );
-
- file->get_byte_array(header.trackername,20);
- header.trackername[20]=0;
-
-
- header.version=file->get_word();
-
- header.headersize=file->get_dword();
-
- header.songlength=file->get_word();
-
- header.restart_pos=file->get_word();
-
- header.channels_used=file->get_word();
-
- header.patterns_used=file->get_word();
-
- header.instruments_used=file->get_word();
-
- song->set_linear_slides( file->get_word() );
-
- song->set_speed( file->get_word() );
-
- song->set_tempo( file->get_word() );
- song->set_instruments( true );
-
- file->get_byte_array(header.orderlist,256);
-
- for (int i=0;i<header.songlength;i++) {
-
- if (i>199)
- break;
- song->set_order(i,header.orderlist[i]);
- }
-
- /**************************************
- LOAD PATTERNS
- ***************************************/
-
- for (int i=0;i<header.patterns_used;i++) {
-
- uint32_t aux,rows;
-
- aux=file->get_dword(); //length
- aux=file->get_byte(); //packing type
- rows=aux=file->get_word(); //rows!
-
- song->get_pattern(i)->set_length( aux );
-
- aux=file->get_word(); //packed size
- if (aux==0)
- continue;
- //unpaaack!
- for(int j=0;j<(int)rows;j++)
- for(int k=0;k<header.channels_used;k++) {
-
- CPNote aux_note;
- uint8_t aux_byte;
- //uint8_t field;
- aux_byte=file->get_byte(); //packing type
- if (!(aux_byte&0x80)) {
-
- aux_note.note=aux_byte;
- aux_byte=0xFE; //if bit 7 not set, read all of them except the note
- }
-
- if (aux_byte&1) aux_note.note=file->get_byte();
- if (aux_byte&2) aux_note.instrument=file->get_byte();
- if (aux_byte&4) aux_note.volume=file->get_byte();
- if (aux_byte&8) aux_note.command=file->get_byte();
- if (aux_byte&16) aux_note.parameter=file->get_byte();
-
- if (aux_note.note!=CPNote::EMPTY) {
-
- if (aux_note.note==97) aux_note.note=CPNote::OFF;
- else {
- aux_note.note+=11; //octave minus one (XM C-0 is 1, not zero )
- }
- }
- if (aux_note.instrument!=CPNote::EMPTY) {
-
- if ((aux_note.instrument>0) && (aux_note.instrument<100))
- aux_note.instrument--;
- else
- aux_note.instrument=CPNote::EMPTY;
- }
- if (aux_note.volume!=CPNote::EMPTY) {
-
- if (aux_note.volume<0x10) {}
- else if (aux_note.volume<0x50) {
-
- aux_note.volume-=0x10;
-
- } else if (aux_note.volume<0x60) {
- //
- aux_note.volume=CPNote::EMPTY;
-
- } else if (aux_note.volume<0x70) {
- //60 -- volume slide down
- aux_note.volume-=0x60;
- if (aux_note.volume>9) aux_note.volume=9;
- aux_note.volume+=95;
-
- } else if (aux_note.volume<0x80) {
- //70 -- volume slide up
- aux_note.volume-=0x70;
- if (aux_note.volume>9) aux_note.volume=9;
- aux_note.volume+=85;
-
-
- } else if (aux_note.volume<0x90) {
- //80 -- fine volume slide down
- aux_note.volume-=0x80;
- if (aux_note.volume>9) aux_note.volume=9;
- aux_note.volume+=75;
-
-
- } else if (aux_note.volume<0xA0) {
- //9 -- fine volume slide up
-
- aux_note.volume-=0x90;
- if (aux_note.volume>9) aux_note.volume=9;
-
- aux_note.volume+=65;
-
-
-
- } else if (aux_note.volume<0xB0) {
- //A -- set vibrato speed
- aux_note.volume=CPNote::EMPTY;
-
- } else if (aux_note.volume<0xC0) {
- //B -- vibrato
- aux_note.volume-=0xB0;
- if (aux_note.volume>9) aux_note.volume=9;
- aux_note.volume+=203;
-
-
- } else if (aux_note.volume<0xD0) {
- //C -- set panning
- int aux=aux_note.volume-=0xC0;
- aux=aux*65/0xF;
- aux_note.volume=128+aux;
-
- } else if (aux_note.volume<0xE0) {
- aux_note.volume=CPNote::EMPTY;
-
-
- } else if (aux_note.volume<0xF0) {
- aux_note.volume=CPNote::EMPTY;
-
-
- } else {
- //F -- tone porta
- aux_note.volume-=0xF0;
- aux_note.volume*=9;
- aux_note.volume/=0xF;
- aux_note.volume+=193;
- }
- }
- if (aux_note.command!=CPNote::EMPTY) {
-
- switch(aux_note.command) {
-
- case 0x0:
- aux_note.command='J'-'A';
- break;
- case 0x1:
- aux_note.command='F'-'A';
- break;
- case 0x2:
- aux_note.command='E'-'A';
- break;
- case 0x3:
- aux_note.command='G'-'A';
- break;
- case 0x4:
- aux_note.command='H'-'A';
- break;
- case 0x5:
- aux_note.command='L'-'A';
- break;
- case 0x6:
- aux_note.command='K'-'A';
- break;
- case 0x7:
- aux_note.command='R'-'A';
- break;
- case 0x8:
- aux_note.command='X'-'A';
- break;
- case 0x9:
- aux_note.command='O'-'A';
- break;
- case 0xa:
- aux_note.command='D'-'A';
- break;
- case 0xb:
- aux_note.command='B'-'A';
- break;
- case 0xc:
- //printf("XM Import: Warning! effect C (set volume) not implemented!\n");
- break;
- case 0xd:
- aux_note.command='C'-'A';
- break;
-
- case 0xe: /* Extended effects */
-
- aux_note.command='S'-'A';
- switch(aux_note.parameter>>4) {
- case 0x1: /* XM fine porta up */
- if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; }
- aux_note.command='F'-'A';
- aux_note.parameter=0xF0|(aux_note.parameter&0xF);
- break;
- case 0x2: /* XM fine porta down */
- if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; }
- aux_note.command='E'-'A';
- aux_note.parameter=0xF0|(aux_note.parameter&0xF);
- break;
- case 0xa: /* XM fine volume up */
- if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; }
- aux_note.command='D'-'A';
- aux_note.parameter=0x0F|((aux_note.parameter&0xF)<<4);
-
- break;
- case 0xb: /* XM fine volume down */
- if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; }
- aux_note.command='D'-'A';
- aux_note.parameter=0xF0|(aux_note.parameter&0xF);
-
- break;
- case 0x9: /* XM fine volume down */
- if (!(aux_note.parameter&0xF)) { aux_note.command=CPNote::EMPTY; aux_note.parameter=0; break; }
- aux_note.command='Q'-'A';
- aux_note.parameter=0x00|(aux_note.parameter&0xF);
- break;
-
- case 0xc: //notecut
-
- aux_note.parameter=0xC0|(aux_note.parameter&0xF);
- break;
-
- case 0xd: //notedelay
-
- aux_note.parameter=0xD0|(aux_note.parameter&0xF);
- break;
-
- case 0xe: //patterndelay
-
- aux_note.parameter=0xE0|(aux_note.parameter&0xF);
- break;
- }
-
- break;
- case 0xf:
- if (aux_note.parameter<32) {
- aux_note.command='A'-'A';
- } else {
- aux_note.command='T'-'A';
- }
- break;
- case 'G'-55:
- aux_note.command='V'-'A';
- break;
- case 'H'-55:
- aux_note.command='W'-'A';
- break;
- case 'K'-55:
- if (aux_note.note!=CPNote::EMPTY) break;
- aux_note.note=CPNote::OFF;
- break;
- case 'P'-55:
- aux_note.command='P'-'A';
- break;
- case 'R'-55:
- aux_note.command='Q'-'A';
- break;
- case 'T'-55:
- aux_note.command='I'-'A';
- break;
- default: {
-
- aux_note.command=CPNote::EMPTY;
- }
- }
-
-
- }
-
- song->get_pattern( i)->set_note( k,j,aux_note );
- }
- }
-
- /**************************************
- LOAD INSTRUMENTS!
- ***************************************/
-
- for (int i=0;i<header.instruments_used;i++) {
-
-
- uint32_t aux;
- int sampnum;
-
- CPInstrument &instrument=*song->get_instrument(i);
- uint32_t cpos=file->get_pos();
- //printf("pos is %i\n",cpos);
-
-
-
-/* +4 */ uint32_t hsize=file->get_dword(); //header length
-
- char instrname[23];
- instrname[22]=0;
-
- file->get_byte_array((uint8_t*)instrname,22);
-//XM_LOAD_DEBUG printf("name is %s\n",instrname);
-
-/* +27 */ aux=file->get_byte(); //byte that must be ignored
-//XM_LOAD_DEBUG printf("header size is %i\n",hsize);
-
-/* +29 */ sampnum=file->get_word();
-
-//XM_LOAD_DEBUG printf("samples %i\n",sampnum);
-
-
- instrument.set_name( instrname );
-// printf("Header Len: %i, CPInstrument %i, %i samples , name: s,\n",hsize,i,sampnum,instrname);
-
- if (sampnum==0) {
- //aux=file->get_dword(); //Why is this for? -- for nothing, skipped
- if (hsize) {
-
- file->seek( cpos+hsize ); //skip header if size has been specified
- }
- continue;
- }
-
-/* +33 */ file->get_dword();
-
- if (Error result=load_instrument_internal(&instrument,false,cpos,hsize,sampnum)) {
-
- CP_PRINTERR("Error loading instrument");
- file->close();
- return result;
- }
-
- }
-//
- file->close();
- return FILE_OK;
-}
-
-CPLoader::Error CPLoader_XM::load_instrument_internal(CPInstrument *p_instr,bool p_xi,int p_cpos, int p_hsize, int p_sampnum) {
-
- int sampnum;
- uint32_t aux;
- uint8_t notenumb[96];
- uint16_t panenv[24],volenv[24];
- int volpoints,panpoints;
- int vol_loop_begin,vol_loop_end,vol_sustain_loop;
- int pan_loop_begin,pan_loop_end,pan_sustain_loop;
- char instrname[23];
- int sample_index[16]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; //-1 means no index!
-
- instrname[22]=0;
-
-
-/* +129 */ file->get_byte_array((uint8_t*)notenumb,96);
- for (int j=0;j<24;j++) {
- volenv[j]=file->get_word();
- }
- for (int j=0;j<24;j++) {
- panenv[j]=file->get_word();
- }
-
-/* +177 */
-/* +225 */
-/* +226 */ volpoints=file->get_byte();
-/* +227 */ panpoints=file->get_byte();
-/* +230 */ vol_sustain_loop=file->get_byte();
-/* +228 */ vol_loop_begin=file->get_byte();
-/* +229 */ vol_loop_end=file->get_byte();
-
-//XM_LOAD_DEBUG printf("1- volpoints: %i, panpoints: %i, susloop: %i, loop begin: %i, loop end %i\n",volpoints,panpoints,vol_sustain_loop,vol_loop_begin,vol_loop_end);
- pan_sustain_loop=file->get_byte();
-/* +231 */ pan_loop_begin=file->get_byte();
-/* +232 */ pan_loop_end=file->get_byte();
-
-
-
-/* +234 */ aux=file->get_byte();
- p_instr->get_volume_envelope()->reset();
- p_instr->get_volume_envelope()->set_enabled(aux&1);
- p_instr->get_volume_envelope()->set_sustain_loop_enabled((aux&2)?true:false);
- p_instr->get_volume_envelope()->set_loop_enabled((aux&4)?true:false);
-/* +235 */ aux=file->get_byte();
- p_instr->get_pan_envelope()->reset();
- p_instr->get_pan_envelope()->set_enabled(aux&1);
- p_instr->get_pan_envelope()->set_sustain_loop_enabled((aux&2)?true:false);
- p_instr->get_pan_envelope()->set_loop_enabled((aux&4)?true:false);
-
-/* +239 */ aux=file->get_dword(); // sadly, cant use those
-/* +241 */ p_instr->set_volume_fadeout( file->get_word() >> 4 );
-/* +243 */ aux=file->get_word(); // reserved!
-
-
-
- for (int j=0;j<volpoints;j++) {
- int ofs=volenv[j*2];
- int val=volenv[j*2+1];
- p_instr->get_volume_envelope()->add_position(ofs,val);
-
- }
-
- //make sure minimum is 2
- while (p_instr->get_volume_envelope()->get_node_count()<2) {
-
- p_instr->get_volume_envelope()->add_position( p_instr->get_volume_envelope()->get_node_count()*20,64 );
- }
-
- for (int j=0;j<panpoints;j++) {
- int ofs=panenv[j*2];
- int val=panenv[j*2+1];
- p_instr->get_pan_envelope()->add_position(ofs,val-32);
- }
-
- //make sure minimum is 2
- while (p_instr->get_pan_envelope()->get_node_count()<2) {
-
- p_instr->get_pan_envelope()->add_position( p_instr->get_pan_envelope()->get_node_count()*20,0 );
- }
-
-
- p_instr->get_volume_envelope()->set_loop_begin(vol_loop_begin);
- p_instr->get_volume_envelope()->set_loop_end(vol_loop_end);
- p_instr->get_volume_envelope()->set_sustain_loop_end(vol_sustain_loop);
- p_instr->get_volume_envelope()->set_sustain_loop_begin(vol_sustain_loop);
- p_instr->get_pan_envelope()->set_loop_begin(pan_loop_begin);
- p_instr->get_pan_envelope()->set_loop_end(pan_loop_end);
- p_instr->get_pan_envelope()->set_sustain_loop_end(pan_sustain_loop);
- p_instr->get_pan_envelope()->set_sustain_loop_begin(pan_sustain_loop);
-
-
- if (!p_xi) {
-
- if ((file->get_pos()-p_cpos)<p_hsize) {
-
- uint8_t junkbuster[500];
-
- //printf("extra junk XM instrument in header! hsize is %i, extra junk: %i\n",p_hsize,(file->get_pos()-p_cpos));
- //printf("extra: %i\n",p_hsize-(file->get_pos()-p_cpos));
- file->get_byte_array((uint8_t*)junkbuster,p_hsize-(file->get_pos()-p_cpos));
- }
-
- sampnum=p_sampnum;
- } else {
-
- uint8_t junkbuster[500];
- file->get_byte_array((uint8_t*)junkbuster,20); //14 bytes?
-
- sampnum=file->get_word();
-
- }
-
-
- CPSampleManager *sm=CPSampleManager::get_singleton();
-
- /*SAMPLE!!*/
-
- for (int j=0;j<sampnum;j++) {
-
- if (j>16) ABORT_LOAD;
-
-
- int s_idx=-1;
- for (int s=0;s<CPSong::MAX_SAMPLES;s++) {
-
- if (song->get_sample(s)->get_sample_data().is_null()) {
- //empty sample!
- s_idx=s;
- break;
- }
- }
-
- if (s_idx==-1) ABORT_LOAD;
- //printf("free sample: %i\n",s_idx);
-
-
- CPSample& sample=*song->get_sample(s_idx);
-
- int sample_size=file->get_dword();
- int tmp_loop_begin=file->get_dword();
-
- int tmp_loop_end=file->get_dword();
-
- sample.set_default_volume(file->get_byte());
-
- uint8_t ftb=file->get_byte();
- int8_t *fts=(int8_t*)&ftb;
- int finetune=*fts;
- uint32_t flags=file->get_byte();
-
- if (flags&16) { // is 16 bits.. at flag 16.. fun :)
-
- tmp_loop_end/=2;
- tmp_loop_begin/=2;
- sample_size/=2;
- }
-
-
- CPSample_ID sample_data=sm->create( flags&16, false, sample_size );
-
- sample.set_sample_data(sample_data);
- sm->set_loop_begin(sample_data,tmp_loop_begin);
- sm->set_loop_end(sample_data,tmp_loop_end+tmp_loop_begin);
-
- sm->set_loop_type( sample_data, (flags&3)?( (flags&2) ? CP_LOOP_BIDI : CP_LOOP_FORWARD ):CP_LOOP_NONE );
-
-
-
- sample.set_pan_enabled(true);
- sample.set_pan(file->get_byte()*64/255);
- uint8_t noteb=file->get_byte();
- int8_t *notes=(int8_t*)&noteb;
- int note_offset=*notes;
- note_offset+=48;
- //note_offset+=60;
-
-
-
- //int linear_period=10*12*16*4 - (note_offset)*16*4 - finetune/2;
- //int freq=(int)(8363*pow(2.0,(double)(6*12*16*4 - linear_period) / (double)(12*16*4)));
-
- //sm->set_c5_freq( sample_data, freq);
- sm->set_c5_freq( sample_data, CPTables::get_linear_frequency(CPTables::get_linear_period(note_offset<<1,finetune)) );
- //printf("NOTE %i,fine %i\n",note_offset,finetune);
-
- char auxb;
- auxb=file->get_byte(); //reserved?
- file->get_byte_array((uint8_t*)instrname,22);
- sample.set_name(instrname);
-
- sample_index[j]=s_idx;
- }
-
- /*SAMPLE __DATA__!!*/
-
- for (int j=0;j<sampnum;j++) {
-
- if (sample_index[j]==-1) continue;
-
- CPSample *sample=song->get_sample(sample_index[j]);
- CPSample_ID sid=sample->get_sample_data();
-
- sm->lock_data(sid);
-
- void*dataptr=sm->get_data(sid);
-
- if (sm->is_16bits( sid)) {
-
- int16_t old=0;
-
-
- for (int k=0;k<sm->get_size(sid);k++) {
-
- int16_t newsample;
- int16_t sampleval=file->get_word();
- newsample=sampleval+old;
- old=newsample;
-
- ((int16_t*)dataptr)[k]=newsample;
- //sm->set_data( sid, k, newsample );
- }
- } else {
-
- int8_t old=0;
-
-
- for (int k=0;k<sm->get_size(sid);k++) {
-
- int8_t newsample;
- int8_t sampleval=file->get_byte();
- newsample=sampleval+old;
- old=newsample;
-
- ((int8_t*)dataptr)[k]=newsample;
-
- //sm->set_data( sid, k, (int16_t)newsample << 8 );
-
- }
- }
-
- sm->unlock_data(sid);
-
- }
-
- for (int j=0;j<96;j++) {
-
- int val=notenumb[j];
- if ((val<0) || (val>15)) continue;
- else val=sample_index[val];
- if (val==-1) continue;
- p_instr->set_sample_number( 12+j,val );
- }
-
-
- return FILE_OK;
-}
-
-
-
-CPLoader::Error CPLoader_XM::load_sample(const char *p_file,CPSample *p_sample) {
-
- return FILE_UNRECOGNIZED;
-}
-
-
-/* Compute CPInstrument Info */
-CPLoader::Error CPLoader_XM::load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx) {
-
- if ( file->open(p_file,CPFileAccessWrapper::READ) ) return FILE_CANNOT_OPEN;
- //int i;
- song=p_song;
- CPInstrument& instr=*p_song->get_instrument( p_instr_idx );
- int aux;
-
-
- char buffer[500];
- file->get_byte_array((uint8_t*)buffer,0x15);
- buffer[8]=0;
- if ( buffer[0]!='E' ||
- buffer[1]!='x' ||
- buffer[2]!='t' ||
- buffer[3]!='e' ||
- buffer[4]!='n' ||
- buffer[5]!='d' ||
- buffer[6]!='e' ||
- buffer[7]!='d') {
- file->close();
- return FILE_UNRECOGNIZED;
- }
-
- file->get_byte_array((uint8_t*)buffer,0x16);
- buffer[0x16]=0;
- instr.set_name(buffer);
- aux=file->get_byte(); //says ignore ti
- /*if(aux!=0x1a) { I'm not sure. this is supposed to be ignored...
-
- file->close();
- return FILE_UNRECOGNIZED;
- } */
-
- file->get_byte_array((uint8_t*)buffer,0x14); //somethingaboutthename
- aux=file->get_word(); //version or blahblah
-
- if (load_instrument_internal(&instr,true,0,0)) {
-
- file->close();
- return FILE_CORRUPTED;
- }
-
- file->close(); //ook, we got it..
-
-
- return FILE_OK;
-
-}
-
-
-
-CPLoader_XM::CPLoader_XM(CPFileAccessWrapper *p_file){
-
- file=p_file;
-}
-CPLoader_XM::~CPLoader_XM(){
-}
-
diff --git a/modules/chibi/cp_loader_xm.h b/modules/chibi/cp_loader_xm.h
deleted file mode 100644
index 0889569b38..0000000000
--- a/modules/chibi/cp_loader_xm.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*************************************************************************/
-/* cp_loader_xm.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_LOADER_XM_H
-#define CP_LOADER_XM_H
-
-#include "cp_loader.h"
-
-
-/**
- *@author red
- */
-
-
-
-
-class CPLoader_XM : public CPLoader {
-
-
- struct XM_Header {
-
- uint8_t idtext[18];
- uint8_t songname[21];
- uint8_t hex1a; // ?
- uint8_t trackername[21];
- uint16_t version;
- uint32_t headersize; //from here
-
- uint16_t songlength; //pattern ordertable
- uint16_t restart_pos;
- uint16_t channels_used;
- uint16_t patterns_used;
- uint16_t instruments_used;
- uint16_t use_linear_freq;
- uint16_t tempo;
- uint16_t speed;
- uint8_t orderlist[256];
-
- } header;
-
- CPFileAccessWrapper *file;
-
- Error load_instrument_internal(CPInstrument *pint,bool p_xi,int p_cpos, int p_hsize, int p_sampnumb=-1);
- CPSong *song;
-
-public:
-
- bool can_load_song() { return true; }
- bool can_load_sample() { return false; }
- bool can_load_instrument() { return true; }
-
- Error load_song(const char *p_file,CPSong *p_song,bool p_sampleset);
- Error load_sample(const char *p_file,CPSample *p_sample);
- Error load_instrument(const char *p_file,CPSong *p_song,int p_instr_idx);
-
-
- CPLoader_XM(CPFileAccessWrapper *p_file);
- ~CPLoader_XM();
-};
-
-
-
-#endif
diff --git a/modules/chibi/cp_mixer.h b/modules/chibi/cp_mixer.h
deleted file mode 100644
index d8564bae00..0000000000
--- a/modules/chibi/cp_mixer.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*************************************************************************/
-/* cp_mixer.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_MIXER_H
-#define CP_MIXER_H
-
-#include "cp_sample_defs.h"
-
-/**Abstract base class representing a mixer
- *@author Juan Linietsky
- */
-
-
-/******************************
- mixer.h
- ----------
-
-Abstract base class for the mixer.
-This is what the player uses to setup
-voices and stuff.. this way
-it can be abstracted to hardware
-devices or other stuff..
-********************************/
-
-class CPSample_ID; /* need this */
-
-class CPMixer {
-public:
-
- enum {
-
- FREQUENCY_BITS=8
-
- };
-
- enum ReverbMode {
- REVERB_MODE_ROOM,
- REVERB_MODE_STUDIO_SMALL,
- REVERB_MODE_STUDIO_MEDIUM,
- REVERB_MODE_STUDIO_LARGE,
- REVERB_MODE_HALL,
- REVERB_MODE_SPACE_ECHO,
- REVERB_MODE_ECHO,
- REVERB_MODE_DELAY,
- REVERB_MODE_HALF_ECHO
- };
-
- /* Callback */
-
- virtual void set_callback_interval(int p_interval_us)=0; //in usecs, for tracker it's 2500000/tempo
- virtual void set_callback(void (*p_callback)(void*),void *p_userdata)=0;
-
- /* Voice Control */
-
- virtual void setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) =0;
- virtual void stop_voice(int p_voice_index) =0;
- virtual void set_voice_frequency(int p_voice_index,int32_t p_freq) =0; //in freq*FREQUENCY_BITS
- virtual void set_voice_panning(int p_voice_index,int p_pan) =0;
- virtual void set_voice_volume(int p_voice_index,int p_vol) =0;
- virtual void set_voice_filter(int p_filter,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance )=0;
- virtual void set_voice_reverb_send(int p_voice_index,int p_reverb)=0;
- virtual void set_voice_chorus_send(int p_voice_index,int p_chorus)=0; /* 0 - 255 */
-
- virtual void set_reverb_mode(ReverbMode p_mode)=0;
- virtual void set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10)=0;
-
-
- /* Info retrieving */
-
- virtual int32_t get_voice_sample_pos_index(int p_voice_index) =0;
- virtual int get_voice_panning(int p_voice_index) =0;
- virtual int get_voice_volume(int p_voice_index) =0;
- virtual CPSample_ID get_voice_sample_id(int p_voice_index) =0;
- virtual bool is_voice_active(int p_voice_index) =0;
- virtual int get_active_voice_count()=0;
- virtual int get_total_voice_count()=0;
-
-
- virtual uint32_t get_mix_frequency()=0; //if mixer is not software, return 0
-
- /* Methods below only work with software mixers, meant for software-based sound drivers, hardware mixers ignore them */
- virtual int32_t process(int32_t p_frames)=0; /* Call this to process N frames, returns how much it was processed */
- virtual int32_t *get_mixdown_buffer_ptr()=0; /* retrieve what was mixed */
- virtual void set_mix_frequency(int32_t p_mix_frequency)=0;
-
- virtual ~CPMixer() {}
-};
-
-#endif
diff --git a/modules/chibi/cp_note.h b/modules/chibi/cp_note.h
deleted file mode 100644
index f9a3ef39fc..0000000000
--- a/modules/chibi/cp_note.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*************************************************************************/
-/* cp_note.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_NOTE_H
-#define CP_NOTE_H
-
-#include "cp_config.h"
-
-struct CPNote {
-
- enum {
-
- NOTES=120,
- OFF=254,
- CUT=253,
- EMPTY=255,
- SCRIPT=252,
- };
-
-
- uint8_t note;
- uint8_t instrument;
- uint8_t volume;
- uint8_t command;
- uint8_t parameter;
- unsigned int script_source_sign;
- bool cloned;
-
- void clear() {
-
- note=EMPTY;
- instrument=EMPTY;
- volume=EMPTY;
- command=EMPTY;
- parameter=0;
- script_source_sign='\0';
- cloned=false;
- }
-
- void raise() {
-
- if (note<(NOTES-1))
- note++;
- else if (note==SCRIPT && parameter<0xFF)
- parameter++;
- }
-
- void lower() {
-
- if ((note>0) && (note<NOTES))
- note--;
- else if (note==SCRIPT && parameter>0)
- parameter--;
-
- }
-
- bool operator== (const CPNote &rvalue) {
-
- return (
- (note==rvalue.note) &&
- (instrument==rvalue.instrument) &&
- (volume==rvalue.volume) &&
- (command==rvalue.command) &&
- (parameter==rvalue.parameter)
- );
- }
-
- bool is_empty() const { return (note==EMPTY && instrument==EMPTY && volume==EMPTY && command==EMPTY && parameter==0 && !cloned); }
- CPNote() {
-
- clear();
- }
-};
-
-
-#endif
-
diff --git a/modules/chibi/cp_pattern.cpp b/modules/chibi/cp_pattern.cpp
deleted file mode 100644
index 8671b6247d..0000000000
--- a/modules/chibi/cp_pattern.cpp
+++ /dev/null
@@ -1,574 +0,0 @@
-/*************************************************************************/
-/* cp_pattern.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_pattern.h"
-
-void CPPattern::clear() {
-
- if (event_count>0) {
-
-
- CP_FREE(events);
- events=NULL;
- event_count=0;
- }
-
- length=DEFAULT_LEN;
-
-}
-
-
-bool CPPattern::resize_event_list_to(uint32_t p_events) {
-
-
- //Module is slow in some cpus, so this should be fast enough
- uint32_t new_size=((p_events-1)&(~((1<<RESIZE_EVERY_BITS)-1)))+(1<<RESIZE_EVERY_BITS);
-
- CP_ERR_COND_V(new_size<p_events,true); //bugARM_INFO
-
- if (event_count==0 && new_size==0)
- return false; //nothing to do
-
- if (event_count==0) {
-
- events=(Event*)CP_ALLOC( new_size*sizeof(Event) );
-
- } else if (new_size==0) {
-
- CP_FREE(events);
- events=NULL;
- } else {
-
- CP_ERR_COND_V(events==NULL,true);
- events=(Event*)CP_REALLOC(events, new_size*sizeof(Event));
-
- }
-
- event_count=p_events;
-
- return false;
-}
-
-
-int32_t CPPattern::get_event_pos(uint16_t p_target_pos) {
-
-
- if (event_count==0)
- return -1;
-
- int low = 0;
- int high = event_count -1;
- int middle;
-
- while( low <= high )
- {
- middle = ( low + high ) / 2;
-
- if( p_target_pos == events[middle].pos ) { //match
- break;
- } else if( p_target_pos < events[middle].pos )
- high = middle - 1; //search low end of array
- else
- low = middle + 1; //search high end of array
- }
-
- /* adapt so we are behind 2 */
-
- if (events[middle].pos<p_target_pos)
- middle++;
- return middle;
-
- /* Linear search for now */
-
- /*
- int32_t pos_idx=0;
-
- for (;pos_idx<event_count;pos_idx++) {
-
- if (event_list[pos_idx].pos>=p_target_pos)
- break;
-
- } */
-
- //return pos_idx;
-}
-
-bool CPPattern::erase_event_at_pos(uint16_t p_pos) {
-
- if (event_count==0)
- return false;
-
-
-
- Event *event_list=events;
-
- int32_t pos_idx = get_event_pos(p_pos);
- if (pos_idx==-1) {
- CP_ERR_COND_V(pos_idx==-1,true);
- }
-
- if (pos_idx==event_count || event_list[pos_idx].pos!=p_pos) {
- /* Nothing to Erase */
- return false;
- }
-
- for (int32_t i=pos_idx;i<(event_count-1);i++) {
-
- event_list[i]=event_list[i+1];
- }
-
-
- resize_event_list_to(event_count-1);
-
- return false;
-}
-
-bool CPPattern::set_note(uint8_t p_column, uint16_t p_row,const CPNote& p_note) {
-
- CP_ERR_COND_V(p_column>=WIDTH,true);
- CP_ERR_COND_V(p_row>=length,true);
-
- int32_t new_pos;
- uint16_t target_pos=p_row*WIDTH+p_column;
-
-
-
- if (p_note.is_empty()) {
- bool res=erase_event_at_pos(target_pos);
-
- return res;;
- }
-
- Event *event_list=0;
-
- if (event_count==0) {
- /* If no events, create the first */
-
- if (resize_event_list_to(1)) {
-
- CP_PRINTERR("Can't resize event list to 1");
- return true;
- }
-
- event_list=events;
- if (event_list==0) {
-
-
- CP_PRINTERR("Can't get event list");
- return true;
- }
-
- new_pos=0;
-
- } else {
- /* Prepare to add */
-
- event_list=events;
- if (event_list==0) {
-
-
- CP_PRINTERR("Can't get event list");
- return true;
- }
-
- int32_t pos_idx = get_event_pos(target_pos);
-
- if (pos_idx==-1) {
-
-
- CP_PRINTERR("Can't find add position");
- return true;
- }
-
-
- if (pos_idx==event_count || event_list[pos_idx].pos!=target_pos) {
- /* If the note being modified didnt exist, then we add it */
-
- //resize, and return if out of mem
- if (resize_event_list_to( event_count+1)) {
-
-
- CP_PRINTERR("Can't resize event list");
- return true;
- }
- event_list=events;
- if (event_list==0) {
-
-
- CP_PRINTERR("Can't get event list");
- return true;
- }
-
- //make room for new pos, this wont do a thing if pos_idx was ==event_count
- for(int32_t i=(event_count-1);i>pos_idx;i--) {
- event_list[i]=event_list[i-1];
-
- }
-
- } /* Else it means that position is taken, so we just modify it! */
-
-
- new_pos=pos_idx;
- }
-
- event_list[new_pos].pos=target_pos;
- event_list[new_pos].note=p_note.note;
- event_list[new_pos].instrument=p_note.instrument;
- event_list[new_pos].volume=p_note.volume;
- event_list[new_pos].command=p_note.command;
- event_list[new_pos].parameter=p_note.parameter;
- event_list[new_pos].script_source_sign=p_note.script_source_sign;
- event_list[new_pos].cloned=p_note.cloned;
-
-
-
-
- return false;
-
-}
-CPNote CPPattern::get_note(uint8_t p_column,uint16_t p_row) {
-
- if (p_column==CPNote::EMPTY) return CPNote();
-
- CP_ERR_COND_V(p_column>=WIDTH,CPNote());
- CP_ERR_COND_V(p_row>=length,CPNote());
-
- if (event_count==0)
- return CPNote();
-
-
- Event *event_list=events;
-
- CP_ERR_COND_V(event_list==0,CPNote());
-
- uint16_t target_pos=p_row*WIDTH+p_column;
- int32_t pos_idx = get_event_pos(target_pos);
- if (pos_idx==-1) {
-
- CP_PRINTERR("Can't find event pos");
- return CPNote();
- }
-
- if (pos_idx>=event_count || event_list[pos_idx].pos!=target_pos) {
- /* no note found */
-
- return CPNote();
- }
-
- CPNote n;
- n.note=event_list[pos_idx].note;
- n.instrument=event_list[pos_idx].instrument;
- n.volume=event_list[pos_idx].volume;
- n.command=event_list[pos_idx].command;
- n.parameter=event_list[pos_idx].parameter;
- n.script_source_sign=event_list[pos_idx].script_source_sign;
- n.cloned=event_list[pos_idx].cloned;
-
-
- return n;
-
-}
-
-CPNote CPPattern::get_transformed_script_note(uint8_t p_column,uint16_t p_row ) {
-
- CPNote n = get_note( p_column, p_row );
-
- // get source channel and note
-
- int channel = get_scripted_note_target_channel( p_column, p_row );
- CPNote src_n = get_note( channel, 0 );
-
- if ( src_n.note == CPNote::SCRIPT ) return CPNote();
-
- script_transform_note( src_n, n );
-
- return src_n;
-
-}
-
-int CPPattern::get_scripted_note_target_channel(uint8_t p_column, uint16_t p_row) {
-
- CPNote n = get_note( p_column, p_row );
-
- if ( n.note != CPNote::SCRIPT ) return CPNote::EMPTY;
-
- int channel = n.instrument;
-
- if ( n.script_source_sign == '\0' ) {
-
- if ( channel < 0 || channel >= CPPattern::WIDTH ) return CPNote::EMPTY;
-
- } else {
-
- channel = p_column + ( ( n.script_source_sign=='+') ? 1 : -1 ) * (channel+1);
- if ( channel < 0 || channel >= CPPattern::WIDTH ) return CPNote::EMPTY;
-
- }
-
- return channel;
-}
-
-void CPPattern::scripted_clone(uint8_t p_column, uint16_t p_row) {
-
- int channel = get_scripted_note_target_channel( p_column, p_row );
- int src_row = 1;
- CPNote script_n = get_note( p_column, p_row );
-
- for ( int row = p_row+1; row < length; ++row ) {
-
- CPNote src_n = get_note( channel, src_row );
- CPNote target_n = get_note( p_column, row );
-
- if ( target_n.note != CPNote::SCRIPT ) {
- if ( src_n.note == CPNote::SCRIPT ) {
- src_n = CPNote();
- channel = CPNote::EMPTY;
- }
-
- script_transform_note( src_n, script_n );
-
- src_n.cloned = true;
- set_note( p_column, row, src_n );
-
- } else {
-
- return;
-
- }
-
- src_row++;
- }
-
-}
-
-void CPPattern::scripted_clone_remove(uint8_t p_column, uint16_t p_row) {
-
- if ( get_note( p_column, p_row ).cloned )
- set_note( p_column, p_row, CPNote() );
-
- for ( int row = p_row+1; row < length; ++row ) {
-
- CPNote target_n = get_note( p_column, row );
-
- if ( target_n.note != CPNote::SCRIPT ) {
-
- set_note( p_column, row, CPNote() );
-
- } else {
-
- return;
-
- }
-
- }
-
-}
-
-void CPPattern::script_transform_note(CPNote& n, const CPNote& p_note) {
-
- // set instrument
-
- if ( n.note < CPNote::NOTES && p_note.volume != CPNote::EMPTY ) {
-
- n.instrument = p_note.volume;
-
- }
-
- // transpose
-
- if ( n.note < CPNote::NOTES && p_note.command != CPNote::EMPTY ) {
-
- int transpose = ( p_note.parameter & 0xF ) + ( p_note.parameter / 0x10 ) * 12;
-
- if ( p_note.command == '^' ) {
-
- if ( n.note >= CPNote::NOTES-transpose )
- n.note = CPNote::NOTES-1;
- else
- n.note += transpose;
-
- } else if ( p_note.command == 'v' ) {
-
- if ( n.note <= transpose )
- n.note = 0;
- else
- n.note -= transpose;
-
- }
- }
-
-}
-
-bool CPPattern::update_scripted_clones_sourcing_channel( int channel ) {
-
- bool updated = false;
-
- for ( int x = 0; x < WIDTH; ++x ) {
-
- for (int y = 0; y < length; ++y ) {
-
- if ( channel == get_scripted_note_target_channel( x, y ) ) {
-
- scripted_clone( x, y );
- updated = true;
- }
-
- }
-
- }
-
- return updated;
-}
-
-void CPPattern::set_length(uint16_t p_rows) {
-
-
-
- if (event_count==0) {
-
- if (p_rows>=MIN_ROWS)
- length=p_rows;
-
-
- return;
-
- }
-
- if (p_rows<MIN_ROWS) {
-
- return;
- }
-
- if (p_rows<length) {
-
- Event* event_list=events;
- if (event_list==0) {
-
- CP_PRINTERR("get_event_list() Failed");
- return;
- }
-
-
- uint16_t target_pos=p_rows*WIDTH;
- int32_t pos_idx = get_event_pos(target_pos);
-
-
- if (pos_idx==-1) {
-
- CP_ERR_COND(pos_idx==-1);
- }
-
- if (resize_event_list_to(pos_idx)) {
-
- CP_PRINTERR("resize_event_list_to(pos_idx) Failed");
- return;
- }
-
- }
-
- length=p_rows;
-
-
-}
-#if 0
-void CPPattern::copy_to(CPPattern *p_pattern) const {
-
-
-
-
- p_pattern->clear();
- p_pattern->length=length;
-
-
- if (!event_count)
- return;
-
-
-
- int bufsiz=MemPool_Wrapper::get_singleton()->get_mem_size( mem_handle );
- MemPool_Handle aux_mem_handle=MemPool_Wrapper::get_singleton()->alloc_mem( bufsiz );
-
- if (aux_mem_handle.is_null()) {
-
- CP_PRINTERR("own handle is null");
-
- return;
- }
-
-
- if (MemPool_Wrapper::get_singleton()->lock_mem(aux_mem_handle)) {
- CP_PRINTERR("Unable to lock aux new handle");
-
- return;
-
- }
-
- if (MemPool_Wrapper::get_singleton()->lock_mem(mem_handle)) {
-
- CP_PRINTERR("Unable to lock own handle");
-
- return;
- }
-
- uint8_t* srcuint8_tt8_t*)MemPool_Wrapper::get_singleton()->get_mem(mem_handle);
- uint8_t* dstuint8_tt8_t*)MemPool_Wrapper::get_singleton()->get_mem(aux_mem_handle);
-
- for (int i=0;i<bufsiz;i++)
- dst[i]=src[i];
-
- MemPool_Wrapper::get_singleton()->unlock_mem(mem_handle);
- MemPool_Wrapper::get_singleton()->unlock_mem(aux_mem_handle);
-
- p_pattern->mem_handle=aux_mem_handle;
- p_pattern->event_count=event_count;
-
-
-}
-#endif
-uint16_t CPPattern::get_length() {
-
-
- return length;
-}
-CPPattern::CPPattern() {
-
-
- length=DEFAULT_LEN;
- event_count=0;
- clear();
-
-}
-bool CPPattern::is_empty() {
-
- return events==NULL;
-}
-
-CPPattern::~CPPattern() {
-
- clear();
-}
diff --git a/modules/chibi/cp_pattern.h b/modules/chibi/cp_pattern.h
deleted file mode 100644
index fc3b032523..0000000000
--- a/modules/chibi/cp_pattern.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*************************************************************************/
-/* cp_pattern.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_PATTERN_H
-#define CP_PATTERN_H
-
-#include "cp_note.h"
-
-class CPPattern {
-public:
-
-
- enum {
- WIDTH=64,
- DEFAULT_LEN=64,
- RESIZE_EVERY_BITS=4,
- MIN_ROWS=1, //otherwise clipboard wont work
- MAX_LEN=256
-
- };
-
-private:
- struct Event {
-
- uint16_t pos; //column*WIDTH+row
- uint8_t note;
- uint8_t instrument;
- uint8_t volume;
- uint8_t command;
- uint8_t parameter;
- unsigned int script_source_sign;
- bool cloned;
- };
-
- uint16_t length;
- uint32_t event_count;
- Event* events;
-
- int32_t get_event_pos(uint16_t p_target_pos);
- bool erase_event_at_pos(uint16_t p_pos);
-
- bool resize_event_list_to(uint32_t p_events);
-
- void operator=(const CPPattern& p_pattern); //no operator=
-public:
-
- bool is_empty();
- void clear();
-
- bool set_note(uint8_t p_column, uint16_t p_row,const CPNote& p_note); //true if no more memory
- CPNote get_note(uint8_t p_column,uint16_t p_row);
-
- CPNote get_transformed_script_note(uint8_t p_column, uint16_t p_row);
- int get_scripted_note_target_channel(uint8_t p_column, uint16_t p_row);
- void scripted_clone(uint8_t p_column, uint16_t p_row);
- void scripted_clone_remove(uint8_t p_column, uint16_t p_row);
- void script_transform_note(CPNote& n, const CPNote& p_note);
- bool update_scripted_clones_sourcing_channel(int channel);
-
- //void copy_to(CPPattern *p_pattern) const;
- void set_length(uint16_t p_rows);
- uint16_t get_length();
- CPPattern();
- ~CPPattern();
-
-
-};
-
-#endif
diff --git a/modules/chibi/cp_player_data.cpp b/modules/chibi/cp_player_data.cpp
deleted file mode 100644
index c8cbfbd06e..0000000000
--- a/modules/chibi/cp_player_data.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*************************************************************************/
-/* cp_player_data.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-#include <stdio.h>
-
-
-CPPlayer::CPPlayer(CPMixer *p_mixer,CPSong *p_song){
-
- song=p_song;
- mixer=p_mixer;
- control.max_voices=p_mixer->get_total_voice_count()-1; //leave one for the sample
- control.force_no_nna=false;
- control.external_vibrato=false;
- control.filters=true;
- control.random_seed=128364; //anything
- control.play_mode=0;
- set_virtual_channels(p_mixer->get_total_voice_count());
- mixer->set_callback( &CPPlayer::callback_function, this );
-
- reset();
-}
-CPPlayer::~CPPlayer(){
-}
-
-void CPPlayer::set_virtual_channels(int p_amount) {
-
- if (p_amount<1) return;
- if (p_amount>mixer->get_total_voice_count())
- return;
-
- control.max_voices=p_amount;
-
-}
-
-
-void CPPlayer::callback_function(void *p_userdata) {
-
- CPPlayer*pd=(CPPlayer*)p_userdata;
- pd->process_tick();
-
-}
-
-void CPPlayer::process_tick() {
-
- handle_tick();
- mixer->set_callback_interval( 2500000/control.tempo );
- song_usecs+=2500000/control.tempo;
-}
-
-void CPPlayer::reset() {
-
- if ( mixer==NULL ) return ;
- if ( song==NULL ) return ;
-
- int i;
-
- for (i=0;i<control.max_voices;i++) {
-
- voice[i].reset();
- mixer->stop_voice(i);
- }
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- control.channel[i].reset();
- control.channel[i].channel_volume=song->get_channel_volume(i);
- control.channel[i].channel_panning=((int)song->get_channel_pan( i)*PAN_RIGHT/64);
- if (song->is_channel_surround(i))
- control.channel[i].channel_panning=PAN_SURROUND;
- control.channel[i].mute=song->is_channel_mute( i );
- control.channel[i].chorus_send=song->get_channel_chorus(i)*0xFF/64;
- control.channel[i].reverb_send=song->get_channel_reverb(i)*0xFF/64;
- }
-
-
- control.speed=song->get_speed();
- control.tempo=song->get_tempo();
- control.global_volume=song->get_global_volume();
-
- control.position.current_pattern=0;
- control.position.current_row=0;
- control.position.current_order=0;
- control.position.force_next_order=-1;
- control.ticks_counter=control.speed;
- control.position.forbid_jump=false;
-
- song_usecs=0;
-
-}
-
-int64_t CPPlayer::get_channel_last_note_time_usec(int p_channel) const {
-
- CP_FAIL_INDEX_V(p_channel,64,-1);
- return control.channel[p_channel].last_event_usecs;
-
-}
-
-void CPPlayer::set_channel_global_volume(int p_channel,int p_volume) {
-
- CP_FAIL_INDEX(p_channel,64);
- control.channel[p_channel].channel_global_volume=CLAMP(p_volume,0,255);
-
-}
-
-int CPPlayer::get_channel_global_volume(int p_channel) const{
-
- CP_FAIL_INDEX_V(p_channel,64,-1);
- return control.channel[p_channel].channel_global_volume;
-
-}
-
-bool CPPlayer::reached_end_of_song() {
-
- return control.reached_end;
-
-}
-void CPPlayer::set_force_external_vibratos(bool p_force) {
-
- control.external_vibrato=p_force;
-}
-void CPPlayer::set_force_no_nna(bool p_force) {
-
- control.force_no_nna=p_force;
-}
diff --git a/modules/chibi/cp_player_data.h b/modules/chibi/cp_player_data.h
deleted file mode 100644
index c59df5f0d9..0000000000
--- a/modules/chibi/cp_player_data.h
+++ /dev/null
@@ -1,582 +0,0 @@
-/*************************************************************************/
-/* cp_player_data.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_PLAYER_DATA_H
-#define CP_PLAYER_DATA_H
-
-#include "cp_config.h"
-#include "cp_song.h"
-#include "cp_mixer.h"
-#include "cp_tables.h"
-
-/**CPPlayer Data
- *@author Juan Linietsky
- */
-
-/******************************
- player_data.h
- ------------------------
-
-The player and its data.
-I hope you dont get sick reading this
-********************************/
-
-//Default pan values
-
-
-class CPPlayer {
-
- enum {
- PAN_SURROUND=512,
- PAN_RIGHT=255,
- PAN_LEFT=0,
- PAN_CENTER=128
- };
-
-
- CPSong *song;
-
- CPMixer *mixer;
-
- struct Filter_Control {
-
- int32_t it_reso;
- int32_t it_cutoff;
- int32_t envelope_cutoff;
- int32_t final_cutoff;
-
- void process();
- void set_filter_parameters(int *p_cutoff,uint8_t *p_reso);
-
- };
-
- //tells you if a channel is doing
- //noteoff/notekill/notefade/etc
- enum {
-
- END_NOTE_NOTHING=0,
- END_NOTE_OFF=1,
- END_NOTE_FADE=2,
- END_NOTE_KILL=4
- };
-
- //Tells you what should a channel restart
- enum {
-
- KICK_NOTHING,
- KICK_NOTE,
- KICK_NOTEOFF,
- KICK_ENVELOPE
- };
-
- enum {
-
- MAX_VOICES=256
- };
-
- struct Channel_Control;
-
- struct Voice_Control {
-
- struct Envelope_Control {
-
- int pos_index;
- int status;
- int value;
- bool sustain_looping;
- bool looping;
- bool terminated;
- bool active;
- bool kill;
-
- };
-
- Filter_Control filter;
- uint16_t reverb_send;
- uint16_t chorus_send;
-
- CPInstrument* instrument_ptr;
- CPSample* sample_ptr;
-
-// Sample_Data *sample_data;
-
- int32_t period;
-
- int32_t sample_start_index; /* The starting byte index in the sample */
-
- bool has_master_channel;
- int master_channel_index;
- int instruement_index;
-
- int instrument_index;
- int sample_index;
- int8_t NNA_type;
-
- int note_end_flags;
-
- uint8_t sample; /* which instrument number */
-
- int16_t output_volume; /* output volume (vol + sampcol + instvol) */
- int8_t channel_volume; /* channel's "global" volume */
- uint16_t fadeout_volume; /* fading volume rate */
- int32_t total_volume; /* total volume of channel (before global mixings) */
- uint8_t kick; /* if true = sample has to be restarted */
-
- uint8_t note; /* the audible note (as heard, direct rep of period) */
-
- int16_t panning; /* panning position */
-
- uint8_t nna; /* New note action type + master/slave flags */
- uint8_t volflg; /* volume envelope settings */
- uint8_t panflg; /* panning envelope settings */
- uint8_t pitflg; /* pitch envelope settings */
- uint8_t keyoff; /* if true = fade out and stuff */
- int16_t handle; /* which sample-handle */
- int32_t start; /* The start byte index in the sample */
-
- /* Below here is info NOT in MP_CONTROL!! */
- //ENVPR venv;
- //ENVPR penv;
- //ENVPR cenv;
-
- Envelope_Control volume_envelope_ctrl;
- Envelope_Control panning_envelope_ctrl;
- Envelope_Control pitch_envelope_ctrl;
-
- uint16_t auto_vibrato_pos; /* autovibrato pos */
- uint16_t auto_vibrato_sweep_pos; /* autovibrato sweep pos */
-
- int16_t masterchn;
- uint16_t masterperiod;
-
- Channel_Control* master_channel; /* index of "master" effects channel */
-
- void start_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl,Envelope_Control *p_from_env);
- bool process_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl);
-
- uint16_t display_volume;
-
- Voice_Control() {
-
- reset();
- }
-
- void reset();
- void update_info_from_master_channel();
-
-
- };
-
-
- struct Channel_Control {
-
- /* NOTE info */
- uint8_t note; /* the audible note as heard, direct rep of period */
- uint8_t real_note; /* the note that indexes the audible */
- int32_t sample_start_index; /* The starting byte index in the sample */
- uint8_t old_note;
-
- uint8_t kick;
-
- Filter_Control filter;
- uint16_t reverb_send;
- uint16_t chorus_send;
-
-
- int note_end_flags;
-
- /* INSTRUMENT INFO */
-
- CPInstrument* instrument_ptr;
- CPSample* sample_ptr;
-
- uint8_t instrument_index;
- uint8_t sample_index;
- bool new_instrument;
-
- /* SAMPLE SPECIFIC INFO */
- int32_t base_speed; /* what finetune to use */
-
- /* INSTRUMENT SPECIFIC INFO */
-
- int8_t NNA_type;
- int8_t duplicate_check_type;
- int8_t duplicate_check_action;
-
- bool volume_envelope_on;
- bool panning_envelope_on;
- bool pitch_envelope_on;
-
- bool has_own_period;
-
- bool row_has_note;
-
- /* VOLUME COLUMN */
-
- int16_t volume; /* amiga volume (0 t/m 64) to play the sample at */
- int16_t aux_volume;
- bool has_own_volume;
- bool mute;
- int16_t random_volume_variation; /* 0-100 - 100 has no effect */
-
- /* VOLUME/PAN/PITCH MODIFIERS */
-
- int8_t default_volume; // CHANNEL default volume (0-64)
- int16_t channel_volume; // CHANNEL current volume //chanvol - current!
- int16_t output_volume; /* output volume (vol + sampcol + instvol) //volume */
- int16_t channel_global_volume;
-
- uint16_t fadeout_volume; /* fading volume rate */
-
- int32_t period; /* period to play the sample at */
-
- /* PAN */
-
- int16_t panning; /* panning position */
- int16_t channel_panning;
- int8_t sliding;
-
- uint16_t aux_period; /* temporary period */
-
-
-
- /* TIMING */
- uint8_t note_delay; /* (used for note delay) */
-
- /* Slave Voice Control */
-
- Voice_Control *slave_voice; /* Audio Slave of current effects control channel */
-
- struct Carry {
-
- Voice_Control::Envelope_Control vol;
- Voice_Control::Envelope_Control pan;
- Voice_Control::Envelope_Control pitch;
- bool maybe;
-
- } carry;
-
-
-
- uint8_t slave_voice_index; /* Audio Slave of current effects control channel */
-
- uint8_t* row; /* row currently playing on this channel */
-
- /* effect memory variables */
-
- uint8_t current_command;
- uint8_t current_parameter;
- uint8_t current_volume_command;
- uint8_t current_volume_parameter;
- uint8_t volcol_volume_slide;
-
- /* CPSample Offset */
-
- int32_t lo_offset;
- int32_t hi_offset;
-
- /* Panbrello waveform */
- uint8_t panbrello_type; /* current panbrello waveform */
- uint8_t panbrello_position; /* current panbrello position */
- int8_t panbrello_speed; /* "" speed */
- uint8_t panbrello_depth; /* "" depth */
- uint8_t panbrello_info;
- /* Arpegio */
-
- uint8_t arpegio_info;
- /* CPPattern Loop */
-
- int pattern_loop_position;
- int8_t pattern_loop_count;
-
- /* Vibrato */
- bool doing_vibrato;
- int8_t vibrato_position; /* current vibrato position */
- uint8_t vibrato_speed; /* "" speed */
- uint8_t vibrato_depth; /* "" depth */
- uint8_t vibrato_type;
- /* Tremor */
- int8_t tremor_position;
- uint8_t tremor_speed; /* s3m tremor ontime/offtime */
- uint8_t tremor_depth;
- uint8_t tremor_info;
-
- /* Tremolo */
- int8_t tremolo_position;
- uint8_t tremolo_speed; /* s3m tremor ontime/offtime */
- uint8_t tremolo_depth;
- uint8_t tremolo_info;
- uint8_t tremolo_type;
-
- /* Retrig */
- int8_t retrig_counter; /* retrig value (0 means don't retrig) */
- uint8_t retrig_speed; /* last used retrig speed */
- uint8_t retrig_volslide; /* last used retrig slide */
-
- /* CPSample Offset */
- int32_t sample_offset_hi; /* last used high order of sample offset */
- uint16_t sample_offset; /* last used low order of sample-offset (effect 9) */
- uint16_t sample_offset_fine; /* fine sample offset memory */
-
- /* Portamento */
- uint16_t slide_to_period; /* period to slide to (with effect 3 or 5) */
- uint8_t portamento_speed;
-
- /* Volume Slide */
-
- uint8_t volume_slide_info;
-
- /* Channel Volume Slide */
-
- uint8_t channel_volume_slide_info;
-
- /* Global Volume Slide */
-
- uint8_t global_volume_slide_info;
-
- /* Channel Pan Slide */
-
- uint8_t channel_pan_slide_info;
-
- /* Pitch Slide */
-
- uint8_t pitch_slide_info;
- /* Tempo Slide */
-
- uint8_t tempo_slide_info;
-
- /* S effects memory */
-
- uint8_t current_S_effect;
- uint8_t current_S_data;
-
- /* Volume column memory */
-
- uint8_t volume_column_effect_mem;
- uint8_t volume_column_data_mem;
-
- int64_t last_event_usecs;
- bool reserved;
-
- void reset();
-
- Channel_Control() { channel_global_volume=255; last_event_usecs=-1; }
- };
-
- struct Control_Variables { // control variables (dynamic version) of initial variables
-
- bool reached_end;
-
- char play_mode;
- bool filters;
- int global_volume;
- int speed;
- int tempo;
-
- int ticks_counter;
-
- int pattern_delay_1;
- int pattern_delay_2;
-
- Channel_Control channel[CPPattern::WIDTH];
-
- int max_voices;
-
- int voices_used; /* reference value */
-
- bool force_no_nna;
- bool external_vibrato;
-
- struct Position {
-
- int current_order;
- int current_pattern;
- int current_row;
- int force_next_order;
- bool forbid_jump;
- };
-
- int32_t random_seed;
-
- Position position;
- Position previous_position;
-
- };
-
-
- Voice_Control voice[MAX_VOICES];
-
- Control_Variables control;
-
- /* VOICE SETUP */
-
- void setup_voices();
-
- /* MIXER SETUP */
- void handle_tick();
- void update_mixer();
-
- /* NOTE / INSTRUMENT PROCESSING */
-
- void process_new_note(int p_track,uint8_t p_note);
- bool process_new_instrument(int p_track,uint8_t p_instrument);
- bool process_note_and_instrument(int p_track,int p_note,int p_instrument);
-
- /* EFFECT PROCESSING */
- void do_effect_S(int p_track);
- void do_panbrello(int p_track);
- void do_global_volume_slide(int p_track);
- void do_tremolo(int p_track);
- void do_retrig(int p_track);
- void do_pan_slide(int p_track);
- void do_channel_volume_slide(int p_track);
- void do_volume_slide(int p_track,int inf);
- void do_pitch_slide_down(int p_track,uint8_t inf);
- void do_pitch_slide_up(int p_track,uint8_t inf);
- void do_tremor(int p_track);
- void do_vibrato(int p_track,bool fine);
- void do_pitch_slide_to_note(int p_track);
- void run_effects(int p_track);
- void run_volume_column_effects(int p_track);
- void pre_process_effects();
- void do_arpegio(int p_track);
- uint64_t song_usecs;
- /* NNA */
-
- void process_NNAs();
-
-
- /* MISC UTILS */
-
-
- int find_empty_voice();
- void process_volume_column(int p_track,uint8_t p_volume);
- void process_note(int p_track,CPNote p_note);
-
- /* CPTables */
- static uint8_t auto_vibrato_table[128];
- static uint8_t vibrato_table[32];
- static int8_t panbrello_table[256];
-
- static void callback_function(void *p_userdata);
-
-public:
- //Play modes
-
- enum {
-
- PLAY_NOTHING =0,
- PLAY_PATTERN =1,
- PLAY_SONG =2
- };
-
-
- int32_t get_frequency(int32_t period);
- int32_t get_period(uint16_t note,int32_t p_c5freq);
-
-
- int get_current_tempo() { return control.tempo; };
- int get_current_speed() { return control.speed; };
-
- int get_voices_used() { return control.voices_used;};
- int get_voice_envelope_pos(int p_voice,CPEnvelope *p_envelope);
- int get_voice_amount_limit() { return control.max_voices; };
- void set_voice_amount_limit(int p_limit);
- void set_reserved_voices(int p_amount);
- int get_reserved_voices_amount();
-
- bool is_voice_active(int p_voice);
- int get_channel_voice(int p_channel);
- const char* get_voice_sample_name(int p_voice);
- const char* get_voice_instrument_name(int p_voice);
- CPEnvelope* get_voice_envelope(int p_voice,CPInstrument::EnvelopeType p_env_type);
- int get_voice_envelope_pos(int p_voice,CPInstrument::EnvelopeType p_env_type);
- int get_voice_volume(int p_voice);
-
- int get_voice_sample_index(int p_voice);
-
- void set_virtual_channels(int p_amount);
- int get_virtual_channels() { return control.max_voices; };
-
-
- /* Play Info/Position */
- bool is_playing() { return (control.play_mode>0); };
- int get_play_mode() {return (control.play_mode);};
- int get_current_order() { return control.position.current_order; };
- int get_current_row() { return control.position.current_row; };
- int get_current_pattern() { return control.position.current_pattern; };
-
- void goto_next_order();
- void goto_previous_order();
-
- void process_tick();
-
-
- CPMixer* get_mixer_ptr() {
-
- return mixer;
- }
-
-
- void reset();
-
-
-
- /* External player control - editor - */
-
- void play_start_pattern(int p_pattern);
- void play_start_song();
- void play_start_song_from_order(int p_order);
- void play_start_song_from_order_and_row(int p_order,int p_row);
- void play_start(int p_pattern, int p_order, int p_row,bool p_lock=true);
-
- void play_stop();
- void play_note(int p_channel,CPNote note,bool p_reserve=false);
-
- bool reached_end_of_song();
-
- void set_force_no_nna(bool p_force);
- void set_force_external_vibratos(bool p_force);
-
- void set_filters_enabled(bool p_enable);
- bool are_filters_enabled() { return control.filters; }
-
- void set_channel_global_volume(int p_channel,int p_volume); //0-255
- int get_channel_global_volume(int p_channel) const;
-
- int64_t get_channel_last_note_time_usec(int p_channel) const;
-
- CPSong *get_song() { return song; };
-
-
- CPPlayer(CPMixer *p_mixer,CPSong *p_song);
- ~CPPlayer();
-};
-
-#endif
diff --git a/modules/chibi/cp_player_data_control.cpp b/modules/chibi/cp_player_data_control.cpp
deleted file mode 100644
index 2ef1c1de8c..0000000000
--- a/modules/chibi/cp_player_data_control.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_control.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-
-void CPPlayer::play_start_pattern(int p_pattern) {
-
- play_start(p_pattern,-1,-1);
-}
-
-void CPPlayer::play_start_song() {
-
- play_start(-1,-1,-1);
-}
-
-void CPPlayer::play_start_song_from_order(int p_order) {
-
- play_start(-1,p_order,-1);
-}
-
-void CPPlayer::play_start_song_from_order_and_row(int p_order,int p_row) {
-
- play_start(-1,p_order,p_row);
-}
-
-void CPPlayer::play_start(int p_pattern, int p_order, int p_row,bool p_lock) {
-
-
- if (control.play_mode!=PLAY_NOTHING) play_stop();
-
-
- reset();
-
- if (p_pattern!=-1) {
-
- control.play_mode=PLAY_PATTERN;
- control.position.current_pattern=p_pattern;
- control.position.current_row=(p_row!=-1)?p_row:0;
-
- } else {
-
- control.position.current_order=get_song_next_order_idx(song,(p_order==-1)?p_order:p_order-1);
- if (control.position.current_order!=-1) {
-
- control.play_mode=PLAY_SONG;
- control.position.current_pattern=song->get_order(control.position.current_order);
- control.position.current_row=(p_row!=-1)?p_row:0;
- }
- }
-
-
- control.reached_end=(control.play_mode==PLAY_NOTHING);
-
-
-}
-
-void CPPlayer::play_stop() {
-
- int i;
-
-
- control.play_mode=PLAY_NOTHING;
-
- for (i=0;i<control.max_voices;i++) {
-
- voice[i].reset();
- mixer->stop_voice(i);
- }
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- control.channel[i].reset();
- }
-
- reset();
-
-}
-
-void CPPlayer::play_note(int p_channel,CPNote note,bool p_reserve) {
-
-
-
- if (control.play_mode==PLAY_NOTHING) {
-
- control.ticks_counter=0;
- }
-
- /*control.channel[p_channel].reset();
- control.channel[p_channel].channel_volume=song->get_channel_volume(p_channel);
- control.channel[p_channel].channel_panning=((int)song->get_channel_pan( p_channel)*255/64);*/
- if (p_reserve) {
- control.channel[p_channel].mute=false;
- control.channel[p_channel].reserved=true;
- } else {
-
- control.channel[p_channel].reserved=false;
-
- }
- process_note(p_channel,note);
-
-
-
-}
-
-
-int CPPlayer::get_voice_volume(int p_voice) {
-
- return voice[p_voice].display_volume;
-}
-
-
-int CPPlayer::get_voice_envelope_pos(int p_voice,CPEnvelope *p_envelope) {
-
- int i,tmp_index=-1;
-
- i=p_voice;
-
-
-
-
- if ((song->has_instruments()) && (voice[i].instrument_ptr!=NULL) && (voice[i].fadeout_volume>0)) {
-
- if ((p_envelope==voice[i].instrument_ptr->get_volume_envelope()) && (voice[i].instrument_ptr->get_volume_envelope()->is_enabled())) {
-
- tmp_index=voice[i].volume_envelope_ctrl.pos_index;
- }
-
- if ((p_envelope==voice[i].instrument_ptr->get_pan_envelope()) && (voice[i].instrument_ptr->get_pan_envelope()->is_enabled())) {
-
- tmp_index=voice[i].panning_envelope_ctrl.pos_index;
- }
-
- if ((p_envelope==voice[i].instrument_ptr->get_pitch_filter_envelope()) && (voice[i].instrument_ptr->get_pitch_filter_envelope()->is_enabled())) {
-
-
- tmp_index=voice[i].pitch_envelope_ctrl.pos_index;
- }
-
- }
-
-
-
- return tmp_index;
-}
-
-void CPPlayer::goto_next_order() {
-
-
- if (control.play_mode!=PLAY_SONG) return;
-
-
-
- control.position.current_row=0;
-
-
- control.position.current_order=get_song_next_order_idx(song, control.position.current_order);
-
-
-
- if (control.position.current_order==-1) {
-
- reset();
- }
-
- control.position.current_pattern=song->get_order(control.position.current_order);
-
-
-}
-void CPPlayer::goto_previous_order() {
-
- if (control.play_mode!=PLAY_SONG) return;
-
-
- int next_order,current_order;
-
- control.position.current_row=0;
-
- current_order=control.position.current_order;
-
- next_order=get_song_next_order_idx(song, current_order);
-
- while ((next_order!=control.position.current_order) && (next_order!=-1)) {
-
- current_order=next_order;
- next_order=get_song_next_order_idx(song, current_order);
- }
-
- if (next_order==-1) {
-
- reset();
- } else {
-
- control.position.current_order=current_order;
- control.position.current_pattern=song->get_order(control.position.current_order);
-
- }
-
-
-
-}
-
-int CPPlayer::get_channel_voice(int p_channel) {
-
- if (control.channel[p_channel].slave_voice==NULL) return -1;
- else return control.channel[p_channel].slave_voice_index;
-}
-
-const char* CPPlayer::get_voice_sample_name(int p_voice) {
-
- const char *name = NULL;
-
-
-
- if (!voice[p_voice].sample_ptr) name=voice[p_voice].sample_ptr->get_name();
-
-
-
- return name;
-
-}
-
-
-bool CPPlayer::is_voice_active(int p_voice) {
-
- return !( ((voice[p_voice].kick==KICK_NOTHING)||(voice[p_voice].kick==KICK_ENVELOPE))&&!mixer->is_voice_active(p_voice) );
-
-}
-
-
-
-int CPPlayer::get_voice_envelope_pos(int p_voice,CPInstrument::EnvelopeType p_env_type) {
-
- if (!is_voice_active(p_voice))
- return -1;
-
- Voice_Control::Envelope_Control *env=0;
-
- switch (p_env_type) {
-
- case CPInstrument::VOLUME_ENVELOPE: env=&voice[p_voice].volume_envelope_ctrl; break;
- case CPInstrument::PAN_ENVELOPE: env=&voice[p_voice].panning_envelope_ctrl; break;
- case CPInstrument::PITCH_ENVELOPE: env=&voice[p_voice].pitch_envelope_ctrl; break;
-
- }
-
- if (!env)
- return -1;
-
- if (!env->active || env->terminated)
- return -1;
-
- return env->pos_index;
-}
-
-
-CPEnvelope* CPPlayer::get_voice_envelope(int p_voice,CPInstrument::EnvelopeType p_env_type) {
-
- CPInstrument *ins=voice[p_voice].instrument_ptr;
-
- if (!ins)
- return 0;
-
- switch( p_env_type ) {
-
-
- case CPInstrument::VOLUME_ENVELOPE: return ins->get_volume_envelope();
- case CPInstrument::PAN_ENVELOPE: return ins->get_pan_envelope();
- case CPInstrument::PITCH_ENVELOPE: return ins->get_pitch_filter_envelope();
- };
-
- return 0;
-
-}
-
-const char * CPPlayer::get_voice_instrument_name(int p_voice) {
-
-
-
- const char *name = NULL;
-
-
-
- if (voice[p_voice].instrument_ptr!=NULL) name=voice[p_voice].instrument_ptr->get_name();
-
-
-
- return name;
-
-}
-void CPPlayer::set_filters_enabled(bool p_enable){
-
- control.filters=p_enable;
-}
-
-int CPPlayer::get_voice_sample_index(int p_voice) {
-
- return voice[p_voice].sample_index;
-}
diff --git a/modules/chibi/cp_player_data_effects.cpp b/modules/chibi/cp_player_data_effects.cpp
deleted file mode 100644
index 6c774afb16..0000000000
--- a/modules/chibi/cp_player_data_effects.cpp
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_effects.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-
-
-
-/**********************
- complex effects
-***********************/
-#define RANDOM_MAX 2147483647
-
-static inline int32_t cp_random_generate(int32_t *seed) {
- int32_t k;
- int32_t s = (int32_t)(*seed);
- if (s == 0)
- s = 0x12345987;
- k = s / 127773;
- s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
- s += 2147483647;
- (*seed) = (int32_t)s;
- return (int32_t)(s & RANDOM_MAX);
-}
-
-
-
-void CPPlayer::do_vibrato(int p_track,bool fine) {
-
- uint8_t q;
- uint16_t temp=0;
-
- if ((control.ticks_counter==0) && control.channel[p_track].row_has_note) control.channel[p_track].vibrato_position=0;
-
- q=(control.channel[p_track].vibrato_position>>2)&0x1f;
-
- switch (control.channel[p_track].vibrato_type) {
- case 0: /* sine */
- temp=vibrato_table[q];
- break;
- case 1: /* square wave */
- temp=255;
- break;
- case 2: /* ramp down */
- q<<=3;
- if (control.channel[p_track].vibrato_position<0) q=255-q;
- temp=q;
- break;
- case 3: /* random */
- temp=cp_random_generate(&control.random_seed) %256;//getrandom(256);
- break;
- }
-
- temp*=control.channel[p_track].vibrato_depth;
-
- if (song->has_old_effects()) {
-
- temp>>=7;
- } else {
-
- temp>>=8;
- }
-
- if (!fine) temp<<=2;
-
- if (control.channel[p_track].vibrato_position>=0) {
-
- control.channel[p_track].period=control.channel[p_track].aux_period+temp;
- } else {
-
- control.channel[p_track].period=control.channel[p_track].aux_period-temp;
- }
-
- if (!song->has_old_effects() || control.ticks_counter) control.channel[p_track].vibrato_position+=control.channel[p_track].vibrato_speed;
-}
-
-
-void CPPlayer::do_pitch_slide_down(int p_track,uint8_t inf) {
-
- uint8_t hi,lo;
-
- if (inf) control.channel[p_track].pitch_slide_info=inf;
- else inf=control.channel[p_track].pitch_slide_info;
-
- hi=inf>>4;
- lo=inf&0xf;
-
- if (hi==0xf) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_period+=(uint16_t)lo<<2;
- } else if (hi==0xe) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_period+=lo;
- } else {
-
- if (control.ticks_counter) control.channel[p_track].aux_period+=(uint16_t)inf<<2;
- }
-}
-
-void CPPlayer::do_pitch_slide_up(int p_track,uint8_t inf) {
-
- uint8_t hi,lo;
-
- if (inf) control.channel[p_track].pitch_slide_info=inf;
- else inf=control.channel[p_track].pitch_slide_info;
-
- hi=inf>>4;
- lo=inf&0xf;
-
- if (hi==0xf) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_period-=(uint16_t)lo<<2;
- } else if (hi==0xe) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_period-=lo;
- } else {
-
- if (control.ticks_counter) control.channel[p_track].aux_period-=(uint16_t)inf<<2;
- }
-}
-
-void CPPlayer::do_pitch_slide_to_note(int p_track) {
-
- if (control.ticks_counter) {
- int dist;
-
- /* We have to slide a->period towards a->wantedperiod, compute the
- difference between those two values */
- dist=control.channel[p_track].period-control.channel[p_track].slide_to_period;
-
- /* if they are equal or if portamentospeed is too big... */
- if ((!dist)||((control.channel[p_track].portamento_speed<<2)>cp_intabs(dist))) {
- /* ... make tmpperiod equal tperiod */
- control.channel[p_track].aux_period=control.channel[p_track].period=control.channel[p_track].slide_to_period;
- } else {
-
- if (dist>0) {
-
- control.channel[p_track].aux_period-=control.channel[p_track].portamento_speed<<2;
- control.channel[p_track].period-=control.channel[p_track].portamento_speed<<2; /* dist>0 slide up */
- } else {
- control.channel[p_track].aux_period+=control.channel[p_track].portamento_speed<<2;
- control.channel[p_track].period+=control.channel[p_track].portamento_speed<<2; /* dist<0 slide down */
- }
- }
-
- } else {
-
- control.channel[p_track].aux_period=control.channel[p_track].period;
- }
-}
-
-void CPPlayer::do_tremor(int p_track) {
-
- uint8_t on,off,inf;
-
- inf=control.channel[p_track].current_parameter;
-
- if (inf) {
- control.channel[p_track].tremor_info=inf;
- } else {
- inf= control.channel[p_track].tremor_info;
- if (!inf) return;
- }
-
- //if (!control.ticks_counter) return;
-
- on=(inf>>4);
- off=(inf&0xf);
-
- control.channel[p_track].tremor_position%=(on+off);
- control.channel[p_track].volume=(control.channel[p_track].tremor_position<on)?control.channel[p_track].aux_volume:0;
- control.channel[p_track].tremor_position++;
-}
-
-void CPPlayer::do_pan_slide(int p_track) {
-
- uint8_t lo,hi,inf;
- int16_t pan;
-
- inf=control.channel[p_track].current_parameter;
-
- if (inf) control.channel[p_track].channel_pan_slide_info=inf;
- else inf=control.channel[p_track].channel_pan_slide_info;
-
- lo=inf&0xf;
- hi=inf>>4;
-
- pan=(control.channel[p_track].panning==PAN_SURROUND)?PAN_CENTER:control.channel[p_track].panning;
-
- if (!hi)
- pan+=lo<<2;
- else
- if (!lo) {
- pan-=hi<<2;
- } else
- if (hi==0xf) {
- if (!control.ticks_counter) pan+=lo<<2;
- } else
- if (lo==0xf) {
- if (!control.ticks_counter) pan-=hi<<2;
- }
- //this sets both chan & voice paning
- control.channel[p_track].panning=(pan<PAN_LEFT)?PAN_LEFT:(pan>PAN_RIGHT?PAN_RIGHT:pan);
- control.channel[p_track].channel_panning=control.channel[p_track].panning;
-}
-
-void CPPlayer::do_volume_slide(int p_track,int inf) {
-
- uint8_t hi,lo;
-
- lo=inf&0xf;
- hi=inf>>4;
-
- if (!lo) {
-
- if ((control.ticks_counter)) control.channel[p_track].aux_volume+=hi;
-
- } else if (!hi) {
-
- if ((control.ticks_counter)) control.channel[p_track].aux_volume-=lo;
-
- } else if (lo==0xf) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_volume+=(hi?hi:0xf);
- } else if (hi==0xf) {
-
- if (!control.ticks_counter) control.channel[p_track].aux_volume-=(lo?lo:0xf);
- } else return;
-
- if (control.channel[p_track].aux_volume<0) {
-
- control.channel[p_track].aux_volume=0;
- } else if (control.channel[p_track].aux_volume>64) {
-
- control.channel[p_track].aux_volume=64;
- }
-}
-
-void CPPlayer::do_channel_volume_slide(int p_track) {
-
- uint8_t lo, hi,inf;
-
- inf=control.channel[p_track].current_parameter;
-
- if (inf) control.channel[p_track].channel_volume_slide_info=inf;
- inf=control.channel[p_track].channel_volume_slide_info;
-
- lo=inf&0xf;
- hi=inf>>4;
-
- if (!hi)
- control.channel[p_track].channel_volume-=lo;
- else
- if (!lo) {
- control.channel[p_track].channel_volume+=hi;
- } else
- if (hi==0xf) {
- if (!control.ticks_counter) control.channel[p_track].channel_volume-=lo;
- } else
- if (lo==0xf) {
- if (!control.ticks_counter) control.channel[p_track].channel_volume+=hi;
- }
-
- if (control.channel[p_track].channel_volume<0) control.channel[p_track].channel_volume=0;
- if (control.channel[p_track].channel_volume>64) control.channel[p_track].channel_volume=64;
-}
-
-void CPPlayer::do_tremolo(int p_track) {
-
- uint8_t q;
- int16_t temp=0;
-
- if ((control.ticks_counter==0) && control.channel[p_track].row_has_note) control.channel[p_track].tremolo_position=0;
-
- q=(control.channel[p_track].tremolo_position>>2)&0x1f;
-
- switch (control.channel[p_track].tremolo_type) {
- case 0: /* sine */
- temp=vibrato_table[q];
- break;
- case 1: /* ramp down */
- q<<=3;
- if (control.channel[p_track].tremolo_position<0) q=255-q;
- temp=q;
- break;
- case 2: /* square wave */
- temp=255;
- break;
- case 3: /* random */
- temp=cp_random_generate(&control.random_seed) % 256;//getrandom(256);
- break;
- }
-
- temp*=control.channel[p_track].tremolo_depth;
- temp>>=7;
-
-
-
- if (control.channel[p_track].tremolo_position>=0) {
-
-
- control.channel[p_track].volume=control.channel[p_track].aux_volume+temp;
- if (control.channel[p_track].volume>64) control.channel[p_track].volume=64;
- } else {
-
- control.channel[p_track].volume=control.channel[p_track].aux_volume-temp;
- if (control.channel[p_track].volume<0) control.channel[p_track].volume=0;
- }
-
- /*if (control.ticks_counter)*/ control.channel[p_track].tremolo_position+=control.channel[p_track].tremolo_speed;
-
-}
-
-void CPPlayer::do_arpegio(int p_track) {
-
- uint8_t note,dat;
- //note=control.channel[p_track].note;
- note=0;
-
- if (control.channel[p_track].current_parameter) {
-
- control.channel[p_track].arpegio_info=control.channel[p_track].current_parameter;
- }
-
- dat=control.channel[p_track].arpegio_info;
-
- if (dat) {
-
- switch (control.ticks_counter%3) {
-
- case 1: {
-
- note+=(dat>>4);
-
- } break;
- case 2: {
-
- note+=(dat&0xf);
- } break;
- }
-
- if (song->has_linear_slides()) {
-
- control.channel[p_track].period=control.channel[p_track].aux_period-cp_intabs(get_period((uint16_t)46,0)-get_period((uint16_t)44,0))*note;
- } else if (control.channel[p_track].sample_ptr) {
-
- control.channel[p_track].period=get_period( (((uint16_t)control.channel[p_track].note)+note)<<1,CPSampleManager::get_singleton()->get_c5_freq( (control.channel[p_track].sample_ptr->get_sample_data())));
- }
-
- control.channel[p_track].has_own_period=true;
- }
-
-
-}
-
-
-void CPPlayer::do_retrig(int p_track) {
-
- uint8_t inf;
-
- inf=control.channel[p_track].current_parameter;
-
- if (inf) {
-
- control.channel[p_track].retrig_volslide=inf>>4;
- control.channel[p_track].retrig_speed=inf&0xf;
- }
-
- /* only retrigger if low nibble > 0 */
- if ( control.channel[p_track].retrig_speed>0) {
-
- if ( !control.channel[p_track].retrig_counter ) {
- /* when retrig counter reaches 0, reset counter and restart the
- sample */
- if (control.channel[p_track].kick!=KICK_NOTE) control.channel[p_track].kick=KICK_NOTEOFF;
- control.channel[p_track].retrig_counter=control.channel[p_track].retrig_speed;
-
-
- if ((control.ticks_counter)/*||(pf->flags&UF_S3MSLIDES)*/) {
- switch (control.channel[p_track].retrig_volslide) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- control.channel[p_track].aux_volume-=(1<<(control.channel[p_track].retrig_volslide-1));
- break;
- case 6:
- control.channel[p_track].aux_volume=(2*control.channel[p_track].aux_volume)/3;
- break;
- case 7:
- control.channel[p_track].aux_volume>>=1;
- break;
- case 9:
- case 0xa:
- case 0xb:
- case 0xc:
- case 0xd:
- control.channel[p_track].aux_volume+=(1<<(control.channel[p_track].retrig_volslide-9));
- break;
- case 0xe:
- control.channel[p_track].aux_volume=(3*control.channel[p_track].aux_volume)>>1;
- break;
- case 0xf:
- control.channel[p_track].aux_volume=control.channel[p_track].aux_volume<<1;
- break;
- }
- if (control.channel[p_track].aux_volume<0) control.channel[p_track].aux_volume=0;
- else if (control.channel[p_track].aux_volume>64) control.channel[p_track].aux_volume=64;
- }
- }
- control.channel[p_track].retrig_counter--; /* countdown */
- }
-}
-
-void CPPlayer::do_global_volume_slide(int p_track) {
-
- uint8_t lo,hi,inf;
-
- inf=control.channel[p_track].current_parameter;
-
- if (inf) control.channel[p_track].global_volume_slide_info=inf;
- inf=control.channel[p_track].global_volume_slide_info;
-
- lo=inf&0xf;
- hi=inf>>4;
-
- if (!lo) {
- if (control.ticks_counter) control.global_volume+=hi;
- } else
- if (!hi) {
- if (control.ticks_counter) control.global_volume-=lo;
- } else
- if (lo==0xf) {
- if (!control.ticks_counter) control.global_volume+=hi;
- } else
- if (hi==0xf) {
- if (!control.ticks_counter) control.global_volume-=lo;
- }
-
- if (control.global_volume<0) control.global_volume=0;
- if (control.global_volume>128) control.global_volume=128;
-}
-
-void CPPlayer::do_panbrello(int p_track) {
-
- uint8_t q;
- int32_t temp=0;
-
- q=control.channel[p_track].panbrello_position;
-
- switch (control.channel[p_track].panbrello_type) {
- case 0: {/* sine */
- temp=panbrello_table[q];
- } break;
- case 1: {/* square wave */
- temp=(q<0x80)?64:0;
- } break;
- case 2: {/* ramp down */
- q<<=3;
- temp=q;
- } break;
- case 3: {/* random */
- if (control.channel[p_track].panbrello_position>=control.channel[p_track].panbrello_speed) {
- control.channel[p_track].panbrello_position=0;
- temp=cp_random_generate(&control.random_seed)%256;//getrandom(256);
- }
- } break;
- }
-
-
-
- temp=temp*(int)control.channel[p_track].panbrello_depth/0xF;
- temp<<=1;
- if (control.channel[p_track].channel_panning!=PAN_SURROUND)
- temp+=control.channel[p_track].channel_panning;
-
- control.channel[p_track].panning=(temp<PAN_LEFT)?PAN_LEFT:(temp>PAN_RIGHT?PAN_RIGHT:temp);
- control.channel[p_track].panbrello_position+=control.channel[p_track].panbrello_speed;
-}
-
-/******************
- S effect
-*******************/
-
-
-void CPPlayer::do_effect_S(int p_track) {
-
- uint8_t inf,c,dat;
-
- dat=control.channel[p_track].current_parameter;
-
- inf=dat&0xf;
- c=dat>>4;
-
- if (!dat) {
- c=control.channel[p_track].current_S_effect;
- inf=control.channel[p_track].current_S_data;
- } else {
- control.channel[p_track].current_S_effect=c;
- control.channel[p_track].current_S_data=inf;
- }
-
- switch (c) {
- case 1: {/* S1x set glissando voice */
- // this is unsupported in IT!
-
- control.channel[p_track].chorus_send=inf*0xFF/0xF;
-
- }break;
- case 2: /* S2x set finetune */
- //Also not supported!
- break;
- case 3: /* S3x set vibrato waveform */
- if (inf<4) control.channel[p_track].vibrato_type=inf;
- break;
- case 4: /* S4x set tremolo waveform */
- if (inf<4) control.channel[p_track].tremolo_type=inf;
- break;
- case 5: /* S5x panbrello */
- if (inf<4) control.channel[p_track].panbrello_type=inf;
- break;
- case 6: {/* S6x delay x number of frames (patdly) */
-
- if (control.ticks_counter) break;
- if (!control.pattern_delay_2) control.pattern_delay_1=inf+1; /* only once, when vbtick=0 */
-
- } break;
- case 7: /* S7x instrument / NNA commands */
-
- if (!song->has_instruments())
- break;
- switch(inf) {
-
- case 0x3: {
-
- control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CUT;
- } break;
- case 0x4: {
-
- control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CONTINUE;
- } break;
- case 0x5: {
-
- control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_OFF;
- } break;
- case 0x6: {
-
- control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_FADE;
- } break;
- case 0x7: {
-
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->volume_envelope_ctrl.active=false;
- } break;
- case 0x8: {
-
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->volume_envelope_ctrl.active=true;
-
- } break;
- case 0x9: {
-
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->panning_envelope_ctrl.active=false;
-
- } break;
- case 0xA: {
-
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->panning_envelope_ctrl.active=true;
-
- } break;
- case 0xB: {
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->pitch_envelope_ctrl.active=false;
-
- } break;
- case 0xC: {
-
- if (control.channel[p_track].slave_voice)
- control.channel[p_track].slave_voice->pitch_envelope_ctrl.active=true;
-
- } break;
-
- } break;
-
- break;
- case 8: {/* S8x set panning position */
-
-// if (pf->panflag) {
- if (inf<=8) inf<<=4;
- else inf*=17;
- control.channel[p_track].panning=control.channel[p_track].channel_panning=inf;
-// }
- } break;
-
- case 9: { /* S9x set surround sound */
- //if (pf->panflag)
- control.channel[p_track].panning=control.channel[p_track].channel_panning=PAN_SURROUND;
- } break;
- case 0xA:{ /* SAy set high order sample offset yxx00h */
-
- if (control.channel[p_track].current_parameter) control.channel[p_track].hi_offset=(int32_t)inf<<16;
- control.channel[p_track].sample_start_index=control.channel[p_track].hi_offset|control.channel[p_track].lo_offset;
- } break;
- case 0xB: { /* SBx pattern loop */
- if (control.ticks_counter) break;
-
- if (inf) { /* set reppos or repcnt ? */
- /* set repcnt, so check if repcnt already is set, which means we
- are already looping */
- if (control.channel[p_track].pattern_loop_count>0)
- control.channel[p_track].pattern_loop_count--; /* already looping, decrease counter */
- else {
- control.channel[p_track].pattern_loop_count=inf; /* not yet looping, so set repcnt */
- }
-
- if (control.channel[p_track].pattern_loop_count>0) { /* jump to reppos if repcnt>0 */
-
- control.position=control.previous_position; // This will also anulate any Cxx or break..
-
- control.position.current_row=control.channel[p_track].pattern_loop_position;
- control.position.forbid_jump=true;
- }
-
- } else {
-
-
- control.channel[p_track].pattern_loop_position=control.position.current_row-1;
- }
-
- } break;
- case 0xC: { /* SCx notecut */
-
- if (control.ticks_counter>=inf) {
-
- control.channel[p_track].aux_volume=0;
- control.channel[p_track].note_end_flags|=END_NOTE_OFF;
- control.channel[p_track].note_end_flags|=END_NOTE_KILL;
- }
- } break;
- case 0xD: {/* SDx notedelay */
-
- if (!control.ticks_counter) {
-
- control.channel[p_track].note_delay=inf;
-
- } else if (control.channel[p_track].note_delay) {
-
- control.channel[p_track].note_delay--;
- }
-
- } break;
- case 0xF: {/* SEx patterndelay */
-
- if (control.ticks_counter) break;
- if (!control.pattern_delay_2) control.pattern_delay_1=inf+1; /* only once, when vbtick=0 */
-
- } break;
- }
-}
-
-
-
-
-
-
-
-
-/*********************
- volume effects
-**********************/
-
-void CPPlayer::run_volume_column_effects(int p_track) {
-
- uint8_t param=control.channel[p_track].current_volume_parameter;
-
-
- switch ('A'+control.channel[p_track].current_volume_command) {
-
- case 'A': {
-
- if (param>0) control.channel[p_track].volcol_volume_slide=param;
- else param=control.channel[p_track].volcol_volume_slide;
-
- do_volume_slide(p_track,param*0x10+0xF);
-
- } break;
- case 'B': {
-
- if (param>0) control.channel[p_track].volcol_volume_slide=param;
- else param=control.channel[p_track].volcol_volume_slide;
-
- do_volume_slide(p_track,0xF0+param);
-
- } break;
- case 'C': {
-
- if (param>0) control.channel[p_track].volcol_volume_slide=param;
- else param=control.channel[p_track].volcol_volume_slide;
-
- do_volume_slide(p_track,param*0x10);
- } break;
- case 'D': {
-
- if (param>0) control.channel[p_track].volcol_volume_slide=param;
- else param=control.channel[p_track].volcol_volume_slide;
- do_volume_slide(p_track,param);
-
- } break;
- case 'E': {
-
- do_pitch_slide_down(p_track,param<<2);
- } break;
- case 'F': {
-
- do_pitch_slide_up(p_track,param<<2);
- } break;
- case 'G': {
-
- const uint8_t slide_table[]={0,1,4,8,16,32,64,96,128,255};
- if (param) {
-
- control.channel[p_track].portamento_speed=slide_table[param];
- }
-
- if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) {
-
- if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){
-
- //control.channel[p_track].kick=KICK_NOTE;
- //control.channel[p_track].sample_start_index=0; // < am i stupid?
- } else {
-
- control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING;
- do_pitch_slide_to_note(p_track);
- control.channel[p_track].has_own_period=true;
- }
-
- }
- } break;
- case 'H': {
-
-
- if (!control.ticks_counter) {
- if (param&0x0f) control.channel[p_track].vibrato_depth=param;
- }
- control.channel[p_track].doing_vibrato=true;
- if (control.external_vibrato) break;
- if (control.channel[p_track].period) {
-
- do_vibrato(p_track,false);
- control.channel[p_track].has_own_period=true;
- }
-
- } break;
- }
-}
-/*********************
- table
-**********************/
-
-
-void CPPlayer::run_effects(int p_track) {
-
- switch ('A'+control.channel[p_track].current_command) {
-
- case 'A': {
-
- if ((control.ticks_counter>0) || (control.pattern_delay_2>0)) break;
-
- int new_speed;
-
- new_speed=control.channel[p_track].current_parameter % 128;
-
- if (new_speed>0) {
- control.speed=new_speed;
- control.ticks_counter=0;
- }
- } break;
- case 'B': {
-
- int next_order;
-
- if (control.ticks_counter || control.position.forbid_jump) break;
-
- control.position.current_row=0;
-
- if (control.play_mode==PLAY_PATTERN) break;
-
- next_order=get_song_next_order_idx(song, (int)control.channel[p_track].current_parameter-1);
-
- if (next_order!=-1) {
- // Do we have a "next order?"
- control.position.current_pattern=song->get_order(next_order);
- control.position.force_next_order=next_order;
-
- } else {
- // no, probably the user deleted the orderlist.
- control.play_mode=PLAY_NOTHING;
- reset();
- }
- } break;
- case 'C': {
-
- int next_order;
-
- if (control.ticks_counter || control.position.forbid_jump) break;
-
- control.position.current_row=control.channel[p_track].current_parameter;
-
- if (control.play_mode==PLAY_PATTERN) {
-
- if (control.position.current_row>=song->get_pattern(control.position.current_pattern)->get_length()) {
-
- control.position.current_row=0;
- }
-
- break;
- }
-
- next_order=get_song_next_order_idx(song, (int)control.position.current_order);
-
- if (next_order!=-1) {
- // Do we have a "next order?"
- control.position.current_pattern=song->get_order(next_order);
-
- if (control.position.current_row>=song->get_pattern(song->get_order(next_order))->get_length()) {
-
- control.position.current_row=0;
- }
-
- control.position.force_next_order=next_order;
-
- } else {
- // no, probably the user deleted the orderlist.
- control.play_mode=PLAY_NOTHING;
- reset();
- }
-
- } break;
- case 'D': {
-
- uint8_t inf ;
- //explicitslides=1;
- inf=control.channel[p_track].current_parameter;
-
- if (inf) control.channel[p_track].volume_slide_info=inf;
- else inf=control.channel[p_track].volume_slide_info;
-
- do_volume_slide(p_track,inf);
-
- } break;
- case 'E': {
-
- uint8_t inf;
-
- inf=control.channel[p_track].current_parameter;
- do_pitch_slide_down(p_track,inf);
-
- } break;
- case 'F': {
-
- uint8_t inf;
-
- inf=control.channel[p_track].current_parameter;
- do_pitch_slide_up(p_track,inf);
-
- } break;
- case 'G': {
-
- if (control.channel[p_track].current_parameter) {
-
- control.channel[p_track].portamento_speed=control.channel[p_track].current_parameter;
- }
-
- if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) {
-
- if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){
-
-
- control.channel[p_track].kick=KICK_NOTE;
- control.channel[p_track].sample_start_index=0;
-
- } else {
-
- control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING;
- }
-
- do_pitch_slide_to_note(p_track);
- control.channel[p_track].has_own_period=true;
- }
-
- } break;
- case 'H': {
-
- uint8_t dat;
-
- control.channel[p_track].doing_vibrato=true;
-
- dat=control.channel[p_track].current_parameter;
-
- if (!control.ticks_counter) {
- if (dat&0x0f) control.channel[p_track].vibrato_depth=dat&0xf;
- if (dat&0xf0) control.channel[p_track].vibrato_speed=(dat&0xf0)>>2;
- }
-
- if (control.external_vibrato) break;
-
- if (control.channel[p_track].period) {
-
- do_vibrato(p_track,false);
- control.channel[p_track].has_own_period=true;
- }
-
- } break;
- case 'I': {
-
- do_tremor(p_track);
- control.channel[p_track].has_own_volume=true;
- } break;
- case 'J': {
-
- do_arpegio(p_track);
- } break;
- case 'K': {
-
- uint8_t inf ;
- //explicitslides=1;
- inf=control.channel[p_track].current_parameter;
-
- control.channel[p_track].doing_vibrato=true;
-
-
- if (inf) control.channel[p_track].volume_slide_info=inf;
- else inf=control.channel[p_track].volume_slide_info;
-
- do_volume_slide(p_track,inf);
-
- if (control.external_vibrato) break;
-
- if (control.channel[p_track].period) {
-
- do_vibrato(p_track,false);
- control.channel[p_track].has_own_period=true;
- }
-
- } break;
- case 'L': {
- uint8_t inf ;
- //explicitslides=1;
- inf=control.channel[p_track].current_parameter;
-
- if (inf) control.channel[p_track].volume_slide_info=inf;
- else inf=control.channel[p_track].volume_slide_info;
-
- do_volume_slide(p_track,inf);
-
- if (control.channel[p_track].period && (control.channel[p_track].old_note<=120)) {
- if ( (!control.ticks_counter) && (control.channel[p_track].new_instrument) ){
-
- control.channel[p_track].kick=KICK_NOTE;
- control.channel[p_track].sample_start_index=0;
-
- } else {
-
- control.channel[p_track].kick=(control.channel[p_track].kick==KICK_NOTE)?KICK_ENVELOPE:KICK_NOTHING;
- }
-
- do_pitch_slide_to_note(p_track);
- control.channel[p_track].has_own_period=true;
- }
- } break;
- case 'M': {
- control.channel[p_track].channel_volume=control.channel[p_track].current_parameter;
- if (control.channel[p_track].channel_volume>64) control.channel[p_track].channel_volume=64;
- else if (control.channel[p_track].channel_volume<0) control.channel[p_track].channel_volume=0;
- } break;
- case 'N': {
-
- do_channel_volume_slide(p_track);
- }
- case 'O': {
-
- if (!control.ticks_counter) {
-
- if (control.channel[p_track].current_parameter) control.channel[p_track].lo_offset=(uint16_t)control.channel[p_track].current_parameter<<8;
- control.channel[p_track].sample_start_index=control.channel[p_track].hi_offset|control.channel[p_track].lo_offset;
-
- //if ((control.channel[p_track].sample_ptr!=NULL)&&(control.channel[p_track].sample_start_index>control.channel[p_track].sample_ptr->data.size)) {
- //TODO, O effect
- //a->start=a->s->flags&(SF_LOOP|SF_BIDI)?a->s->loopstart:a->s->length;
- //}
- }
- } break;
- case 'P': {
-
- do_pan_slide(p_track);
- } break;
- case 'Q': {
- do_retrig(p_track);
-
- } break;
- case 'R': {
-
-
- uint8_t dat;
-
- if (control.channel[p_track].current_parameter) {
-
- control.channel[p_track].tremolo_info=control.channel[p_track].current_parameter;
- }
-
- dat=control.channel[p_track].tremolo_info;
-
- if (!control.ticks_counter && dat) {
-
- if (dat&0x0f) control.channel[p_track].tremolo_depth=dat&0xf;
- if (dat&0xf0) control.channel[p_track].tremolo_speed=(dat&0xf0)>>2;
- }
-
- do_tremolo(p_track);
- control.channel[p_track].has_own_volume=true;
-
- } break;
- case 'S': {
-
- do_effect_S(p_track);
- } break;
- case 'T': {
- uint8_t dat;
- int16_t temp=control.tempo;
-
- if (control.pattern_delay_2) return;
-
- if (control.channel[p_track].current_parameter) {
-
- control.channel[p_track].tempo_slide_info=control.channel[p_track].current_parameter;
- }
-
- dat=control.channel[p_track].tempo_slide_info;
-
- if (dat>=0x20) {
-
- if (control.ticks_counter) break;
- control.tempo=dat;
- } else {
-
- if (!control.ticks_counter) break;
-
- if (dat&0x10) {
-
- temp+=(dat&0x0f);
- } else {
-
- temp-=dat;
- }
- control.tempo=(temp>255)?255:(temp<0x20?0x20:temp);
- }
-
- } break;
- case 'U': {
-
- uint8_t dat;
-
- dat=control.channel[p_track].current_parameter;
- control.channel[p_track].doing_vibrato=true;
- if (!control.ticks_counter) {
- if (dat&0x0f) control.channel[p_track].vibrato_depth=dat&0xf;
- if (dat&0xf0) control.channel[p_track].vibrato_speed=(dat&0xf0)>>2;
- }
-
- if (control.external_vibrato) break;
-
- if (control.channel[p_track].period) {
-
- do_vibrato(p_track,true);
- control.channel[p_track].has_own_period=true;
- }
- } break;
- case 'V': {
-
- control.global_volume=control.channel[p_track].current_parameter;
- if (control.global_volume>128) control.global_volume=128;
- } break;
- case 'W': {
- do_global_volume_slide(p_track);
- } break;
- case 'X': {
- //sets both channel and current
- control.channel[p_track].channel_panning=control.channel[p_track].current_parameter;
- control.channel[p_track].panning=control.channel[p_track].current_parameter;
- } break;
- case 'Y': {
-
- uint8_t dat;
-
- if (control.channel[p_track].current_parameter) {
-
- control.channel[p_track].panbrello_info=control.channel[p_track].current_parameter;
- }
-
- dat=control.channel[p_track].panbrello_info;
-
- if (!control.ticks_counter) {
-
- if (dat&0x0f) control.channel[p_track].panbrello_depth=(dat&0xf);
- if (dat&0xf0) control.channel[p_track].panbrello_speed=(dat&0xf0)>>4;
- }
-
- //if (pf->panflag)
- if (control.channel[p_track].panning!=PAN_SURROUND)do_panbrello(p_track);
-
- } break;
- case 'Z': {
- //I DO! cuttoff!
- uint16_t dat=control.channel[p_track].current_parameter;
-
- if (dat<0x80) {
-
- control.channel[p_track].filter.it_cutoff=dat*2;
- if (control.channel[p_track].filter.it_cutoff>0x80)
- control.channel[p_track].filter.it_cutoff++;
- } else if (dat<0x90) {
-
- control.channel[p_track].filter.it_reso=(dat-0x80)*0x10;
- } else {
-
- control.channel[p_track].reverb_send=(dat-0x90)*255/0x6F;
- }
-
- } break;
-
- }
-
-}
-
-void CPPlayer::pre_process_effects() {
-
-// MP_VOICE *aout;
- int i;
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- //a=&pf->control[mp_channel];
-
- // if ((aout=a->slave)) {
- // a->fadevol=aout->fadevol;
- // a->period=aout->period;
- // if (a->kick==KICK_KEYOFF) a->keyoff=aout->keyoff;
- //}
-
- //if (!a->row) continue;
- //UniSetRow(a->row);
- control.channel[i].has_own_period=false;
- control.channel[i].has_own_volume=false;
- control.channel[i].doing_vibrato=false;
- //explicitslides=0;
- //pt_playeffects();
- if (control.ticks_counter<control.speed) {
-
- run_effects(i);
- run_volume_column_effects(i);
- }
-
- /* continue volume slide if necessary for XM and IT */
- //if (pf->flags&UF_BGSLIDES) {
- // if (!explicitslides && a->sliding)
- // DoS3MVolSlide(0);
- // else if (a->tmpvolume) a->sliding=explicitslides;
- //}
-
- if (!control.channel[i].has_own_period) control.channel[i].period=control.channel[i].aux_period;
- if (!control.channel[i].has_own_volume) control.channel[i].volume=control.channel[i].aux_volume;
-
- if ((control.channel[i].sample_ptr!=NULL) && !(song->has_instruments() && (control.channel[i].instrument_ptr==NULL))) {
-
- if (song->has_instruments()) {
-
- control.channel[i].output_volume=
- (control.channel[i].volume*control.channel[i].sample_ptr->get_global_volume()*control.channel[i].instrument_ptr->get_volume_global_amount())/2048;
- control.channel[i].output_volume=control.channel[i].output_volume*control.channel[i].random_volume_variation/100;
-
- } else {
-
- control.channel[i].output_volume=
- (control.channel[i].volume*control.channel[i].sample_ptr->get_global_volume())>>4;
-
- }
-
- if (control.channel[i].output_volume>256) {
-
- control.channel[i].output_volume=256;
-
- } else if (control.channel[i].output_volume<0) {
-
- control.channel[i].output_volume=0;
- }
-
-
- }
- }
-
-}
diff --git a/modules/chibi/cp_player_data_envelopes.cpp b/modules/chibi/cp_player_data_envelopes.cpp
deleted file mode 100644
index a720eaf734..0000000000
--- a/modules/chibi/cp_player_data_envelopes.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_envelopes.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-
-
-void CPPlayer::Voice_Control::start_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl,Envelope_Control *p_from_env) {
-
-
- if (p_from_env && p_envelope->is_carry_enabled() && !p_from_env->terminated) {
-
-
- *p_envelope_ctrl=*p_from_env;
- } else {
- p_envelope_ctrl->pos_index=0;
- p_envelope_ctrl->status=1;
- p_envelope_ctrl->sustain_looping=p_envelope->is_sustain_loop_enabled();
- p_envelope_ctrl->looping=p_envelope->is_loop_enabled();
- p_envelope_ctrl->terminated=false;
- p_envelope_ctrl->kill=false;
- p_envelope_ctrl->value=p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index);
- }
-}
-
-bool CPPlayer::Voice_Control::process_envelope(CPEnvelope *p_envelope,Envelope_Control *p_envelope_ctrl) {
-
- if (!p_envelope_ctrl->active)
- return false;
-
- if (note_end_flags&END_NOTE_OFF) p_envelope_ctrl->sustain_looping=false;
-
- p_envelope_ctrl->value=p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index);
- if (p_envelope_ctrl->value==CPEnvelope::NO_POINT)
- return false;
-
-
- p_envelope_ctrl->pos_index++;
-
- if (p_envelope_ctrl->sustain_looping) {
-
- if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_sustain_loop_end()).tick_offset) {
-
- p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_sustain_loop_begin()).tick_offset;
- }
-
- } else if (p_envelope_ctrl->looping) {
-
- if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_loop_end()).tick_offset) {
-
- p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_loop_begin()).tick_offset;
- }
-
- }
-
- if (p_envelope_ctrl->pos_index>p_envelope->get_node(p_envelope->get_node_count()-1).tick_offset) {
-
- p_envelope_ctrl->terminated=true;
- p_envelope_ctrl->pos_index=p_envelope->get_node(p_envelope->get_node_count()-1).tick_offset;
- if (p_envelope->get_node(p_envelope->get_node_count()-1).value==0) p_envelope_ctrl->kill=true;
- }
-
- return true;
-}
diff --git a/modules/chibi/cp_player_data_events.cpp b/modules/chibi/cp_player_data_events.cpp
deleted file mode 100644
index 7ec3f1931c..0000000000
--- a/modules/chibi/cp_player_data_events.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_events.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-#include "cp_sample_manager.h"
-#include "stdio.h"
-/*
- setup_voices():
-
-This will go throught all the REAL channels, if it finds a channel
-that needs to be restarted or assigned a new VIRTUAL channel, then it
-will just find one and do it.
-
-*/
-
-
-#define C5FREQ 261.6255653006
-static const int32_t C5FREQ_MIXER = ((int32_t)(C5FREQ*(float)(1<<CPMixer::FREQUENCY_BITS)));
-
-
-void CPPlayer::setup_voices() {
-
- int i,voice_index;
-
-
-
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- voice_index=-1;
-
- if (control.channel[i].note_delay) continue;
-
-
- // check if we need a new empty voice
- if (control.channel[i].kick==KICK_NOTE) {
-
- /* if no channel was cut above, find an empty or quiet channel
- here */
- if ( song->has_instruments() && !control.force_no_nna) {
-
- if (control.channel[i].slave_voice==NULL) { // no slave??
-
- int newchn;
- if ((newchn=find_empty_voice())!=-1) {
-
- control.channel[i].slave_voice_index=newchn;
- control.channel[i].slave_voice=&voice[newchn];
- }
- }
-
- } else {
- if (i<control.max_voices) {
-
- control.channel[i].slave_voice_index=i;
- control.channel[i].slave_voice=&voice[i];
- } else {
- //This is a _DIRTY_ hack, but i cant think a better way.
- control.channel[i].slave_voice_index=control.max_voices-1;
- control.channel[i].slave_voice=&voice[control.max_voices-1];
- }
-
- }
-
-
- /* assign parts of MP_VOICE only done for a KICK_NOTE */
- if ( ( control.channel[i].slave_voice!=NULL ) ) {
-
- voice_index=control.channel[i].slave_voice_index;
- Voice_Control &v=voice[voice_index];
-
- if (v.has_master_channel && (v.master_channel!=NULL) ) {
- // If this voice already has a master channel, make sure to remove the reference to it.
- v.master_channel->slave_voice=NULL;
-
- }
- //notify the voice that the current channel is the master
- v.master_channel=&control.channel[i];
- //set the voice as slave of the current channel
- control.channel[i].slave_voice=&v;
- //master channel index of the voice
- v.master_channel_index=i;
- v.has_master_channel=true;
- }
-
- } else {
- // nope..
- // so if we DO have a slave voice then use it.
- if ( control.channel[i].slave_voice!=NULL ) {
-
- voice_index=control.channel[i].slave_voice_index;
- }
- }
- //assuming this channel has a slave voice..
- if (voice_index>=0) {
-
- // IMPROVE: Code a method for this:
- voice[voice_index].update_info_from_master_channel();
- }
-
- control.channel[i].kick=KICK_NOTHING;
- }
-}
-void CPPlayer::Voice_Control::reset() {
-
- cp_memzero(this,sizeof(*this));
-
- instrument_ptr=NULL;
- sample_ptr=NULL;
- has_master_channel=false;
- instrument_index=-1;
- reverb_send=0;
- chorus_send=0;
- filter.it_cutoff=255;
- filter.it_reso=0;
- display_volume=0;
-
-
-}
-
-void CPPlayer::Channel_Control::reset() {
-
- int prev_gv =channel_global_volume;
- cp_memzero(this,sizeof(*this));
-
- slave_voice=NULL;
- slave_voice_index=255;
-
- mute=false;
- old_note=255;
- real_note=255;
- instrument_index=255;
- filter.it_cutoff=255;
- filter.it_reso=0;
- reverb_send=0;
- chorus_send=0;
- reserved=false;
- carry.maybe=false;
- last_event_usecs=-1;
- channel_global_volume=prev_gv;
-}
-
-void CPPlayer::Voice_Control::update_info_from_master_channel() {
-
- instrument_ptr=master_channel->instrument_ptr;
- sample_ptr=master_channel->sample_ptr;
-
- instrument_index=master_channel->instrument_index;
- sample_index=master_channel->sample_index;
-
- note=master_channel->note;
- output_volume=master_channel->output_volume;
-
- channel_volume=master_channel->channel_volume;
-
- panning=master_channel->panning;
-
- kick=master_channel->kick;
- note_end_flags=master_channel->note_end_flags;
- period=master_channel->period;
-
- volume_envelope_ctrl.active=master_channel->volume_envelope_on;
- panning_envelope_ctrl.active=master_channel->panning_envelope_on;
- pitch_envelope_ctrl.active=master_channel->pitch_envelope_on;
-
-
- NNA_type=master_channel->NNA_type;
- reverb_send=master_channel->reverb_send;
- chorus_send=master_channel->chorus_send;
-
-// last_note_type=master_channel->last_note_type;
-
- sample_start_index=master_channel->sample_start_index;
- filter=master_channel->filter;
-
-}
-
-
-void CPPlayer::update_mixer() {
-
- int tmp_mixer_period;
- int32_t tmp_vibrato_value,tmp_vibrato_depth,tmp_volenv_value;
- uint64_t tmpvol; // 64bits should be the only way to avoid getting notes raped out
- int i;
-
-
- control.voices_used=0;
-
- for (i=0;i<control.max_voices;i++) {
-
-
- int filter_env=-1;
- Voice_Control &v=voice[i];
-
- if ( !((v.kick==KICK_NOTE)||(v.kick==KICK_NOTEOFF)) && !is_voice_active(i))
- continue;
-
- //if voice doesnt have a sample set or size is 0.. forget it
- if ( v.sample_ptr==NULL) continue;
-
-
- //TODO set limits somewhere else
-
- if (v.period<40) {
-
- v.period=40;
-
- } else if (v.period>50000) {
-
- v.period=50000;
- }
-
-
- if ((v.kick==KICK_NOTE)||(v.kick==KICK_NOTEOFF)) {
-
- int real_start_index;
-
- if (v.sample_start_index==-1) {
-
- real_start_index=0;
-
- } else {
-
- real_start_index=v.sample_start_index;
- }
-
- mixer->setup_voice(i,v.sample_ptr->get_sample_data(),real_start_index);
- v.fadeout_volume=1024; //IT Docs it is 1024 internally
- v.auto_vibrato_sweep_pos=0;
-
-
-
- }
-
-
- /* Start Envelopes */
- if ( song->has_instruments() && ((v.kick==KICK_NOTE)||(v.kick==KICK_ENVELOPE))) {
-
-// Voice_Control *carry=0;
-
-
- if (v.has_master_channel && v.master_channel->carry.maybe) {
-
- v.start_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl,&v.master_channel->carry.vol);
- v.start_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl,&v.master_channel->carry.pan);
- v.start_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl,&v.master_channel->carry.pitch);
-
- } else {
-
- v.start_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl,NULL);
- v.start_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl,NULL);
- v.start_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl,NULL);
-
- }
-
-
- }
-
- v.kick=KICK_NOTHING;
-
- if (song->has_instruments()) {
-
- if (!v.process_envelope(v.instrument_ptr->get_volume_envelope(),&v.volume_envelope_ctrl))
- v.volume_envelope_ctrl.value=64;
-
- if (!v.process_envelope(v.instrument_ptr->get_pan_envelope(),&v.panning_envelope_ctrl))
- v.panning_envelope_ctrl.value=0;
-
- if (!v.process_envelope(v.instrument_ptr->get_pitch_filter_envelope(),&v.pitch_envelope_ctrl))
- v.pitch_envelope_ctrl.value=0;
-
-
- if (v.volume_envelope_ctrl.terminated) {
-
- if (v.volume_envelope_ctrl.kill) {
-
- v.fadeout_volume=0;
- } else {
-
- v.note_end_flags|=END_NOTE_FADE;
- }
- }
-
- }
-
- if (song->has_instruments()) {
-
- tmp_volenv_value=v.volume_envelope_ctrl.value;
- } else {
-
- tmp_volenv_value=64;
-
- }
-
- /*printf("fadeout %i\n",(int)v.fadeout_volume);
- printf("channel %i\n",(int)v.channel_volume);
- printf("output %i\n",(int)v.output_volume);
- printf("env %i\n",(int)tmp_volenv_value);
- printf("cgb %i\n",(int)v.master_channel->channel_global_volume);
-*/
-
-
- tmpvol=(uint64_t)v.fadeout_volume; /* max 1024 - 10 bits */
- tmpvol*=(uint64_t)v.channel_volume; /* * max 64 - 6 bits */
- tmpvol*=(uint64_t)v.output_volume; /* * max 256 - 8 bits */
- tmpvol*=(uint64_t)tmp_volenv_value; /* max 64 - 6 bits*/
- tmpvol*=(uint64_t)v.master_channel->channel_global_volume;
- v.display_volume=tmpvol>>22; //volume used for display purposes , 0 -- 256
-
- tmpvol*=(uint64_t)song->get_mixing_volume(); /* max 128 - 7 bits */
- tmpvol*=(uint64_t)control.global_volume; /* max 128 - 7 bits*/
- /* total 10+6+8+6+7+7=44 bits */
-
- tmpvol>>=43; /* Move back to 8 bits range , 44-19+8=43*/
-
- if (tmpvol>CP_VOL_MAX)
- tmpvol=CP_VOL_MAX;
-
- //printf("volume check - fade %i, channel %i, output %i, env %i, mix %i, global %i -- final %i\n",v.fadeout_volume, v.channel_volume,v.output_volume,tmp_volenv_value, song->get_mixing_volume(),control.global_volume,tmpvol);
-
- v.total_volume=tmpvol;
-
-
- if ((v.master_channel!=NULL) && song->is_channel_mute( v.master_channel_index ) && !v.master_channel->reserved) {
-
- mixer->set_voice_volume(i,0);
- } else {
- mixer->set_voice_volume(i,tmpvol);
- if (v.fadeout_volume>0) control.voices_used++;
- }
-
-
- if (!song->is_stereo()) {
-
- mixer->set_voice_panning(i,PAN_CENTER);
-
- } else if (v.panning==PAN_SURROUND) {
-
- mixer->set_voice_panning(i,PAN_SURROUND);
- } else if (song->has_instruments()) {
-
- int newpan,real_modifier;
-
-
- real_modifier=(v.panning_envelope_ctrl.value*(PAN_CENTER-cp_intabs(v.panning-PAN_CENTER)))/32;
-
- newpan=v.panning+real_modifier;
-
- newpan=(newpan<PAN_LEFT)?PAN_LEFT:(newpan>PAN_RIGHT)?PAN_RIGHT:newpan;
- //printf("panenv val: %i, finalpan val %i\n",v.panning_envelope_ctrl.value,newpan);
-
- mixer->set_voice_panning(i,newpan);
- } else {
- mixer->set_voice_panning(i,v.panning);
- }
-
-
-
- /* VIBRATO */
-
- if ( (v.period>0) && (v.sample_ptr->get_vibrato_depth()>0) ) {
-
- switch (v.sample_ptr->get_vibrato_type()) {
- case CPSample::VIBRATO_SINE:
- tmp_vibrato_value=auto_vibrato_table[v.auto_vibrato_pos&127];
- if (v.auto_vibrato_pos & 0x80) tmp_vibrato_value=-tmp_vibrato_value;
- break;
- case CPSample::VIBRATO_SQUARE:
- tmp_vibrato_value=64;
- if (v.auto_vibrato_pos & 0x80) tmp_vibrato_value=-tmp_vibrato_value;
- break;
- case CPSample::VIBRATO_SAW:
- tmp_vibrato_value=63-(((v.auto_vibrato_pos+128)&255)>>1);
- break;
- default:
- tmp_vibrato_value=(((v.auto_vibrato_pos+128)&255)>>1)-64;
- break;
- }
- } else {
-
- tmp_vibrato_value=0;
- }
-
- if ((v.auto_vibrato_sweep_pos>>8)<v.sample_ptr->get_vibrato_depth()) {
-
- v.auto_vibrato_sweep_pos+=v.sample_ptr->get_vibrato_speed(); //FIXME - speed? i think so
- tmp_vibrato_depth=v.auto_vibrato_sweep_pos;
-
- } else {
-
- tmp_vibrato_depth=v.sample_ptr->get_vibrato_depth()<<8;
- }
-
- tmp_vibrato_value=(tmp_vibrato_value*tmp_vibrato_depth)>>16;
- if (song->has_linear_slides())
- tmp_vibrato_value>>=1;
- v.period-=tmp_vibrato_value;
-
-
- /* update vibrato position */
- v.auto_vibrato_pos=(v.auto_vibrato_pos+v.sample_ptr->get_vibrato_rate())&0xff;
-
-
- /* process pitch envelope */
- tmp_mixer_period=v.period;
-
- if (v.pitch_envelope_ctrl.active) {
-
- long aux_pitch_diff;
- int pe_value=v.pitch_envelope_ctrl.value;
-
- if (!v.instrument_ptr->is_pitch_use_as_filter()) {
-
-
- if (((uint16_t)v.note<<1)+pe_value<=0)
- pe_value=-(v.note<<1);
-
- int smp_c5=CPSampleManager::get_singleton()->get_c5_freq( v.sample_ptr->get_sample_data());
-
- int base=get_period(((uint16_t)v.note<<1),smp_c5);
- int env=get_period(((uint16_t)v.note<<1)+pe_value,smp_c5);
- /*
- int env_next=(pe_value<0)?get_period(((uint16_t)(v.note-1)<<1)+pe_value,smp_c5):get_period(((uint16_t)(v.note+1)<<1)+pe_value,smp_c5);
-
- env=env+(abs(v.pitch_envelope_ctrl.value)&((1<<CPEnvelope::FX_HEIGHT_BITS)-1))*(env_next-env)/(1<<CPEnvelope::FX_HEIGHT_BITS);
-
- printf("env %i\n",env);
- */
- aux_pitch_diff=env-base;
-
-
- if ( ((int)tmp_mixer_period-aux_pitch_diff)<0 ) aux_pitch_diff=0;
-
- tmp_mixer_period+=aux_pitch_diff;
-
- } else {
-
- filter_env=pe_value+32; //max 64
-// printf("pitch envelope at %i",filter_env);
-
- }
- }
-
- if (v.fadeout_volume==0 || (v.note_end_flags & END_NOTE_KILL)) { /* check for a dead note (fadevol=0) */
-
- mixer->stop_voice(i);
-
- } else {
-
-
- int32_t freq=get_frequency(tmp_mixer_period);
- int32_t tracker_c5=get_frequency(get_period(60<<1,CPSampleManager::get_singleton()->get_c5_freq( v.sample_ptr->get_sample_data())));
-
- freq=(int32_t)((uint64_t)freq*(uint64_t)C5FREQ_MIXER/(uint64_t)tracker_c5); //numbers may become very high
- mixer->set_voice_frequency(i,freq);
-
- /* if keyfade, start substracting fadeoutspeed from fadevol: */
- if ((song->has_instruments())&&(v.note_end_flags & END_NOTE_FADE)) {
-
- if (v.fadeout_volume>=(v.instrument_ptr->get_volume_fadeout())) {
-
- v.fadeout_volume-=(v.instrument_ptr->get_volume_fadeout());
- } else {
-
- v.fadeout_volume=0;
- }
- }
-
- /*FILTARSSSSSSSS*/
-
-
-
- v.filter.envelope_cutoff=filter_env;
- v.filter.process();
-
- if ((v.filter.final_cutoff<0xFF) && (control.filters)) {
-
- //int final_cutoff;
- //uint8_t final_reso;
-
- //v.filter.set_filter_parameters( &final_cutoff, &final_reso );
-
- mixer->set_voice_filter(i,true,v.filter.final_cutoff,v.filter.it_reso);
- } else {
-
-
- mixer->set_voice_filter(i,false,0,0);
- }
-
- /* RAIVERV */
-
- mixer->set_voice_reverb_send(i,v.reverb_send);
-
- /* CHAURUZ */
-
- mixer->set_voice_chorus_send(i,v.chorus_send);
-
- }
- }
-
-
- switch(song->get_reverb_mode()) {
-
- case CPSong::REVERB_MODE_ROOM: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_ROOM );
- } break;
- case CPSong::REVERB_MODE_STUDIO_SMALL: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_SMALL );
-
- } break;
- case CPSong::REVERB_MODE_STUDIO_MEDIUM: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_MEDIUM );
-
- } break;
- case CPSong::REVERB_MODE_STUDIO_LARGE: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_STUDIO_LARGE );
-
- } break;
- case CPSong::REVERB_MODE_HALL: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_HALL );
-
- } break;
- case CPSong::REVERB_MODE_SPACE_ECHO: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_SPACE_ECHO );
-
- } break;
- case CPSong::REVERB_MODE_ECHO: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_ECHO );
-
- } break;
- case CPSong::REVERB_MODE_DELAY: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_DELAY );
-
- } break;
- case CPSong::REVERB_MODE_HALF_ECHO: {
-
- mixer->set_reverb_mode( CPMixer::REVERB_MODE_HALF_ECHO );
-
- } break;
-
- }
-
- mixer->set_chorus_params(song->get_chorus_delay_ms(),song->get_chorus_separation_ms(),song->get_chorus_depth_ms10(),song->get_chorus_speed_hz10() );
-
-
-}
-
-
-
-
-
-
-
-
-void CPPlayer::handle_tick() {
-
- int i;
-
-
- if ( mixer==NULL ) return;
- if ( song==NULL ) return;
-
-
- /* update time counter (sngtime is in milliseconds (in fact 2^-10)) */
-
- if (control.ticks_counter>=control.speed) { // time to process... ***THE ROW***!
-
- /* process pattern-delay. pf->patdly2 is the counter and pf->patdly is
- the command memory. */
-
-// if (control.pattern_delay_1) {
-
-// control.pattern_delay_2=control.pattern_delay_1;
-// control.pattern_delay_1=0;
-// }
-// if (control.pattern_delay_2) {
-// patterndelay active
-// if (--control.pattern_delay_2)
-// so turn back pf->patpos by 1
-// if (pf->patpos) pf->patpos--;
-// }
-
- if (control.play_mode!=PLAY_NOTHING) {
-
- control.ticks_counter=0;
-
-
- if (control.position.force_next_order>=0) {
-
- control.position.current_order=control.position.force_next_order;
- }
-
- control.position.force_next_order=-1;
-
- control.previous_position=control.position; // for those special cases...
- control.position.forbid_jump=false;
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- process_note(i,song->get_pattern(control.position.current_pattern)->get_note(i,control.position.current_row));
- }
-
- control.position.current_row++;
-
- if ( control.position.current_row>=song->get_pattern(control.position.current_pattern)->get_length() ) {
-
- if (control.play_mode==PLAY_SONG) {
-
- int next_order;
-
- next_order=get_song_next_order_idx(song,control.position.current_order);
-
- if (next_order!=-1) {
- // Do we have a "next order?"
- control.position.current_pattern=song->get_order(next_order);
- if (next_order<=control.position.current_order)
- control.reached_end=true;
- control.position.current_order=next_order;
-
- } else {
- // no, probably the user deleted the orderlist.
- control.play_mode=PLAY_NOTHING;
- reset();
- control.reached_end=true;
- }
- }
- control.position.current_row=0;
- }
-
- }
-
-
- }
-
-
-
- pre_process_effects();
- process_NNAs();
- setup_voices();
-
- /* now set up the actual hardware channel playback information */
- update_mixer();
-
- control.ticks_counter++;
-}
diff --git a/modules/chibi/cp_player_data_filter.cpp b/modules/chibi/cp_player_data_filter.cpp
deleted file mode 100644
index e04ae126fd..0000000000
--- a/modules/chibi/cp_player_data_filter.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_filter.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-
-static float filter_cutoff[256] = {
- 130, 132, 134, 136, 138, 140, 142, 144,
- 146, 148, 151, 153, 155, 157, 160, 162,
- 164, 167, 169, 172, 174, 177, 179, 182,
- 184, 187, 190, 193, 195, 198, 201, 204,
- 207, 210, 213, 216, 220, 223, 226, 229,
- 233, 236, 239, 243, 246, 250, 254, 257,
- 261, 265, 269, 273, 277, 281, 285, 289,
- 293, 297, 302, 306, 311, 315, 320, 324,
- 329, 334, 339, 344, 349, 354, 359, 364,
- 369, 375, 380, 386, 391, 397, 403, 409,
- 415, 421, 427, 433, 440, 446, 452, 459,
- 466, 472, 479, 486, 493, 501, 508, 515,
- 523, 530, 538, 546, 554, 562, 570, 578,
- 587, 595, 604, 613, 622, 631, 640, 649,
- 659, 668, 678, 688, 698, 708, 718, 729,
- 739, 750, 761, 772, 783, 795, 806, 818,
- 830, 842, 854, 867, 880, 892, 905, 918,
- 932, 945, 959, 973, 987, 1002, 1016, 1031,
- 1046, 1061, 1077, 1092, 1108, 1124, 1141, 1157,
- 1174, 1191, 1209, 1226, 1244, 1262, 1280, 1299,
- 1318, 1337, 1357, 1376, 1396, 1417, 1437, 1458,
- 1479, 1501, 1523, 1545, 1567, 1590, 1613, 1637,
- 1661, 1685, 1709, 1734, 1760, 1785, 1811, 1837,
- 1864, 1891, 1919, 1947, 1975, 2004, 2033, 2062,
- 2093, 2123, 2154, 2185, 2217, 2249, 2282, 2315,
- 2349, 2383, 2418, 2453, 2489, 2525, 2561, 2599,
- 2637, 2675, 2714, 2753, 2793, 2834, 2875, 2917,
- 2959, 3003, 3046, 3091, 3135, 3181, 3227, 3274,
- 3322, 3370, 3419, 3469, 3520, 3571, 3623, 3675,
- 3729, 3783, 3838, 3894, 3951, 4008, 4066, 4125,
- 4186, 4246, 4308, 4371, 4434, 4499, 4564, 4631,
- 4698, 4766, 4836, 4906, 4978, 5050, 5123, 5198
-};
-
-
-void CPPlayer::Filter_Control::process() {
-
-
- final_cutoff=it_cutoff;
- if (envelope_cutoff>=0) {
-
- envelope_cutoff=envelope_cutoff*255/64;
- final_cutoff=final_cutoff*envelope_cutoff/255;
- if (final_cutoff>=0xFF) final_cutoff=0xFE;
-
- }
-
-}
-
-void CPPlayer::Filter_Control::set_filter_parameters(int *p_cutoff,uint8_t *p_reso) {
-
-
-
- *p_cutoff=filter_cutoff[final_cutoff];
- *p_reso=it_reso;
-}
diff --git a/modules/chibi/cp_player_data_nna.cpp b/modules/chibi/cp_player_data_nna.cpp
deleted file mode 100644
index 3c50bfb01f..0000000000
--- a/modules/chibi/cp_player_data_nna.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_nna.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-
-void CPPlayer::process_NNAs() {
-
- int i;
-
- if (!song->has_instruments()) return;
-
- for (i=0;i<CPPattern::WIDTH;i++) {
-
- Channel_Control *aux_chn_ctrl = &control.channel[i];
-
- if (aux_chn_ctrl->kick==KICK_NOTE) {
-
- bool k=false;
-
- if (aux_chn_ctrl->slave_voice!=NULL) {
-
- Voice_Control *aux_voc_ctrl;
-
- aux_voc_ctrl=aux_chn_ctrl->slave_voice;
-
- if (aux_chn_ctrl->instrument_index==aux_chn_ctrl->slave_voice->instrument_index) { //maybe carry
-
- aux_chn_ctrl->carry.pan=aux_chn_ctrl->slave_voice->panning_envelope_ctrl;
- aux_chn_ctrl->carry.vol=aux_chn_ctrl->slave_voice->volume_envelope_ctrl;
- aux_chn_ctrl->carry.pitch=aux_chn_ctrl->slave_voice->pitch_envelope_ctrl;
- aux_chn_ctrl->carry.maybe=true;
- } else
- aux_chn_ctrl->carry.maybe=false;
-
- if (aux_voc_ctrl->NNA_type != CPInstrument::NNA_NOTE_CUT) {
- /* Make sure the old MP_VOICE channel knows it has no
- master now ! */
-
-
-
- aux_chn_ctrl->slave_voice=NULL;
- /* assume the channel is taken by NNA */
- aux_voc_ctrl->has_master_channel=false;
-
- switch (aux_voc_ctrl->NNA_type) {
- case CPInstrument::NNA_NOTE_CONTINUE: {
-
- } break;
- case CPInstrument::NNA_NOTE_OFF: {
-
-
- aux_voc_ctrl->note_end_flags|=END_NOTE_OFF;
-
- if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_voc_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) {
- aux_voc_ctrl->note_end_flags|=END_NOTE_FADE;
- }
- } break;
- case CPInstrument::NNA_NOTE_FADE: {
-
- aux_voc_ctrl->note_end_flags|=END_NOTE_FADE;
- } break;
- }
- }
- }
-
- if (aux_chn_ctrl->duplicate_check_type!=CPInstrument::DCT_DISABLED) {
- int i;
-
- for (i=0;i<control.max_voices;i++) {
- if (!mixer->is_voice_active(i)||
- (voice[i].master_channel!=aux_chn_ctrl) ||
- (aux_chn_ctrl->instrument_index!=voice[i].instrument_index))
- continue;
-
- Voice_Control *aux_voc_ctrl;
-
- aux_voc_ctrl=&voice[i];
-
- k=false;
- switch (aux_chn_ctrl->duplicate_check_type) {
- case CPInstrument::DCT_NOTE:
- if (aux_chn_ctrl->note==aux_voc_ctrl->note)
- k=true;
- break;
- case CPInstrument::DCT_SAMPLE:
- if (aux_chn_ctrl->sample_ptr==aux_voc_ctrl->sample_ptr)
- k=true;
- break;
- case CPInstrument::DCT_INSTRUMENT:
- k=true;
- break;
- }
- if (k) {
- switch (aux_chn_ctrl->duplicate_check_action) {
- case CPInstrument::DCA_NOTE_CUT: {
- aux_voc_ctrl->fadeout_volume=0;
- } break;
- case CPInstrument::DCA_NOTE_OFF: {
-
- aux_voc_ctrl->note_end_flags|=END_NOTE_OFF;
-
- if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_chn_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) {
-
- aux_voc_ctrl->note_end_flags|=END_NOTE_FADE;
- }
-
- } break;
- case CPInstrument::DCA_NOTE_FADE: {
- aux_voc_ctrl->note_end_flags|=END_NOTE_FADE;
- } break;
- }
- }
- }
-
- }
- } /* if (aux_chn_ctrl->kick==KICK_NOTE) */
- }
-}
diff --git a/modules/chibi/cp_player_data_notes.cpp b/modules/chibi/cp_player_data_notes.cpp
deleted file mode 100644
index 1bfe24bc20..0000000000
--- a/modules/chibi/cp_player_data_notes.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_notes.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-#include "cp_sample_manager.h"
-
-#define RANDOM_MAX 2147483647
-
-static inline int32_t cp_random_generate(int32_t *seed) {
- int32_t k;
- int32_t s = (int32_t)(*seed);
- if (s == 0)
- s = 0x12345987;
- k = s / 127773;
- s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
- s += 2147483647;
- (*seed) = (int32_t)s;
- return (int32_t)(s & RANDOM_MAX);
-}
-
-
-void CPPlayer::process_new_note(int p_track,uint8_t p_note) { // if there's really a new note....
-
- if (control.channel[p_track].real_note!=255) {
- control.channel[p_track].old_note=control.channel[p_track].real_note;
-
- }
-
- control.channel[p_track].real_note=p_note;
-
- control.channel[p_track].kick=KICK_NOTE;
-
- control.channel[p_track].sample_start_index=-1;
- control.channel[p_track].sliding=0;
- control.channel[p_track].row_has_note=true;
- control.channel[p_track].last_event_usecs=song_usecs;
-
- if (control.channel[p_track].panbrello_type) control.channel[p_track].panbrello_position=0;
-}
-
-bool CPPlayer::process_new_instrument(int p_track,uint8_t p_instrument) {
-
-// bool different_instrument=false;
- ERR_FAIL_INDEX_V(p_instrument,CPSong::MAX_INSTRUMENTS,false);
-
- if ( song->has_instruments() ) {
-
-
- control.channel[p_track].instrument_ptr=song->get_instrument(p_instrument);
- } else {
-
- control.channel[p_track].instrument_ptr=NULL;
- }
-
- control.channel[p_track].retrig_counter=0;
- control.channel[p_track].tremor_position=0;
- control.channel[p_track].sample_offset_fine=0;
- int old_instr_index=control.channel[p_track].instrument_index;
- control.channel[p_track].instrument_index=p_instrument;
-
- return (old_instr_index!=p_instrument);
-
-
-}
-
-
- // returns if it was able to process
-bool CPPlayer::process_note_and_instrument(int p_track,int p_note,int p_instrument) {
-
- bool aux_result;
- aux_result=false;
- CPSample *aux_sample=0; // current sample
- int dest_sample_index;
- bool new_instrument=false;
-
- control.channel[p_track].row_has_note=false; // wise man says.. "we dont have a note... until we really know we have a note".
- control.channel[p_track].new_instrument=false;
-
- if ( (p_note<0) && (p_instrument<0) ) return aux_result; // nothing to do here
- if ( (p_note==255) && (p_instrument==255) ) return aux_result;
-
- if ( (p_note>=0) && (p_note<120) ) {
-
- process_new_note(p_track,p_note);
-
- } else if (p_note==CPNote::CUT) {
-
- control.channel[p_track].aux_volume=0;
- control.channel[p_track].note_end_flags|=END_NOTE_OFF;
- control.channel[p_track].note_end_flags|=END_NOTE_KILL;
- return aux_result;
-
- } else if ((p_note==CPNote::OFF) && (song->has_instruments())) {
-
- if (control.channel[p_track].instrument_ptr!=NULL) {
-
- control.channel[p_track].note_end_flags|=END_NOTE_OFF;
-
- if (!control.channel[p_track].instrument_ptr->get_volume_envelope()->is_enabled() || control.channel[p_track].instrument_ptr->get_volume_envelope()->is_loop_enabled()) {
-
- control.channel[p_track].note_end_flags|=END_NOTE_FADE;
- }
- }
-
- return aux_result;
- } else return aux_result; // invalid note!
-
-
- if ( (p_instrument>=0) && (p_instrument<CPSong::MAX_INSTRUMENTS)) {
- new_instrument=process_new_instrument(p_track,p_instrument);
-
- if ( song->has_instruments() ) {
- // If we're in instrument mode...
- if ( control.channel[p_track].instrument_ptr->get_sample_number(control.channel[p_track].real_note) >= CPSong::MAX_SAMPLES) {
-
- control.channel[p_track].kick=KICK_NOTHING;
- return aux_result;
-
- } else {
- dest_sample_index=control.channel[p_track].instrument_ptr->get_sample_number(control.channel[p_track].real_note);
- control.channel[p_track].note=control.channel[p_track].instrument_ptr->get_note_number(control.channel[p_track].real_note);
- }
-
- } else {
- // If we're in sample mode...
- dest_sample_index=control.channel[p_track].instrument_index;
- control.channel[p_track].note=control.channel[p_track].real_note;
- }
-
- control.channel[p_track].sample_index=dest_sample_index;
- aux_sample=song->get_sample(dest_sample_index);
-
- if (!CPSampleManager::get_singleton()->check( aux_sample->get_sample_data() )) {
- /* INVALID SAMPLE */
- control.channel[p_track].kick=KICK_NOTHING;
- return aux_result;
-
- }
-
- aux_sample=song->get_sample(dest_sample_index);
- } else {
-
-
- if (!control.channel[p_track].sample_ptr)
- return aux_result;
-
- if (song->has_instruments()) {
-
- if (!control.channel[p_track].instrument_ptr)
- return aux_result;
-
- control.channel[p_track].note=control.channel[p_track].instrument_ptr->get_note_number(control.channel[p_track].real_note);
-
- } else {
-
- control.channel[p_track].note=control.channel[p_track].real_note;
-
- }
-
- aux_sample=control.channel[p_track].sample_ptr;
-
- }
-
-
-
- if (p_instrument>=CPSong::MAX_INSTRUMENTS && control.channel[p_track].sample_ptr!=aux_sample) {
-
- control.channel[p_track].new_instrument=(control.channel[p_track].period>0);
- }
-
- control.channel[p_track].sample_ptr=aux_sample;
-
- /* channel or instrument determined panning ? */
-
- control.channel[p_track].panning=control.channel[p_track].channel_panning;
-
- /* set filter,if any ? */
-
-
- if (aux_sample->is_pan_enabled()) {
-
- control.channel[p_track].panning=(int)aux_sample->get_pan()*255/64;
-
- } else if ( song->has_instruments() && (control.channel[p_track].instrument_ptr->is_pan_default_enabled()) ) {
-
- control.channel[p_track].panning=(int)control.channel[p_track].instrument_ptr->get_pan_default_amount()*255/64;
- }
-
-
- if (song->has_instruments()) {
-
-
- /* Pitch-Pan Separation */
- if ((control.channel[p_track].instrument_ptr->get_pan_pitch_separation()!=0) && (control.channel[p_track].channel_panning!=PAN_SURROUND)){
-
- control.channel[p_track].panning+=((control.channel[p_track].real_note-control.channel[p_track].instrument_ptr->get_pan_pitch_center())*control.channel[p_track].instrument_ptr->get_pan_pitch_separation())/8;
-
- if (control.channel[p_track].panning<PAN_LEFT) control.channel[p_track].panning=PAN_LEFT;
- if (control.channel[p_track].panning>PAN_RIGHT) control.channel[p_track].panning=PAN_RIGHT;
- }
-
- /* Random Volume Variation */
- if (control.channel[p_track].instrument_ptr->get_volume_random_variation()>0) {
-
- control.channel[p_track].random_volume_variation=100-(cp_random_generate(&control.random_seed) % control.channel[p_track].instrument_ptr->get_volume_random_variation());
-
- } else {
-
- control.channel[p_track].random_volume_variation=100;
- }
-
-
- /* Random Pan Variation */
- if ((control.channel[p_track].instrument_ptr->get_pan_random_variation()>0) && (control.channel[p_track].panning!=PAN_SURROUND)){
-
- int aux_pan_modifier;
-
- aux_pan_modifier=(cp_random_generate(&control.random_seed) % (control.channel[p_track].instrument_ptr->get_pan_random_variation() << 2));
- if ((cp_random_generate(&control.random_seed) % 2)==1) aux_pan_modifier=0-aux_pan_modifier; /* it's 5am, let me sleep :) */
-
- control.channel[p_track].panning+=aux_pan_modifier;
-
- if (control.channel[p_track].panning<PAN_LEFT) control.channel[p_track].panning=PAN_LEFT;
- if (control.channel[p_track].panning>PAN_RIGHT) control.channel[p_track].panning=PAN_RIGHT;
-
-
- }
-
- /*filter*/
-
- if (control.channel[p_track].instrument_ptr->filter_use_default_cutoff()) {
-
- control.channel[p_track].filter.it_cutoff=control.channel[p_track].instrument_ptr->get_filter_default_cutoff()*2;
-
- }
-
- if (control.channel[p_track].instrument_ptr->filter_use_default_resonance()) {
-
- control.channel[p_track].filter.it_reso=control.channel[p_track].instrument_ptr->get_filter_default_resonance()*2;
-
- }
-
- /*envelopes*/
-
-
- control.channel[p_track].volume_envelope_on=control.channel[p_track].instrument_ptr->get_volume_envelope()->is_enabled();
- control.channel[p_track].panning_envelope_on=control.channel[p_track].instrument_ptr->get_pan_envelope()->is_enabled();
- control.channel[p_track].pitch_envelope_on=control.channel[p_track].instrument_ptr->get_pitch_filter_envelope()->is_enabled();
- control.channel[p_track].NNA_type=control.channel[p_track].instrument_ptr->get_NNA_type();
- control.channel[p_track].duplicate_check_type=control.channel[p_track].instrument_ptr->get_DC_type();
- control.channel[p_track].duplicate_check_action=control.channel[p_track].instrument_ptr->get_DC_action();
-
-
- } else {
-
- control.channel[p_track].NNA_type=CPInstrument::NNA_NOTE_CUT;
- control.channel[p_track].duplicate_check_type=CPInstrument::DCT_DISABLED;
- control.channel[p_track].duplicate_check_action=CPInstrument::DCA_NOTE_CUT;
- }
-
-
- if (p_instrument<CPSong::MAX_INSTRUMENTS) { // instrument change
-
- control.channel[p_track].volume=control.channel[p_track].aux_volume=aux_sample->get_default_volume();
-
- }
-
-
- control.channel[p_track].slide_to_period=control.channel[p_track].aux_period=get_period((uint16_t)(control.channel[p_track].note)<<1,CPSampleManager::get_singleton()->get_c5_freq( (aux_sample->get_sample_data())));
-
- control.channel[p_track].note_end_flags=END_NOTE_NOTHING; /* clears flags */
-
- return true;
-}
-
-void CPPlayer::process_volume_column(int p_track,uint8_t p_volume) {
-
- control.channel[p_track].current_volume_command=CPNote::EMPTY;
- control.channel[p_track].current_volume_parameter=CPNote::EMPTY;
-
- if (p_volume<65) { // VOLUME
-
- control.channel[p_track].aux_volume=p_volume;
- } else if (p_volume<125) { // Volume Command
-
-
- control.channel[p_track].current_volume_command=(p_volume-65) / 10;
- control.channel[p_track].current_volume_parameter=(p_volume-65) % 10;
- } else if (p_volume<193) { // PAN
-
- control.channel[p_track].channel_panning=(p_volume-128)*PAN_RIGHT/64;
- control.channel[p_track].panning=control.channel[p_track].channel_panning;
-
- } else if (p_volume<213) { //More volume Commands
-
- control.channel[p_track].current_volume_command=((p_volume-193) / 10)+6;
- control.channel[p_track].current_volume_parameter=(p_volume-193) % 10;
- }
-}
-
-
-void CPPlayer::process_note(int p_track,CPNote p_note) {
-
- if ( p_note.note!=CPNote::SCRIPT ) {
-
- process_note_and_instrument(p_track,p_note.note,p_note.instrument);
- process_volume_column(p_track,p_note.volume);
- control.channel[p_track].current_command=p_note.command;
- control.channel[p_track].current_parameter=p_note.parameter;
-
- } else {
-
- CPNote n = song->get_pattern( control.position.current_pattern )->get_transformed_script_note( p_track, control.position.current_row );
- process_note( p_track, n );
-
- song->get_pattern( control.position.current_pattern )->scripted_clone( p_track, control.position.current_row );
- }
-}
diff --git a/modules/chibi/cp_player_data_utils.cpp b/modules/chibi/cp_player_data_utils.cpp
deleted file mode 100644
index 1ee3f30b33..0000000000
--- a/modules/chibi/cp_player_data_utils.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*************************************************************************/
-/* cp_player_data_utils.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_player_data.h"
-uint8_t CPPlayer::vibrato_table[32]={
- 0, 24, 49, 74, 97,120,141,161,180,197,212,224,235,244,250,253,
- 255,253,250,244,235,224,212,197,180,161,141,120, 97, 74, 49, 24
-};
-
-uint8_t CPPlayer::auto_vibrato_table[128]={
- 0, 1, 3, 4, 6, 7, 9,10,12,14,15,17,18,20,21,23,
- 24,25,27,28,30,31,32,34,35,36,38,39,40,41,42,44,
- 45,46,47,48,49,50,51,52,53,54,54,55,56,57,57,58,
- 59,59,60,60,61,61,62,62,62,63,63,63,63,63,63,63,
- 64,63,63,63,63,63,63,63,62,62,62,61,61,60,60,59,
- 59,58,57,57,56,55,54,54,53,52,51,50,49,48,47,46,
- 45,44,42,41,40,39,38,36,35,34,32,31,30,28,27,25,
- 24,23,21,20,18,17,15,14,12,10, 9, 7, 6, 4, 3, 1
-};
-
-
-int8_t CPPlayer::panbrello_table[256]={
- 0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23,
- 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59,
- 59, 60, 60, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 64, 64,
- 64, 64, 64, 64, 64, 64, 63, 63, 63, 62, 62, 62, 61, 61, 60, 60,
- 59, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46,
- 45, 44, 43, 42, 41, 39, 38, 37, 36, 34, 33, 32, 30, 29, 27, 26,
- 24, 23, 22, 20, 19, 17, 16, 14, 12, 11, 9, 8, 6, 5, 3, 2,
- 0,- 2,- 3,- 5,- 6,- 8,- 9,-11,-12,-14,-16,-17,-19,-20,-22,-23,
- -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44,
- -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59,
- -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64,
- -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60,
- -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46,
- -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26,
- -24,-23,-22,-20,-19,-17,-16,-14,-12,-11,- 9,- 8,- 6,- 5,- 3,- 2
-};
-
-
-
-
-
-
-int32_t CPPlayer::get_period(uint16_t p_note,int32_t p_c5speed) {
-
- if (song->has_linear_slides()) {
-
- return CPTables::get_linear_period(p_note,0);
- } else {
-
-
- return CPTables::get_log_period(p_note>>1,p_c5speed >>1);
- }
-}
-
-
-int32_t CPPlayer::get_frequency(int32_t period) {
-
- if (song->has_linear_slides()) {
-
- return CPTables::get_linear_frequency(period);
- } else {
-
- return CPTables::get_old_frequency(period);
- }
-}
-
-int CPPlayer::find_empty_voice() {
-
- int i;
- int min_priority,min_priority_chan=0,priority;
-
- for (i=0;i<control.max_voices;i++) {
-
- if ( ((voice[i].kick==KICK_NOTHING)||(voice[i].kick==KICK_ENVELOPE))&&!mixer->is_voice_active(i) ) {
-
- return i;
-
- }
- }
-
- // todo more
-
- for (i=0;i<control.max_voices;i++) {
- /* allow us to take over a nonexisting sample */
-// if ((voice[i].s==NULL)
-// return k;
-
- if ((voice[i].kick==KICK_NOTHING)||(voice[i].kick==KICK_ENVELOPE)) {
-
- priority=voice[i].total_volume<<((CPSampleManager::get_singleton()->get_loop_type( voice[i].sample_ptr->get_sample_data())!=CP_LOOP_NONE)?1:0);
-
- if ((voice[i].has_master_channel)&&(&voice[i]==voice[i].master_channel->slave_voice)) {
-
- priority<<=2;
-
- }
-
- if ((i==0) || (priority<min_priority)) {
- min_priority=priority;
- min_priority_chan=i;
- }
- }
- }
-
- if (min_priority>8000*7) return -1; /* what the fuck is this? */
-
- return min_priority_chan;
-}
-
diff --git a/modules/chibi/cp_sample.cpp b/modules/chibi/cp_sample.cpp
deleted file mode 100644
index bea8835548..0000000000
--- a/modules/chibi/cp_sample.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*************************************************************************/
-/* cp_sample.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_sample.h"
-
-const char * CPSample::get_name() const {
-
- return name;
-}
-void CPSample::set_name(const char *p_name) {
-
- if (p_name==NULL) {
- name[0]=0;
- return;
- }
-
-
- bool done=false;
- for (int i=0;i<NAME_MAX_LEN;i++) {
-
-
- name[i]=done?0:p_name[i];
- if (!done && p_name[i]==0)
- done=true;
- }
-
- name[NAME_MAX_LEN-1]=0; /* just in case */
-
-}
-
-void CPSample::set_default_volume(uint8_t p_vol) {
-
- default_volume=p_vol;
-}
-uint8_t CPSample::get_default_volume() const{
-
- return default_volume;
-}
-
-void CPSample::set_global_volume(uint8_t p_vol) {
-
- global_volume=p_vol;
-}
-uint8_t CPSample::get_global_volume() const{
-
- return global_volume;
-}
-
-void CPSample::set_pan_enabled(bool p_vol) {
-
- pan_enabled=p_vol;
-}
-bool CPSample::is_pan_enabled() const{
-
- return pan_enabled;
-}
-
-void CPSample::set_pan(uint8_t p_pan) {
-
- pan=p_pan;
-
-}
-uint8_t CPSample::get_pan() const{
-
- return pan;
-}
-
-
-void CPSample::set_vibrato_type(VibratoType p_vibrato_type) {
-
- vibrato_type=p_vibrato_type;
-}
-CPSample::VibratoType CPSample::get_vibrato_type() const{
-
- return vibrato_type;
-}
-
-void CPSample::set_vibrato_speed(uint8_t p_vibrato_speed) {
-
- vibrato_speed=p_vibrato_speed;
-}
-uint8_t CPSample::get_vibrato_speed() const {
-
- return vibrato_speed;
-}
-
-void CPSample::set_vibrato_depth(uint8_t p_vibrato_depth) {
-
- vibrato_depth=p_vibrato_depth;
-}
-uint8_t CPSample::get_vibrato_depth() const{
-
- return vibrato_depth;
-}
-
-void CPSample::set_vibrato_rate(uint8_t p_vibrato_rate) {
-
- vibrato_rate=p_vibrato_rate;
-}
-uint8_t CPSample::get_vibrato_rate() const{
-
- return vibrato_rate;
-}
-
-void CPSample::set_sample_data(CPSample_ID p_ID) {
-
- id=p_ID;
-}
-CPSample_ID CPSample::get_sample_data() const{
-
- return id;
-}
-
-void CPSample::operator=(const CPSample &p_sample) {
-
- copy_from(p_sample);
-}
-void CPSample::copy_from(const CPSample &p_sample) {
-
- reset();
- set_name(p_sample.get_name());
-
- default_volume=p_sample.default_volume;
- global_volume=p_sample.global_volume;
-
- pan_enabled=p_sample.pan_enabled;
- pan=p_sample.pan;
-
- vibrato_type=p_sample.vibrato_type;
- vibrato_speed=p_sample.vibrato_speed;
- vibrato_depth=p_sample.vibrato_depth;
- vibrato_rate=p_sample.vibrato_rate;
-
- if (CPSampleManager::get_singleton() && !p_sample.id.is_null())
- CPSampleManager::get_singleton()->copy_to( p_sample.id, id );
-}
-
-
-
-
-
-void CPSample::reset() {
-
-
- name[0]=0;
-
- default_volume=64;
- global_volume=64;
-
- pan_enabled=false;
- pan=32;
-
- vibrato_type=VIBRATO_SINE;
- vibrato_speed=0;
- vibrato_depth=0;
- vibrato_rate=0;
-
- if (!id.is_null() && CPSampleManager::get_singleton())
- CPSampleManager::get_singleton()->destroy( id );
-
- id=CPSample_ID();
-
-}
-
-CPSample::CPSample(const CPSample&p_from) {
-
- reset();
- copy_from(p_from);
-}
-CPSample::CPSample() {
-
- reset();
-}
-
-CPSample::~CPSample() {
-
- reset();
-}
diff --git a/modules/chibi/cp_sample.h b/modules/chibi/cp_sample.h
deleted file mode 100644
index c02b220c84..0000000000
--- a/modules/chibi/cp_sample.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*************************************************************************/
-/* cp_sample.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CPSAMPLE_H
-#define CPSAMPLE_H
-
-
-#include "cp_config.h"
-#include "cp_sample_manager.h"
-class CPSample {
-
-public:
- enum VibratoType {
- VIBRATO_SINE,
- VIBRATO_SAW,
- VIBRATO_SQUARE,
- VIBRATO_RANDOM
-
- };
-
-private:
-
- enum { NAME_MAX_LEN=26 };
-
- char name[NAME_MAX_LEN];
-
- uint8_t default_volume; /* 0.. 64 */
- uint8_t global_volume; /* 0.. 64 */
-
- bool pan_enabled;
- uint8_t pan; /* 0.. 64 */
-
- VibratoType vibrato_type;
- uint8_t vibrato_speed; /* 0.. 64 */
- uint8_t vibrato_depth; /* 0.. 64 */
- uint8_t vibrato_rate; /* 0.. 64 */
-
- CPSample_ID id;
-
- void copy_from(const CPSample &p_sample);
-public:
-
-
- void operator=(const CPSample &p_sample);
-
- const char * get_name() const;
- void set_name(const char *p_name);
-
- void set_default_volume(uint8_t p_vol);
- uint8_t get_default_volume() const;
-
- void set_global_volume(uint8_t p_vol);
- uint8_t get_global_volume() const;
-
- void set_pan_enabled(bool p_vol);
- bool is_pan_enabled() const;
-
- void set_pan(uint8_t p_pan);
- uint8_t get_pan() const;
-
- void set_vibrato_type(VibratoType p_vibrato_type);
- VibratoType get_vibrato_type() const;
-
- void set_vibrato_speed(uint8_t p_vibrato_speed) ;
- uint8_t get_vibrato_speed() const;
-
- void set_vibrato_depth(uint8_t p_vibrato_depth);
- uint8_t get_vibrato_depth() const;
-
- void set_vibrato_rate(uint8_t p_vibrato_rate);
- uint8_t get_vibrato_rate() const;
-
- void set_sample_data(CPSample_ID);
- CPSample_ID get_sample_data() const;
-
- void reset();
-
- CPSample(const CPSample&p_from);
- CPSample();
- ~CPSample();
-
-};
-
-
-
-
-#endif
diff --git a/modules/chibi/cp_sample_defs.h b/modules/chibi/cp_sample_defs.h
deleted file mode 100644
index 5ae57aed82..0000000000
--- a/modules/chibi/cp_sample_defs.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*************************************************************************/
-/* cp_sample_defs.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_SAMPLE_DEFS_H
-#define CP_SAMPLE_DEFS_H
-
-#include "cp_config.h"
-
-enum CPSample_Loop_Type {
-
- CP_LOOP_NONE,
- CP_LOOP_FORWARD,
- CP_LOOP_BIDI
-};
-
-//#define INVALID_SAMPLE_ID -1
-
-#define CP_MIXING_FRAC_BITS_MACRO 13
-#define CP_MIXING_FRAC_BITS_TEXT "13"
-// 1<<9 - 1
-#define CP_MIXING_FRAC_BITS_MASK_TEXT "8191"
-
-enum CPMixConstants {
- CP_MIXING_FRAC_BITS=CP_MIXING_FRAC_BITS_MACRO,
- CP_MIXING_FRAC_LENGTH=(1<<CP_MIXING_FRAC_BITS),
- CP_MIXING_FRAC_MASK=CP_MIXING_FRAC_LENGTH-1,
- CP_MIXING_VOL_FRAC_BITS=8,
- CP_MIXING_FREQ_FRAC_BITS=8
-};
-
-enum CPFilterConstants {
- CP_FILTER_SHIFT=16,
- CP_FILTER_LENGTH=(1<<CP_FILTER_SHIFT)
-};
-
-
-enum CPInterpolationType {
- CP_INTERPOLATION_RAW,
- CP_INTERPOLATION_LINEAR,
- CP_INTERPOLATION_CUBIC
-};
-
-enum CPPanConstants {
-
- CP_PAN_BITS=8, // 0 .. 256
- CP_PAN_LEFT=0,
- CP_PAN_RIGHT=((1<<CP_PAN_BITS)-1), // 255
- CP_PAN_CENTER=CP_PAN_RIGHT/2, // 128
- CP_PAN_SURROUND=512
-};
-
-enum CPMixerVolConstants {
- CP_VOL_MAX=512,
- CP_VOL_RAMP_BITS=9,
- CP_VOL_SHIFT=2
-
-
-};
-
-enum CPStereoCannels {
- CP_CHAN_LEFT,
- CP_CHAN_RIGHT
-};
-
-#define CP_FIRST_SAMPLE_DECLICK_THRESHOLD 1000
-#define CP_FIRST_SAMPLE_RAMP_LEN 32
-
-typedef signed char CPFrame8;
-typedef signed short CPFrame16;
-
-
-#endif
diff --git a/modules/chibi/cp_sample_manager.h b/modules/chibi/cp_sample_manager.h
deleted file mode 100644
index b6d47a3013..0000000000
--- a/modules/chibi/cp_sample_manager.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*************************************************************************/
-/* cp_sample_manager.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CP_SAMPLE_MANAGER_H
-#define CP_SAMPLE_MANAGER_H
-
-#include "cp_config.h"
-#include "cp_sample_defs.h"
-
-
-
-/**
-@author Juan Linietsky
-*/
-
-
-/* abstract base CPSample_ID class */
-
-struct CPSample_ID {
-
- void *_private;
-
- bool operator==(const CPSample_ID&p_other) const { return _private==p_other._private; }
- bool operator!=(const CPSample_ID&p_other) const { return _private!=p_other._private; }
- bool is_null() const { return _private==0; }
- CPSample_ID(void *p_private=0) { _private=p_private; };
-};
-
-
-class CPSampleManager {
-
- static CPSampleManager * singleton;
-
-public:
-
- /* get the singleton instance */
- static CPSampleManager *get_singleton();
-
- virtual void copy_to(CPSample_ID p_from,CPSample_ID &p_to); ///< if p_to is null, it gets created
-
- virtual CPSample_ID create(bool p_16bits,bool p_stereo,int32_t p_len)=0;
- virtual void recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len)=0;
- virtual void destroy(CPSample_ID p_id)=0;
- virtual bool check(CPSample_ID p_id)=0; // return false if invalid
-
- virtual void set_c5_freq(CPSample_ID p_id,int32_t p_freq)=0;
- virtual void set_loop_begin(CPSample_ID p_id,int32_t p_begin)=0;
- virtual void set_loop_end(CPSample_ID p_id,int32_t p_end)=0;
- virtual void set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type)=0;
- virtual void set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len)=0;
-
-
- virtual int32_t get_loop_begin(CPSample_ID p_id)=0;
- virtual int32_t get_loop_end(CPSample_ID p_id)=0;
- virtual CPSample_Loop_Type get_loop_type(CPSample_ID p_id)=0;
- virtual int32_t get_c5_freq(CPSample_ID p_id)=0;
- virtual int32_t get_size(CPSample_ID p_id)=0;
- virtual bool is_16bits(CPSample_ID p_id)=0;
- virtual bool is_stereo(CPSample_ID p_id)=0;
- virtual bool lock_data(CPSample_ID p_id)=0;
- virtual void *get_data(CPSample_ID p_id)=0; /* WARNING: Not all sample managers
-may be able to implement this, it depends on the mixer in use! */
- virtual int16_t get_data(CPSample_ID p_id, int p_sample, int p_channel=0)=0; /// Does not need locking
- virtual void set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel=0)=0; /// Does not need locking
- virtual void unlock_data(CPSample_ID p_id)=0;
-
- virtual void get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len)=0;
-
- CPSampleManager();
- virtual ~CPSampleManager(){}
-
-};
-
-#endif
diff --git a/modules/chibi/cp_song.cpp b/modules/chibi/cp_song.cpp
deleted file mode 100644
index 197e44f69d..0000000000
--- a/modules/chibi/cp_song.cpp
+++ /dev/null
@@ -1,957 +0,0 @@
-/*************************************************************************/
-/* cp_song.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_song.h"
-
-void CPSong::set_name(const char *p_name) {
-
- if (p_name==NULL) {
- variables.name[0]=0;
- return;
- }
-
-
- bool done=false;
- for (int i=0;i<MAX_SONG_NAME;i++) {
-
-
- variables.name[i]=done?0:p_name[i];
- if (!done && p_name[i]==0)
- done=true;
- }
-
- variables.name[MAX_SONG_NAME-1]=0; /* just in case */
-}
-
-const char * CPSong::get_name() {
-
- return variables.name;
-
-}
-
-void CPSong::set_message(const char *p_message) {
-
- if (p_message==NULL) {
- variables.message[0]=0;
- return;
- }
-
- bool done=false;
- for (int i=0;i<MAX_MESSAGE_LEN;i++) {
-
-
- variables.message[i]=done?0:p_message[i];
- if (!done && p_message[i]==0)
- done=true;
- }
-
- variables.message[MAX_MESSAGE_LEN-1]=0; /* just in case */
-}
-
-const char * CPSong::get_message() {
-
- return variables.message;
-
-}
-
-void CPSong::set_row_highlight_minor(int p_hl_minor) {
-
- variables.row_highlight_minor=p_hl_minor;
-}
-int CPSong::get_row_highlight_minor() {
-
- return variables.row_highlight_minor;
-}
-
-void CPSong::set_row_highlight_major(int p_hl_major) {
-
- variables.row_highlight_major=p_hl_major;
-
-
-} /* 0 .. 256 */
-int CPSong::get_row_highlight_major() {
-
- return variables.row_highlight_major;
-
-
-} /* 0 .. 256 */
-
-void CPSong::set_mixing_volume(int p_mix_volume) {
-
-
- variables.mixing_volume=p_mix_volume;
-} /* 0 .. 128 */
-int CPSong::get_mixing_volume() {
-
- return variables.mixing_volume;
-
-} /* 0 .. 128 */
-
-void CPSong::set_global_volume(int p_global_volume) {
-
-
- initial_variables.global_volume=p_global_volume;
-
-} /* 0 .. 128 */
-int CPSong::get_global_volume() {
-
- return initial_variables.global_volume;
-
-} /* 0 .. 128 */
-
-void CPSong::set_stereo_separation(int p_separation) {
-
- variables.stereo_separation=p_separation;
-
-} /* 0 .. 128 */
-int CPSong::get_stereo_separation() {
-
- return variables.stereo_separation;
-} /* 0 .. 128 */
-
-void CPSong::set_stereo(bool p_stereo) {
-
- variables.use_stereo=p_stereo;
-
-}
-bool CPSong::is_stereo() {
-
- return variables.use_stereo;
-}
-
-void CPSong::set_instruments(bool p_instruments) {
-
- variables.use_instruments=p_instruments;
-
-
-}
-bool CPSong::has_instruments() {
-
-
- return variables.use_instruments;
-
-}
-
-void CPSong::set_linear_slides(bool p_linear_slides) {
-
- variables.use_linear_slides=p_linear_slides;
-
-
-}
-bool CPSong::has_linear_slides() {
-
- return variables.use_linear_slides;
-
-
-}
-
-void CPSong::set_old_effects(bool p_old_effects) {
-
- variables.old_effects=p_old_effects;
-
-
-}
-bool CPSong::has_old_effects() {
-
- return variables.old_effects;
-}
-
-void CPSong::set_compatible_gxx(bool p_compatible_gxx) {
-
-
- variables.compatible_gxx=p_compatible_gxx;
-}
-bool CPSong::has_compatible_gxx() {
-
- return variables.compatible_gxx;
-
-}
-
-void CPSong::set_speed(int p_speed) {
-
- CP_ERR_COND(p_speed<MIN_SPEED);
- CP_ERR_COND(p_speed>MAX_SPEED);
-
- initial_variables.speed=p_speed;
-
-} /* 1 .. 255 */
-int CPSong::get_speed() {
-
- return initial_variables.speed;
-
-} /* 1 .. 255 */
-
-void CPSong::set_tempo(int p_tempo) {
-
- CP_ERR_COND( p_tempo<MIN_TEMPO );
- CP_ERR_COND( p_tempo>MAX_TEMPO );
-
- initial_variables.tempo=p_tempo;
-
-} /* MIN_TEMPO .. MAX_TEMPO */
-int CPSong::get_tempo() {
-
- return initial_variables.tempo;
-
-
-} /* MIN_TEMPO .. MAX_TEMPO */
-
-void CPSong::set_channel_pan(int p_channel,int p_pan) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
- CP_FAIL_INDEX(p_pan,CHANNEL_MAX_PAN+1);
-
- initial_variables.channel[p_channel].pan=p_pan;
-
-} /* 0 .. CHANNEL_MAX_PAN */
-int CPSong::get_channel_pan(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1);
-
- return initial_variables.channel[p_channel].pan;
-}
-
-void CPSong::set_channel_volume(int p_channel,int p_volume) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
- CP_FAIL_INDEX(p_volume,CHANNEL_MAX_VOLUME+1);
-
-
- initial_variables.channel[p_channel].volume=p_volume;
-
-
-} /* 0 .. CHANNEL_MAX_VOLUME */
-
-
-int CPSong::get_channel_volume(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1);
-
- return initial_variables.channel[p_channel].volume;
-
-}
-
-void CPSong::set_channel_chorus(int p_channel,int p_chorus) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
- CP_FAIL_INDEX(p_chorus,CHANNEL_MAX_CHORUS+1);
-
-
- initial_variables.channel[p_channel].chorus=p_chorus;
-
-
-} /* 0 .. CHANNEL_MAX_CHORUS */
-
-
-int CPSong::get_channel_chorus(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1);
-
- return initial_variables.channel[p_channel].chorus;
-
-}
-
-void CPSong::set_channel_reverb(int p_channel,int p_reverb) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
- CP_FAIL_INDEX(p_reverb,CHANNEL_MAX_REVERB+1);
-
-
- initial_variables.channel[p_channel].reverb=p_reverb;
-
-
-} /* 0 .. CHANNEL_MAX_CHORUS */
-
-
-int CPSong::get_channel_reverb(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,-1);
-
- return initial_variables.channel[p_channel].reverb;
-
-}
-
-void CPSong::set_channel_surround(int p_channel,bool p_surround) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
- initial_variables.channel[p_channel].surround=p_surround;
-
-}
-bool CPSong::is_channel_surround(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,false);
-
- return initial_variables.channel[p_channel].surround;
-
-
-}
-
-void CPSong::set_channel_mute(int p_channel,bool p_mute) {
-
- CP_FAIL_INDEX(p_channel,CPPattern::WIDTH);
-
- initial_variables.channel[p_channel].mute=p_mute;
-
-}
-bool CPSong::is_channel_mute(int p_channel) {
-
- CP_FAIL_INDEX_V(p_channel,CPPattern::WIDTH,false);
-
- return initial_variables.channel[p_channel].mute;
-
-}
-
-/* arrays of stuff */
-
-CPPattern* CPSong::get_pattern(int p_pattern) {
-
- CP_FAIL_INDEX_V(p_pattern,MAX_PATTERNS, NULL);
-
- return &pattern[p_pattern];
-
-}
-CPSample* CPSong::get_sample(int p_sample) {
-
- CP_FAIL_INDEX_V(p_sample,MAX_SAMPLES,NULL);
-
- return &sample[p_sample];
-
-
-}
-CPInstrument* CPSong::get_instrument(int p_instrument) {
-
-
- CP_FAIL_INDEX_V(p_instrument,MAX_INSTRUMENTS,NULL);
-
- return &instrument[p_instrument];
-
-}
-
-int CPSong::get_order(int p_order) {
-
- CP_FAIL_INDEX_V(p_order,MAX_ORDERS,CP_ORDER_NONE);
-
-
- return order[p_order];
-
-}
-void CPSong::set_order(int p_order,int p_pattern) {
-
- CP_FAIL_INDEX(p_order,MAX_ORDERS);
-
- order[p_order]=p_pattern;
-
-}
-
-
-void CPSong::clear_instrument_with_samples(int p_instrument) {
-
- CPInstrument *ins = get_instrument( p_instrument );
- if (!ins)
- return;
-
- for (int i=0;i<CPNote::NOTES;i++) {
-
- CPSample *s=get_sample( ins->get_sample_number( i ) );
-
- if (!s)
- continue;
-
- if (s->get_sample_data().is_null())
- continue;
-
- s->reset();
- }
- ins->reset();
-}
-
-void CPSong::make_instrument_from_sample(int p_sample) {
-
- if (!has_instruments())
- return;
- CP_ERR_COND(!get_sample( p_sample ));
-
- for (int i=0;i<MAX_INSTRUMENTS;i++) {
-
-
- CPInstrument *ins=get_instrument(i);
-
- bool empty_slot=true;
- for (int n=0;n<CPNote::NOTES;n++) {
-
- if (ins->get_sample_number(n)<MAX_SAMPLES) {
-
- empty_slot=false;
- break;
- }
- }
-
- if (!empty_slot)
- continue;
-
- for (int n=0;n<CPNote::NOTES;n++) {
-
- ins->set_sample_number(n,p_sample);
- ins->set_note_number(n,n);
- }
-
- ins->set_name( get_sample( p_sample )->get_name() );
- break;
- }
-
-}
-
-void CPSong::make_instruments_from_samples() {
-
- for (int i=0;i<MAX_SAMPLES;i++) {
-
- CPInstrument *ins=get_instrument( i );
-
- if (!ins)
- continue;
-
- ins->reset();
-
- CPSample *s=get_sample( i );
-
- if (!s)
- continue;
-
- ins->set_name( s->get_name() );
-
- if (s->get_sample_data().is_null())
- continue;
-
-
-
-
- for(int j=0;j<CPNote::NOTES;j++)
- ins->set_sample_number( j, i );
-
-
-
- }
-}
-
-void CPSong::reset(bool p_clear_patterns,bool p_clear_samples,bool p_clear_instruments,bool p_clear_variables) {
-
- if (p_clear_variables) {
- variables.name[0]=0;
- variables.message[0]=0;
- variables.row_highlight_major=16;
- variables.row_highlight_minor=4;
- variables.mixing_volume=48;
- variables.old_effects=false;
- if (p_clear_instruments) //should not be cleared, if not clearing instruments!!
- variables.use_instruments=false;
- variables.stereo_separation=128;
- variables.use_linear_slides=true;
- variables.use_stereo=true;
-
- initial_variables.global_volume=128;
- initial_variables.speed=6;
- initial_variables.tempo=125;
-
- for (int i=0;i<CPPattern::WIDTH;i++) {
-
- initial_variables.channel[i].pan=32;
- initial_variables.channel[i].volume=CHANNEL_MAX_VOLUME;
- initial_variables.channel[i].mute=false;
- initial_variables.channel[i].surround=false;
- initial_variables.channel[i].chorus=0;
- initial_variables.channel[i].reverb=0;
-
- }
-
- effects.chorus.delay_ms=6;
- effects.chorus.separation_ms=3;
- effects.chorus.depth_ms10=6,
- effects.chorus.speed_hz10=5;
- effects.reverb_mode=REVERB_MODE_ROOM;
- }
-
- if (p_clear_samples) {
- for (int i=0;i<MAX_SAMPLES;i++)
- get_sample(i)->reset();
- }
-
- if (p_clear_instruments) {
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- get_instrument(i)->reset();
- }
-
- if (p_clear_patterns) {
- for (int i=0;i<MAX_PATTERNS;i++)
- get_pattern(i)->clear();
-
- for (int i=0;i<MAX_ORDERS;i++)
- set_order( i, CP_ORDER_NONE );
- }
-
-
-}
-
-
-CPSong::ReverbMode CPSong::get_reverb_mode() {
-
- return effects.reverb_mode;
-}
-void CPSong::set_reverb_mode(ReverbMode p_mode) {
-
- effects.reverb_mode=p_mode;
-}
-
-void CPSong::set_chorus_delay_ms(int p_amount) {
-
- effects.chorus.delay_ms=p_amount;
-}
-void CPSong::set_chorus_separation_ms(int p_amount) {
-
- effects.chorus.separation_ms=p_amount;
-
-}
-void CPSong::set_chorus_depth_ms10(int p_amount) {
-
- effects.chorus.depth_ms10=p_amount;
-
-}
-void CPSong::set_chorus_speed_hz10(int p_amount) {
-
- effects.chorus.speed_hz10=p_amount;
-
-}
-
-int CPSong::get_chorus_delay_ms() {
-
- return effects.chorus.delay_ms;
-
-}
-int CPSong::get_chorus_separation_ms() {
-
- return effects.chorus.separation_ms;
-}
-int CPSong::get_chorus_depth_ms10() {
-
- return effects.chorus.depth_ms10;
-
-}
-int CPSong::get_chorus_speed_hz10() {
-
- return effects.chorus.speed_hz10;
-
-}
-
-void CPSong::cleanup_unused_patterns() {
-
- for (int i=0;i<MAX_PATTERNS;i++) {
-
- bool used=false;
- if (get_pattern(i)->is_empty())
- continue;
-
- for (int j=0;j<MAX_ORDERS;j++) {
-
- if (get_order(j)==i) {
- used=true;
-
- }
- }
-
- if (!used)
- get_pattern(i)->clear();
- }
-
-}
-void CPSong::cleanup_unused_instruments(){
-
- if (!has_instruments())
- return;
-
- bool instr_found[MAX_INSTRUMENTS];
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- instr_found[i]=false;
-
- for (int i=0;i<MAX_PATTERNS;i++) {
-
- if (get_pattern(i)->is_empty())
- continue;
-
- for (int row=0;row<get_pattern(i)->get_length();row++) {
-
-
- for (int col=0;col<CPPattern::WIDTH;col++) {
-
- CPNote n;
- n=get_pattern(i)->get_note( col,row );
-
- if (n.instrument<MAX_INSTRUMENTS)
- instr_found[n.instrument]=true;
-
- }
-
- }
-
- }
-
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- if (!instr_found[i])
- get_instrument(i)->reset();
-
-
-}
-void CPSong::cleanup_unused_samples(){
-
- if (!has_instruments())
- return;
-
- bool sample_found[MAX_SAMPLES];
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- sample_found[i]=false;
-
- for (int i=0;i<MAX_PATTERNS;i++) {
-
- if (get_pattern(i)->is_empty())
- continue;
-
-
- for (int row=0;row<get_pattern(i)->get_length();row++) {
-
-
- for (int col=0;col<CPPattern::WIDTH;col++) {
-
- CPNote n;
- n=get_pattern(i)->get_note( col,row );
-
- if (n.instrument>=MAX_SAMPLES)
- continue;
-
- if (has_instruments()) {
-
- for (int nt=0;nt<CPNote::NOTES;nt++) {
-
- int smp=get_instrument(n.instrument)->get_sample_number(nt);
- if (smp<MAX_SAMPLES)
- sample_found[smp]=true;
- }
-
- } else {
- if (n.instrument<MAX_SAMPLES)
- sample_found[n.instrument]=true;
- }
-
- }
-
- }
-
- }
-
- for (int i=0;i<MAX_SAMPLES;i++)
- if (!sample_found[i])
- get_sample(i)->reset();
-
-}
-void CPSong::cleanup_unused_orders(){
-
- bool finito=false;
- for (int j=0;j<MAX_ORDERS;j++) {
-
-
- if (get_order(j)==CP_ORDER_NONE)
- finito=true;
- if (finito)
- set_order(j,CP_ORDER_NONE);
-
- }
-
-}
-
-void CPSong::clear_all_default_pan() {
-
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- get_instrument(i)->set_pan_default_enabled( false ); //die!
-
- for (int i=0;i<MAX_SAMPLES;i++)
- get_sample(i)->set_pan_enabled( false ); //die!
-
-}
-
-
-void CPSong::clear_all_default_vol(){
-
- for (int i=0;i<MAX_SAMPLES;i++)
- get_sample(i)->set_default_volume( 64 ); //die!
- for (int i=0;i<MAX_INSTRUMENTS;i++)
- get_instrument(i)->set_volume_global_amount( CPInstrument::MAX_VOLUME );
-
-}
-
-
-int CPSong::get_order_in_use_count() {
-
-
- int order_count = 0;
-
- for (int i=(MAX_ORDERS-1);i>=0;i--) {
-
-
- if (get_order(i)!=CP_ORDER_NONE) {
- order_count=i+1;
- break;
- }
- }
-
- return order_count;
-}
-int CPSong::get_pattern_in_use_count() {
-
-
- int pattern_count=0;
-
- for (int i=(CPSong::MAX_PATTERNS-1);i>=0;i--) {
-
-
- if (!get_pattern(i)->is_empty()) {
- pattern_count=i+1;
- break;
- }
- }
-
- return pattern_count;
-}
-
-int CPSong::get_instrument_in_use_count() {
-
- int instrument_count=0;
-
- for (int i=(CPSong::MAX_INSTRUMENTS-1);i>=0;i--) {
-
- CPInstrument *ins = get_instrument(i);
- bool in_use=false;
-
- for (int s = 0 ; s < CPNote::NOTES ; s++ ) {
-
- int smp_idx = ins->get_sample_number(s);
- if (smp_idx<0 || smp_idx>=CPSong::MAX_SAMPLES)
- continue;
-
- if (!get_sample(smp_idx)->get_sample_data().is_null()) {
- in_use=true;
- break;
- }
-
- }
-
- if (in_use) {
- instrument_count=i+1;
- break;
- }
- }
-
- return instrument_count;
-}
-#include <stdio.h>
-int CPSong::get_channels_in_use() {
-
- int max=0;
-
- for (int p=0;p<CPSong::MAX_PATTERNS;p++) {
-
- CPPattern *pat = get_pattern(p);
- if (pat->is_empty())
- continue;
-
-
- for (int c=(CPPattern::WIDTH-1);c>=0;c--) {
-
- if (c<max)
- break;
-
- bool has_note=false;
- for (int r=0;r<pat->get_length();r++) {
-
- CPNote n = pat->get_note( c, r );
- if (!n.is_empty()) {
- has_note=true;
- break;
- }
- }
-
- if (has_note) {
-
- max=c+1;
- }
- }
- }
-
- return max;
-}
-
-
-void CPSong::separate_in_one_sample_instruments(int p_instrument) {
-
- CP_ERR_COND( !variables.use_instruments );
- CP_FAIL_INDEX( p_instrument, MAX_INSTRUMENTS );
-
- int remapped_count=0;
-
- signed char remap[MAX_SAMPLES];
-
- for (int i=0;i<MAX_SAMPLES;i++) {
-
- remap[i]=-1;
- }
-
- /* Find remaps */
- CPInstrument *ins=get_instrument(p_instrument);
- for (int i=0;i<CPNote::NOTES;i++) {
-
- int sn = ins->get_sample_number(i);
-
- // check for unusable sample
- if (sn<0 || sn>=MAX_SAMPLES || get_sample(sn)->get_sample_data().is_null())
- continue;
- printf("sample %i\n",sn);
- if ( remap[sn] !=-1 ) {
- printf("already mapped to %i\n",remap[sn]);
- continue;
- }
-
- printf("isn't remapped\n");
-
- // find remap
-
- for (int j=0;j<MAX_INSTRUMENTS;j++) {
-
- if (!get_instrument(j)->is_empty())
- continue;
-
- printf("map to %i\n",j);
-
- //copy
- *get_instrument(j)=*ins;
-
- // assign samples
- for (int k=0;k<CPNote::NOTES;k++) {
-
- get_instrument(j)->set_note_number(k,k);
- get_instrument(j)->set_sample_number(k,sn);
- }
- remap[sn]=j;
- remapped_count++;
- break;
- }
-
- CP_ERR_COND(remap[sn]==-1); // no more free instruments
- }
-
- printf("remapped %i\n",remapped_count);
-
- if (remapped_count<2) {
- //undo if only one is remapped
- for (int i=0;i<MAX_SAMPLES;i++) {
-
- if (remap[i]!=-1) {
-
- get_instrument(remap[i])->reset();
- }
- }
- return;
- }
-
- /* remap all song */
-
- for (int p=0;p<CPSong::MAX_PATTERNS;p++) {
-
- CPPattern *pat = get_pattern(p);
- if (pat->is_empty())
- continue;
-
-
- for (int c=0;c<CPPattern::WIDTH;c++) {
-
- for (int r=0;r<pat->get_length();r++) {
-
- CPNote n = pat->get_note(c,r);
- if (n.note<CPNote::NOTES && n.instrument==p_instrument) {
-
- int sn = ins->get_sample_number(n.note);
- if (remap[sn]==-1)
- pat->set_note(c,r,CPNote());
- else {
-
- n.instrument=remap[sn];
- pat->set_note(c,r,n);
- }
- }
- }
- }
- }
-
- ins->reset();
-
-}
-
-
-CPSong::CPSong() {
-
- reset();
-}
-CPSong::~CPSong() {
-
-}
-
-
-
-
-int get_song_next_order_idx(CPSong *p_song, int p_order_idx) {
-
- int baseorder,order_counter;
-
- order_counter=-1;
-
- baseorder=p_order_idx;
-
- do {
-
- baseorder++;
- if ( baseorder>(CPSong::MAX_ORDERS-1) ) baseorder=0;
- order_counter++;
-
- } while ( (p_song->get_order(baseorder)>=(CPSong::MAX_PATTERNS) ) && (order_counter<CPSong::MAX_ORDERS) );
-
-
- if (order_counter==CPSong::MAX_ORDERS) {
-
- return -1;
-
- } else {
-
- return baseorder;
- }
-
-}
diff --git a/modules/chibi/cp_song.h b/modules/chibi/cp_song.h
deleted file mode 100644
index ba0fa3e80a..0000000000
--- a/modules/chibi/cp_song.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*************************************************************************/
-/* cp_song.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CPSONG_H
-#define CPSONG_H
-
-
-/**CPSong Class
- *@author Juan Linietsky
- */
-
-#include "cp_order.h"
-#include "cp_pattern.h"
-#include "cp_sample.h"
-#include "cp_instrument.h"
-
-class CPSong {
-public:
- enum {
- MAX_SONG_NAME=26,
- MAX_ORDERS=200,
- MAX_PATTERNS=200,
- MAX_SAMPLES=99,
- MAX_INSTRUMENTS=99,
-
- CHANNEL_MAX_PAN=64,
- CHANNEL_MAX_VOLUME=64,
- CHANNEL_MAX_CHORUS=64,
- CHANNEL_MAX_REVERB=64,
-
- MIN_TEMPO=31,
- MAX_TEMPO=255,
- MIN_SPEED=1,
- MAX_SPEED=255,
- MAX_MESSAGE_LEN=8000,
-
-
-
- };
-
- enum ReverbMode {
- REVERB_MODE_ROOM,
- REVERB_MODE_STUDIO_SMALL,
- REVERB_MODE_STUDIO_MEDIUM,
- REVERB_MODE_STUDIO_LARGE,
- REVERB_MODE_HALL,
- REVERB_MODE_SPACE_ECHO,
- REVERB_MODE_ECHO,
- REVERB_MODE_DELAY,
- REVERB_MODE_HALF_ECHO
- };
-
-private:
- CPOrder order[MAX_ORDERS];
- CPPattern pattern[MAX_PATTERNS];
- CPSample sample[MAX_SAMPLES];
- CPInstrument instrument[MAX_INSTRUMENTS];
-
-
-
- struct Song_Variables { // variables that wont change in playback
-
- char name[MAX_SONG_NAME];
- char message[MAX_MESSAGE_LEN];
- /* string message; */
-
- int row_highlight_minor;
- int row_highlight_major;
-
- int mixing_volume;
- int stereo_separation;
-
- bool use_stereo;
- bool use_instruments;
- bool use_linear_slides;
-
- bool old_effects;
- bool compatible_gxx;
-
- } variables;
-
- struct Initial_Variables { // Initial values used for playback
-
- struct Channel_State {
-
- int pan,volume; // 0-- CHANNEL_MAX_PAN, CHANNEL_MAX_VOLUME
- bool surround;
- bool mute;
- int chorus; //0 - 64
- int reverb; //0 - 64
- };
-
- int global_volume;
- int speed;
- int tempo;
-
- Channel_State channel[CPPattern::WIDTH];
- } initial_variables;
-
- struct Effects {
-
- ReverbMode reverb_mode;
-
- struct Chorus {
-
- int delay_ms;
- int separation_ms;
- int depth_ms10;
- int speed_hz10;
- } chorus;
-
- } effects;
-
-public:
-
- /* Properties */
-
- const char *get_name();
- void set_name(const char *p_name);
-
- const char *get_message();
- void set_message(const char *p_message);
-
- void set_row_highlight_minor(int p_hl_minor); /* 0 .. 256 */
- int get_row_highlight_minor(); /* 0 .. 256 */
-
- void set_row_highlight_major(int p_hl_major); /* 0 .. 256 */
- int get_row_highlight_major(); /* 0 .. 256 */
-
- void set_mixing_volume(int p_mix_volume); /* 0 .. 128 */
- int get_mixing_volume(); /* 0 .. 128 */
-
- void set_global_volume(int p_global_volume); /* 0 .. 128 */
- int get_global_volume(); /* 0 .. 128 */
-
- void set_stereo_separation(int p_separation); /* 0 .. 128 */
- int get_stereo_separation(); /* 0 .. 128 */
-
- void set_stereo(bool p_stereo);
- bool is_stereo();
-
- void set_instruments(bool p_instruments);
- bool has_instruments();
-
- void set_linear_slides(bool p_linear_slides);
- bool has_linear_slides();
-
- void set_old_effects(bool p_old_effects);
- bool has_old_effects();
-
- void set_compatible_gxx(bool p_compatible_gxx);
- bool has_compatible_gxx();
-
- void set_speed(int p_speed); /* 1 .. 255 */
- int get_speed(); /* 1 .. 255 */
-
- void set_tempo(int p_tempo); /* 31 .. 255 */
- int get_tempo(); /* 31 .. 255 */
-
- void set_channel_pan(int p_channel,int p_pan); /* 0 .. 64 */
- int get_channel_pan(int p_channel);
-
- void set_channel_volume(int p_channel,int p_volume); /* 0 .. 64 */
- int get_channel_volume(int p_channel);
-
- void set_channel_surround(int p_channel,bool p_surround);
- bool is_channel_surround(int p_channel);
-
- void set_channel_mute(int p_channel,bool p_mute);
- bool is_channel_mute(int p_channel);
-
- void set_channel_chorus(int p_channel,int p_chorus); /* 0 .. 64 */
- int get_channel_chorus(int p_channel);
-
- void set_channel_reverb(int p_channel,int p_reverb); /* 0 .. 64 */
- int get_channel_reverb(int p_channel);
-
- /* arrays of stuff */
-
- CPPattern* get_pattern(int p_pattern);
- CPSample* get_sample(int p_sample);
- CPInstrument* get_instrument(int p_instrument);
-
- int get_order(int p_position);
- void set_order(int p_position,int p_order);
-
-
- /* Effects */
-
- ReverbMode get_reverb_mode();
- void set_reverb_mode(ReverbMode p_mode);
-
- void set_chorus_delay_ms(int p_amount);
- void set_chorus_separation_ms(int p_amount);
- void set_chorus_depth_ms10(int p_amount);
- void set_chorus_speed_hz10(int p_amount);
-
- int get_chorus_delay_ms();
- int get_chorus_separation_ms();
- int get_chorus_depth_ms10();
- int get_chorus_speed_hz10();
-
- /* utils */
-
- void reset(bool p_clear_patterns=true,bool p_clear_samples=true,bool p_clear_instruments=true,bool p_clear_variables=true);
-
- void cleanup_unused_patterns();
- void cleanup_unused_instruments();
- void cleanup_unused_samples();
- void cleanup_unused_orders();
- void clear_all_default_pan();
- void clear_all_default_vol();
-
- void clear_instrument_with_samples(int p_instrument);
-
- void make_instruments_from_samples();
- void make_instrument_from_sample(int p_sample);
-
- void separate_in_one_sample_instruments(int p_instrument);
-
- int get_order_in_use_count();
- int get_pattern_in_use_count();
- int get_instrument_in_use_count();
- int get_channels_in_use();
-
- CPSong();
- ~CPSong();
-
-};
-
-
-/* Some helper for something used a lot */
-
-int get_song_next_order_idx(CPSong *p_song, int p_order_idx);
-
-#endif
diff --git a/modules/chibi/cp_tables.cpp b/modules/chibi/cp_tables.cpp
deleted file mode 100644
index a7ed34ff31..0000000000
--- a/modules/chibi/cp_tables.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/*************************************************************************/
-/* cp_tables.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "cp_tables.h"
-
-int32_t CPTables::linear_period_to_freq_tab[768]={
-
- 535232,534749,534266,533784,533303,532822,532341,531861,
- 531381,530902,530423,529944,529466,528988,528511,528034,
- 527558,527082,526607,526131,525657,525183,524709,524236,
- 523763,523290,522818,522346,521875,521404,520934,520464,
- 519994,519525,519057,518588,518121,517653,517186,516720,
- 516253,515788,515322,514858,514393,513929,513465,513002,
- 512539,512077,511615,511154,510692,510232,509771,509312,
- 508852,508393,507934,507476,507018,506561,506104,505647,
- 505191,504735,504280,503825,503371,502917,502463,502010,
- 501557,501104,500652,500201,499749,499298,498848,498398,
- 497948,497499,497050,496602,496154,495706,495259,494812,
- 494366,493920,493474,493029,492585,492140,491696,491253,
- 490809,490367,489924,489482,489041,488600,488159,487718,
- 487278,486839,486400,485961,485522,485084,484647,484210,
- 483773,483336,482900,482465,482029,481595,481160,480726,
- 480292,479859,479426,478994,478562,478130,477699,477268,
- 476837,476407,475977,475548,475119,474690,474262,473834,
- 473407,472979,472553,472126,471701,471275,470850,470425,
- 470001,469577,469153,468730,468307,467884,467462,467041,
- 466619,466198,465778,465358,464938,464518,464099,463681,
- 463262,462844,462427,462010,461593,461177,460760,460345,
- 459930,459515,459100,458686,458272,457859,457446,457033,
- 456621,456209,455797,455386,454975,454565,454155,453745,
- 453336,452927,452518,452110,451702,451294,450887,450481,
- 450074,449668,449262,448857,448452,448048,447644,447240,
- 446836,446433,446030,445628,445226,444824,444423,444022,
- 443622,443221,442821,442422,442023,441624,441226,440828,
- 440430,440033,439636,439239,438843,438447,438051,437656,
- 437261,436867,436473,436079,435686,435293,434900,434508,
- 434116,433724,433333,432942,432551,432161,431771,431382,
- 430992,430604,430215,429827,429439,429052,428665,428278,
- 427892,427506,427120,426735,426350,425965,425581,425197,
- 424813,424430,424047,423665,423283,422901,422519,422138,
- 421757,421377,420997,420617,420237,419858,419479,419101,
- 418723,418345,417968,417591,417214,416838,416462,416086,
- 415711,415336,414961,414586,414212,413839,413465,413092,
- 412720,412347,411975,411604,411232,410862,410491,410121,
- 409751,409381,409012,408643,408274,407906,407538,407170,
- 406803,406436,406069,405703,405337,404971,404606,404241,
- 403876,403512,403148,402784,402421,402058,401695,401333,
- 400970,400609,400247,399886,399525,399165,398805,398445,
- 398086,397727,397368,397009,396651,396293,395936,395579,
- 395222,394865,394509,394153,393798,393442,393087,392733,
- 392378,392024,391671,391317,390964,390612,390259,389907,
- 389556,389204,388853,388502,388152,387802,387452,387102,
- 386753,386404,386056,385707,385359,385012,384664,384317,
- 383971,383624,383278,382932,382587,382242,381897,381552,
- 381208,380864,380521,380177,379834,379492,379149,378807,
- 378466,378124,377783,377442,377102,376762,376422,376082,
- 375743,375404,375065,374727,374389,374051,373714,373377,
- 373040,372703,372367,372031,371695,371360,371025,370690,
- 370356,370022,369688,369355,369021,368688,368356,368023,
- 367691,367360,367028,366697,366366,366036,365706,365376,
- 365046,364717,364388,364059,363731,363403,363075,362747,
- 362420,362093,361766,361440,361114,360788,360463,360137,
- 359813,359488,359164,358840,358516,358193,357869,357547,
- 357224,356902,356580,356258,355937,355616,355295,354974,
- 354654,354334,354014,353695,353376,353057,352739,352420,
- 352103,351785,351468,351150,350834,350517,350201,349885,
- 349569,349254,348939,348624,348310,347995,347682,347368,
- 347055,346741,346429,346116,345804,345492,345180,344869,
- 344558,344247,343936,343626,343316,343006,342697,342388,
- 342079,341770,341462,341154,340846,340539,340231,339924,
- 339618,339311,339005,338700,338394,338089,337784,337479,
- 337175,336870,336566,336263,335959,335656,335354,335051,
- 334749,334447,334145,333844,333542,333242,332941,332641,
- 332341,332041,331741,331442,331143,330844,330546,330247,
- 329950,329652,329355,329057,328761,328464,328168,327872,
- 327576,327280,326985,326690,326395,326101,325807,325513,
- 325219,324926,324633,324340,324047,323755,323463,323171,
- 322879,322588,322297,322006,321716,321426,321136,320846,
- 320557,320267,319978,319690,319401,319113,318825,318538,
- 318250,317963,317676,317390,317103,316817,316532,316246,
- 315961,315676,315391,315106,314822,314538,314254,313971,
- 313688,313405,313122,312839,312557,312275,311994,311712,
- 311431,311150,310869,310589,310309,310029,309749,309470,
- 309190,308911,308633,308354,308076,307798,307521,307243,
- 306966,306689,306412,306136,305860,305584,305308,305033,
- 304758,304483,304208,303934,303659,303385,303112,302838,
- 302565,302292,302019,301747,301475,301203,300931,300660,
- 300388,300117,299847,299576,299306,299036,298766,298497,
- 298227,297958,297689,297421,297153,296884,296617,296349,
- 296082,295815,295548,295281,295015,294749,294483,294217,
- 293952,293686,293421,293157,292892,292628,292364,292100,
- 291837,291574,291311,291048,290785,290523,290261,289999,
- 289737,289476,289215,288954,288693,288433,288173,287913,
- 287653,287393,287134,286875,286616,286358,286099,285841,
- 285583,285326,285068,284811,284554,284298,284041,283785,
- 283529,283273,283017,282762,282507,282252,281998,281743,
- 281489,281235,280981,280728,280475,280222,279969,279716,
- 279464,279212,278960,278708,278457,278206,277955,277704,
- 277453,277203,276953,276703,276453,276204,275955,275706,
- 275457,275209,274960,274712,274465,274217,273970,273722,
- 273476,273229,272982,272736,272490,272244,271999,271753,
- 271508,271263,271018,270774,270530,270286,270042,269798,
- 269555,269312,269069,268826,268583,268341,268099,267857
-};
-
-uint16_t CPTables::old_period_table[OCTAVE*2]={
-
- 0x6b00, 0x6800, 0x6500, 0x6220, 0x5f50, 0x5c80,
- 0x5a00, 0x5740, 0x54d0, 0x5260, 0x5010, 0x4dc0,
- 0x4b90, 0x4960, 0x4750, 0x4540, 0x4350, 0x4160,
- 0x3f90, 0x3dc0, 0x3c10, 0x3a40, 0x38b0, 0x3700
-};
-
-#define LOGFAC 2*16
-
-uint16_t CPTables::log_table[104]= {
- LOGFAC*907,LOGFAC*900,LOGFAC*894,LOGFAC*887,
- LOGFAC*881,LOGFAC*875,LOGFAC*868,LOGFAC*862,
- LOGFAC*856,LOGFAC*850,LOGFAC*844,LOGFAC*838,
- LOGFAC*832,LOGFAC*826,LOGFAC*820,LOGFAC*814,
- LOGFAC*808,LOGFAC*802,LOGFAC*796,LOGFAC*791,
- LOGFAC*785,LOGFAC*779,LOGFAC*774,LOGFAC*768,
- LOGFAC*762,LOGFAC*757,LOGFAC*752,LOGFAC*746,
- LOGFAC*741,LOGFAC*736,LOGFAC*730,LOGFAC*725,
- LOGFAC*720,LOGFAC*715,LOGFAC*709,LOGFAC*704,
- LOGFAC*699,LOGFAC*694,LOGFAC*689,LOGFAC*684,
- LOGFAC*678,LOGFAC*675,LOGFAC*670,LOGFAC*665,
- LOGFAC*660,LOGFAC*655,LOGFAC*651,LOGFAC*646,
- LOGFAC*640,LOGFAC*636,LOGFAC*632,LOGFAC*628,
- LOGFAC*623,LOGFAC*619,LOGFAC*614,LOGFAC*610,
- LOGFAC*604,LOGFAC*601,LOGFAC*597,LOGFAC*592,
- LOGFAC*588,LOGFAC*584,LOGFAC*580,LOGFAC*575,
- LOGFAC*570,LOGFAC*567,LOGFAC*563,LOGFAC*559,
- LOGFAC*555,LOGFAC*551,LOGFAC*547,LOGFAC*543,
- LOGFAC*538,LOGFAC*535,LOGFAC*532,LOGFAC*528,
- LOGFAC*524,LOGFAC*520,LOGFAC*516,LOGFAC*513,
- LOGFAC*508,LOGFAC*505,LOGFAC*502,LOGFAC*498,
- LOGFAC*494,LOGFAC*491,LOGFAC*487,LOGFAC*484,
- LOGFAC*480,LOGFAC*477,LOGFAC*474,LOGFAC*470,
- LOGFAC*467,LOGFAC*463,LOGFAC*460,LOGFAC*457,
- LOGFAC*453,LOGFAC*450,LOGFAC*447,LOGFAC*443,
- LOGFAC*440,LOGFAC*437,LOGFAC*434,LOGFAC*431
-};
-
-
-
-int32_t CPTables::get_linear_period(uint16_t note,int32_t fine) {
-
- int32_t t;
-
- t=(24L*OCTAVE-(int32_t)note)*32L-(fine>>1);
- return t;
-}
-
-static int s3m_period_table[12]={1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907};
-
-
-int32_t CPTables::get_log_period(uint16_t note,int32_t p_c5freq) {
-
- return (8363L * 16 * s3m_period_table[note%12] >> (note/12)) / p_c5freq;
-
-}
-
-/*
-int32_t CPTables::get_log_period(uint16_t note,int32_t p_c5freq)
-{
- uint16_t n,o;
- uint16_t p1,p2;
- int32_t i;
-
- n=note%(2*OCTAVE);
- o=note/(2*OCTAVE);
- i=(n<<2); // n*8 + fine/16
-
- if (i<0)
- i=0;
-
- if (i>102)
- i=102;
-
-
- p1=log_table[i];
- p2=log_table[i+1];
-
-
- return (Interpolate(fine>>4,0,15,p1,p2)>>o);
-
-} */
-
-int32_t CPTables::get_old_period(uint16_t note,int32_t speed) {
-
- uint16_t n,o,res;
-
-// if (!speed) {
-
- // return 4242; /* <- prevent divide overflow */
- // }
-
- n=note%(2*OCTAVE);
- o=note/(2*OCTAVE);
-
- res=((8363L*(int32_t)old_period_table[n])>>o)/((old_period_table[17]>>1)+(speed<<2)); /*/(128-speed)*/;
-
- return res;
-}
-
-int32_t CPTables::get_linear_frequency(int32_t period) {
-
- int32_t shift_value=(((int32_t)period/768)-2);
- if (shift_value>0) {
-
- return linear_period_to_freq_tab[period%768]>>shift_value;
- } else {
- shift_value=0-shift_value;
- return linear_period_to_freq_tab[period%768]<<shift_value;
- }
-}
-
-int32_t CPTables::get_old_frequency(int32_t period) {
-
- return (8363L*1712L)/(period?period:1);
-
-}
-
-CPTables::CPTables(){
-}
-CPTables::~CPTables(){
-}
diff --git a/modules/chibi/cp_tables.h b/modules/chibi/cp_tables.h
deleted file mode 100644
index 4baa1c6488..0000000000
--- a/modules/chibi/cp_tables.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*************************************************************************/
-/* cp_tables.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 CPTABLES_H
-#define CPTABLES_H
-
-#include "cp_config.h"
-
-/**conversion CPTables/functions
- *@author Juan Linietsky
- */
-
-/******************************
- CPTables.h
- --------
-
-CPTables methods for miscelaneous
-conversion utilities
-********************************/
-
-class CPTables {
-public:
-
- enum { OCTAVE=12 };
-
- static uint16_t old_period_table[OCTAVE*2];
- static uint16_t log_table[104];
- static int32_t linear_period_to_freq_tab[768];
-
- static int32_t get_old_period(uint16_t note,int32_t speed);
- static int32_t get_amiga_period(uint16_t note,int32_t fine);
- static int32_t get_linear_period(uint16_t note,int32_t fine);
- static int32_t get_linear_frequency(int32_t period);
- static int32_t get_old_frequency(int32_t period);
- static int32_t get_log_period(uint16_t note,int32_t p_c5freq);
-
- CPTables();
- ~CPTables();
-};
-
-#endif
diff --git a/modules/chibi/event_stream_chibi.cpp b/modules/chibi/event_stream_chibi.cpp
deleted file mode 100644
index 73d1c01e33..0000000000
--- a/modules/chibi/event_stream_chibi.cpp
+++ /dev/null
@@ -1,872 +0,0 @@
-/*************************************************************************/
-/* event_stream_chibi.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "event_stream_chibi.h"
-#include "cp_loader_it.h"
-#include "cp_loader_xm.h"
-#include "cp_loader_s3m.h"
-#include "cp_loader_mod.h"
-
-static CPSampleManagerImpl *sample_manager;
-static ResourceFormatLoaderChibi *resource_loader;
-
-CPSample_ID CPSampleManagerImpl::create(bool p_16bits,bool p_stereo,int32_t p_len) {
-
- AudioServer::SampleFormat sf=p_16bits?AudioServer::SAMPLE_FORMAT_PCM16:AudioServer::SAMPLE_FORMAT_PCM8;
-
- SampleData *sd = memnew( SampleData );
- sd->rid = AudioServer::get_singleton()->sample_create(sf,p_stereo,p_len);
- sd->stereo=p_stereo;
- sd->len=p_len;
- sd->is16=p_16bits;
- sd->mixfreq=44100;
- sd->loop_begin=0;
- sd->loop_end=0;
- sd->loop_type=CP_LOOP_NONE;
- sd->locks=0;
-#ifdef DEBUG_ENABLED
- valid.insert(sd);
-#endif
- CPSample_ID sid;
- sid._private=sd;
- return sid;
-}
-
-void CPSampleManagerImpl::recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len){
-
- AudioServer::SampleFormat sf=p_16bits?AudioServer::SAMPLE_FORMAT_PCM16:AudioServer::SAMPLE_FORMAT_PCM8;
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
- AudioServer::get_singleton()->free(sd->rid);
- sd->rid = AudioServer::get_singleton()->sample_create(sf,p_stereo,p_len);
- sd->stereo=p_stereo;
- sd->len=p_len;
- sd->is16=p_16bits;
- sd->mixfreq=44100;
- sd->loop_begin=0;
- sd->loop_end=0;
- sd->loop_type=CP_LOOP_NONE;
-}
-void CPSampleManagerImpl::destroy(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
- valid.erase(sd);
-#endif
- AudioServer::get_singleton()->free(sd->rid);
-
- memdelete(sd);
-}
-bool CPSampleManagerImpl::check(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- return valid.has(sd);
-#else
- return _getsd(p_id)!=NULL;
-#endif
-}
-
-void CPSampleManagerImpl::set_c5_freq(CPSample_ID p_id,int32_t p_freq){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
- sd->mixfreq=p_freq;
- AudioServer::get_singleton()->sample_set_mix_rate(sd->rid,p_freq);
-
-}
-void CPSampleManagerImpl::set_loop_begin(CPSample_ID p_id,int32_t p_begin){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
- sd->loop_begin=p_begin;
- AudioServer::get_singleton()->sample_set_loop_begin(sd->rid,p_begin);
-
-}
-void CPSampleManagerImpl::set_loop_end(CPSample_ID p_id,int32_t p_end){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
- sd->loop_end=p_end;
- AudioServer::get_singleton()->sample_set_loop_end(sd->rid,p_end);
-
-}
-void CPSampleManagerImpl::set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
-
- sd->loop_type=p_type;
- AudioServer::get_singleton()->sample_set_loop_format(sd->rid,AudioServer::SampleLoopFormat(p_type));
-
-
-}
-void CPSampleManagerImpl::set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
-
- ERR_FAIL();
-}
-
-
-int32_t CPSampleManagerImpl::get_loop_begin(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- return sd->loop_begin;
-
-}
-int32_t CPSampleManagerImpl::get_loop_end(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- return sd->loop_end;
-}
-CPSample_Loop_Type CPSampleManagerImpl::get_loop_type(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),CP_LOOP_NONE);
-#endif
-
- return sd->loop_type;
-}
-int32_t CPSampleManagerImpl::get_c5_freq(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- return sd->mixfreq;
-}
-int32_t CPSampleManagerImpl::get_size(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- return sd->len;
-
-}
-bool CPSampleManagerImpl::is_16bits(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),false);
-#endif
-
- return sd->is16;
-
-}
-bool CPSampleManagerImpl::is_stereo(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),false);
-#endif
- return sd->stereo;
-
-
-}
-bool CPSampleManagerImpl::lock_data(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- sd->locks++;
- if (sd->locks==1) {
- sd->lock=AudioServer::get_singleton()->sample_get_data(sd->rid);
- sd->w=sd->lock.write();
- }
-
- return true;
-}
-void *CPSampleManagerImpl::get_data(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- ERR_FAIL_COND_V(sd->locks==0,0);
- return sd->w.ptr();
-}
-
-int16_t CPSampleManagerImpl::get_data(CPSample_ID p_id, int p_sample, int p_channel){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V(!valid.has(sd),0);
-#endif
-
- ERR_FAIL_V(0);
- lock_data(p_id);
-
- int sofs = sd->stereo ? 2:1;
- uint16_t v=0;
- if (sd->is16) {
- int16_t *p=(int16_t*)sd->w.ptr();
- v=p[p_sample*sofs+p_channel];
- } else {
- int8_t *p=(int8_t*)sd->w.ptr();
- v=p[p_sample*sofs+p_channel];
- }
-
- unlock_data(p_id);
-
- return v;
-}
-void CPSampleManagerImpl::set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
-
- ERR_FAIL();
- lock_data(p_id);
-
- int sofs = sd->stereo ? 2:1;
- if (sd->is16) {
- int16_t *p=(int16_t*)sd->w.ptr();
- p[p_sample*sofs+p_channel]=p_data;
- } else {
- int8_t *p=(int8_t*)sd->w.ptr();
- p[p_sample*sofs+p_channel]=p_data;
- }
-
- unlock_data(p_id);
-
-}
-void CPSampleManagerImpl::unlock_data(CPSample_ID p_id){
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
-
- ERR_FAIL_COND(sd->locks==0);
-
- sd->locks--;
- if (sd->locks==0) {
- sd->w=PoolVector<uint8_t>::Write();
- AudioServer::get_singleton()->sample_set_data(sd->rid,sd->lock);
- sd->lock=PoolVector<uint8_t>();
- }
-}
-
-void CPSampleManagerImpl::get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len) {
-
- SampleData *sd=_getsd(p_id);
-#ifdef DEBUG_ENABLED
- ERR_FAIL_COND(!valid.has(sd));
-#endif
-
- ERR_FAIL();
-}
-
-
-/** MIXER **/
-
-void CPMixerImpl::set_callback_interval(int p_interval_us) {
-
- callback_interval=p_interval_us;
-}
-
-void CPMixerImpl::set_callback(void (*p_callback)(void*),void *p_userdata) {
-
- callback=p_callback;
- userdata=p_userdata;
-}
-
-void CPMixerImpl::setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) {
-
- Voice &v=voices[p_voice_index];
- if (v.channel!=AudioMixer::INVALID_CHANNEL) {
- mixer->channel_free(v.channel);
- }
- v.channel=mixer->channel_alloc(sample_manager->get_rid(p_sample_id));
- v.freq_mult = sample_manager->get_c5_freq(p_sample_id)/261.6255653006;
- v.sample = p_sample_id;
-}
-
-void CPMixerImpl::stop_voice(int p_voice_index) {
-
- Voice &v=voices[p_voice_index];
- if (v.channel==AudioMixer::INVALID_CHANNEL)
- return;
-
- mixer->channel_free(v.channel);
- v.channel=AudioMixer::INVALID_CHANNEL;
-
-}
-
-void CPMixerImpl::set_voice_frequency(int p_voice_index,int32_t p_freq) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- float f = p_freq / 256.0;
- f*=pitch_scale;
- mixer->channel_set_mix_rate(v.channel,f * v.freq_mult );
-}
-
-void CPMixerImpl::set_voice_panning(int p_voice_index,int p_pan) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- if (p_pan==CP_PAN_SURROUND)
- p_pan=CP_PAN_CENTER;
- float p = p_pan / 256.0;
- mixer->channel_set_pan(v.channel,p);
-
-}
-
-void CPMixerImpl::set_voice_volume(int p_voice_index,int p_vol) {
-
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- float vol = p_vol/512.0;
- vol*=voice_scale;
- mixer->channel_set_volume(v.channel,vol);
- mixer->channel_set_reverb(v.channel,reverb_type,vol*v.reverb);
-}
-
-void CPMixerImpl::set_voice_filter(int p_voice_index,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance ){
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
-
-}
-
-void CPMixerImpl::set_voice_reverb_send(int p_voice_index,int p_reverb){
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- v.reverb=p_reverb/255.0;
- //mixer->channel_set_reverb(v.channel,reverb_type,p_reverb/255.0);
-
-}
-
-void CPMixerImpl::set_voice_chorus_send(int p_voice_index,int p_chorus){
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- mixer->channel_set_chorus(v.channel,p_chorus/255.0);
-
-}
-
-
-void CPMixerImpl::set_reverb_mode(ReverbMode p_mode){
-
-// Voice &v=voices[p_voice_index];
-// ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
- switch(p_mode) {
- case CPMixer::REVERB_MODE_STUDIO_SMALL: reverb_type=AudioMixer::REVERB_SMALL; break;
- case CPMixer::REVERB_MODE_STUDIO_MEDIUM: reverb_type=AudioMixer::REVERB_MEDIUM; break;
- case CPMixer::REVERB_MODE_STUDIO_LARGE: reverb_type=AudioMixer::REVERB_LARGE; break;
- case CPMixer::REVERB_MODE_HALL: reverb_type=AudioMixer::REVERB_HALL; break;
- default: reverb_type=AudioMixer::REVERB_SMALL; break;
- }
-
-}
-
-void CPMixerImpl::set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10){
-
-// Voice &v=voices[p_voice_index];
-// ERR_FAIL_COND(v.channel==AudioMixer::INVALID_CHANNEL);
-
-}
-
-
-
-/* Info retrieving */
-
-int32_t CPMixerImpl::get_voice_sample_pos_index(int p_voice_index) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND_V(v.channel==AudioMixer::INVALID_CHANNEL,0);
- return 0;
-
-}
-
-int CPMixerImpl::get_voice_panning(int p_voice_index) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND_V(!is_voice_active(p_voice_index),0);
- return mixer->channel_get_pan(v.channel)*CP_PAN_RIGHT;
-
-}
-
-int CPMixerImpl::get_voice_volume(int p_voice_index) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND_V(!is_voice_active(p_voice_index),0);
- return mixer->channel_get_volume(v.channel);
-
-
-}
-
-CPSample_ID CPMixerImpl::get_voice_sample_id(int p_voice_index) {
-
- Voice &v=voices[p_voice_index];
- ERR_FAIL_COND_V(v.channel==AudioMixer::INVALID_CHANNEL,CPSample_ID());
- return v.sample;
-
-
-}
-
-bool CPMixerImpl::is_voice_active(int p_voice_index){
-
- Voice &v=voices[p_voice_index];
- if (v.channel==AudioMixer::INVALID_CHANNEL)
- return false;
- if (!mixer->channel_is_valid(v.channel))
- v.channel=AudioMixer::INVALID_CHANNEL;
-
- return v.channel!=AudioMixer::INVALID_CHANNEL;
-}
-
-void CPMixerImpl::process_usecs(int p_usec,float p_volume,float p_pitch_scale,float p_tempo_scale) {
-
- ERR_FAIL_COND(callback_interval==0);
- //update this somewhere
- pitch_scale=p_pitch_scale;
- tempo_scale=p_tempo_scale;
- voice_scale = AudioServer::get_singleton()->get_event_voice_global_volume_scale()*p_volume;
- while(p_usec) {
-
- if (p_usec>=callback_timeout) {
-
- p_usec-=callback_timeout;
- callback_timeout=0;
- if (callback) {
- callback(userdata);
- }
- callback_timeout=callback_interval*(1.0/p_tempo_scale);
-
- } else {
-
- callback_timeout-=p_usec;
- p_usec=0;
- }
- }
-}
-
-
-CPMixerImpl::CPMixerImpl(AudioMixer *p_mixer) {
-
- callback_interval=1;
- callback_timeout=0;
- userdata=0;
- callback=0;
- tempo_scale=1.0;
- pitch_scale=1.0;
- mixer=p_mixer;
- voice_scale = AudioServer::get_singleton()->get_event_voice_global_volume_scale();
- reverb_type = AudioMixer::REVERB_SMALL;
-
-}
-
-/** FILE ACCESS WRAPPER **/
-
-
-CPFileAccessWrapperImpl::Error CPFileAccessWrapperImpl::open(const char *p_filename, int p_mode_flags) {
-
- ERR_FAIL_COND_V(p_mode_flags&WRITE,ERROR_WRITING_FILE);
- close();
- f = FileAccess::open(String::utf8(p_filename),p_mode_flags);
- if (!f)
- return ERROR_FILE_NOT_FOUND;
- return OK;
-}
-
-void CPFileAccessWrapperImpl::close(){
-
- if (f)
- memdelete(f);
- f=NULL;
-
-
-}
-
-void CPFileAccessWrapperImpl::seek(uint32_t p_position){
-
- f->seek(p_position);
-}
-void CPFileAccessWrapperImpl::seek_end(){
-
- f->seek_end();
-}
-uint32_t CPFileAccessWrapperImpl::get_pos(){
-
- return f->get_pos();
-}
-
-bool CPFileAccessWrapperImpl::eof_reached(){
-
- return f->eof_reached();
-}
-
-uint8_t CPFileAccessWrapperImpl::get_byte(){
-
- return f->get_8();
-}
-void CPFileAccessWrapperImpl::get_byte_array(uint8_t *p_dest,int p_elements){
-
- f->get_buffer(p_dest,p_elements);
-}
-void CPFileAccessWrapperImpl::get_word_array(uint16_t *p_dest,int p_elements){
-
- for(int i=0;i<p_elements;i++) {
- p_dest[i]=f->get_16();
- }
-
-}
-
-uint16_t CPFileAccessWrapperImpl::get_word(){
-
- return f->get_16();
-}
-uint32_t CPFileAccessWrapperImpl::get_dword(){
-
- return f->get_32();
-}
-
-void CPFileAccessWrapperImpl::set_endian_conversion(bool p_swap){
-
- f->set_endian_swap(p_swap);
-}
-bool CPFileAccessWrapperImpl::is_open(){
-
- return f!=NULL;
-}
-
-CPFileAccessWrapperImpl::Error CPFileAccessWrapperImpl::get_error(){
-
- return (f->get_error()!=::OK)?ERROR_READING_FILE:OK;
-}
-
-void CPFileAccessWrapperImpl::store_byte(uint8_t p_dest){
-
-}
-void CPFileAccessWrapperImpl::store_byte_array(const uint8_t *p_dest,int p_elements){
-
-}
-
-void CPFileAccessWrapperImpl::store_word(uint16_t p_dest){
-
-}
-void CPFileAccessWrapperImpl::store_dword(uint32_t p_dest){
-
-}
-
-////////////////////////////////////////////////
-
-
-Error EventStreamPlaybackChibi::_play() {
-
- last_order=0;
- loops=0;
- player->play_start_song();
- total_usec=0;
-
- return OK;
-}
-
-bool EventStreamPlaybackChibi::_update(AudioMixer* p_mixer, uint64_t p_usec){
-
- total_usec+=p_usec;
- mixer.process_usecs(p_usec,volume,pitch_scale,tempo_scale);
- int order=player->get_current_order();
- if (order<last_order) {
- if (!loop) {
- stop();
- } else {
- loops++;
- }
- }
- last_order=order;
- return false;
-}
-void EventStreamPlaybackChibi::_stop(){
-
- player->play_stop();
-}
-
-void EventStreamPlaybackChibi::set_paused(bool p_paused){
-
-}
-bool EventStreamPlaybackChibi::is_paused() const{
-
- return false;
-}
-void EventStreamPlaybackChibi::set_loop(bool p_loop){
-
- loop=p_loop;
-
-}
-bool EventStreamPlaybackChibi::is_loop_enabled() const{
-
- return loop;
-}
-
-int EventStreamPlaybackChibi::get_loop_count() const{
-
- //return player->is
- return loops;
-}
-
-float EventStreamPlaybackChibi::get_pos() const{
-
- return double(total_usec)/1000000.0;
-}
-void EventStreamPlaybackChibi::seek_pos(float p_time){
-
- WARN_PRINT("seek_pos unimplemented.");
-}
-
-void EventStreamPlaybackChibi::set_volume(float p_volume) {
-
- volume=p_volume;
-}
-
-float EventStreamPlaybackChibi::get_volume() const{
-
- return volume;
-}
-
-void EventStreamPlaybackChibi::set_pitch_scale(float p_pitch_scale) {
-
- pitch_scale=p_pitch_scale;
-}
-
-float EventStreamPlaybackChibi::get_pitch_scale() const{
-
- return pitch_scale;
-}
-
-void EventStreamPlaybackChibi::set_tempo_scale(float p_tempo_scale) {
-
- tempo_scale=p_tempo_scale;
-}
-
-float EventStreamPlaybackChibi::get_tempo_scale() const{
-
- return tempo_scale;
-}
-
-
-void EventStreamPlaybackChibi::set_channel_volume(int p_channel,float p_volume) {
-
-
- if (p_channel>=64)
- return;
- player->set_channel_global_volume(p_channel,p_volume*256);
-}
-
-
-
-float EventStreamPlaybackChibi::get_channel_volume(int p_channel) const{
-
- return player->get_channel_global_volume(p_channel)/256.0;
-
-}
-
-float EventStreamPlaybackChibi::get_last_note_time(int p_channel) const {
-
-
- double v = (player->get_channel_last_note_time_usec(p_channel))/1000000.0;
- if (v<0)
- v=-1;
- return v;
-}
-
-EventStreamPlaybackChibi::EventStreamPlaybackChibi(Ref<EventStreamChibi> p_stream) : mixer(_get_mixer()) {
-
- stream=p_stream;
- player = memnew( CPPlayer(&mixer,&p_stream->song) );
- loop=false;
- last_order=0;
- loops=0;
- volume=1.0;
- pitch_scale=1.0;
- tempo_scale=1.0;
-}
-EventStreamPlaybackChibi::~EventStreamPlaybackChibi(){
-
- player->play_stop();
- memdelete(player);
-}
-
-////////////////////////////////////////////////////
-
-Ref<EventStreamPlayback> EventStreamChibi::instance_playback() {
-
- return Ref<EventStreamPlayback>( memnew(EventStreamPlaybackChibi(Ref<EventStreamChibi>(this))) );
-}
-
-String EventStreamChibi::get_stream_name() const{
-
- return song.get_name();
-
-}
-
-
-
-float EventStreamChibi::get_length() const{
-
- return 1;
-}
-
-
-EventStreamChibi::EventStreamChibi() {
-
-
-}
-
-
-
-//////////////////////////////////////////////////////////////////
-
-
-
-
-RES ResourceFormatLoaderChibi::load(const String &p_path, const String& p_original_path, Error *r_error) {
-
- if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
- String el = p_path.extension().to_lower();
-
- CPFileAccessWrapperImpl f;
-
- if (el=="it") {
-
- Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
- CPLoader_IT loader(&f);
- CPLoader::Error err = loader.load_song(p_path.utf8().get_data(),&esc->song,false);
- ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
- if (r_error)
- *r_error=OK;
-
- return esc;
-
- } else if (el=="xm") {
-
- Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
- CPLoader_XM loader(&f);
- CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
- ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
- if (r_error)
- *r_error=OK;
- return esc;
-
- } else if (el=="s3m") {
-
- Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
- CPLoader_S3M loader(&f);
- CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
- ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
- if (r_error)
- *r_error=OK;
-
- return esc;
-
- } else if (el=="mod") {
-
- Ref<EventStreamChibi> esc( memnew( EventStreamChibi ) );
- CPLoader_MOD loader(&f);
- CPLoader::Error err=loader.load_song(p_path.utf8().get_data(),&esc->song,false);
- ERR_FAIL_COND_V(err!=CPLoader::FILE_OK,RES());
- if (r_error)
- *r_error=OK;
- return esc;
- }
-
- return RES();
-
-}
-
-void ResourceFormatLoaderChibi::get_recognized_extensions(List<String> *p_extensions) const {
-
- p_extensions->push_back("it");
- p_extensions->push_back("xm");
- p_extensions->push_back("s3m");
- p_extensions->push_back("mod");
-}
-bool ResourceFormatLoaderChibi::handles_type(const String& p_type) const {
-
- return (p_type=="EventStreamChibi" || p_type=="EventStream");
-}
-
-String ResourceFormatLoaderChibi::get_resource_type(const String &p_path) const {
- String el = p_path.extension().to_lower();
- if (el=="it" || el=="s3m" || el=="xm" || el=="mod")
- return "EventStreamChibi";
- return "";
-}
-
-/////////////////////////////////////////////////////////////////
-void initialize_chibi() {
-
- sample_manager = memnew( CPSampleManagerImpl );
- resource_loader = memnew( ResourceFormatLoaderChibi );
- ClassDB::register_class<EventStreamChibi>();
- ResourceLoader::add_resource_format_loader( resource_loader );
-}
-
-void finalize_chibi() {
-
- memdelete( sample_manager );
- memdelete( resource_loader );
-}
-
diff --git a/modules/chibi/event_stream_chibi.h b/modules/chibi/event_stream_chibi.h
deleted file mode 100644
index 0244ee0a95..0000000000
--- a/modules/chibi/event_stream_chibi.h
+++ /dev/null
@@ -1,314 +0,0 @@
-/*************************************************************************/
-/* event_stream_chibi.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 EVENT_STREAM_CHIBI_H
-#define EVENT_STREAM_CHIBI_H
-
-#include "scene/resources/event_stream.h"
-#include "cp_sample_manager.h"
-#include "cp_mixer.h"
-#include "cp_song.h"
-#include "cp_file_access_wrapper.h"
-#include "cp_player_data.h"
-#include "resource.h"
-#include "servers/audio_server.h"
-#include "os/file_access.h"
-#include "io/resource_loader.h"
-
-/** SAMPLE MANAGER **/
-
-class CPSampleManagerImpl : public CPSampleManager {
-
- struct SampleData {
-
- RID rid;
- bool stereo;
- bool is16;
- int len;
- int mixfreq;
- int loop_begin;
- int loop_end;
- int locks;
- PoolVector<uint8_t> lock;
- PoolVector<uint8_t>::Write w;
- CPSample_Loop_Type loop_type;
- };
-
-
- _FORCE_INLINE_ SampleData* _getsd(CPSample_ID p_id) {
-
- return ((SampleData*)p_id._private);
- }
- Set<SampleData*> valid;
-
-public:
-
- _FORCE_INLINE_ RID get_rid(CPSample_ID p_id) { return _getsd(p_id)->rid; }
- virtual CPSample_ID create(bool p_16bits,bool p_stereo,int32_t p_len);
- virtual void recreate(CPSample_ID p_id,bool p_16bits,bool p_stereo,int32_t p_len);
- virtual void destroy(CPSample_ID p_id);
- virtual bool check(CPSample_ID p_id); // return false if invalid
-
- virtual void set_c5_freq(CPSample_ID p_id,int32_t p_freq);
- virtual void set_loop_begin(CPSample_ID p_id,int32_t p_begin);
- virtual void set_loop_end(CPSample_ID p_id,int32_t p_end);
- virtual void set_loop_type(CPSample_ID p_id,CPSample_Loop_Type p_type);
- virtual void set_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len);
-
-
- virtual int32_t get_loop_begin(CPSample_ID p_id);
- virtual int32_t get_loop_end(CPSample_ID p_id);
- virtual CPSample_Loop_Type get_loop_type(CPSample_ID p_id);
- virtual int32_t get_c5_freq(CPSample_ID p_id);
- virtual int32_t get_size(CPSample_ID p_id);
- virtual bool is_16bits(CPSample_ID p_id);
- virtual bool is_stereo(CPSample_ID p_id);
- virtual bool lock_data(CPSample_ID p_id);
- virtual void *get_data(CPSample_ID p_id); /* WARNING: Not all sample managers
-may be able to implement this, it depends on the mixer in use! */
- virtual int16_t get_data(CPSample_ID p_id, int p_sample, int p_channel=0); /// Does not need locking
- virtual void set_data(CPSample_ID p_id, int p_sample, int16_t p_data,int p_channel=0); /// Does not need locking
- virtual void unlock_data(CPSample_ID p_id);
-
- virtual void get_chunk(CPSample_ID p_id,int32_t p_index,void *p_data,int p_data_len);
-
-};
-
-
-/** MIXER **/
-
-class CPMixerImpl : public CPMixer {
-
- enum {
- MAX_VOICES=64
- };
-
- struct Voice {
-
- AudioMixer::ChannelID channel;
- CPSample_ID sample;
- float freq_mult;
- float reverb;
- Voice() { reverb=0.0; }
- };
-
- Voice voices[MAX_VOICES];
-
-
- int callback_interval;
- int callback_timeout;
- void (*callback)(void*);
- void *userdata;
- float voice_scale;
- float tempo_scale;
- float pitch_scale;
- AudioMixer::ReverbRoomType reverb_type;
- AudioMixer *mixer;
-public:
-
- void process_usecs(int p_usec,float p_volume,float p_pitch_scale,float p_tempo_scale);
-
- /* Callback */
-
- virtual void set_callback_interval(int p_interval_us); //in usecs, for tracker it's 2500000/tempo
- virtual void set_callback(void (*p_callback)(void*),void *p_userdata);
-
- /* Voice Control */
-
- virtual void setup_voice(int p_voice_index,CPSample_ID p_sample_id,int32_t p_start_index) ;
- virtual void stop_voice(int p_voice_index) ;
- virtual void set_voice_frequency(int p_voice_index,int32_t p_freq) ; //in freq*FREQUENCY_BITS
- virtual void set_voice_panning(int p_voice_index,int p_pan) ;
- virtual void set_voice_volume(int p_voice_index,int p_vol) ;
- virtual void set_voice_filter(int p_filter,bool p_enabled,uint8_t p_cutoff, uint8_t p_resonance );
- virtual void set_voice_reverb_send(int p_voice_index,int p_reverb);
- virtual void set_voice_chorus_send(int p_voice_index,int p_chorus); /* 0 - 255 */
-
- virtual void set_reverb_mode(ReverbMode p_mode);
- virtual void set_chorus_params(unsigned int p_delay_ms,unsigned int p_separation_ms,unsigned int p_depth_ms10,unsigned int p_speed_hz10);
-
-
- /* Info retrieving */
-
- virtual int32_t get_voice_sample_pos_index(int p_voice_index) ;
- virtual int get_voice_panning(int p_voice_index) ;
- virtual int get_voice_volume(int p_voice_index) ;
- virtual CPSample_ID get_voice_sample_id(int p_voice_index) ;
- virtual bool is_voice_active(int p_voice_index);
- virtual int get_active_voice_count() { return 0; }
- virtual int get_total_voice_count() { return MAX_VOICES; }
-
-
- virtual uint32_t get_mix_frequency() { return 0; }
-
- /* Methods below only work with software mixers, meant for software-based sound drivers, hardware mixers ignore them */
- virtual int32_t process(int32_t p_frames) { return 0; }
- virtual int32_t *get_mixdown_buffer_ptr() { return NULL; }
- virtual void set_mix_frequency(int32_t p_mix_frequency) {};
-
- CPMixerImpl(AudioMixer *p_mixer=NULL);
- virtual ~CPMixerImpl() {}
-};
-
-/** FILE ACCESS **/
-
-class CPFileAccessWrapperImpl : public CPFileAccessWrapper {
-
- FileAccess *f;
-public:
-
-
- virtual Error open(const char *p_filename, int p_mode_flags);
- virtual void close();
-
- virtual void seek(uint32_t p_position);
- virtual void seek_end();
- virtual uint32_t get_pos();
-
- virtual bool eof_reached();
-
- virtual uint8_t get_byte();
- virtual void get_byte_array(uint8_t *p_dest,int p_elements);
- virtual void get_word_array(uint16_t *p_dest,int p_elements);
-
- virtual uint16_t get_word();
- virtual uint32_t get_dword();
-
- virtual void set_endian_conversion(bool p_swap);
- virtual bool is_open();
-
- virtual Error get_error();
-
- virtual void store_byte(uint8_t p_dest);
- virtual void store_byte_array(const uint8_t *p_dest,int p_elements);
-
- virtual void store_word(uint16_t p_dest);
- virtual void store_dword(uint32_t p_dest);
-
- CPFileAccessWrapperImpl() { f=NULL; }
- virtual ~CPFileAccessWrapperImpl(){ if (f) memdelete(f); }
-
-};
-
-
-
-/////////////////////
-
-class EventStreamChibi;
-
-class EventStreamPlaybackChibi : public EventStreamPlayback {
-
- GDCLASS(EventStreamPlaybackChibi,EventStreamPlayback);
-
- CPMixerImpl mixer;
- uint64_t total_usec;
- Ref<EventStreamChibi> stream;
- mutable CPPlayer *player;
- bool loop;
- int last_order;
- int loops;
- virtual Error _play();
- virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec);
- virtual void _stop();
- float volume;
- float tempo_scale;
- float pitch_scale;
-
-
-public:
-
-
- virtual void set_paused(bool p_paused);
- virtual bool is_paused() const;
-
- virtual void set_loop(bool p_loop);
- virtual bool is_loop_enabled() const;
-
- virtual int get_loop_count() const;
-
- virtual float get_pos() const;
- virtual void seek_pos(float p_time);
-
- virtual void set_volume(float p_vol);
- virtual float get_volume() const;
-
- virtual void set_pitch_scale(float p_pitch_scale);
- virtual float get_pitch_scale() const;
-
- virtual void set_tempo_scale(float p_tempo_scale);
- virtual float get_tempo_scale() const;
-
- virtual void set_channel_volume(int p_channel,float p_volume);
- virtual float get_channel_volume(int p_channel) const;
-
- virtual float get_last_note_time(int p_channel) const;
-
- EventStreamPlaybackChibi(Ref<EventStreamChibi> p_stream=Ref<EventStreamChibi>());
- ~EventStreamPlaybackChibi();
-};
-
-
-class EventStreamChibi : public EventStream {
-
- GDCLASS(EventStreamChibi,EventStream);
-
-friend class ResourceFormatLoaderChibi;
-friend class EventStreamPlaybackChibi;
- //I think i didn't know what const was when i wrote this more than a decade ago
- //so it goes mutable :(
- mutable CPSong song;
-
-
-public:
-
- virtual Ref<EventStreamPlayback> instance_playback();
-
- virtual String get_stream_name() const;
-
- virtual float get_length() const;
-
- virtual int get_channel_count() const { return 64; } //tracker limit
-
- EventStreamChibi();
-};
-
-
-class ResourceFormatLoaderChibi : 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;
-
-};
-
-void initialize_chibi();
-void finalize_chibi();
-
-#endif // EVENT_STREAM_CHIBI_H
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 1de98a6b1f..600cae991e 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -114,7 +114,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
uint32_t width = f->get_32();
uint32_t height = f->get_32();
uint32_t pitch = f->get_32();
- uint32_t depth = f->get_32();
+ /* uint32_t depth = */ f->get_32();
uint32_t mipmaps = f->get_32();
//skip 11
@@ -130,7 +130,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
}
- uint32_t format_size = f->get_32();
+ /* uint32_t format_size = */ f->get_32();
uint32_t format_flags = f->get_32();
uint32_t format_fourcc = f->get_32();
uint32_t format_rgb_bits = f->get_32();
@@ -139,9 +139,9 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
uint32_t format_blue_mask = f->get_32();
uint32_t format_alpha_mask = f->get_32();
- uint32_t caps_1 = f->get_32();
- uint32_t caps_2 = f->get_32();
- uint32_t caps_ddsx = f->get_32();
+ /* uint32_t caps_1 = */ f->get_32();
+ /* uint32_t caps_2 = */ f->get_32();
+ /* uint32_t caps_ddsx = */ f->get_32();
//reserved skip
f->get_32();
@@ -221,7 +221,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String& p_original_path,
if (!(flags&DDSD_MIPMAPCOUNT))
mipmaps=1;
-// print_line("found format: "+String(dds_format_info[dds_format].name));
+ //print_line("found format: "+String(dds_format_info[dds_format].name));
PoolVector<uint8_t> src_data;
@@ -478,7 +478,7 @@ bool ResourceFormatDDS::handles_type(const String& p_type) const {
String ResourceFormatDDS::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="dds")
+ if (p_path.get_extension().to_lower()=="dds")
return "ImageTexture";
return "";
}
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 43d9988de1..af555b7eb6 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -506,8 +506,10 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const {
(uint32_t)OS::get_singleton()->get_unix_time(), hash );
hash = hash_djb2_one_32(
(uint32_t)OS::get_singleton()->get_data_dir().hash64(), hash );
- //hash = hash_djb2_one_32(
- // (uint32_t)OS::get_singleton()->get_unique_ID().hash64(), hash );
+ /*
+ hash = hash_djb2_one_32(
+ (uint32_t)OS::get_singleton()->get_unique_ID().hash64(), hash );
+ */
hash = hash_djb2_one_32(
(uint32_t)((uint64_t)this), hash ); //rely on aslr heap
hash = hash_djb2_one_32(
@@ -643,12 +645,12 @@ void NetworkedMultiplayerENet::enet_compressor_destroy(void * context){
void NetworkedMultiplayerENet::_bind_methods() {
- ClassDB::bind_method(_MD("create_server","port","max_clients","in_bandwidth","out_bandwidth"),&NetworkedMultiplayerENet::create_server,DEFVAL(32),DEFVAL(0),DEFVAL(0));
- ClassDB::bind_method(_MD("create_client","ip","port","in_bandwidth","out_bandwidth"),&NetworkedMultiplayerENet::create_client,DEFVAL(0),DEFVAL(0));
- ClassDB::bind_method(_MD("close_connection"),&NetworkedMultiplayerENet::close_connection);
- ClassDB::bind_method(_MD("set_compression_mode","mode"),&NetworkedMultiplayerENet::set_compression_mode);
- ClassDB::bind_method(_MD("get_compression_mode"),&NetworkedMultiplayerENet::get_compression_mode);
- ClassDB::bind_method(_MD("set_bind_ip", "ip"),&NetworkedMultiplayerENet::set_bind_ip);
+ ClassDB::bind_method(D_METHOD("create_server","port","max_clients","in_bandwidth","out_bandwidth"),&NetworkedMultiplayerENet::create_server,DEFVAL(32),DEFVAL(0),DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("create_client","ip","port","in_bandwidth","out_bandwidth"),&NetworkedMultiplayerENet::create_client,DEFVAL(0),DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("close_connection"),&NetworkedMultiplayerENet::close_connection);
+ ClassDB::bind_method(D_METHOD("set_compression_mode","mode"),&NetworkedMultiplayerENet::set_compression_mode);
+ ClassDB::bind_method(D_METHOD("get_compression_mode"),&NetworkedMultiplayerENet::get_compression_mode);
+ ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"),&NetworkedMultiplayerENet::set_bind_ip);
BIND_CONSTANT( COMPRESS_NONE );
BIND_CONSTANT( COMPRESS_RANGE_CODER );
diff --git a/modules/etc1/image_etc.cpp b/modules/etc1/image_etc.cpp
index 845084fef7..2d883bff0f 100644
--- a/modules/etc1/image_etc.cpp
+++ b/modules/etc1/image_etc.cpp
@@ -95,7 +95,7 @@ static void _decompress_etc(Image *p_img) {
//print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps()));
*p_img=Image(p_img->get_width(),p_img->get_height(),p_img->has_mipmaps(),Image::FORMAT_RGB8,dst);
if (p_img->has_mipmaps())
- p_img->generate_mipmaps(true);
+ p_img->generate_mipmaps();
}
@@ -112,16 +112,17 @@ static void _compress_etc(Image *p_img) {
img.convert(Image::FORMAT_RGB8);
- int mmc=img.get_mipmap_count();
- if (mmc==0)
- img.generate_mipmaps(); // force mipmaps, so it works on most hardware
-
-
PoolVector<uint8_t> res_data;
PoolVector<uint8_t> dst_data;
PoolVector<uint8_t>::Read r = img.get_data().read();
+ int target_size = Image::get_image_data_size(p_img->get_width(),p_img->get_height(),Image::FORMAT_ETC,p_img->has_mipmaps()?-1:0);
+ int mmc = p_img->has_mipmaps() ? Image::get_image_required_mipmaps(p_img->get_width(),p_img->get_height(),Image::FORMAT_ETC) : 0;
+
+ dst_data.resize(target_size);
int mc=0;
+ int ofs=0;
+ PoolVector<uint8_t>::Write w=dst_data.write();
rg_etc1::etc1_pack_params pp;
@@ -133,18 +134,18 @@ static void _compress_etc(Image *p_img) {
int bh=MAX(imgh/4,1);
const uint8_t *src = &r[img.get_mipmap_offset(i)];
int mmsize = MAX(bw,1)*MAX(bh,1)*8;
- dst_data.resize(dst_data.size()+mmsize);
- PoolVector<uint8_t>::Write w=dst_data.write();
- uint8_t *dst = &w[dst_data.size()-mmsize];
+
+ uint8_t *dst = &w[ofs];
+ ofs+=mmsize;
-// print_line("bh: "+itos(bh)+" bw: "+itos(bw));
+ //print_line("bh: "+itos(bh)+" bw: "+itos(bw));
for(int y=0;y<bh;y++) {
for(int x=0;x<bw;x++) {
-// print_line("x: "+itos(x)+" y: "+itos(y));
+ //print_line("x: "+itos(x)+" y: "+itos(y));
uint8_t block[4*4*4];
zeromem(block,4*4*4);
diff --git a/modules/etc1/texture_loader_pkm.cpp b/modules/etc1/texture_loader_pkm.cpp
index 42c9937b8f..e720e1fb4c 100644
--- a/modules/etc1/texture_loader_pkm.cpp
+++ b/modules/etc1/texture_loader_pkm.cpp
@@ -78,7 +78,7 @@ bool ResourceFormatPKM::handles_type(const String& p_type) const {
String ResourceFormatPKM::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="pkm")
+ if (p_path.get_extension().to_lower()=="pkm")
return "ImageTexture";
return "";
}
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index 7483af298c..398c2cf82a 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -1099,7 +1099,72 @@ Error GDCompiler::_parse_block(CodeGen& codegen,const GDParser::BlockNode *p_blo
switch(cf->cf_type) {
-
+ case GDParser::ControlFlowNode::CF_MATCH: {
+ GDParser::MatchNode *match = cf->match;
+
+ GDParser::IdentifierNode *id = memnew(GDParser::IdentifierNode);
+ id->name = "#match_value";
+
+ // var #match_value
+ // copied because there is no _parse_statement :(
+ codegen.add_stack_identifier(id->name, p_stack_level++);
+ codegen.alloc_stack(p_stack_level);
+ new_identifiers++;
+
+ GDParser::OperatorNode *op = memnew(GDParser::OperatorNode);
+ op->op=GDParser::OperatorNode::OP_ASSIGN;
+ op->arguments.push_back(id);
+ op->arguments.push_back(match->val_to_match);
+
+ int ret = _parse_expression(codegen, op, p_stack_level);
+ if (ret < 0) {
+ return ERR_PARSE_ERROR;
+ }
+
+ // break address
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(codegen.opcodes.size() + 3);
+ int break_addr = codegen.opcodes.size();
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(0); // break addr
+
+ for (int j = 0; j < match->compiled_pattern_branches.size(); j++) {
+ GDParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j];
+
+ // jump over continue
+ // jump unconditionally
+ // continue address
+ // compile the condition
+ int ret = _parse_expression(codegen, branch.compiled_pattern, p_stack_level);
+ if (ret < 0) {
+ return ERR_PARSE_ERROR;
+ }
+
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(ret);
+ codegen.opcodes.push_back(codegen.opcodes.size() + 3);
+ int continue_addr = codegen.opcodes.size();
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(0);
+
+
+
+ Error err = _parse_block(codegen, branch.body, p_stack_level, p_break_addr, continue_addr);
+ if (err) {
+ return ERR_PARSE_ERROR;
+ }
+
+ codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(break_addr);
+
+ codegen.opcodes[continue_addr + 1] = codegen.opcodes.size();
+ }
+
+ codegen.opcodes[break_addr + 1] = codegen.opcodes.size();
+
+
+ } break;
+
case GDParser::ControlFlowNode::CF_IF: {
#ifdef DEBUG_ENABLED
@@ -1420,9 +1485,10 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
GDFunction *gdfunc=NULL;
- //if (String(p_func->name)=="") { //initializer func
- // gdfunc = &p_script->initializer;
-
+ /*
+ if (String(p_func->name)=="") { //initializer func
+ gdfunc = &p_script->initializer;
+ */
//} else { //regular func
p_script->member_functions[func_name]=memnew(GDFunction);
gdfunc = p_script->member_functions[func_name];
@@ -1510,7 +1576,7 @@ Error GDCompiler::_parse_function(GDScript *p_script,const GDParser::ClassNode *
//funciton and class
if (p_class->name) {
- signature+="::"+String(p_class->name)+"."+String(func_name);;
+ signature+="::"+String(p_class->name)+"."+String(func_name);
} else {
signature+="::"+String(func_name);
}
@@ -1729,9 +1795,14 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
}
+ }else {
+ // without extends, implicitly extend Reference
+ int native_idx = GDScriptLanguage::get_singleton()->get_global_map()["Reference"];
+ native = GDScriptLanguage::get_singleton()->get_global_array()[native_idx];
+ ERR_FAIL_COND_V(native.is_null(), ERR_BUG);
+ p_script->native=native;
}
-
//print_line("Script: "+p_script->get_path()+" indices: "+itos(p_script->member_indices.size()));
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h
index dd211a852c..eb6079e8e0 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gd_compiler.h
@@ -93,7 +93,7 @@ class GDCompiler {
//int get_identifier_pos(const StringName& p_dentifier) const;
- HashMap<Variant,int,VariantHasher> constant_map;
+ HashMap<Variant,int,VariantHasher,VariantComparator> constant_map;
Map<StringName,int> name_map;
int get_name_map_pos(const StringName& p_identifier) {
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 00b080190f..9dd41847d7 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "gd_script.h"
#include "gd_compiler.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -323,6 +323,16 @@ void GDScriptLanguage::get_public_constants(List<Pair<String,Variant> > *p_const
pi.first="PI";
pi.second=Math_PI;
p_constants->push_back(pi);
+
+ Pair<String, Variant> infinity;
+ infinity.first = "INF";
+ infinity.second = Math_INF;
+ p_constants->push_back(infinity);
+
+ Pair<String, Variant> nan;
+ nan.first = "NAN";
+ nan.second = Math_NAN;
+ p_constants->push_back(nan);
}
String GDScriptLanguage::make_function(const String& p_class,const String& p_name,const PoolStringArray& p_args) const {
@@ -364,10 +374,12 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant& p_variant) {
if (p_variant.get_type()==Variant::OBJECT) {
Object *obj = p_variant;
if (obj) {
- //if (obj->cast_to<GDNativeClass>()) {
- // t.obj_type=obj->cast_to<GDNativeClass>()->get_name();
- // t.value=Variant();
- //} else {
+ /*
+ if (obj->cast_to<GDNativeClass>()) {
+ t.obj_type=obj->cast_to<GDNativeClass>()->get_name();
+ t.value=Variant();
+ } else {
+ */
t.obj_type=obj->get_class();
//}
}
@@ -671,7 +683,7 @@ static bool _guess_expression_type(GDCompletionContext& context,const GDParser::
if (!script.ends_with(".gd")) {
//not a script, try find the script anyway,
//may have some success
- script=script.basename()+".gd";
+ script=script.get_basename()+".gd";
}
if (FileAccess::exists(script)) {
@@ -1168,7 +1180,7 @@ static bool _guess_identifier_type(GDCompletionContext& context,int p_line,const
if (!script.ends_with(".gd")) {
//not a script, try find the script anyway,
//may have some success
- script=script.basename()+".gd";
+ script=script.get_basename()+".gd";
}
if (FileAccess::exists(script)) {
@@ -1771,7 +1783,7 @@ static void _find_type_arguments(GDCompletionContext& context,const GDParser::No
String s = E->get().name;
if (!s.begins_with("autoload/"))
continue;
- // print_line("found "+s);
+ //print_line("found "+s);
String name = s.get_slice("/",1);
result.insert("\"/root/"+name+"\"");
}
@@ -1998,10 +2010,10 @@ static void _find_call_arguments(GDCompletionContext& context,const GDParser::No
List<MethodInfo> methods;
ClassDB::get_method_list(type,&methods);
for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
- //if (E->get().arguments.size())
- // result.insert(E->get().name+"(");
- //else
- // result.insert(E->get().name+"()");
+ if (E->get().arguments.size())
+ result.insert(E->get().name+"(");
+ else
+ result.insert(E->get().name+"()");
}*/
}
break;
@@ -2643,6 +2655,7 @@ Error GDScriptLanguage::lookup_code(const String& p_code, const String& p_symbol
switch(p.get_completion_type()) {
+ case GDParser::COMPLETION_GET_NODE:
case GDParser::COMPLETION_NONE: {
} break;
case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
@@ -2832,7 +2845,7 @@ Error GDScriptLanguage::lookup_code(const String& p_code, const String& p_symbol
if (!script.ends_with(".gd")) {
//not a script, try find the script anyway,
//may have some success
- script=script.basename()+".gd";
+ script=script.get_basename()+".gd";
}
if (FileAccess::exists(script)) {
@@ -2912,7 +2925,7 @@ Error GDScriptLanguage::lookup_code(const String& p_code, const String& p_symbol
Ref<GDNativeClass> gdn = t.value;
if (gdn.is_valid()) {
r_result.type=ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
- r_result.class_name=gdn->get_name();;
+ r_result.class_name=gdn->get_name();
r_result.class_member=p_symbol;
return OK;
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 6659988602..0c72f6d187 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -171,7 +171,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
if (p_state) {
//use existing (supplied) state (yielded)
stack=(Variant*)p_state->stack.ptr();
- call_args=(Variant**)&p_state->stack[sizeof(Variant)*p_state->stack_size];
+ call_args=(Variant**)stack + sizeof(Variant)*p_state->stack_size;
line=p_state->line;
ip=p_state->ip;
alloca_size=p_state->stack.size();
@@ -331,8 +331,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
#endif
ip+=5;
-
- } continue;
+ continue;
+ }
case OPCODE_EXTENDS_TEST: {
CHECK_SPACE(4);
@@ -404,8 +404,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst=extends_ok;
ip+=4;
-
- } continue;
+ continue;
+ }
case OPCODE_SET: {
CHECK_SPACE(3);
@@ -429,7 +429,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
ip+=4;
- } continue;
+ continue;
+ }
case OPCODE_GET: {
CHECK_SPACE(3);
@@ -460,7 +461,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst=ret;
#endif
ip+=4;
- } continue;
+ continue;
+ }
case OPCODE_SET_NAMED: {
CHECK_SPACE(3);
@@ -483,7 +485,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
ip+=4;
- } continue;
+ continue;
+ }
case OPCODE_GET_NAMED: {
@@ -518,7 +521,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst=ret;
#endif
ip+=4;
- } continue;
+ continue;
+ }
case OPCODE_SET_MEMBER: {
CHECK_SPACE(3);
@@ -540,7 +544,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
#endif
ip+=3;
- } continue;
+ continue;
+ }
case OPCODE_GET_MEMBER: {
CHECK_SPACE(3);
@@ -557,8 +562,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
#endif
ip+=3;
-
- } continue;
+ continue;
+ }
case OPCODE_ASSIGN: {
CHECK_SPACE(3);
@@ -568,8 +573,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst = *src;
ip+=3;
-
- } continue;
+ continue;
+ }
case OPCODE_ASSIGN_TRUE: {
CHECK_SPACE(2);
@@ -578,7 +583,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst = true;
ip+=2;
- } continue;
+ continue;
+ }
case OPCODE_ASSIGN_FALSE: {
CHECK_SPACE(2);
@@ -587,7 +593,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst = false;
ip+=2;
- } continue;
+ continue;
+ }
case OPCODE_CONSTRUCT: {
CHECK_SPACE(2);
@@ -612,7 +619,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
ip+=4+argc;
//construct a basic type
- } continue;
+ continue;
+ }
case OPCODE_CONSTRUCT_ARRAY: {
CHECK_SPACE(1);
@@ -632,8 +640,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst=array;
ip+=3+argc;
-
- } continue;
+ continue;
+ }
case OPCODE_CONSTRUCT_DICTIONARY: {
CHECK_SPACE(1);
@@ -655,8 +663,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
*dst=dict;
ip+=3+argc*2;
-
- } continue;
+ continue;
+ }
case OPCODE_CALL_RETURN:
case OPCODE_CALL: {
@@ -717,7 +725,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
err.argument-=1;
}
}
- } if (methodstr=="free") {
+ } else if (methodstr=="free") {
if (err.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) {
@@ -737,8 +745,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
//_call_func(NULL,base,*methodname,ip,argc,p_instance,stack);
ip+=argc+1;
-
- } continue;
+ continue;
+ }
case OPCODE_CALL_BUILT_IN: {
CHECK_SPACE(4);
@@ -775,12 +783,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
break;
}
ip+=argc+1;
-
- } continue;
+ continue;
+ }
case OPCODE_CALL_SELF: {
-
- } break;
+ break;
+ }
case OPCODE_CALL_SELF_BASE: {
CHECK_SPACE(2);
@@ -857,8 +865,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
ip+=4+argc;
-
- } continue;
+ continue;
+ }
case OPCODE_YIELD:
case OPCODE_YIELD_SIGNAL: {
@@ -938,8 +946,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
exit_ok=true;
-
- } break;
+ break;
+ }
case OPCODE_YIELD_RESUME: {
CHECK_SPACE(2);
@@ -950,8 +958,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
GET_VARIANT_PTR(result,1);
*result=p_state->result;
ip+=2;
-
- } continue;
+ continue;
+ }
case OPCODE_JUMP: {
CHECK_SPACE(2);
@@ -959,8 +967,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
ERR_BREAK(to<0 || to>_code_size);
ip=to;
-
- } continue;
+ continue;
+ }
case OPCODE_JUMP_IF: {
CHECK_SPACE(3);
@@ -983,7 +991,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
continue;
}
ip+=3;
- } continue;
+ continue;
+ }
case OPCODE_JUMP_IF_NOT: {
CHECK_SPACE(3);
@@ -1006,21 +1015,22 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
continue;
}
ip+=3;
- } continue;
+ continue;
+ }
case OPCODE_JUMP_TO_DEF_ARGUMENT: {
CHECK_SPACE(2);
ip=_default_arg_ptr[defarg];
-
- } continue;
+ continue;
+ }
case OPCODE_RETURN: {
CHECK_SPACE(2);
GET_VARIANT_PTR(r,1);
retvalue=*r;
exit_ok=true;
-
- } break;
+ break;
+ }
case OPCODE_ITERATE_BEGIN: {
CHECK_SPACE(8); //space for this an regular iterate
@@ -1050,8 +1060,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
ip+=5; //skip regular iterate which is always next
-
- } continue;
+ continue;
+ }
case OPCODE_ITERATE: {
CHECK_SPACE(4);
@@ -1079,7 +1089,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
ip+=5; //loop again
- } continue;
+ continue;
+ }
case OPCODE_ASSERT: {
CHECK_SPACE(2);
GET_VARIANT_PTR(test,1);
@@ -1105,7 +1116,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
#endif
ip+=2;
- } continue;
+ continue;
+ }
case OPCODE_BREAKPOINT: {
#ifdef DEBUG_ENABLED
if (ScriptDebugger::get_singleton()) {
@@ -1113,7 +1125,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
}
#endif
ip+=1;
- } continue;
+ continue;
+ }
case OPCODE_LINE: {
CHECK_SPACE(2);
@@ -1142,17 +1155,19 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
ScriptDebugger::get_singleton()->line_poll();
}
- } continue;
+ continue;
+ }
case OPCODE_END: {
exit_ok=true;
break;
- } break;
+ }
default: {
err_text="Illegal opcode "+itos(_code_ptr[ip])+" at address "+itos(ip);
- } break;
+ break;
+ }
}
@@ -1475,8 +1490,8 @@ Variant GDFunctionState::resume(const Variant& p_arg) {
void GDFunctionState::_bind_methods() {
- ClassDB::bind_method(_MD("resume:Variant","arg"),&GDFunctionState::resume,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("is_valid"),&GDFunctionState::is_valid);
+ ClassDB::bind_method(D_METHOD("resume:Variant","arg"),&GDFunctionState::resume,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("is_valid"),&GDFunctionState::is_valid);
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"_signal_callback",&GDFunctionState::_signal_callback,MethodInfo("_signal_callback"));
}
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 1c41b2e73b..d0fc241734 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "gd_functions.h"
#include "math_funcs.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "reference.h"
#include "gd_script.h"
#include "func_ref.h"
@@ -159,85 +159,85 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
case MATH_SIN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::sin(*p_args[0]);
+ r_ret=Math::sin((double)*p_args[0]);
} break;
case MATH_COS: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::cos(*p_args[0]);
+ r_ret=Math::cos((double)*p_args[0]);
} break;
case MATH_TAN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::tan(*p_args[0]);
+ r_ret=Math::tan((double)*p_args[0]);
} break;
case MATH_SINH: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::sinh(*p_args[0]);
+ r_ret=Math::sinh((double)*p_args[0]);
} break;
case MATH_COSH: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::cosh(*p_args[0]);
+ r_ret=Math::cosh((double)*p_args[0]);
} break;
case MATH_TANH: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::tanh(*p_args[0]);
+ r_ret=Math::tanh((double)*p_args[0]);
} break;
case MATH_ASIN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::asin(*p_args[0]);
+ r_ret=Math::asin((double)*p_args[0]);
} break;
case MATH_ACOS: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::acos(*p_args[0]);
+ r_ret=Math::acos((double)*p_args[0]);
} break;
case MATH_ATAN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::atan(*p_args[0]);
+ r_ret=Math::atan((double)*p_args[0]);
} break;
case MATH_ATAN2: {
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::atan2(*p_args[0],*p_args[1]);
+ r_ret=Math::atan2((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_SQRT: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::sqrt(*p_args[0]);
+ r_ret=Math::sqrt((double)*p_args[0]);
} break;
case MATH_FMOD: {
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::fmod(*p_args[0],*p_args[1]);
+ r_ret=Math::fmod((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_FPOSMOD: {
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::fposmod(*p_args[0],*p_args[1]);
+ r_ret=Math::fposmod((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_FLOOR: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::floor(*p_args[0]);
+ r_ret=Math::floor((double)*p_args[0]);
} break;
case MATH_CEIL: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::ceil(*p_args[0]);
+ r_ret=Math::ceil((double)*p_args[0]);
} break;
case MATH_ROUND: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::round(*p_args[0]);
+ r_ret=Math::round((double)*p_args[0]);
} break;
case MATH_ABS: {
VALIDATE_ARG_COUNT(1);
@@ -247,7 +247,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
r_ret=ABS(i);
} else if (p_args[0]->get_type()==Variant::REAL) {
- real_t r = *p_args[0];
+ double r = *p_args[0];
r_ret=Math::abs(r);
} else {
@@ -279,58 +279,58 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::pow(*p_args[0],*p_args[1]);
+ r_ret=Math::pow((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_LOG: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::log(*p_args[0]);
+ r_ret=Math::log((double)*p_args[0]);
} break;
case MATH_EXP: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::exp(*p_args[0]);
+ r_ret=Math::exp((double)*p_args[0]);
} break;
case MATH_ISNAN: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::is_nan(*p_args[0]);
+ r_ret=Math::is_nan((double)*p_args[0]);
} break;
case MATH_ISINF: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::is_inf(*p_args[0]);
+ r_ret=Math::is_inf((double)*p_args[0]);
} break;
case MATH_EASE: {
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::ease(*p_args[0],*p_args[1]);
+ r_ret=Math::ease((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_DECIMALS: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::step_decimals(*p_args[0]);
+ r_ret=Math::step_decimals((double)*p_args[0]);
} break;
case MATH_STEPIFY: {
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::stepify(*p_args[0],*p_args[1]);
+ r_ret=Math::stepify((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_LERP: {
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
- r_ret=Math::lerp(*p_args[0],*p_args[1],*p_args[2]);
+ r_ret=Math::lerp((double)*p_args[0],(double)*p_args[1],(double)*p_args[2]);
} break;
case MATH_DECTIME: {
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
- r_ret=Math::dectime(*p_args[0],*p_args[1],*p_args[2]);
+ r_ret=Math::dectime((double)*p_args[0],(double)*p_args[1],(double)*p_args[2]);
} break;
case MATH_RANDOMIZE: {
Math::randomize();
@@ -346,19 +346,19 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
VALIDATE_ARG_COUNT(2);
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- r_ret=Math::random(*p_args[0],*p_args[1]);
+ r_ret=Math::random((double)*p_args[0],(double)*p_args[1]);
} break;
case MATH_SEED: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_args[0];
+ uint64_t seed=*p_args[0];
Math::seed(seed);
r_ret=Variant();
} break;
case MATH_RANDSEED: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_args[0];
+ uint64_t seed=*p_args[0];
int ret = Math::rand_from_seed(&seed);
Array reta;
reta.push_back(ret);
@@ -369,22 +369,22 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
case MATH_DEG2RAD: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::deg2rad(*p_args[0]);
+ r_ret=Math::deg2rad((double)*p_args[0]);
} break;
case MATH_RAD2DEG: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::rad2deg(*p_args[0]);
+ r_ret=Math::rad2deg((double)*p_args[0]);
} break;
case MATH_LINEAR2DB: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::linear2db(*p_args[0]);
+ r_ret=Math::linear2db((double)*p_args[0]);
} break;
case MATH_DB2LINEAR: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::db2linear(*p_args[0]);
+ r_ret=Math::db2linear((double)*p_args[0]);
} break;
case LOGIC_MAX: {
VALIDATE_ARG_COUNT(2);
@@ -555,7 +555,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
String str;
for(int i=0;i<p_arg_count;i++) {
- String os = p_args[i]->operator String();;
+ String os = p_args[i]->operator String();
if (i==0)
str=os;
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 6aed7c9491..5147ccd63f 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -225,8 +225,8 @@ bool GDParser::_get_completable_identifier(CompletionType p_type,StringName& ide
GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_allow_assign,bool p_parsing_constant) {
-// Vector<Node*> expressions;
-// Vector<OperatorNode::Operator> operators;
+ //Vector<Node*> expressions;
+ //Vector<OperatorNode::Operator> operators;
Vector<Expression> expression;
@@ -375,6 +375,22 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
constant->value=Math_PI;
tokenizer->advance();
expr=constant;
+ }
+ else if (tokenizer->get_token() == GDTokenizer::TK_CONST_INF) {
+
+ //constant defined by tokenizer
+ ConstantNode *constant = alloc_node<ConstantNode>();
+ constant->value = Math_INF;
+ tokenizer->advance();
+ expr = constant;
+ }
+ else if (tokenizer->get_token() == GDTokenizer::TK_CONST_NAN) {
+
+ //constant defined by tokenizer
+ ConstantNode *constant = alloc_node<ConstantNode>();
+ constant->value = Math_NAN;
+ tokenizer->advance();
+ expr = constant;
} else if (tokenizer->get_token()==GDTokenizer::TK_PR_PRELOAD) {
//constant defined by tokenizer
@@ -386,21 +402,42 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
tokenizer->advance();
String path;
+ bool found_constant = false;
bool valid = false;
+ ConstantNode *cn;
+
Node *subexpr = _parse_and_reduce_expression(p_parent, p_static);
if (subexpr) {
if (subexpr->type == Node::TYPE_CONSTANT) {
- ConstantNode *cn = static_cast<ConstantNode*>(subexpr);
- if (cn->value.get_type() == Variant::STRING) {
- valid = true;
- path = (String) cn->value;
+ cn = static_cast<ConstantNode*>(subexpr);
+ found_constant = true;
+ }
+ if (subexpr->type == Node::TYPE_IDENTIFIER) {
+ IdentifierNode *in = static_cast<IdentifierNode*>(subexpr);
+ Vector<ClassNode::Constant> ce = current_class->constant_expressions;
+
+ // Try to find the constant expression by the identifier
+ for(int i=0; i < ce.size(); ++i){
+ if(ce[i].identifier == in->name) {
+ if(ce[i].expression->type == Node::TYPE_CONSTANT) {
+ cn = static_cast<ConstantNode*>(ce[i].expression);
+ found_constant = true;
+ }
+ }
}
}
+
+ if (found_constant && cn->value.get_type() == Variant::STRING) {
+ valid = true;
+ path = (String) cn->value;
+ }
}
+
if (!valid) {
_set_error("expected string constant as 'preload' argument.");
return NULL;
}
+
if (!path.is_abs_path() && base_path!="")
path=base_path+"/"+path;
path = path.replace("///","//").simplify_path();
@@ -643,7 +680,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
case GDTokenizer::TK_OP_ADD: e.op=OperatorNode::OP_POS; break;
case GDTokenizer::TK_OP_SUB: e.op=OperatorNode::OP_NEG; break;
case GDTokenizer::TK_OP_NOT: e.op=OperatorNode::OP_NOT; break;
- case GDTokenizer::TK_OP_BIT_INVERT: e.op=OperatorNode::OP_BIT_INVERT;; break;
+ case GDTokenizer::TK_OP_BIT_INVERT: e.op=OperatorNode::OP_BIT_INVERT; break;
default: {}
}
@@ -724,6 +761,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
};
Node *key=NULL;
+ Set<Variant> keys;
DictExpect expecting=DICT_EXPECT_KEY;
@@ -819,6 +857,16 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
return NULL;
expecting=DICT_EXPECT_COMMA;
+ if (key->type == GDParser::Node::TYPE_CONSTANT) {
+ Variant const& keyName = static_cast<const GDParser::ConstantNode*>(key)->value;
+
+ if (keys.has(keyName)) {
+ _set_error("Duplicate key found in Dictionary literal");
+ return NULL;
+ }
+ keys.insert(keyName);
+ }
+
DictionaryNode::Pair pair;
pair.key=key;
pair.value=value;
@@ -1032,8 +1080,8 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_MUL ; break;
case GDTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_DIV ; break;
case GDTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_MOD ; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_LEFT; ; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_RIGHT; ; break;
+ case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_LEFT; break;
+ case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break;
case GDTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_AND ; break;
case GDTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_OR ; break;
case GDTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op=OperatorNode::OP_ASSIGN_BIT_XOR ; break;
@@ -1679,6 +1727,541 @@ bool GDParser::_recover_from_completion() {
return true;
}
+GDParser::PatternNode *GDParser::_parse_pattern(bool p_static)
+{
+
+ PatternNode *pattern = alloc_node<PatternNode>();
+
+ GDTokenizer::Token token = tokenizer->get_token();
+ if (error_set)
+ return NULL;
+
+ if (token == GDTokenizer::TK_EOF) {
+ return NULL;
+ }
+
+ switch (token) {
+ // array
+ case GDTokenizer::TK_BRACKET_OPEN: {
+ tokenizer->advance();
+ pattern->pt_type = GDParser::PatternNode::PT_ARRAY;
+ while (true) {
+
+ if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ tokenizer->advance();
+ break;
+ }
+
+ if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ // match everything
+ tokenizer->advance(2);
+ PatternNode *sub_pattern = alloc_node<PatternNode>();
+ sub_pattern->pt_type = GDParser::PatternNode::PT_IGNORE_REST;
+ pattern->array.push_back(sub_pattern);
+ if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_BRACKET_CLOSE) {
+ tokenizer->advance(2);
+ break;
+ } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ tokenizer->advance(1);
+ break;
+ } else {
+ _set_error("'..' pattern only allowed at the end of an array pattern");
+ return NULL;
+ }
+ }
+
+ PatternNode *sub_pattern = _parse_pattern(p_static);
+ if (!sub_pattern) {
+ return NULL;
+ }
+
+ pattern->array.push_back(sub_pattern);
+
+ if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ tokenizer->advance();
+ continue;
+ } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ tokenizer->advance();
+ break;
+ } else {
+ _set_error("Not a valid pattern");
+ return NULL;
+ }
+ }
+ } break;
+ // bind
+ case GDTokenizer::TK_PR_VAR: {
+ tokenizer->advance();
+ pattern->pt_type = GDParser::PatternNode::PT_BIND;
+ pattern->bind = tokenizer->get_token_identifier();
+ tokenizer->advance();
+ } break;
+ // dictionary
+ case GDTokenizer::TK_CURLY_BRACKET_OPEN: {
+ tokenizer->advance();
+ pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY;
+ while (true) {
+
+ if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ tokenizer->advance();
+ break;
+ }
+
+ if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ // match everything
+ tokenizer->advance(2);
+ PatternNode *sub_pattern = alloc_node<PatternNode>();
+ sub_pattern->pt_type = PatternNode::PT_IGNORE_REST;
+ pattern->array.push_back(sub_pattern);
+ if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ tokenizer->advance(2);
+ break;
+ } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ tokenizer->advance(1);
+ break;
+ } else {
+ _set_error("'..' pattern only allowed at the end of an dictionary pattern");
+ return NULL;
+ }
+ }
+
+ Node *key = _parse_and_reduce_expression(pattern, p_static);
+ if (!key) {
+ _set_error("Not a valid key in pattern");
+ return NULL;
+ }
+
+ if (key->type != GDParser::Node::TYPE_CONSTANT) {
+ _set_error("Not a constant expression as key");
+ return NULL;
+ }
+
+ if (tokenizer->get_token() == GDTokenizer::TK_COLON) {
+ tokenizer->advance();
+
+ PatternNode *value = _parse_pattern(p_static);
+ if (!value) {
+ _set_error("Expected pattern in dictionary value");
+ return NULL;
+ }
+
+ pattern->dictionary.insert(static_cast<ConstantNode*>(key), value);
+ } else {
+ pattern->dictionary.insert(static_cast<ConstantNode*>(key), NULL);
+ }
+
+
+ if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ tokenizer->advance();
+ continue;
+ } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ tokenizer->advance();
+ break;
+ } else {
+ _set_error("Not a valid pattern");
+ return NULL;
+ }
+ }
+ } break;
+ case GDTokenizer::TK_WILDCARD: {
+ tokenizer->advance();
+ pattern->pt_type = PatternNode::PT_WILDCARD;
+ } break;
+ // all the constants like strings and numbers
+ default: {
+ Node *value = _parse_and_reduce_expression(pattern, p_static);
+ if (error_set) {
+ return NULL;
+ }
+
+ if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) {
+ _set_error("Only constant expressions or variables allowed in a pattern");
+ return NULL;
+ }
+
+ pattern->pt_type = PatternNode::PT_CONSTANT;
+ pattern->constant = value;
+ } break;
+ }
+
+ return pattern;
+}
+
+void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode*> &p_branches, bool p_static)
+{
+ int indent_level = tab_level.back()->get();
+
+ while (true) {
+
+ while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline());
+
+ // GDTokenizer::Token token = tokenizer->get_token();
+ if (error_set)
+ return;
+
+ if (indent_level > tab_level.back()->get()) {
+ return; // go back a level
+ }
+
+ if (pending_newline!=-1) {
+ pending_newline=-1;
+ }
+
+ PatternBranchNode *branch = alloc_node<PatternBranchNode>();
+
+ branch->patterns.push_back(_parse_pattern(p_static));
+ if (!branch->patterns[0]) {
+ return;
+ }
+
+ while (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ tokenizer->advance();
+ branch->patterns.push_back(_parse_pattern(p_static));
+ if (!branch->patterns[branch->patterns.size() - 1]) {
+ return;
+ }
+ }
+
+ if(!_enter_indent_block()) {
+ _set_error("Expected block in pattern branch");
+ return;
+ }
+
+ branch->body = alloc_node<BlockNode>();
+ branch->body->parent_block = p_block;
+ p_block->sub_blocks.push_back(branch->body);
+ current_block = branch->body;
+
+ _parse_block(branch->body, p_static);
+
+ current_block = p_block;
+
+ p_branches.push_back(branch);
+ }
+}
+
+
+void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node*> &p_bindings)
+{
+ switch (p_pattern->pt_type) {
+ case PatternNode::PT_CONSTANT: {
+
+ // typecheck
+ BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
+ typeof_node->function = GDFunctions::TYPE_OF;
+
+ OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
+ typeof_match_value->op = OperatorNode::OP_CALL;
+ typeof_match_value->arguments.push_back(typeof_node);
+ typeof_match_value->arguments.push_back(p_node_to_match);
+
+ OperatorNode *typeof_pattern_value = alloc_node<OperatorNode>();
+ typeof_pattern_value->op = OperatorNode::OP_CALL;
+ typeof_pattern_value->arguments.push_back(typeof_node);
+ typeof_pattern_value->arguments.push_back(p_pattern->constant);
+
+ OperatorNode *type_comp = alloc_node<OperatorNode>();
+ type_comp->op = OperatorNode::OP_EQUAL;
+ type_comp->arguments.push_back(typeof_match_value);
+ type_comp->arguments.push_back(typeof_pattern_value);
+
+
+ // comare the actual values
+ OperatorNode *value_comp = alloc_node<OperatorNode>();
+ value_comp->op = OperatorNode::OP_EQUAL;
+ value_comp->arguments.push_back(p_pattern->constant);
+ value_comp->arguments.push_back(p_node_to_match);
+
+
+ OperatorNode *comparison = alloc_node<OperatorNode>();
+ comparison->op = OperatorNode::OP_AND;
+ comparison->arguments.push_back(type_comp);
+ comparison->arguments.push_back(value_comp);
+
+ p_resulting_node = comparison;
+
+ } break;
+ case PatternNode::PT_BIND: {
+ p_bindings[p_pattern->bind] = p_node_to_match;
+
+ // a bind always matches
+ ConstantNode *true_value = alloc_node<ConstantNode>();
+ true_value->value = Variant(true);
+ p_resulting_node = true_value;
+ } break;
+ case PatternNode::PT_ARRAY: {
+
+ bool open_ended = false;
+
+ if (p_pattern->array.size() > 0) {
+ if (p_pattern->array[p_pattern->array.size() - 1]->pt_type == PatternNode::PT_IGNORE_REST) {
+ open_ended = true;
+ }
+ }
+
+ // typeof(value_to_match) == TYPE_ARRAY && value_to_match.size() >= length
+ // typeof(value_to_match) == TYPE_ARRAY && value_to_match.size() == length
+
+ {
+ // typecheck
+ BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
+ typeof_node->function = GDFunctions::TYPE_OF;
+
+ OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
+ typeof_match_value->op = OperatorNode::OP_CALL;
+ typeof_match_value->arguments.push_back(typeof_node);
+ typeof_match_value->arguments.push_back(p_node_to_match);
+
+ IdentifierNode *typeof_array = alloc_node<IdentifierNode>();
+ typeof_array->name = "TYPE_ARRAY";
+
+ OperatorNode *type_comp = alloc_node<OperatorNode>();
+ type_comp->op = OperatorNode::OP_EQUAL;
+ type_comp->arguments.push_back(typeof_match_value);
+ type_comp->arguments.push_back(typeof_array);
+
+
+ // size
+ ConstantNode *length = alloc_node<ConstantNode>();
+ length->value = Variant(open_ended ? p_pattern->array.size() - 1 : p_pattern->array.size());
+
+ OperatorNode *call = alloc_node<OperatorNode>();
+ call->op = OperatorNode::OP_CALL;
+ call->arguments.push_back(p_node_to_match);
+
+ IdentifierNode *size = alloc_node<IdentifierNode>();
+ size->name = "size";
+ call->arguments.push_back(size);
+
+ OperatorNode *length_comparison = alloc_node<OperatorNode>();
+ length_comparison->op = open_ended ? OperatorNode::OP_GREATER_EQUAL : OperatorNode::OP_EQUAL;
+ length_comparison->arguments.push_back(call);
+ length_comparison->arguments.push_back(length);
+
+ OperatorNode *type_and_length_comparison = alloc_node<OperatorNode>();
+ type_and_length_comparison->op = OperatorNode::OP_AND;
+ type_and_length_comparison->arguments.push_back(type_comp);
+ type_and_length_comparison->arguments.push_back(length_comparison);
+
+ p_resulting_node = type_and_length_comparison;
+ }
+
+
+
+ for (int i = 0; i < p_pattern->array.size(); i++) {
+ PatternNode *pattern = p_pattern->array[i];
+
+ Node *condition = NULL;
+
+ ConstantNode *index = alloc_node<ConstantNode>();
+ index->value = Variant(i);
+
+ OperatorNode *indexed_value = alloc_node<OperatorNode>();
+ indexed_value->op = OperatorNode::OP_INDEX;
+ indexed_value->arguments.push_back(p_node_to_match);
+ indexed_value->arguments.push_back(index);
+
+ _generate_pattern(pattern, indexed_value, condition, p_bindings);
+
+ // concatenate all the patterns with &&
+ OperatorNode *and_node = alloc_node<OperatorNode>();
+ and_node->op = OperatorNode::OP_AND;
+ and_node->arguments.push_back(p_resulting_node);
+ and_node->arguments.push_back(condition);
+
+ p_resulting_node = and_node;
+ }
+
+
+ } break;
+ case PatternNode::PT_DICTIONARY: {
+
+ bool open_ended = false;
+
+ if (p_pattern->array.size() > 0) {
+ open_ended = true;
+ }
+
+ // typeof(value_to_match) == TYPE_DICTIONARY && value_to_match.size() >= length
+ // typeof(value_to_match) == TYPE_DICTIONARY && value_to_match.size() == length
+
+
+ {
+ // typecheck
+ BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
+ typeof_node->function = GDFunctions::TYPE_OF;
+
+ OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
+ typeof_match_value->op = OperatorNode::OP_CALL;
+ typeof_match_value->arguments.push_back(typeof_node);
+ typeof_match_value->arguments.push_back(p_node_to_match);
+
+ IdentifierNode *typeof_dictionary = alloc_node<IdentifierNode>();
+ typeof_dictionary->name = "TYPE_DICTIONARY";
+
+ OperatorNode *type_comp = alloc_node<OperatorNode>();
+ type_comp->op = OperatorNode::OP_EQUAL;
+ type_comp->arguments.push_back(typeof_match_value);
+ type_comp->arguments.push_back(typeof_dictionary);
+
+ // size
+ ConstantNode *length = alloc_node<ConstantNode>();
+ length->value = Variant(open_ended ? p_pattern->dictionary.size() - 1 : p_pattern->dictionary.size());
+
+ OperatorNode *call = alloc_node<OperatorNode>();
+ call->op = OperatorNode::OP_CALL;
+ call->arguments.push_back(p_node_to_match);
+
+ IdentifierNode *size = alloc_node<IdentifierNode>();
+ size->name = "size";
+ call->arguments.push_back(size);
+
+ OperatorNode *length_comparison = alloc_node<OperatorNode>();
+ length_comparison->op = open_ended ? OperatorNode::OP_GREATER_EQUAL : OperatorNode::OP_EQUAL;
+ length_comparison->arguments.push_back(call);
+ length_comparison->arguments.push_back(length);
+
+ OperatorNode *type_and_length_comparison = alloc_node<OperatorNode>();
+ type_and_length_comparison->op = OperatorNode::OP_AND;
+ type_and_length_comparison->arguments.push_back(type_comp);
+ type_and_length_comparison->arguments.push_back(length_comparison);
+
+ p_resulting_node = type_and_length_comparison;
+ }
+
+
+
+ for (Map<ConstantNode*, PatternNode*>::Element *e = p_pattern->dictionary.front(); e; e = e->next()) {
+
+ Node *condition = NULL;
+
+ // chech for has, then for pattern
+
+ IdentifierNode *has = alloc_node<IdentifierNode>();
+ has->name = "has";
+
+ OperatorNode *has_call = alloc_node<OperatorNode>();
+ has_call->op = OperatorNode::OP_CALL;
+ has_call->arguments.push_back(p_node_to_match);
+ has_call->arguments.push_back(has);
+ has_call->arguments.push_back(e->key());
+
+
+ if (e->value()) {
+
+ OperatorNode *indexed_value = alloc_node<OperatorNode>();
+ indexed_value->op = OperatorNode::OP_INDEX;
+ indexed_value->arguments.push_back(p_node_to_match);
+ indexed_value->arguments.push_back(e->key());
+
+ _generate_pattern(e->value(), indexed_value, condition, p_bindings);
+
+ OperatorNode *has_and_pattern = alloc_node<OperatorNode>();
+ has_and_pattern->op = OperatorNode::OP_AND;
+ has_and_pattern->arguments.push_back(has_call);
+ has_and_pattern->arguments.push_back(condition);
+
+ condition = has_and_pattern;
+
+ } else {
+ condition = has_call;
+ }
+
+
+
+ // concatenate all the patterns with &&
+ OperatorNode *and_node = alloc_node<OperatorNode>();
+ and_node->op = OperatorNode::OP_AND;
+ and_node->arguments.push_back(p_resulting_node);
+ and_node->arguments.push_back(condition);
+
+ p_resulting_node = and_node;
+ }
+
+ } break;
+ case PatternNode::PT_IGNORE_REST:
+ case PatternNode::PT_WILDCARD: {
+ // simply generate a `true`
+ ConstantNode *true_value = alloc_node<ConstantNode>();
+ true_value->value = Variant(true);
+ p_resulting_node = true_value;
+ } break;
+ default: {
+
+ } break;
+ }
+}
+
+void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement)
+{
+ IdentifierNode *id = alloc_node<IdentifierNode>();
+ id->name = "#match_value";
+
+ for (int i = 0; i < p_match_statement->branches.size(); i++) {
+
+ PatternBranchNode *branch = p_match_statement->branches[i];
+
+ MatchNode::CompiledPatternBranch compiled_branch;
+ compiled_branch.compiled_pattern = NULL;
+
+ Map<StringName, Node*> binding;
+
+ for (int j = 0; j < branch->patterns.size(); j++) {
+ PatternNode *pattern = branch->patterns[j];
+
+ Map<StringName, Node*> bindings;
+ Node *resulting_node;
+ _generate_pattern(pattern, id, resulting_node, bindings);
+
+ if (!binding.empty() && !bindings.empty()) {
+ _set_error("Multipatterns can't contain bindings");
+ return;
+ } else {
+ binding = bindings;
+ }
+
+ if (compiled_branch.compiled_pattern) {
+ OperatorNode *or_node = alloc_node<OperatorNode>();
+ or_node->op = OperatorNode::OP_OR;
+ or_node->arguments.push_back(compiled_branch.compiled_pattern);
+ or_node->arguments.push_back(resulting_node);
+
+ compiled_branch.compiled_pattern = or_node;
+ } else {
+ // single pattern | first one
+ compiled_branch.compiled_pattern = resulting_node;
+ }
+
+ }
+
+
+ // prepare the body ...hehe
+ for (Map<StringName, Node*>::Element *e = binding.front(); e; e = e->next()) {
+ LocalVarNode *local_var = alloc_node<LocalVarNode>();
+ local_var->name = e->key();
+ local_var->assign = e->value();
+
+
+ IdentifierNode *id = alloc_node<IdentifierNode>();
+ id->name = local_var->name;
+
+ OperatorNode *op = alloc_node<OperatorNode>();
+ op->op=OperatorNode::OP_ASSIGN;
+ op->arguments.push_back(id);
+ op->arguments.push_back(local_var->assign);
+
+ branch->body->statements.push_front(op);
+ branch->body->statements.push_front(local_var);
+ }
+
+ compiled_branch.body = branch->body;
+
+
+ p_match_statement->compiled_pattern_branches.push_back(compiled_branch);
+ }
+
+}
+
void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
int indent_level = tab_level.back()->get();
@@ -1762,6 +2345,24 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
}
StringName n = tokenizer->get_token_identifier();
tokenizer->advance();
+ if (current_function){
+ for (int i=0;i<current_function->arguments.size();i++){
+ if (n == current_function->arguments[i]){
+ _set_error("Variable '"+String(n)+"' already defined in the scope (at line: "+itos(current_function->line)+").");
+ return;
+ }
+ }
+ }
+ BlockNode *check_block = p_block;
+ while (check_block){
+ for (int i=0;i<check_block->variables.size();i++){
+ if (n == check_block->variables[i]){
+ _set_error("Variable '"+String(n)+"' already defined in the scope (at line: "+itos(check_block->variable_lines[i])+").");
+ return;
+ }
+ }
+ check_block = check_block->parent_block;
+ }
p_block->variables.push_back(n); //line?
p_block->variable_lines.push_back(tokenizer->get_token_line());
@@ -2013,7 +2614,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
Vector<Node*> args;
Vector<double> constants;
- bool constant=true;
+ bool constant=false;
for(int i=1;i<op->arguments.size();i++) {
args.push_back(op->arguments[i]);
@@ -2021,13 +2622,14 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
ConstantNode *c = static_cast<ConstantNode*>(op->arguments[i]);
if (c->value.get_type()==Variant::REAL || c->value.get_type()==Variant::INT) {
constants.push_back(c->value);
- } else {
- constant=false;
+ constant=true;
}
+ } else {
+ constant=false;
}
}
- if (args.size()>0 || args.size()<4) {
+ if (args.size()>0 && args.size()<4) {
if (constant) {
@@ -2079,7 +2681,14 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
}
current_block=cf_for->body;
+
+ // this is for checking variable for redefining
+ // inside this _parse_block
+ cf_for->body->variables.push_back(id->name);
+ cf_for->body->variable_lines.push_back(id->line);
_parse_block(cf_for->body,p_static);
+ cf_for->body->variables.remove(0);
+ cf_for->body->variable_lines.remove(0);
current_block=p_block;
if (error_set)
@@ -2141,6 +2750,46 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
} break;
+ case GDTokenizer::TK_CF_MATCH: {
+
+ tokenizer->advance();
+
+ MatchNode *match_node = alloc_node<MatchNode>();
+
+ Node *val_to_match = _parse_and_reduce_expression(p_block, p_static);
+
+ if (!val_to_match) {
+ if (_recover_from_completion()) {
+ break;
+ }
+ return;
+ }
+
+ match_node->val_to_match = val_to_match;
+
+ if (!_enter_indent_block()) {
+ _set_error("Expected indented pattern matching block after 'match'");
+ return;
+ }
+
+ BlockNode *compiled_branches = alloc_node<BlockNode>();
+ compiled_branches->parent_block = p_block;
+ compiled_branches->parent_class = p_block->parent_class;
+
+ p_block->sub_blocks.push_back(compiled_branches);
+
+ _parse_pattern_block(compiled_branches, match_node->branches, p_static);
+
+ _transform_match_statment(compiled_branches, match_node);
+
+ ControlFlowNode *match_cf_node = alloc_node<ControlFlowNode>();
+ match_cf_node->cf_type = ControlFlowNode::CF_MATCH;
+ match_cf_node->match = match_node;
+
+ p_block->statements.push_back(match_cf_node);
+
+ _end_statement();
+ } break;
case GDTokenizer::TK_PR_ASSERT: {
tokenizer->advance();
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index e8f5f0f981..7968bf85df 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -258,6 +258,44 @@ public:
Vector<Node*> arguments;
OperatorNode() { type=TYPE_OPERATOR; }
};
+
+
+ struct PatternNode : public Node {
+
+ enum PatternType {
+ PT_CONSTANT,
+ PT_BIND,
+ PT_DICTIONARY,
+ PT_ARRAY,
+ PT_IGNORE_REST,
+ PT_WILDCARD
+ };
+
+ PatternType pt_type;
+
+ Node *constant;
+ StringName bind;
+ Map<ConstantNode*, PatternNode*> dictionary;
+ Vector<PatternNode*> array;
+
+ };
+
+ struct PatternBranchNode : public Node {
+ Vector<PatternNode*> patterns;
+ BlockNode *body;
+ };
+
+ struct MatchNode : public Node {
+ Node *val_to_match;
+ Vector<PatternBranchNode*> branches;
+
+ struct CompiledPatternBranch {
+ Node *compiled_pattern;
+ BlockNode *body;
+ };
+
+ Vector<CompiledPatternBranch> compiled_pattern_branches;
+ };
struct ControlFlowNode : public Node {
enum CFType {
@@ -267,13 +305,16 @@ public:
CF_SWITCH,
CF_BREAK,
CF_CONTINUE,
- CF_RETURN
+ CF_RETURN,
+ CF_MATCH
};
CFType cf_type;
Vector<Node*> arguments;
BlockNode *body;
BlockNode *body_else;
+
+ MatchNode *match;
ControlFlowNode *_else; //used for if
ControlFlowNode() { type=TYPE_CONTROL_FLOW; cf_type=CF_IF; body=NULL; body_else=NULL;}
@@ -452,6 +493,15 @@ private:
Node* _reduce_expression(Node *p_node,bool p_to_const=false);
Node* _parse_and_reduce_expression(Node *p_parent,bool p_static,bool p_reduce_const=false,bool p_allow_assign=false);
+
+
+
+ PatternNode *_parse_pattern(bool p_static);
+ void _parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode*> &p_branches, bool p_static);
+ void _transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement);
+ void _generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node*> &p_bindings);
+
+
void _parse_block(BlockNode *p_block,bool p_static);
void _parse_extends(ClassNode *p_class);
void _parse_class(ClassNode *p_class);
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 0b81780b0c..4e72bc39a4 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_script.h"
-#include "globals.h"
+#include "global_config.h"
#include "global_constants.h"
#include "gd_compiler.h"
#include "os/file_access.h"
@@ -63,7 +63,7 @@ bool GDNativeClass::_get(const StringName& p_name,Variant &r_ret) const {
void GDNativeClass::_bind_methods() {
- ClassDB::bind_method(_MD("new"),&GDNativeClass::_new);
+ ClassDB::bind_method(D_METHOD("new"),&GDNativeClass::_new);
}
@@ -160,6 +160,8 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError&
_baseptr=_baseptr->_base;
}
+ ERR_FAIL_COND_V(_baseptr->native.is_null(), Variant());
+
if (_baseptr->native.ptr()) {
owner=_baseptr->native->instance();
} else {
@@ -356,9 +358,11 @@ bool GDScript::get_property_default_value(const StringName& p_property, Variant
#ifdef TOOLS_ENABLED
- //for (const Map<StringName,Variant>::Element *I=member_default_values.front();I;I=I->next()) {
- // print_line("\t"+String(String(I->key())+":"+String(I->get())));
- //}
+ /*
+ for (const Map<StringName,Variant>::Element *I=member_default_values.front();I;I=I->next()) {
+ print_line("\t"+String(String(I->key())+":"+String(I->get())));
+ }
+ */
const Map<StringName,Variant>::Element *E=member_default_values_cache.find(p_property);
if (E) {
r_value=E->get();
@@ -537,7 +541,7 @@ bool GDScript::_update_exports() {
}
}
- members_cache.clear();;
+ members_cache.clear();
member_default_values_cache.clear();
for(int i=0;i<c->variables.size();i++) {
@@ -785,7 +789,7 @@ void GDScript::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo(Variant::OBJECT,"new"));
- ClassDB::bind_method(_MD("get_as_byte_code"),&GDScript::get_as_byte_code);
+ ClassDB::bind_method(D_METHOD("get_as_byte_code"),&GDScript::get_as_byte_code);
}
@@ -1513,6 +1517,8 @@ void GDScriptLanguage::init() {
}
_add_global(StaticCString::create("PI"),Math_PI);
+ _add_global(StaticCString::create("INF"),Math_INF);
+ _add_global(StaticCString::create("NAN"),Math_NAN);
//populate native classes
@@ -1860,7 +1866,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script>& p_script,bool p_sof
void GDScriptLanguage::frame() {
- // print_line("calls: "+itos(calls));
+ //print_line("calls: "+itos(calls));
calls=0;
#ifdef DEBUG_ENABLED
@@ -1905,6 +1911,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"bool",
"null",
"PI",
+ "INF",
+ "NAN",
"self",
"true",
// functions
@@ -1934,6 +1942,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"for",
"pass",
"return",
+ "match",
"while",
"remote",
"sync",
@@ -2066,7 +2075,7 @@ bool ResourceFormatLoaderGDScript::handles_type(const String& p_type) const {
String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) const {
- String el = p_path.extension().to_lower();
+ String el = p_path.get_extension().to_lower();
if (el=="gd" || el=="gdc" || el=="gde")
return "GDScript";
return "";
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 960b06f3ff..4d3baa5bc0 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -139,7 +139,7 @@ protected:
void _get_property_list(List<PropertyInfo> *p_properties) const;
Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error);
-// void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount);
+ //void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount);
static void _bind_methods();
public:
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 30ac988295..54b9624e8e 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -85,6 +85,7 @@ const char* GDTokenizer::token_names[TK_MAX]={
"continue",
"pass",
"return",
+"match",
"func",
"class",
"extends",
@@ -118,6 +119,9 @@ const char* GDTokenizer::token_names[TK_MAX]={
"':'",
"'\\n'",
"PI",
+"_",
+"INF",
+"NAN",
"Error",
"EOF",
"Cursor"};
@@ -513,9 +517,11 @@ void GDTokenizerText::_advance() {
if (GETCHAR(1)=='=') {
_make_token(TK_OP_ASSIGN_ADD);
INCPOS(1);
- //} else if (GETCHAR(1)=='+') {
- // _make_token(TK_OP_PLUS_PLUS);
- // INCPOS(1);
+ /*
+ } else if (GETCHAR(1)=='+') {
+ _make_token(TK_OP_PLUS_PLUS);
+ INCPOS(1);
+ */
} else {
_make_token(TK_OP_ADD);
}
@@ -526,9 +532,11 @@ void GDTokenizerText::_advance() {
if (GETCHAR(1)=='=') {
_make_token(TK_OP_ASSIGN_SUB);
INCPOS(1);
- //} else if (GETCHAR(1)=='-') {
- // _make_token(TK_OP_MINUS_MINUS);
- // INCPOS(1);
+ /*
+ } else if (GETCHAR(1)=='-') {
+ _make_token(TK_OP_MINUS_MINUS);
+ INCPOS(1);
+ */
} else {
_make_token(TK_OP_SUB);
}
@@ -890,9 +898,13 @@ void GDTokenizerText::_advance() {
{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}
};
@@ -1161,7 +1173,7 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String& p_code) {
Map<StringName,int> identifier_map;
- HashMap<Variant,int,VariantHasher> constant_map;
+ HashMap<Variant,int,VariantHasher,VariantComparator> constant_map;
Map<uint32_t,int> line_map;
Vector<uint32_t> token_array;
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h
index 18e5547d36..1e9eda7947 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gd_tokenizer.h
@@ -92,6 +92,7 @@ public:
TK_CF_CONTINUE,
TK_CF_PASS,
TK_CF_RETURN,
+ TK_CF_MATCH,
TK_PR_FUNCTION,
TK_PR_CLASS,
TK_PR_EXTENDS,
@@ -126,6 +127,9 @@ public:
TK_DOLLAR,
TK_NEWLINE,
TK_CONST_PI,
+ TK_WILDCARD,
+ TK_CONST_INF,
+ TK_CONST_NAN,
TK_ERROR,
TK_EOF,
TK_CURSOR, //used for code completion
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 11bdf783f8..db47ee43ce 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -38,7 +38,7 @@
GDScriptLanguage *script_language_gd=NULL;
ResourceFormatLoaderGDScript *resource_loader_gd=NULL;
ResourceFormatSaverGDScript *resource_saver_gd=NULL;
-
+#if 0
#ifdef TOOLS_ENABLED
#include "tools/editor/editor_import_export.h"
@@ -100,7 +100,7 @@ public:
if (err==OK) {
fae->store_buffer(file.ptr(),file.size());
- p_path=p_path.basename()+".gde";
+ p_path=p_path.get_basename()+".gde";
}
memdelete(fae);
@@ -111,7 +111,7 @@ public:
} else {
- p_path=p_path.basename()+".gdc";
+ p_path=p_path.get_basename()+".gdc";
return file;
}
}
@@ -135,7 +135,7 @@ static void register_editor_plugin() {
#endif
-
+#endif
void register_gdscript_types() {
ClassDB::register_class<GDScript>();
@@ -148,11 +148,12 @@ void register_gdscript_types() {
ResourceLoader::add_resource_format_loader(resource_loader_gd);
resource_saver_gd=memnew( ResourceFormatSaverGDScript );
ResourceSaver::add_resource_format_saver(resource_saver_gd);
-
+#if 0
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(register_editor_plugin);
#endif
+#endif
}
void unregister_gdscript_types() {
diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py
index 1ab13c4aeb..5698a37295 100644
--- a/modules/gridmap/config.py
+++ b/modules/gridmap/config.py
@@ -1,8 +1,7 @@
def can_build(platform):
- # FIXME: Disabled temporary for gles3 implementation
- return False
+ return True
def configure(env):
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index b5fa55846c..d4fb174bfe 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -31,7 +31,7 @@
#include "scene/resources/surface_tool.h"
#include "message_queue.h"
#include "scene/3d/light.h"
-#include "scene/3d/baked_light_instance.h"
+
#include "io/marshalls.h"
#include "scene/scene_string_names.h"
#include "os/os.h"
@@ -41,31 +41,27 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
- if (name=="theme/theme") {
+ if (name=="theme") {
set_theme(p_value);
- } else if (name=="cell/size") {
+ } else if (name=="cell_size") {
set_cell_size(p_value);
- } else if (name=="cell/octant_size") {
+ } else if (name=="cell_octant_size") {
set_octant_size(p_value);
- } else if (name=="cell/center_x") {
+ } else if (name=="cell_center_x") {
set_center_x(p_value);
- } else if (name=="cell/center_y") {
+ } else if (name=="cell_center_y") {
set_center_y(p_value);
- } else if (name=="cell/center_z") {
+ } else if (name=="cell_center_z") {
set_center_z(p_value);
- } else if (name=="cell/scale") {
+ } else if (name=="cell_scale") {
set_cell_scale(p_value);
- } else if (name=="lighting/bake") {
- set_use_baked_light(p_value);
- } else if (name=="theme/bake") {
- set_bake(p_value);
/* } else if (name=="cells") {
PoolVector<int> cells = p_value;
int amount=cells.size();
PoolVector<int>::Read r = cells.read();
ERR_FAIL_COND_V(amount&1,false); // not even
- cell_map.clear();;
+ cell_map.clear();
for(int i=0;i<amount/3;i++) {
@@ -81,16 +77,13 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
Dictionary d = p_value;
- Dictionary baked;
- if (d.has("baked"))
- baked=d["baked"];
if (d.has("cells")) {
PoolVector<int> cells = d["cells"];
int amount=cells.size();
PoolVector<int>::Read r = cells.read();
ERR_FAIL_COND_V(amount%3,false); // not even
- cell_map.clear();;
+ cell_map.clear();
for(int i=0;i<amount/3;i++) {
IndexKey ik;
@@ -101,33 +94,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
}
}
- baked_lock=baked.size()!=0;
_recreate_octant_data();
- baked_lock=false;
- if (!baked.empty()) {
- List<Variant> kl;
- baked.get_key_list(&kl);
- for (List<Variant>::Element *E=kl.front();E;E=E->next()) {
-
- Plane ikv = E->get();
- Ref<Mesh> b=baked[ikv];
- ERR_CONTINUE(!b.is_valid());
- OctantKey ok;
- ok.x=ikv.normal.x;
- ok.y=ikv.normal.y;
- ok.z=ikv.normal.z;
- ok.area=ikv.d;
-
- ERR_CONTINUE(!octant_map.has(ok));
-
- Octant &g = *octant_map[ok];
-
- g.baked=b;
- g.bake_instance=VS::get_singleton()->instance_create();;
- VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid());
- VS::get_singleton()->instance_geometry_set_baked_light(g.bake_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
- }
- }
} else if (name.begins_with("areas/")) {
@@ -161,24 +128,20 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
String name=p_name;
- if (name=="theme/theme") {
+ if (name=="theme") {
r_ret= get_theme();
- } else if (name=="cell/size") {
+ } else if (name=="cell_size") {
r_ret= get_cell_size();
- } else if (name=="cell/octant_size") {
+ } else if (name=="cell_octant_size") {
r_ret= get_octant_size();
- } else if (name=="cell/center_x") {
+ } else if (name=="cell_center_x") {
r_ret= get_center_x();
- } else if (name=="cell/center_y") {
+ } else if (name=="cell_center_y") {
r_ret= get_center_y();
- } else if (name=="cell/center_z") {
+ } else if (name=="cell_center_z") {
r_ret= get_center_z();
- } else if (name=="cell/scale") {
+ } else if (name=="cell_scale") {
r_ret= cell_scale;
- } else if (name=="lighting/bake") {
- r_ret=is_using_baked_light();
- } else if (name=="theme/bake") {
- r_ret= bake;
} else if (name=="data") {
Dictionary d;
@@ -197,23 +160,8 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
d["cells"]=cells;
- Dictionary baked;
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- Octant &g=*E->get();
-
- if (g.baked.is_valid()) {
-
- baked[Plane(E->key().x,E->key().y,E->key().z,E->key().area)]=g.baked;
- }
- }
-
- if (baked.size()) {
- d["baked"]=baked;
- }
-
r_ret= d;
} else if (name.begins_with("areas/")) {
int which = name.get_slicec('/',1).to_int();
@@ -237,15 +185,14 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
void GridMap::_get_property_list( List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::OBJECT, "theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "theme/bake"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "lighting/bake"));
- p_list->push_back( PropertyInfo( Variant::REAL, "cell/size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
- p_list->push_back( PropertyInfo( Variant::INT, "cell/octant_size",PROPERTY_HINT_RANGE,"1,1024,1") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_x") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_y") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_z") );
- p_list->push_back( PropertyInfo( Variant::REAL, "cell/scale") );
+ p_list->push_back( PropertyInfo( Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
+ p_list->push_back( PropertyInfo( Variant::NIL, "Cell", PROPERTY_HINT_NONE,"cell_",PROPERTY_USAGE_GROUP));
+ p_list->push_back( PropertyInfo( Variant::REAL, "cell_size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
+ p_list->push_back( PropertyInfo( Variant::INT, "cell_octant_size",PROPERTY_HINT_RANGE,"1,1024,1") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_x") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_y") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_z") );
+ p_list->push_back( PropertyInfo( Variant::REAL, "cell_scale") );
p_list->push_back( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) );
@@ -380,17 +327,6 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){
g.items.erase(prev_item);
}
-
- if (g.items.empty() || !baked_lock) {
- //unbake just in case
- if (g.baked.is_valid()) {
- VS::get_singleton()->free(g.bake_instance);
- g.bake_instance=RID();
- g.baked=Ref<Mesh>();
- }
-
-
- }
if (g.items.empty()) {
PhysicsServer::get_singleton()->free(g.static_body);
@@ -454,24 +390,12 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){
ii.navmesh=theme->get_item_navmesh(p_item);
}
ii.multimesh = Ref<MultiMesh>( memnew( MultiMesh ) );
+ ii.multimesh->set_color_format(MultiMesh::COLOR_NONE);
+ ii.multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
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_baked_light(ii.multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
- if (!baked_lock) {
-
- //unbake just in case
- if (g.bake_instance.is_valid())
- VS::get_singleton()->free(g.bake_instance);
- g.baked=Ref<Mesh>();
- if (is_inside_world()) {
- VS::get_singleton()->instance_set_scenario(ii.multimesh_instance,get_world()->get_scenario());
- if (ok.area) {
- VS::get_singleton()->instance_set_room( ii.multimesh_instance,area_map[ok.area]->instance);
- }
- }
- }
g.items[p_item]=ii;
}
@@ -585,27 +509,14 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
VS::get_singleton()->instance_set_room(g.collision_debug_instance,area_map[p_key.area]->instance);
}
}
- if (g.baked.is_valid()) {
+ for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
- Transform xf = get_global_transform();
- xf.translate(_octant_get_offset(p_key));
+ VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ //print_line("INSTANCEPOS: "+get_global_transform());
- VS::get_singleton()->instance_set_transform(g.bake_instance,xf);
- VS::get_singleton()->instance_set_scenario(g.bake_instance,get_world()->get_scenario());
if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(g.bake_instance,area_map[p_key.area]->instance);
-
- }
- } else {
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
-
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- //print_line("INSTANCEPOS: "+get_global_transform());
-
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance);
- }
+ VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance);
}
}
}
@@ -621,17 +532,10 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
VS::get_singleton()->instance_set_transform(g.collision_debug_instance,get_global_transform());
}
- if (g.baked.is_valid()) {
-
- Transform xf = get_global_transform();
- xf.origin+=_octant_get_offset(p_key);
- VS::get_singleton()->instance_set_transform(g.bake_instance,xf);
- } else {
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
+ for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- //print_line("UPDATEPOS: "+get_global_transform());
- }
+ VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ //print_line("UPDATEPOS: "+get_global_transform());
}
}
@@ -711,7 +615,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
ii.multimesh->set_instance_transform(idx,xform);
//ii.multimesh->set_instance_transform(idx,Transform() );
- ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
+ //ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
//print_line("MMINST: "+xform);
@@ -731,7 +635,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
ii.shape->add_vertices_to_array(col_debug,xform);
}
- // print_line("PHIS x: "+xform);
+ //print_line("PHIS x: "+xform);
}
// add the item's navmesh at given xform to GridMap's Navigation ancestor
@@ -748,7 +652,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
idx++;
}
- ii.multimesh->set_aabb(aabb);
+ //ii.multimesh->set_aabb(aabb);
}
@@ -760,7 +664,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
arr.resize(VS::ARRAY_MAX);
arr[VS::ARRAY_VERTEX]=col_debug;
- VS::get_singleton()->mesh_add_surface(g.collision_debug,VS::PRIMITIVE_LINES,arr);
+ VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug,VS::PRIMITIVE_LINES,arr);
SceneTree *st=SceneTree::get_singleton();
if (st) {
VS::get_singleton()->mesh_surface_set_material( g.collision_debug, 0,st->get_debug_collision_material()->get_rid() );
@@ -780,13 +684,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
PhysicsServer::get_singleton()->body_set_space(g.static_body,RID());
- if (g.baked.is_valid()) {
-
- VS::get_singleton()->instance_set_room(g.bake_instance,RID());
- VS::get_singleton()->instance_set_scenario(g.bake_instance,RID());
-
- }
-
if (g.collision_debug_instance.is_valid()) {
VS::get_singleton()->instance_set_room(g.collision_debug_instance,RID());
@@ -796,200 +693,12 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,RID());
- // VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ //VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
VS::get_singleton()->instance_set_room(E->get().multimesh_instance,RID());
}
}
-void GridMap::_octant_clear_baked(const OctantKey &p_key) {
-
-
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant&g = *octant_map[p_key];
-
- if (!g.baked.is_valid())
- return;
-
- VS::get_singleton()->free(g.bake_instance);
- g.bake_instance=RID();
- g.baked=Ref<Mesh>();
-
- if (is_inside_tree())
- _octant_enter_world(p_key);
- g.dirty=true;
- _queue_dirty_map();
-}
-
-void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tmesh,const Vector<BakeLight> &p_lights,List<Vector3> *p_prebake) {
-
-
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant&g = *octant_map[p_key];
-
- Ref<TriangleMesh> tm=p_tmesh;
- if (!p_prebake && is_inside_world())
- _octant_exit_world(p_key);
-
- Map< Ref<Material>, Ref<SurfaceTool> > surfaces;
- Vector3 ofs(cell_size*0.5*int(center_x),cell_size*0.5*int(center_y),cell_size*0.5*int(center_z));
- Vector3 octant_ofs=_octant_get_offset(p_key);
-
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
-
- Octant::ItemInstances &ii=E->get();
-
- if (ii.mesh.is_null())
- continue;
-
- for(Set<IndexKey>::Element *F=ii.cells.front();F;F=F->next()) {
-
- IndexKey ik=F->get();
- Map<IndexKey,Cell>::Element *C=cell_map.find(ik);
- ERR_CONTINUE(!C);
- Vector3 cellpos = Vector3(ik.x,ik.y,ik.z );
-
- Transform xform;
- xform.basis.set_orthogonal_index(C->get().rot);
- xform.set_origin( cellpos*cell_size+ofs);
- if (!p_prebake)
- xform.origin-=octant_ofs;
-
-
- for(int i=0;i<ii.mesh->get_surface_count();i++) {
-
- if (p_prebake) {
-
- if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
- continue;
- Array a = ii.mesh->surface_get_arrays(i);
- PoolVector<Vector3> av=a[VS::ARRAY_VERTEX];
- int avs = av.size();
- PoolVector<Vector3>::Read vr = av.read();
-
- PoolVector<int> ai=a[VS::ARRAY_INDEX];
- int ais=ai.size();
- if (ais) {
-
- PoolVector<int>::Read ir=ai.read();
- for(int j=0;j<ais;j++) {
-
- p_prebake->push_back(xform.xform(vr[ir[j]]));
- //print_line("V SET: "+xform.xform(vr[ir[j]]));
- }
-
- } else {
-
- for(int j=0;j<avs;j++) {
-
- p_prebake->push_back(xform.xform(vr[j]));
- }
- }
-
- } else {
-
- Ref<Material> m = ii.mesh->surface_get_material(i);
-
- Map< Ref<Material>, Ref<SurfaceTool> >::Element *S=surfaces.find(m);
-
- if (!S) {
-
- S=surfaces.insert(m,Ref<SurfaceTool>( memnew( SurfaceTool )));
- }
-
- Ref<SurfaceTool> st = S->get();
- List<SurfaceTool::Vertex>::Element *V=st->get_vertex_array().back();
- st->append_from(ii.mesh,i,xform);
- st->set_material(m);
-
-
- if (tm.is_valid()) {
-
- if (V)
- V=V->next();
- else
- V=st->get_vertex_array().front();;
- int lc = p_lights.size();
- const BakeLight* bl = p_lights.ptr();
- float ofs = cell_size*0.02;
-
-
- for(;V;V=V->next()) {
-
- SurfaceTool::Vertex &v=V->get();
-
- Vector3 vertex = v.vertex + octant_ofs;
- //print_line("V GET: "+vertex);
- Vector3 normal = tm->get_area_normal( Rect3( Vector3(-ofs,-ofs,-ofs)+vertex,Vector3(ofs,ofs,ofs)*2.0));
- if (normal==Vector3()) {
- print_line("couldn't find for vertex: "+vertex);
- }
- ERR_CONTINUE( normal== Vector3());
-
- float max_l=1.0;
- float max_dist=1.0;
-
- if (lc) {
-
- for(int j=0;j<lc;j++) {
- const BakeLight &l=bl[j];
- switch(l.type) {
- case VS::LIGHT_DIRECTIONAL: {
-
- Vector3 ray_from=vertex + normal *ofs;
- Vector3 ray_to=l.dir*5000;
- Vector3 n;
- Vector3 p;
- if (tm->intersect_segment(ray_from,ray_to,p,n)) {
-
- float dist = 1.0-l.param[VS::LIGHT_PARAM_SHADOW_DARKENING];
- if (dist<=max_dist) {
- max_dist=dist;
- max_l=1.0-dist;
- }
- }
- } break;
- }
-
- }
- }
-
- v.color=Color(max_l,max_l,max_l,1.0);
-
- }
-
- st->add_to_format(VS::ARRAY_FORMAT_COLOR);
- if (m.is_valid()) {
- Ref<FixedSpatialMaterial> fm = m;
- if (fm.is_valid())
- fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true);
- }
- }
- }
- }
- }
- }
-
- if (p_prebake)
- return;
-
- g.baked = Ref<Mesh>( memnew( Mesh ));
-
- for(Map< Ref<Material>, Ref<SurfaceTool> >::Element *E=surfaces.front();E;E=E->next()) {
-
- Ref<SurfaceTool> st = E->get();
- st->commit(g.baked);
- }
-
- g.bake_instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid());
-
- if (is_inside_world())
- _octant_enter_world(p_key);
-
- g.dirty=true;
- _queue_dirty_map();
-}
void GridMap::_notification(int p_what) {
@@ -1001,8 +710,8 @@ void GridMap::_notification(int p_what) {
_update_area_instances();
for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-// IndexKey ik;
-// ik.key = E->key().indexkey;
+ //IndexKey ik;
+ //ik.key = E->key().indexkey;
_octant_enter_world(E->key());
_octant_update(E->key());
}
@@ -1011,10 +720,6 @@ void GridMap::_notification(int p_what) {
last_transform=get_global_transform();
- if (use_baked_light) {
-
- _find_baked_light();
- }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -1036,15 +741,6 @@ void GridMap::_notification(int p_what) {
_octant_exit_world(E->key());
}
- if (use_baked_light) {
-
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
-
- }
//_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
//_update_dirty_map_callback();
@@ -1122,9 +818,6 @@ void GridMap::_clear_internal(bool p_keep_areas) {
VS::get_singleton()->free(F->get().multimesh_instance);
}
- //unbake just in case
- if (E->get()->bake_instance.is_valid())
- VS::get_singleton()->free(E->get()->bake_instance);
if (E->get()->collision_debug.is_valid())
VS::get_singleton()->free(E->get()->collision_debug);
@@ -1185,60 +878,48 @@ void GridMap::_update_dirty_map_callback() {
void GridMap::_bind_methods() {
- ClassDB::bind_method(_MD("set_theme","theme:MeshLibrary"),&GridMap::set_theme);
- ClassDB::bind_method(_MD("get_theme:MeshLibrary"),&GridMap::get_theme);
-
- ClassDB::bind_method(_MD("set_bake","enable"),&GridMap::set_bake);
- ClassDB::bind_method(_MD("is_baking_enabled"),&GridMap::is_baking_enabled);
-
- ClassDB::bind_method(_MD("set_cell_size","size"),&GridMap::set_cell_size);
- ClassDB::bind_method(_MD("get_cell_size"),&GridMap::get_cell_size);
-
- ClassDB::bind_method(_MD("set_octant_size","size"),&GridMap::set_octant_size);
- ClassDB::bind_method(_MD("get_octant_size"),&GridMap::get_octant_size);
+ ClassDB::bind_method(D_METHOD("set_theme","theme:MeshLibrary"),&GridMap::set_theme);
+ ClassDB::bind_method(D_METHOD("get_theme:MeshLibrary"),&GridMap::get_theme);
- ClassDB::bind_method(_MD("set_cell_item","x","y","z","item","orientation"),&GridMap::set_cell_item,DEFVAL(0));
- ClassDB::bind_method(_MD("get_cell_item","x","y","z"),&GridMap::get_cell_item);
- ClassDB::bind_method(_MD("get_cell_item_orientation","x","y","z"),&GridMap::get_cell_item_orientation);
+ ClassDB::bind_method(D_METHOD("set_cell_size","size"),&GridMap::set_cell_size);
+ ClassDB::bind_method(D_METHOD("get_cell_size"),&GridMap::get_cell_size);
-// ClassDB::bind_method(_MD("_recreate_octants"),&GridMap::_recreate_octants);
- ClassDB::bind_method(_MD("_update_dirty_map_callback"),&GridMap::_update_dirty_map_callback);
- ClassDB::bind_method(_MD("resource_changed","resource"),&GridMap::resource_changed);
+ ClassDB::bind_method(D_METHOD("set_octant_size","size"),&GridMap::set_octant_size);
+ ClassDB::bind_method(D_METHOD("get_octant_size"),&GridMap::get_octant_size);
- ClassDB::bind_method(_MD("set_center_x","enable"),&GridMap::set_center_x);
- ClassDB::bind_method(_MD("get_center_x"),&GridMap::get_center_x);
- ClassDB::bind_method(_MD("set_center_y","enable"),&GridMap::set_center_y);
- ClassDB::bind_method(_MD("get_center_y"),&GridMap::get_center_y);
- ClassDB::bind_method(_MD("set_center_z","enable"),&GridMap::set_center_z);
- ClassDB::bind_method(_MD("get_center_z"),&GridMap::get_center_z);
+ ClassDB::bind_method(D_METHOD("set_cell_item","x","y","z","item","orientation"),&GridMap::set_cell_item,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_cell_item","x","y","z"),&GridMap::get_cell_item);
+ ClassDB::bind_method(D_METHOD("get_cell_item_orientation","x","y","z"),&GridMap::get_cell_item_orientation);
- ClassDB::bind_method(_MD("set_clip","enabled","clipabove","floor","axis"),&GridMap::set_clip,DEFVAL(true),DEFVAL(0),DEFVAL(Vector3::AXIS_X));
+ //ClassDB::bind_method(D_METHOD("_recreate_octants"),&GridMap::_recreate_octants);
+ ClassDB::bind_method(D_METHOD("_update_dirty_map_callback"),&GridMap::_update_dirty_map_callback);
+ ClassDB::bind_method(D_METHOD("resource_changed","resource"),&GridMap::resource_changed);
- ClassDB::bind_method(_MD("create_area","id","area"),&GridMap::create_area);
- ClassDB::bind_method(_MD("area_get_bounds","area","bounds"),&GridMap::area_get_bounds);
- ClassDB::bind_method(_MD("area_set_exterior_portal","area","enable"),&GridMap::area_set_exterior_portal);
- ClassDB::bind_method(_MD("area_set_name","area","name"),&GridMap::area_set_name);
- ClassDB::bind_method(_MD("area_get_name","area"),&GridMap::area_get_name);
- ClassDB::bind_method(_MD("area_is_exterior_portal","area"),&GridMap::area_is_exterior_portal);
- ClassDB::bind_method(_MD("area_set_portal_disable_distance","area","distance"),&GridMap::area_set_portal_disable_distance);
- ClassDB::bind_method(_MD("area_get_portal_disable_distance","area"),&GridMap::area_get_portal_disable_distance);
- ClassDB::bind_method(_MD("area_set_portal_disable_color","area","color"),&GridMap::area_set_portal_disable_color);
- ClassDB::bind_method(_MD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color);
- ClassDB::bind_method(_MD("erase_area","area"),&GridMap::erase_area);
- ClassDB::bind_method(_MD("get_unused_area_id","area"),&GridMap::get_unused_area_id);
- ClassDB::bind_method(_MD("bake_geometry"),&GridMap::bake_geometry);
+ ClassDB::bind_method(D_METHOD("set_center_x","enable"),&GridMap::set_center_x);
+ ClassDB::bind_method(D_METHOD("get_center_x"),&GridMap::get_center_x);
+ ClassDB::bind_method(D_METHOD("set_center_y","enable"),&GridMap::set_center_y);
+ ClassDB::bind_method(D_METHOD("get_center_y"),&GridMap::get_center_y);
+ ClassDB::bind_method(D_METHOD("set_center_z","enable"),&GridMap::set_center_z);
+ ClassDB::bind_method(D_METHOD("get_center_z"),&GridMap::get_center_z);
- ClassDB::bind_method(_MD("_baked_light_changed"),&GridMap::_baked_light_changed);
- ClassDB::bind_method(_MD("set_use_baked_light","use"),&GridMap::set_use_baked_light);
- ClassDB::bind_method(_MD("is_using_baked_light","use"),&GridMap::is_using_baked_light);
+ ClassDB::bind_method(D_METHOD("set_clip","enabled","clipabove","floor","axis"),&GridMap::set_clip,DEFVAL(true),DEFVAL(0),DEFVAL(Vector3::AXIS_X));
- ClassDB::bind_method(_MD("_get_baked_light_meshes"),&GridMap::_get_baked_light_meshes);
+ ClassDB::bind_method(D_METHOD("create_area","id","area"),&GridMap::create_area);
+ ClassDB::bind_method(D_METHOD("area_get_bounds","area","bounds"),&GridMap::area_get_bounds);
+ ClassDB::bind_method(D_METHOD("area_set_exterior_portal","area","enable"),&GridMap::area_set_exterior_portal);
+ ClassDB::bind_method(D_METHOD("area_set_name","area","name"),&GridMap::area_set_name);
+ ClassDB::bind_method(D_METHOD("area_get_name","area"),&GridMap::area_get_name);
+ ClassDB::bind_method(D_METHOD("area_is_exterior_portal","area"),&GridMap::area_is_exterior_portal);
+ ClassDB::bind_method(D_METHOD("area_set_portal_disable_distance","area","distance"),&GridMap::area_set_portal_disable_distance);
+ ClassDB::bind_method(D_METHOD("area_get_portal_disable_distance","area"),&GridMap::area_get_portal_disable_distance);
+ ClassDB::bind_method(D_METHOD("area_set_portal_disable_color","area","color"),&GridMap::area_set_portal_disable_color);
+ ClassDB::bind_method(D_METHOD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color);
+ ClassDB::bind_method(D_METHOD("erase_area","area"),&GridMap::erase_area);
+ ClassDB::bind_method(D_METHOD("get_unused_area_id","area"),&GridMap::get_unused_area_id);
+ ClassDB::bind_method(D_METHOD("clear"),&GridMap::clear);
-
- ClassDB::set_method_flags("GridMap","bake_geometry",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
-
- ClassDB::bind_method(_MD("clear"),&GridMap::clear);
+ ClassDB::bind_method(D_METHOD("get_meshes"),&GridMap::get_meshes);
BIND_CONSTANT( INVALID_CELL_ITEM );
@@ -1622,23 +1303,6 @@ int GridMap::get_unused_area_id() const {
return area_map.back()->key()+1;
}
-
-void GridMap::set_bake(bool p_bake) {
-
- bake=p_bake;
- if (bake==false) {
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- _octant_clear_baked(E->key());
- }
- }
-}
-
-bool GridMap::is_baking_enabled() const {
-
- return bake;
-}
-
void GridMap::set_cell_scale(float p_scale) {
cell_scale=p_scale;
@@ -1652,98 +1316,8 @@ float GridMap::get_cell_scale() const{
-void GridMap::bake_geometry() {
-
- //used to compute vertex occlusion
- Ref<TriangleMesh> tmesh;
- Vector<BakeLight> lights;
-
- if (true) {
-
- List<Vector3> vertices;
-
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
- _octant_bake(E->key(),tmesh,lights,&vertices);
-
- }
-
- PoolVector<Vector3> vv;
- vv.fill_with(vertices);
- //print_line("TOTAL VERTICES: "+itos(vv.size()));
- tmesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
- tmesh->create(vv);
-
-
- for(int i=0;i<get_child_count();i++) {
-
- if (get_child(i)->cast_to<Light>()) {
- Light *l = get_child(i)->cast_to<Light>();
- BakeLight bl;
- for(int i=0;i<Light::PARAM_MAX;i++) {
- bl.param[i]=l->get_parameter(Light::Parameter(i));
- }
- Transform t=l->get_global_transform();
- bl.pos=t.origin;
- bl.dir=t.basis.get_axis(2);
- bl.type=l->get_light_type();
- lights.push_back(bl);
-
- }
- }
- }
-
- int idx=0;
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
- if (E->get()->baked.is_valid())
- _octant_clear_baked(E->key());
-
- _octant_bake(E->key(),tmesh,lights);
- print_line("baking "+itos(idx)+"/"+itos(octant_map.size()));
- idx++;
- }
-
-}
-
-void GridMap::_baked_light_changed() {
-
-// if (!baked_light_instance)
-// VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
-// else
-// VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- for(Map<int,Octant::ItemInstances>::Element *F=E->get()->items.front();F;F=F->next()) {
-
- VS::get_singleton()->instance_geometry_set_baked_light(F->get().multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
- }
-
- }
-
-}
-
-void GridMap::_find_baked_light() {
-
- Node *n=get_parent();
- while(n) {
-
- BakedLightInstance *bl=n->cast_to<BakedLightInstance>();
- if (bl) {
-
- baked_light_instance=bl;
- baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- _baked_light_changed();
- return;
- }
-
- n=n->get_parent();
- }
-
- _baked_light_changed();
-}
-
-
-Array GridMap::_get_baked_light_meshes() {
+Array GridMap::get_meshes() {
if (theme.is_null())
return Array();
@@ -1781,31 +1355,6 @@ Array GridMap::_get_baked_light_meshes() {
return meshes;
}
-void GridMap::set_use_baked_light(bool p_use) {
-
- if (use_baked_light==p_use)
- return;
-
- use_baked_light=p_use;
-
- if (is_inside_world()) {
- if (!p_use) {
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
- } else {
- _find_baked_light();
- }
- }
-
-}
-
-bool GridMap::is_using_baked_light() const{
-
- return use_baked_light;
-}
@@ -1823,14 +1372,11 @@ GridMap::GridMap() {
clip_floor=0;
clip_axis=Vector3::AXIS_Z;
clip_above=true;
- baked_lock=false;
- bake=false;
cell_scale=1.0;
- baked_light_instance=NULL;
- use_baked_light=false;
navigation = NULL;
+ set_notify_transform(true);
}
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 04d140cdc6..5d4133383b 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -103,8 +103,6 @@ class GridMap : public Spatial {
Ref<NavigationMesh> navmesh;
};
- Ref<Mesh> baked;
- RID bake_instance;
RID collision_debug;
RID collision_debug_instance;
@@ -140,14 +138,12 @@ class GridMap : public Spatial {
float cell_size;
int octant_size;
bool center_x,center_y,center_z;
- bool bake;
float cell_scale;
Navigation *navigation;
bool clip;
bool clip_above;
int clip_floor;
- bool baked_lock;
Vector3::Axis clip_axis;
@@ -205,9 +201,7 @@ class GridMap : public Spatial {
void _octant_exit_world(const OctantKey &p_key);
void _octant_update(const OctantKey &p_key);
void _octant_transform(const OctantKey &p_key);
- void _octant_clear_baked(const OctantKey &p_key);
void _octant_clear_navmesh(const GridMap::OctantKey&);
- void _octant_bake(const OctantKey &p_key,const Ref<TriangleMesh>& p_tmesh=RES(),const Vector<BakeLight> &p_lights=Vector<BakeLight>(),List<Vector3> *r_prebake=NULL);
bool awaiting_update;
void _queue_dirty_map();
@@ -221,14 +215,6 @@ class GridMap : public Spatial {
void _clear_internal(bool p_keep_areas=false);
- BakedLightInstance *baked_light_instance;
- bool use_baked_light;
- void _find_baked_light();
- void _baked_light_changed();
-
-
- Array _get_baked_light_meshes();
-
protected:
bool _set(const StringName& p_name, const Variant& p_value);
@@ -285,13 +271,11 @@ public:
void set_cell_scale(float p_scale);
float get_cell_scale() const;
- void set_bake(bool p_bake);
- bool is_baking_enabled() const;
- void bake_geometry();
- void set_use_baked_light(bool p_use);
- bool is_using_baked_light() const;
+ Array get_meshes();
+
+
void clear();
GridMap();
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 109f6338db..2630360058 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -249,7 +249,7 @@ void GridMapEditor::_update_cursor_transform() {
if (cursor_instance.is_valid()) {
VisualServer::get_singleton()->instance_set_transform(cursor_instance,cursor_transform);
- VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance,VS::INSTANCE_FLAG_VISIBLE,cursor_visible);
+ VisualServer::get_singleton()->instance_set_visible(cursor_instance,cursor_visible);
}
}
@@ -852,11 +852,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
if (!node) {
set_process(false);
for(int i=0;i<3;i++) {
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,false);
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i],false);
}
- VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance, VS::INSTANCE_FLAG_VISIBLE,false);
+ VisualServer::get_singleton()->instance_set_visible(cursor_instance,false);
_clear_areas();
@@ -884,13 +884,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
{
//update grids
- indicator_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
- VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false );
-
- VisualServer::get_singleton()->fixed_material_set_param(indicator_mat,VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.8,0.5,0.1));
- VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
- VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY, true );
+ indicator_mat.instance();
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
+ indicator_mat->set_albedo(Color(0.8,0.5,0.1));
Vector<Vector3> grid_points[3];
@@ -903,7 +901,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
Vector3 axis;
axis[i]=1;
Vector3 axis_n1;
- axis_n1[(i+1)%3]=cell_size[(i+1)%3];;
+ axis_n1[(i+1)%3]=cell_size[(i+1)%3];
Vector3 axis_n2;
axis_n2[(i+2)%3]=cell_size[(i+2)%3];
@@ -937,8 +935,8 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
d.resize(VS::ARRAY_MAX);
d[VS::ARRAY_VERTEX]=grid_points[i];
d[VS::ARRAY_COLOR]=grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat->get_rid());
}
@@ -976,7 +974,7 @@ void GridMapEditor::update_grid() {
for(int i=0;i<3;i++) {
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,i==edit_axis);
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i],i==edit_axis);
}
@@ -1103,7 +1101,7 @@ void GridMapEditor::_update_areas_display() {
if (!node) {
return;
}
-
+#if 0
_clear_areas();
List<int> areas;
node->get_area_list(&areas);
@@ -1118,6 +1116,8 @@ void GridMapEditor::_update_areas_display() {
color=Color(1,1,1,0.2);
else
color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
+
+
RID material = VisualServer::get_singleton()->fixed_material_create();
VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
@@ -1149,7 +1149,7 @@ void GridMapEditor::_update_areas_display() {
this->areas.push_back(ad);
}
-
+#endif
}
void GridMapEditor::_edit_mode_changed(int p_what) {
@@ -1189,7 +1189,7 @@ void GridMapEditor::_bind_methods() {
ClassDB::bind_method("_area_selected",&GridMapEditor::_area_selected);
ClassDB::bind_method("_floor_changed",&GridMapEditor::_floor_changed);
- ClassDB::bind_method(_MD("_set_display_mode","mode"), &GridMapEditor::_set_display_mode);
+ ClassDB::bind_method(D_METHOD("_set_display_mode","mode"), &GridMapEditor::_set_display_mode);
}
@@ -1274,8 +1274,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
edit_mode = memnew(OptionButton);
edit_mode->set_area_as_parent_rect();
- edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24);;
- edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14);;
+ edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24);
+ edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14);
edit_mode->add_item("Tiles");
edit_mode->add_item("Areas");
hb->add_child(edit_mode);
@@ -1295,7 +1295,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
hb->add_child(mode_list);
mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
- EDITOR_DEF("editors/grid_map/preview_size",64)
+ EDITOR_DEF("editors/grid_map/preview_size",64);
display_mode = DISPLAY_THUMBNAIL;
selected_area=-1;
@@ -1387,52 +1387,36 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
Array d;
d.resize(VS::ARRAY_MAX);
- inner_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3));
- VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( inner_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
+ inner_mat.instance();
+ inner_mat->set_albedo(Color(0.7,0.7,1.0,0.3));
+ inner_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ inner_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ inner_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
d[VS::ARRAY_VERTEX]=triangles;
- VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_TRIANGLES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat->get_rid());
- outer_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8));
- VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0);
- VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( outer_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
+ outer_mat.instance();
+ outer_mat->set_albedo(Color(0.7,0.7,1.0,0.3));
+ outer_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ outer_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ outer_mat->set_line_width(3.0);
+ outer_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
d[VS::ARRAY_VERTEX]=lines;
- VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat);
-
-
- inner_mat_dup = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3));
- VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( inner_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat->get_rid());
d[VS::ARRAY_VERTEX]=triangles;
- VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup);
-
- outer_mat_dup = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8));
- VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0);
- VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( outer_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat->get_rid());
d[VS::ARRAY_VERTEX]=lines;
- VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat->get_rid());
}
@@ -1452,14 +1436,10 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(grid[i]);
if (grid_instance[i].is_valid())
VisualServer::get_singleton()->free(grid_instance[i]);
- if (cursor_instance)
+ if (cursor_instance.is_valid())
VisualServer::get_singleton()->free(cursor_instance);
}
- VisualServer::get_singleton()->free(inner_mat);
- VisualServer::get_singleton()->free(outer_mat);
- VisualServer::get_singleton()->free(inner_mat_dup);
- VisualServer::get_singleton()->free(outer_mat_dup);
VisualServer::get_singleton()->free(selection_mesh);
if (selection_instance.is_valid())
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 2c0ff99dc6..66ec5dc4bc 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -112,12 +112,9 @@ class GridMapEditor : public VBoxContainer {
RID duplicate_mesh;
RID duplicate_instance;
- RID indicator_mat;
-
- RID inner_mat;
- RID outer_mat;
- RID inner_mat_dup;
- RID outer_mat_dup;
+ Ref<FixedSpatialMaterial> indicator_mat;
+ Ref<FixedSpatialMaterial> inner_mat;
+ Ref<FixedSpatialMaterial> outer_mat;
bool updating;
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index b4a0d3b0b7..9cd70a0f9b 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "register_types.h"
#ifndef _3D_DISABLED
-#include "object_type_db.h"
+#include "class_db.h"
#include "grid_map.h"
#include "grid_map_editor_plugin.h"
#endif
diff --git a/modules/ogg/config.py b/modules/ogg/config.py
index fb920482f5..ef5daca05c 100644
--- a/modules/ogg/config.py
+++ b/modules/ogg/config.py
@@ -1,6 +1,7 @@
def can_build(platform):
- return True
+# return True
+ return False
def configure(env):
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
index 140ea1b9e7..43a1f610d8 100644
--- a/modules/openssl/stream_peer_openssl.cpp
+++ b/modules/openssl/stream_peer_openssl.cpp
@@ -35,8 +35,8 @@
bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname) {
return Tool_Curl_cert_hostcheck(name,hostname)==CURL_HOST_MATCH;
-// print_line("MATCH: "+String(name)+" vs "+String(hostname));
-// return true;
+ //print_line("MATCH: "+String(name)+" vs "+String(hostname));
+ //return true;
}
Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {
@@ -293,10 +293,10 @@ BIO_METHOD StreamPeerOpenSSL::_bio_method = {
_bio_destroy
};
-Error StreamPeerOpenSSL::connect(Ref<StreamPeer> p_base, bool p_validate_certs, const String& p_for_hostname) {
+Error StreamPeerOpenSSL::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String& p_for_hostname) {
if (connected)
- disconnect();
+ disconnect_from_stream();
hostname=p_for_hostname;
@@ -415,7 +415,7 @@ Error StreamPeerOpenSSL::connect(Ref<StreamPeer> p_base, bool p_validate_certs,
return OK;
}
-Error StreamPeerOpenSSL::accept(Ref<StreamPeer> p_base) {
+Error StreamPeerOpenSSL::accept_stream(Ref<StreamPeer> p_base) {
return ERR_UNAVAILABLE;
@@ -451,7 +451,7 @@ Error StreamPeerOpenSSL::put_data(const uint8_t* p_data,int p_bytes) {
int ret = SSL_write(ssl,p_data,p_bytes);
if (ret<=0) {
_print_error(ret);
- disconnect();
+ disconnect_from_stream();
return ERR_CONNECTION_ERROR;
}
p_data+=ret;
@@ -486,7 +486,7 @@ Error StreamPeerOpenSSL::get_data(uint8_t* p_buffer, int p_bytes){
int ret = SSL_read(ssl,p_buffer,p_bytes);
if (ret<=0) {
_print_error(ret);
- disconnect();
+ disconnect_from_stream();
return ERR_CONNECTION_ERROR;
}
p_buffer+=ret;
@@ -529,7 +529,7 @@ StreamPeerOpenSSL::StreamPeerOpenSSL() {
flags=0;
}
-void StreamPeerOpenSSL::disconnect() {
+void StreamPeerOpenSSL::disconnect_from_stream() {
if (!connected)
return;
@@ -552,7 +552,7 @@ StreamPeerOpenSSL::Status StreamPeerOpenSSL::get_status() const {
StreamPeerOpenSSL::~StreamPeerOpenSSL() {
- disconnect();
+ disconnect_from_stream();
}
StreamPeerSSL* StreamPeerOpenSSL::_create_func() {
diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h
index d79fb97ff8..84ae03fe07 100644
--- a/modules/openssl/stream_peer_openssl.h
+++ b/modules/openssl/stream_peer_openssl.h
@@ -31,7 +31,7 @@
#include <stdio.h> // If you don't know what this is for stop reading now.
#include "io/stream_peer_ssl.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "curl_hostcheck.h"
@@ -85,11 +85,11 @@ protected:
public:
- virtual Error accept(Ref<StreamPeer> p_base);
- virtual Error connect(Ref<StreamPeer> p_base,bool p_validate_certs=false,const String& p_for_hostname=String());
+ virtual Error accept_stream(Ref<StreamPeer> p_base);
+ virtual Error connect_to_stream(Ref<StreamPeer> p_base,bool p_validate_certs=false,const String& p_for_hostname=String());
virtual Status get_status() const;
- virtual void disconnect();
+ virtual void disconnect_from_stream();
virtual Error put_data(const uint8_t* p_data,int p_bytes);
virtual Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index f438dde689..4a6b2e224c 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -366,7 +366,7 @@ void ResourceFormatLoaderAudioStreamOpus::get_recognized_extensions(List<String>
}
String ResourceFormatLoaderAudioStreamOpus::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="opus")
+ if (p_path.get_extension().to_lower()=="opus")
return "AudioStreamOpus";
return "";
}
diff --git a/modules/opus/config.py b/modules/opus/config.py
index fb920482f5..ef5daca05c 100644
--- a/modules/opus/config.py
+++ b/modules/opus/config.py
@@ -1,6 +1,7 @@
def can_build(platform):
- return True
+# return True
+ return False
def configure(env):
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
index 6caaf10334..ab0805a6b0 100644
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ b/modules/pbm/bitmap_loader_pbm.cpp
@@ -244,7 +244,7 @@ bool ResourceFormatPBM::handles_type(const String& p_type) const {
}
String ResourceFormatPBM::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="pbm")
+ if (p_path.get_extension().to_lower()=="pbm")
return "BitMap";
return "";
}
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index 9f8db98e05..9805675f2c 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -185,7 +185,7 @@ bool ResourceFormatPVR::handles_type(const String& p_type) const {
String ResourceFormatPVR::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="pvr")
+ if (p_path.get_extension().to_lower()=="pvr")
return "Texture";
return "";
}
@@ -464,16 +464,19 @@ static void get_modulation_value(int x, int y, const int p_2bit, const int p_mod
if(((x^y)&1)==0)
mod_val = rep_vals0[p_modulation[y][x]];
else if(p_modulation_modes[y][x] == 1) {
- mod_val = (rep_vals0[p_modulation[y-1][x]] +
- rep_vals0[p_modulation[y+1][x]] +
- rep_vals0[p_modulation[y][x-1]] +
- rep_vals0[p_modulation[y][x+1]] + 2) / 4;
+ mod_val = (
+ rep_vals0[p_modulation[y-1][x]] +
+ rep_vals0[p_modulation[y+1][x]] +
+ rep_vals0[p_modulation[y][x-1]] +
+ rep_vals0[p_modulation[y][x+1]] + 2) / 4;
} else if(p_modulation_modes[y][x] == 2) {
- mod_val = (rep_vals0[p_modulation[y][x-1]] +
- rep_vals0[p_modulation[y][x+1]] + 1) / 2;
+ mod_val = (
+ rep_vals0[p_modulation[y][x-1]] +
+ rep_vals0[p_modulation[y][x+1]] + 1) / 2;
} else {
- mod_val = (rep_vals0[p_modulation[y-1][x]] +
- rep_vals0[p_modulation[y+1][x]] + 1) / 2;
+ mod_val = (
+ rep_vals0[p_modulation[y-1][x]] +
+ rep_vals0[p_modulation[y+1][x]] + 1) / 2;
}
} else {
mod_val = rep_vals1[p_modulation[y][x]];
@@ -615,11 +618,12 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
for(j = 0; j < 2; j++) {
unpack_5554(p_blocks[i][j], colors5554[i][j].Reps);
- unpack_modulations(p_blocks[i][j],
- p_2bit,
- p_modulation,
- p_modulation_modes,
- p_x, p_y);
+ unpack_modulations(
+ p_blocks[i][j],
+ p_2bit,
+ p_modulation,
+ p_modulation_modes,
+ p_x, p_y);
p_x += x_block_size;
}
@@ -632,19 +636,21 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
}
- interpolate_colors(colors5554[0][0].Reps[0],
- colors5554[0][1].Reps[0],
- colors5554[1][0].Reps[0],
- colors5554[1][1].Reps[0],
- p_2bit, x, y,
- ASig);
+ interpolate_colors(
+ colors5554[0][0].Reps[0],
+ colors5554[0][1].Reps[0],
+ colors5554[1][0].Reps[0],
+ colors5554[1][1].Reps[0],
+ p_2bit, x, y,
+ ASig);
- interpolate_colors(colors5554[0][0].Reps[1],
- colors5554[0][1].Reps[1],
- colors5554[1][0].Reps[1],
- colors5554[1][1].Reps[1],
- p_2bit, x, y,
- BSig);
+ interpolate_colors(
+ colors5554[0][0].Reps[1],
+ colors5554[0][1].Reps[1],
+ colors5554[1][0].Reps[1],
+ colors5554[1][1].Reps[1],
+ p_2bit, x, y,
+ BSig);
get_modulation_value(x,y, p_2bit, (const int (*)[16])p_modulation, (const int (*)[16])p_modulation_modes,
&Mod, &DoPT);
@@ -669,9 +675,11 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int
static void _pvrtc_decompress(Image* p_img) {
-// static void decompress_pvrtc(const void *p_comp_img, const int p_2bit, const int p_width, const int p_height, unsigned char* p_dst) {
-// decompress_pvrtc((PVRTCBlock*)p_comp_img,p_2bit,p_width,p_height,1,p_dst);
-// }
+ /*
+ static void decompress_pvrtc(const void *p_comp_img, const int p_2bit, const int p_width, const int p_height, unsigned char* p_dst) {
+ decompress_pvrtc((PVRTCBlock*)p_comp_img,p_2bit,p_width,p_height,1,p_dst);
+ }
+ */
ERR_FAIL_COND( p_img->get_format()!=Image::FORMAT_PVRTC2 && p_img->get_format()!=Image::FORMAT_PVRTC2A && p_img->get_format()!=Image::FORMAT_PVRTC4 && p_img->get_format()!=Image::FORMAT_PVRTC4A);
@@ -687,9 +695,11 @@ static void _pvrtc_decompress(Image* p_img) {
decompress_pvrtc((PVRTCBlock*)r.ptr(),_2bit,p_img->get_width(),p_img->get_height(),0,(unsigned char*)w.ptr());
- //for(int i=0;i<newdata.size();i++) {
- // print_line(itos(w[i]));
- //}
+ /*
+ for(int i=0;i<newdata.size();i++) {
+ print_line(itos(w[i]));
+ }
+ */
w=PoolVector<uint8_t>::Write();
r=PoolVector<uint8_t>::Read();
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index e67040b5a3..3d1dd048a8 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -321,7 +321,7 @@ struct RegExNodeClass : public RegExNode {
case Type_lower:
return ('a' <= c && c <= 'z');
case Type_print:
- return (0x1F < c && c < 0x1F);
+ return (0x20 < c && c < 0x7f);
case Type_punct:
return (REGEX_NODE_PUNCT.find(c) >= 0);
case Type_space:
@@ -1481,27 +1481,27 @@ RegEx::~RegEx() {
void RegExMatch::_bind_methods() {
- ClassDB::bind_method(_MD("expand","template"),&RegExMatch::expand);
- ClassDB::bind_method(_MD("get_group_count"),&RegExMatch::get_group_count);
- ClassDB::bind_method(_MD("get_group_array"),&RegExMatch::get_group_array);
- ClassDB::bind_method(_MD("get_names"),&RegExMatch::get_names);
- ClassDB::bind_method(_MD("get_name_dict"),&RegExMatch::get_name_dict);
- ClassDB::bind_method(_MD("get_string","name"),&RegExMatch::get_string, DEFVAL(0));
- ClassDB::bind_method(_MD("get_start","name"),&RegExMatch::get_start, DEFVAL(0));
- ClassDB::bind_method(_MD("get_end","name"),&RegExMatch::get_end, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("expand","template"),&RegExMatch::expand);
+ ClassDB::bind_method(D_METHOD("get_group_count"),&RegExMatch::get_group_count);
+ ClassDB::bind_method(D_METHOD("get_group_array"),&RegExMatch::get_group_array);
+ ClassDB::bind_method(D_METHOD("get_names"),&RegExMatch::get_names);
+ ClassDB::bind_method(D_METHOD("get_name_dict"),&RegExMatch::get_name_dict);
+ ClassDB::bind_method(D_METHOD("get_string","name"),&RegExMatch::get_string, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_start","name"),&RegExMatch::get_start, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_end","name"),&RegExMatch::get_end, DEFVAL(0));
}
void RegEx::_bind_methods() {
- ClassDB::bind_method(_MD("clear"),&RegEx::clear);
- ClassDB::bind_method(_MD("compile","pattern"),&RegEx::compile);
- ClassDB::bind_method(_MD("search","text","start","end"),&RegEx::search, DEFVAL(0), DEFVAL(-1));
- ClassDB::bind_method(_MD("sub","text","replacement","all","start","end"),&RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1));
- ClassDB::bind_method(_MD("is_valid"),&RegEx::is_valid);
- ClassDB::bind_method(_MD("get_pattern"),&RegEx::get_pattern);
- ClassDB::bind_method(_MD("get_group_count"),&RegEx::get_group_count);
- ClassDB::bind_method(_MD("get_names"),&RegEx::get_names);
+ ClassDB::bind_method(D_METHOD("clear"),&RegEx::clear);
+ ClassDB::bind_method(D_METHOD("compile","pattern"),&RegEx::compile);
+ ClassDB::bind_method(D_METHOD("search","text","start","end"),&RegEx::search, DEFVAL(0), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("sub","text","replacement","all","start","end"),&RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("is_valid"),&RegEx::is_valid);
+ ClassDB::bind_method(D_METHOD("get_pattern"),&RegEx::get_pattern);
+ ClassDB::bind_method(D_METHOD("get_group_count"),&RegEx::get_group_count);
+ ClassDB::bind_method(D_METHOD("get_names"),&RegEx::get_names);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "pattern"), _SCS("compile"), _SCS("get_pattern"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "pattern"), "compile", "get_pattern");
}
diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp
index d44c7e563c..c62a04d80f 100644
--- a/modules/regex/register_types.cpp
+++ b/modules/regex/register_types.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "register_types.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "regex.h"
void register_regex_types() {
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 7410658603..28c200596b 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -54,20 +54,19 @@ void image_compress_squish(Image *p_image) {
if (p_image->get_format()==Image::FORMAT_LA8) {
//compressed normalmap
- target_format = Image::FORMAT_DXT5; squish_comp|=squish::kDxt5;;
+ target_format = Image::FORMAT_DXT5; squish_comp|=squish::kDxt5;
} else if (p_image->detect_alpha()!=Image::ALPHA_NONE) {
- target_format = Image::FORMAT_DXT3; squish_comp|=squish::kDxt3;;
+ target_format = Image::FORMAT_DXT3; squish_comp|=squish::kDxt3;
} else {
- target_format = Image::FORMAT_DXT1; shift=1; squish_comp|=squish::kDxt1;;
+ target_format = Image::FORMAT_DXT1; shift=1; squish_comp|=squish::kDxt1;
}
p_image->convert(Image::FORMAT_RGBA8); //always expects rgba
- int mm_count = p_image->get_mipmap_count();
-
PoolVector<uint8_t> data;
- int target_size = Image::get_image_data_size(w,h,target_format,mm_count);
+ int target_size = Image::get_image_data_size(w,h,target_format,p_image->has_mipmaps()?-1:0);
+ int mm_count = p_image->has_mipmaps() ? Image::get_image_required_mipmaps(w,h,target_format) : 0;
data.resize(target_size);
PoolVector<uint8_t>::Read rb = p_image->get_data().read();
diff --git a/modules/stb_vorbis/SCsub b/modules/stb_vorbis/SCsub
new file mode 100644
index 0000000000..897d05961c
--- /dev/null
+++ b/modules/stb_vorbis/SCsub
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+Import('env')
+Import('env_modules')
+
+# Thirdparty source files
+
+env_stb_vorbis = env_modules.Clone()
+
+env_stb_vorbis.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
new file mode 100644
index 0000000000..ee7cbeece9
--- /dev/null
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -0,0 +1,232 @@
+
+#include "audio_stream_ogg_vorbis.h"
+#include "thirdparty/stb_vorbis/stb_vorbis.c"
+#include "os/file_access.h"
+
+
+void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame* p_buffer,int p_frames) {
+
+ ERR_FAIL_COND(!active);
+
+ int todo=p_frames;
+
+ while(todo) {
+
+ int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream,2,(float*)p_buffer,todo*2);
+ todo-=mixed;
+
+ if (todo) {
+ //end of file!
+ if (vorbis_stream->loop) {
+ //loop
+ seek_pos(0);
+ loops++;
+ } else {
+ for(int i=mixed;i<p_frames;i++) {
+ p_buffer[i]=AudioFrame(0,0);
+ }
+ active=false;
+ }
+ }
+ }
+
+
+}
+
+float AudioStreamPlaybackOGGVorbis::get_stream_sampling_rate() {
+
+ return vorbis_stream->sample_rate;
+}
+
+
+void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) {
+
+ seek_pos(p_from_pos);
+ active=true;
+ loops=0;
+ _begin_resample();
+
+
+}
+
+void AudioStreamPlaybackOGGVorbis::stop() {
+
+ active=false;
+}
+bool AudioStreamPlaybackOGGVorbis::is_playing() const {
+
+ return active;
+}
+
+int AudioStreamPlaybackOGGVorbis::get_loop_count() const {
+
+ return loops;
+}
+
+float AudioStreamPlaybackOGGVorbis::get_pos() const {
+
+ return float(frames_mixed)/vorbis_stream->sample_rate;
+}
+void AudioStreamPlaybackOGGVorbis::seek_pos(float p_time) {
+
+ if (!active)
+ return;
+
+ stb_vorbis_seek(ogg_stream, uint32_t(p_time*vorbis_stream->sample_rate));
+}
+
+float AudioStreamPlaybackOGGVorbis::get_length() const {
+
+ return vorbis_stream->length;
+}
+
+AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
+ if (ogg_alloc.alloc_buffer) {
+ AudioServer::get_singleton()->audio_data_free(ogg_alloc.alloc_buffer);
+ stb_vorbis_close(ogg_stream);
+ }
+}
+
+Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
+
+
+
+ Ref<AudioStreamPlaybackOGGVorbis> ovs;
+ printf("instance at %p, data %p\n",this,data);
+
+ ERR_FAIL_COND_V(data==NULL,ovs);
+
+ ovs.instance();
+ ovs->vorbis_stream=Ref<AudioStreamOGGVorbis>(this);
+ ovs->ogg_alloc.alloc_buffer=(char*)AudioServer::get_singleton()->audio_data_alloc(decode_mem_size);
+ ovs->ogg_alloc.alloc_buffer_length_in_bytes=decode_mem_size;
+ ovs->frames_mixed=0;
+ ovs->active=false;
+ ovs->loops=0;
+ int error ;
+ ovs->ogg_stream = stb_vorbis_open_memory( (const unsigned char*)data, data_len, &error, &ovs->ogg_alloc );
+ if (!ovs->ogg_stream) {
+
+ AudioServer::get_singleton()->audio_data_free(ovs->ogg_alloc.alloc_buffer);
+ ovs->ogg_alloc.alloc_buffer=NULL;
+ ERR_FAIL_COND_V(!ovs->ogg_stream,Ref<AudioStreamPlaybackOGGVorbis>());
+ }
+
+ return ovs;
+}
+
+String AudioStreamOGGVorbis::get_stream_name() const {
+
+ return "";//return stream_name;
+}
+
+void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t>& p_data) {
+
+ int src_data_len=p_data.size();
+#define MAX_TEST_MEM (1<<20)
+
+ uint32_t alloc_try=1024;
+ PoolVector<char> alloc_mem;
+ PoolVector<char>::Write w;
+ stb_vorbis * ogg_stream=NULL;
+ stb_vorbis_alloc ogg_alloc;
+
+ while(alloc_try<MAX_TEST_MEM) {
+
+ alloc_mem.resize(alloc_try);
+ w = alloc_mem.write();
+
+ ogg_alloc.alloc_buffer=w.ptr();
+ ogg_alloc.alloc_buffer_length_in_bytes=alloc_try;
+
+ PoolVector<uint8_t>::Read src_datar = p_data.read();
+
+ int error;
+ ogg_stream = stb_vorbis_open_memory( (const unsigned char*)src_datar.ptr(), src_data_len, &error, &ogg_alloc );
+
+ if (!ogg_stream && error==VORBIS_outofmem) {
+ w = PoolVector<char>::Write();
+ alloc_try*=2;
+ } else {
+
+ ERR_FAIL_COND(alloc_try==MAX_TEST_MEM);
+ ERR_FAIL_COND(ogg_stream==NULL);
+
+ stb_vorbis_info info = stb_vorbis_get_info(ogg_stream);
+
+ channels = info.channels;
+ sample_rate = info.sample_rate;
+ decode_mem_size = alloc_try;
+ //does this work? (it's less mem..)
+ //decode_mem_size = ogg_alloc.alloc_buffer_length_in_bytes + info.setup_memory_required + info.temp_memory_required + info.max_frame_size;
+
+ //print_line("succeded "+itos(ogg_alloc.alloc_buffer_length_in_bytes)+" setup "+itos(info.setup_memory_required)+" setup temp "+itos(info.setup_temp_memory_required)+" temp "+itos(info.temp_memory_required)+" maxframe"+itos(info.max_frame_size));
+
+ length=stb_vorbis_stream_length_in_seconds(ogg_stream);
+ stb_vorbis_close(ogg_stream);
+
+ data = AudioServer::get_singleton()->audio_data_alloc(src_data_len,src_datar.ptr());
+ data_len=src_data_len;
+
+ break;
+ }
+ }
+
+
+ printf("create at %p, data %p\n",this,data);
+
+}
+
+PoolVector<uint8_t> AudioStreamOGGVorbis::get_data() const {
+
+ PoolVector<uint8_t> vdata;
+
+ if (data_len && data) {
+ vdata.resize(data_len);
+ {
+ PoolVector<uint8_t>::Write w = vdata.write();
+ copymem(w.ptr(),data,data_len);
+ }
+
+ }
+
+ return vdata;
+}
+
+void AudioStreamOGGVorbis::set_loop(bool p_enable) {
+ loop=p_enable;
+}
+
+bool AudioStreamOGGVorbis::has_loop() const {
+
+ return loop;
+}
+
+
+void AudioStreamOGGVorbis::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_data","data"),&AudioStreamOGGVorbis::set_data);
+ ClassDB::bind_method(D_METHOD("get_data"),&AudioStreamOGGVorbis::get_data);
+
+ ClassDB::bind_method(D_METHOD("set_loop","enable"),&AudioStreamOGGVorbis::set_loop);
+ ClassDB::bind_method(D_METHOD("has_loop"),&AudioStreamOGGVorbis::has_loop);
+
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_data","get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"loop",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_loop","has_loop");
+
+}
+
+AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
+
+
+ data=NULL;
+ length=0;
+ sample_rate=1;
+ channels=1;
+ decode_mem_size=0;
+ loop=false;
+}
+
+
+
+
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
new file mode 100644
index 0000000000..21ce23740c
--- /dev/null
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -0,0 +1,83 @@
+#ifndef AUDIO_STREAM_STB_VORBIS_H
+#define AUDIO_STREAM_STB_VORBIS_H
+
+#include "servers/audio/audio_stream.h"
+#include "io/resource_loader.h"
+
+#define STB_VORBIS_HEADER_ONLY
+#include "thirdparty/stb_vorbis/stb_vorbis.c"
+#undef STB_VORBIS_HEADER_ONLY
+
+
+class AudioStreamOGGVorbis;
+
+class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled {
+
+ GDCLASS( AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled )
+
+ stb_vorbis * ogg_stream;
+ stb_vorbis_alloc ogg_alloc;
+ uint32_t frames_mixed;
+ bool active;
+ int loops;
+
+friend class AudioStreamOGGVorbis;
+
+ Ref<AudioStreamOGGVorbis> vorbis_stream;
+protected:
+
+ virtual void _mix_internal(AudioFrame* p_buffer, int p_frames);
+ virtual float get_stream_sampling_rate();
+
+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 float get_length() const; //if supported, otherwise return 0
+
+ AudioStreamPlaybackOGGVorbis() { }
+ ~AudioStreamPlaybackOGGVorbis();
+};
+
+class AudioStreamOGGVorbis : public AudioStream {
+
+ GDCLASS( AudioStreamOGGVorbis, AudioStream )
+ OBJ_SAVE_TYPE( AudioStream ) //children are all saved as AudioStream, so they can be exchanged
+ RES_BASE_EXTENSION("asogg");
+
+friend class AudioStreamPlaybackOGGVorbis;
+
+ void *data;
+ uint32_t data_len;
+
+ int decode_mem_size;
+ float sample_rate;
+ int channels;
+ float length;
+ bool loop;
+protected:
+
+ static void _bind_methods();
+public:
+
+ void set_loop(bool p_enable);
+ bool has_loop() const;
+
+ virtual Ref<AudioStreamPlayback> instance_playback();
+ virtual String get_stream_name() const;
+
+ void set_data(const PoolVector<uint8_t>& p_data);
+ PoolVector<uint8_t> get_data() const;
+
+ AudioStreamOGGVorbis();
+};
+
+
+
+#endif
diff --git a/modules/chibi/config.py b/modules/stb_vorbis/config.py
index fb920482f5..fb920482f5 100644
--- a/modules/chibi/config.py
+++ b/modules/stb_vorbis/config.py
diff --git a/modules/chibi/cp_order.h b/modules/stb_vorbis/register_types.cpp
index 8df67df40c..41fbc6fbd7 100644
--- a/modules/chibi/cp_order.h
+++ b/modules/stb_vorbis/register_types.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* cp_order.h */
+/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,18 +26,20 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CP_ORDER_H
-#define CP_ORDER_H
+#include "register_types.h"
+#include "audio_stream_ogg_vorbis.h"
+#include "resource_importer_ogg_vorbis.h"
+void register_stb_vorbis_types() {
-#include "cp_config.h"
-
-enum CPOrderType {
- CP_ORDER_NONE=255,
- CP_ORDER_BREAK=254
-};
-
-typedef uint8_t CPOrder;
-
+#ifdef TOOLS_ENABLED
+ Ref<ResourceImporterOGGVorbis> ogg_import;
+ ogg_import.instance();
+ ResourceFormatImporter::get_singleton()->add_importer(ogg_import);
#endif
+ ClassDB::register_class<AudioStreamOGGVorbis>();
+}
+
+void unregister_stb_vorbis_types() {
+}
diff --git a/modules/chibi/register_types.h b/modules/stb_vorbis/register_types.h
index 08856c0744..2824aa9f0c 100644
--- a/modules/chibi/register_types.h
+++ b/modules/stb_vorbis/register_types.h
@@ -26,5 +26,5 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-void register_chibi_types();
-void unregister_chibi_types();
+void register_stb_vorbis_types();
+void unregister_stb_vorbis_types();
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
new file mode 100644
index 0000000000..6f90c8587b
--- /dev/null
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -0,0 +1,84 @@
+#include "resource_importer_ogg_vorbis.h"
+
+#include "io/resource_saver.h"
+#include "os/file_access.h"
+#include "scene/resources/texture.h"
+
+String ResourceImporterOGGVorbis::get_importer_name() const {
+
+ return "ogg_vorbis";
+}
+
+String ResourceImporterOGGVorbis::get_visible_name() const{
+
+ return "OGGVorbis";
+}
+void ResourceImporterOGGVorbis::get_recognized_extensions(List<String> *p_extensions) const{
+
+ p_extensions->push_back("ogg");
+}
+
+String ResourceImporterOGGVorbis::get_save_extension() const {
+ return "asogg";
+}
+
+String ResourceImporterOGGVorbis::get_resource_type() const{
+
+ return "AudioStreamOGGVorbis";
+}
+
+bool ResourceImporterOGGVorbis::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ return true;
+}
+
+int ResourceImporterOGGVorbis::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
+
+ return String();
+}
+
+
+void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options,int p_preset) const {
+
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"loop"),true));
+
+}
+
+
+
+Error ResourceImporterOGGVorbis::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) {
+
+ bool loop = p_options["loop"];
+
+ FileAccess *f = FileAccess::open(p_source_file,FileAccess::READ);
+ if (!f) {
+ ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
+ }
+
+ size_t len = f->get_len();
+
+ PoolVector<uint8_t> data;
+ data.resize(len);
+ PoolVector<uint8_t>::Write w = data.write();
+
+ f->get_buffer(w.ptr(),len);
+
+ memdelete(f);
+
+ Ref<AudioStreamOGGVorbis> ogg_stream;
+ ogg_stream.instance();
+
+ ogg_stream->set_data(data);
+ ogg_stream->set_loop(loop);
+
+ return ResourceSaver::save(p_save_path+".asogg",ogg_stream);
+}
+
+ResourceImporterOGGVorbis::ResourceImporterOGGVorbis()
+{
+
+}
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
new file mode 100644
index 0000000000..8a3b2d8ec6
--- /dev/null
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
@@ -0,0 +1,28 @@
+#ifndef RESOURCEIMPORTEROGGVORBIS_H
+#define RESOURCEIMPORTEROGGVORBIS_H
+
+
+#include "io/resource_import.h"
+#include "audio_stream_ogg_vorbis.h"
+
+class ResourceImporterOGGVorbis : public ResourceImporter {
+ GDCLASS(ResourceImporterOGGVorbis,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;
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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;
+
+ 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);
+
+ ResourceImporterOGGVorbis();
+};
+
+#endif // RESOURCEIMPORTEROGGVORBIS_H
diff --git a/modules/theora/config.py b/modules/theora/config.py
index fb920482f5..8eefe81288 100644
--- a/modules/theora/config.py
+++ b/modules/theora/config.py
@@ -1,6 +1,7 @@
def can_build(platform):
- return True
+# return True
+ return False
def configure(env):
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index b847f17bb7..2a7b2707bf 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "video_stream_theora.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
#include "yuv2rgb.h"
@@ -81,6 +81,9 @@ void VideoStreamPlaybackTheora::video_write(void){
th_ycbcr_buffer yuv;
th_decode_ycbcr_out(td,yuv);
+ // FIXME: The way stuff is commented out with `//*/` closing comments
+ // sounds very fishy...
+
/*
int y_offset, uv_offset;
y_offset=(ti.pic_x&~1)+yuv[0].stride*(ti.pic_y&~1);
@@ -105,7 +108,7 @@ void VideoStreamPlaybackTheora::video_write(void){
}
format = Image::FORMAT_RGBA8;
}
- // */
+ //*/
//*
@@ -228,7 +231,7 @@ void VideoStreamPlaybackTheora::video_write(void){
format = Image::FORMAT_YUV_422;
};
};
- // */
+ //*/
frames_pending = 1;
}
@@ -598,7 +601,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
if (vd.granulepos>=0) {
- // print_line("wrote: "+itos(audio_frames_wrote)+" gpos: "+itos(vd.granulepos));
+ //print_line("wrote: "+itos(audio_frames_wrote)+" gpos: "+itos(vd.granulepos));
}
//print_line("mix audio!");
@@ -933,7 +936,7 @@ bool ResourceFormatLoaderVideoStreamTheora::handles_type(const String& p_type) c
String ResourceFormatLoaderVideoStreamTheora::get_resource_type(const String &p_path) const {
- String exl=p_path.extension().to_lower();
+ String exl=p_path.get_extension().to_lower();
if (exl=="ogm" || exl=="ogv")
return "VideoStreamTheora";
return "";
diff --git a/modules/theora/yuv2rgb.h b/modules/theora/yuv2rgb.h
index 431b47e651..3b81607a65 100644
--- a/modules/theora/yuv2rgb.h
+++ b/modules/theora/yuv2rgb.h
@@ -3,8 +3,7 @@
#include "typedefs.h"
-static const uint32_t tables[256*3] =
-{
+static const uint32_t tables[256*3] = {
/* y_table */
0x7FFFFFEDU,
0x7FFFFFEFU,
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index 79bf3d50b2..5fe87a4956 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -82,7 +82,7 @@ void register_visual_script_types() {
ClassDB::register_class<VisualScriptFunctionCall>();
ClassDB::register_class<VisualScriptPropertySet>();
ClassDB::register_class<VisualScriptPropertyGet>();
-// ClassDB::register_type<VisualScriptScriptCall>();
+ //ClassDB::register_type<VisualScriptScriptCall>();
ClassDB::register_class<VisualScriptEmitSignal>();
ClassDB::register_class<VisualScriptReturn>();
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 08796b3868..6941ed5486 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -2,7 +2,7 @@
#include "visual_script_nodes.h"
#include "scene/main/node.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
@@ -104,13 +104,13 @@ Array VisualScriptNode::_get_default_input_values() const {
void VisualScriptNode::_bind_methods() {
- ClassDB::bind_method(_MD("get_visual_script:VisualScript"),&VisualScriptNode::get_visual_script);
- ClassDB::bind_method(_MD("set_default_input_value","port_idx","value:Variant"),&VisualScriptNode::set_default_input_value);
- ClassDB::bind_method(_MD("get_default_input_value:Variant","port_idx"),&VisualScriptNode::get_default_input_value);
- ClassDB::bind_method(_MD("_set_default_input_values","values"),&VisualScriptNode::_set_default_input_values);
- ClassDB::bind_method(_MD("_get_default_input_values"),&VisualScriptNode::_get_default_input_values);
+ ClassDB::bind_method(D_METHOD("get_visual_script:VisualScript"),&VisualScriptNode::get_visual_script);
+ ClassDB::bind_method(D_METHOD("set_default_input_value","port_idx","value:Variant"),&VisualScriptNode::set_default_input_value);
+ ClassDB::bind_method(D_METHOD("get_default_input_value:Variant","port_idx"),&VisualScriptNode::get_default_input_value);
+ ClassDB::bind_method(D_METHOD("_set_default_input_values","values"),&VisualScriptNode::_set_default_input_values);
+ ClassDB::bind_method(D_METHOD("_get_default_input_values"),&VisualScriptNode::_get_default_input_values);
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"_default_input_values",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_default_input_values"),_SCS("_get_default_input_values"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"_default_input_values",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_default_input_values","_get_default_input_values");
ADD_SIGNAL(MethodInfo("ports_changed"));
}
@@ -1317,65 +1317,65 @@ void VisualScript::_bind_methods() {
- ClassDB::bind_method(_MD("_node_ports_changed"),&VisualScript::_node_ports_changed);
+ ClassDB::bind_method(D_METHOD("_node_ports_changed"),&VisualScript::_node_ports_changed);
- ClassDB::bind_method(_MD("add_function","name"),&VisualScript::add_function);
- ClassDB::bind_method(_MD("has_function","name"),&VisualScript::has_function);
- ClassDB::bind_method(_MD("remove_function","name"),&VisualScript::remove_function);
- ClassDB::bind_method(_MD("rename_function","name","new_name"),&VisualScript::rename_function);
- ClassDB::bind_method(_MD("set_function_scroll","ofs"),&VisualScript::set_function_scroll);
- ClassDB::bind_method(_MD("get_function_scroll"),&VisualScript::get_function_scroll);
+ ClassDB::bind_method(D_METHOD("add_function","name"),&VisualScript::add_function);
+ 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(_MD("add_node","func","id","node","pos"),&VisualScript::add_node,DEFVAL(Point2()));
- ClassDB::bind_method(_MD("remove_node","func","id"),&VisualScript::remove_node);
- ClassDB::bind_method(_MD("get_function_node_id","name"),&VisualScript::get_function_node_id);
+ ClassDB::bind_method(D_METHOD("add_node","func","id","node","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(_MD("get_node","func","id"),&VisualScript::get_node);
- ClassDB::bind_method(_MD("has_node","func","id"),&VisualScript::has_node);
- ClassDB::bind_method(_MD("set_node_pos","func","id","pos"),&VisualScript::set_node_pos);
- ClassDB::bind_method(_MD("get_node_pos","func","id"),&VisualScript::get_node_pos);
+ ClassDB::bind_method(D_METHOD("get_node","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);
- ClassDB::bind_method(_MD("sequence_connect","func","from_node","from_output","to_node"),&VisualScript::sequence_connect);
- ClassDB::bind_method(_MD("sequence_disconnect","func","from_node","from_output","to_node"),&VisualScript::sequence_disconnect);
- ClassDB::bind_method(_MD("has_sequence_connection","func","from_node","from_output","to_node"),&VisualScript::has_sequence_connection);
+ ClassDB::bind_method(D_METHOD("sequence_connect","func","from_node","from_output","to_node"),&VisualScript::sequence_connect);
+ ClassDB::bind_method(D_METHOD("sequence_disconnect","func","from_node","from_output","to_node"),&VisualScript::sequence_disconnect);
+ ClassDB::bind_method(D_METHOD("has_sequence_connection","func","from_node","from_output","to_node"),&VisualScript::has_sequence_connection);
- ClassDB::bind_method(_MD("data_connect","func","from_node","from_port","to_node","to_port"),&VisualScript::data_connect);
- ClassDB::bind_method(_MD("data_disconnect","func","from_node","from_port","to_node","to_port"),&VisualScript::data_disconnect);
- ClassDB::bind_method(_MD("has_data_connection","func","from_node","from_port","to_node","to_port"),&VisualScript::has_data_connection);
+ ClassDB::bind_method(D_METHOD("data_connect","func","from_node","from_port","to_node","to_port"),&VisualScript::data_connect);
+ ClassDB::bind_method(D_METHOD("data_disconnect","func","from_node","from_port","to_node","to_port"),&VisualScript::data_disconnect);
+ ClassDB::bind_method(D_METHOD("has_data_connection","func","from_node","from_port","to_node","to_port"),&VisualScript::has_data_connection);
- ClassDB::bind_method(_MD("add_variable","name","default_value","export"),&VisualScript::add_variable,DEFVAL(Variant()),DEFVAL(false));
- ClassDB::bind_method(_MD("has_variable","name"),&VisualScript::has_variable);
- ClassDB::bind_method(_MD("remove_variable","name"),&VisualScript::remove_variable);
- ClassDB::bind_method(_MD("set_variable_default_value","name","value"),&VisualScript::set_variable_default_value);
- ClassDB::bind_method(_MD("get_variable_default_value","name"),&VisualScript::get_variable_default_value);
- ClassDB::bind_method(_MD("set_variable_info","name","value"),&VisualScript::_set_variable_info);
- ClassDB::bind_method(_MD("get_variable_info","name"),&VisualScript::_get_variable_info);
- ClassDB::bind_method(_MD("set_variable_export","name","enable"),&VisualScript::set_variable_export);
- ClassDB::bind_method(_MD("get_variable_export","name"),&VisualScript::get_variable_export);
- ClassDB::bind_method(_MD("rename_variable","name","new_name"),&VisualScript::rename_variable);
+ ClassDB::bind_method(D_METHOD("add_variable","name","default_value","export"),&VisualScript::add_variable,DEFVAL(Variant()),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("has_variable","name"),&VisualScript::has_variable);
+ ClassDB::bind_method(D_METHOD("remove_variable","name"),&VisualScript::remove_variable);
+ ClassDB::bind_method(D_METHOD("set_variable_default_value","name","value"),&VisualScript::set_variable_default_value);
+ ClassDB::bind_method(D_METHOD("get_variable_default_value","name"),&VisualScript::get_variable_default_value);
+ ClassDB::bind_method(D_METHOD("set_variable_info","name","value"),&VisualScript::_set_variable_info);
+ ClassDB::bind_method(D_METHOD("get_variable_info","name"),&VisualScript::_get_variable_info);
+ ClassDB::bind_method(D_METHOD("set_variable_export","name","enable"),&VisualScript::set_variable_export);
+ ClassDB::bind_method(D_METHOD("get_variable_export","name"),&VisualScript::get_variable_export);
+ ClassDB::bind_method(D_METHOD("rename_variable","name","new_name"),&VisualScript::rename_variable);
- ClassDB::bind_method(_MD("add_custom_signal","name"),&VisualScript::add_custom_signal);
- ClassDB::bind_method(_MD("has_custom_signal","name"),&VisualScript::has_custom_signal);
- ClassDB::bind_method(_MD("custom_signal_add_argument","name","type","argname","index"),&VisualScript::custom_signal_add_argument,DEFVAL(-1));
- ClassDB::bind_method(_MD("custom_signal_set_argument_type","name","argidx","type"),&VisualScript::custom_signal_set_argument_type);
- ClassDB::bind_method(_MD("custom_signal_get_argument_type","name","argidx"),&VisualScript::custom_signal_get_argument_type);
- ClassDB::bind_method(_MD("custom_signal_set_argument_name","name","argidx","argname"),&VisualScript::custom_signal_set_argument_name);
- ClassDB::bind_method(_MD("custom_signal_get_argument_name","name","argidx"),&VisualScript::custom_signal_get_argument_name);
- ClassDB::bind_method(_MD("custom_signal_remove_argument","argidx"),&VisualScript::custom_signal_remove_argument);
- ClassDB::bind_method(_MD("custom_signal_get_argument_count","name"),&VisualScript::custom_signal_get_argument_count);
- ClassDB::bind_method(_MD("custom_signal_swap_argument","name","argidx","withidx"),&VisualScript::custom_signal_swap_argument);
- ClassDB::bind_method(_MD("remove_custom_signal","name"),&VisualScript::remove_custom_signal);
- ClassDB::bind_method(_MD("rename_custom_signal","name","new_name"),&VisualScript::rename_custom_signal);
+ ClassDB::bind_method(D_METHOD("add_custom_signal","name"),&VisualScript::add_custom_signal);
+ ClassDB::bind_method(D_METHOD("has_custom_signal","name"),&VisualScript::has_custom_signal);
+ ClassDB::bind_method(D_METHOD("custom_signal_add_argument","name","type","argname","index"),&VisualScript::custom_signal_add_argument,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("custom_signal_set_argument_type","name","argidx","type"),&VisualScript::custom_signal_set_argument_type);
+ 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_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);
+ ClassDB::bind_method(D_METHOD("rename_custom_signal","name","new_name"),&VisualScript::rename_custom_signal);
- //ClassDB::bind_method(_MD("set_variable_info","name","info"),&VScript::set_variable_info);
- //ClassDB::bind_method(_MD("get_variable_info","name"),&VScript::set_variable_info);
+ //ClassDB::bind_method(D_METHOD("set_variable_info","name","info"),&VScript::set_variable_info);
+ //ClassDB::bind_method(D_METHOD("get_variable_info","name"),&VScript::set_variable_info);
- ClassDB::bind_method(_MD("set_instance_base_type","type"),&VisualScript::set_instance_base_type);
+ ClassDB::bind_method(D_METHOD("set_instance_base_type","type"),&VisualScript::set_instance_base_type);
- ClassDB::bind_method(_MD("_set_data","data"),&VisualScript::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&VisualScript::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data","data"),&VisualScript::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&VisualScript::_get_data);
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_data","_get_data");
ADD_SIGNAL(MethodInfo("node_ports_changed",PropertyInfo(Variant::STRING,"function"),PropertyInfo(Variant::INT,"id")));
}
@@ -2436,9 +2436,9 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
void VisualScriptFunctionState::_bind_methods() {
- ClassDB::bind_method(_MD("connect_to_signal","obj","signals","args"),&VisualScriptFunctionState::connect_to_signal);
- ClassDB::bind_method(_MD("resume:Array","args"),&VisualScriptFunctionState::resume,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("is_valid"),&VisualScriptFunctionState::is_valid);
+ ClassDB::bind_method(D_METHOD("connect_to_signal","obj","signals","args"),&VisualScriptFunctionState::connect_to_signal);
+ ClassDB::bind_method(D_METHOD("resume:Array","args"),&VisualScriptFunctionState::resume,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("is_valid"),&VisualScriptFunctionState::is_valid);
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"_signal_callback",&VisualScriptFunctionState::_signal_callback,MethodInfo("_signal_callback"));
}
@@ -2631,7 +2631,7 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level,List<String>
const StringName *f = _call_stack[l].function;
ERR_FAIL_COND(!_call_stack[l].instance->functions.has(*f));
-// VisualScriptInstance::Function *func = &_call_stack[l].instance->functions[*f];
+ //VisualScriptInstance::Function *func = &_call_stack[l].instance->functions[*f];
VisualScriptNodeInstance *node =_call_stack[l].instance->instances[*_call_stack[l].current_id];
ERR_FAIL_COND(!node);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 27242384ac..f9780400d8 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -1,6 +1,6 @@
#include "visual_script_builtin_funcs.h"
#include "math_funcs.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "reference.h"
#include "func_ref.h"
#include "os/os.h"
@@ -329,7 +329,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const
case LOGIC_CLAMP: {
if (p_idx==0)
return PropertyInfo(Variant::REAL,"a");
- else if (p_idx==0)
+ else if (p_idx==0) // FIXME: is it ok to test p_idx == 0 twice?
return PropertyInfo(Variant::REAL,"min");
else
return PropertyInfo(Variant::REAL,"max");
@@ -610,85 +610,85 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
case VisualScriptBuiltinFunc::MATH_SIN: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::sin(*p_inputs[0]);
+ *r_return=Math::sin((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_COS: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::cos(*p_inputs[0]);
+ *r_return=Math::cos((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_TAN: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::tan(*p_inputs[0]);
+ *r_return=Math::tan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_SINH: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::sinh(*p_inputs[0]);
+ *r_return=Math::sinh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_COSH: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::cosh(*p_inputs[0]);
+ *r_return=Math::cosh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_TANH: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::tanh(*p_inputs[0]);
+ *r_return=Math::tanh((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ASIN: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::asin(*p_inputs[0]);
+ *r_return=Math::asin((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ACOS: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::acos(*p_inputs[0]);
+ *r_return=Math::acos((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ATAN: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::atan(*p_inputs[0]);
+ *r_return=Math::atan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ATAN2: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::atan2(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::atan2((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_SQRT: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::sqrt(*p_inputs[0]);
+ *r_return=Math::sqrt((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_FMOD: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::fmod(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::fmod((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_FPOSMOD: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::fposmod(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::fposmod((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_FLOOR: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::floor(*p_inputs[0]);
+ *r_return=Math::floor((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_CEIL: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::ceil(*p_inputs[0]);
+ *r_return=Math::ceil((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ROUND: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::round(*p_inputs[0]);
+ *r_return=Math::round((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ABS: {
@@ -730,58 +730,58 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::pow(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::pow((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_LOG: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::log(*p_inputs[0]);
+ *r_return=Math::log((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_EXP: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::exp(*p_inputs[0]);
+ *r_return=Math::exp((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ISNAN: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::is_nan(*p_inputs[0]);
+ *r_return=Math::is_nan((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_ISINF: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::is_inf(*p_inputs[0]);
+ *r_return=Math::is_inf((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_EASE: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::ease(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::ease((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_DECIMALS: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::step_decimals(*p_inputs[0]);
+ *r_return=Math::step_decimals((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_STEPIFY: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::stepify(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::stepify((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_LERP: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
- *r_return=Math::lerp(*p_inputs[0],*p_inputs[1],*p_inputs[2]);
+ *r_return=Math::lerp((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_DECTIME: {
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
VALIDATE_ARG_NUM(2);
- *r_return=Math::dectime(*p_inputs[0],*p_inputs[1],*p_inputs[2]);
+ *r_return=Math::dectime((double)*p_inputs[0],(double)*p_inputs[1],(double)*p_inputs[2]);
} break;
case VisualScriptBuiltinFunc::MATH_RANDOMIZE: {
Math::randomize();
@@ -797,19 +797,19 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
VALIDATE_ARG_NUM(0);
VALIDATE_ARG_NUM(1);
- *r_return=Math::random(*p_inputs[0],*p_inputs[1]);
+ *r_return=Math::random((double)*p_inputs[0],(double)*p_inputs[1]);
} break;
case VisualScriptBuiltinFunc::MATH_SEED: {
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_inputs[0];
+ uint64_t seed=*p_inputs[0];
Math::seed(seed);
} break;
case VisualScriptBuiltinFunc::MATH_RANDSEED: {
VALIDATE_ARG_NUM(0);
- uint32_t seed=*p_inputs[0];
+ uint64_t seed=*p_inputs[0];
int ret = Math::rand_from_seed(&seed);
Array reta;
reta.push_back(ret);
@@ -820,22 +820,22 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp
case VisualScriptBuiltinFunc::MATH_DEG2RAD: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::deg2rad(*p_inputs[0]);
+ *r_return=Math::deg2rad((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_RAD2DEG: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::rad2deg(*p_inputs[0]);
+ *r_return=Math::rad2deg((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_LINEAR2DB: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::linear2db(*p_inputs[0]);
+ *r_return=Math::linear2db((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::MATH_DB2LINEAR: {
VALIDATE_ARG_NUM(0);
- *r_return=Math::db2linear(*p_inputs[0]);
+ *r_return=Math::db2linear((double)*p_inputs[0]);
} break;
case VisualScriptBuiltinFunc::LOGIC_MAX: {
@@ -1166,8 +1166,8 @@ VisualScriptNodeInstance* VisualScriptBuiltinFunc::instance(VisualScriptInstance
void VisualScriptBuiltinFunc::_bind_methods() {
- ClassDB::bind_method(_MD("set_func","which"),&VisualScriptBuiltinFunc::set_func);
- ClassDB::bind_method(_MD("get_func"),&VisualScriptBuiltinFunc::get_func);
+ ClassDB::bind_method(D_METHOD("set_func","which"),&VisualScriptBuiltinFunc::set_func);
+ ClassDB::bind_method(D_METHOD("get_func"),&VisualScriptBuiltinFunc::get_func);
String cc;
@@ -1177,7 +1177,7 @@ void VisualScriptBuiltinFunc::_bind_methods() {
cc+=",";
cc+=func_name[i];
}
- ADD_PROPERTY(PropertyInfo(Variant::INT,"function",PROPERTY_HINT_ENUM,cc),_SCS("set_func"),_SCS("get_func"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"function",PROPERTY_HINT_ENUM,cc),"set_func","get_func");
}
VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 6f3ea3b4ad..eadc9a8892 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -590,9 +590,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
t=type_icons[left_type];
}
if (t.is_valid()) {
- TextureFrame *tf = memnew(TextureFrame);
+ TextureRect *tf = memnew(TextureRect);
tf->set_texture(t);
- tf->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
+ tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
hbc->add_child(tf);
}
@@ -657,9 +657,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
t=type_icons[right_type];
}
if (t.is_valid()) {
- TextureFrame *tf = memnew(TextureFrame);
+ TextureRect *tf = memnew(TextureRect);
tf->set_texture(t);
- tf->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
+ tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
hbc->add_child(tf);
}
@@ -822,7 +822,7 @@ void VisualScriptEditor::_member_selected() {
selected=ti->get_metadata(0);
-// print_line("selected: "+String(selected));
+ //print_line("selected: "+String(selected));
if (ti->get_parent()==members->get_root()->get_children()) {
@@ -1136,9 +1136,11 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
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));
- //}
+ /*
+ 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");
@@ -1776,7 +1778,7 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
if (node) {
graph->set_selected(node);
_node_selected(node);
- }
+ }
}
if (d.has("type") && String(d["type"])=="resource") {
@@ -1916,7 +1918,7 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
Ref<VisualScriptFunctionCall> call;
call.instance();
call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
- call->set_base_path(sn->get_path_to(node));;
+ call->set_base_path(sn->get_path_to(node));
call->set_base_type(node->get_class());
n=call;
@@ -3082,7 +3084,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
//popup disappearing grabs focus to owner, so use call deferred
node_filter->call_deferred("grab_focus");
node_filter->call_deferred("select_all");
- } break;
+ } break;
case EDIT_COPY_NODES:
case EDIT_CUT_NODES: {
@@ -3346,8 +3348,8 @@ 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( TextureFrame );
- node_filter_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
+ 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);
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index e120bdc655..1dc62b3e69 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -58,7 +58,7 @@ class VisualScriptEditor : public ScriptEditorBase {
GraphEdit *graph;
LineEdit *node_filter;
- TextureFrame *node_filter_icon;
+ TextureRect *node_filter_icon;
VisualScriptEditorSignalEdit *signal_editor;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index cc3b5f2174..f14aee5d71 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -558,6 +558,12 @@ Error VisualScriptExpression::_get_token(Token& r_token) {
} else if (id=="PI") {
r_token.type=TK_CONSTANT;
r_token.value=Math_PI;
+ } else if (id == "INF") {
+ r_token.type = TK_CONSTANT;
+ r_token.value = Math_INF;
+ } else if (id == "NAN") {
+ r_token.type = TK_CONSTANT;
+ r_token.value = Math_NAN;
} else if (id=="not") {
r_token.type=TK_OP_NOT;
} else if (id=="or") {
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 0e526f8a42..93e395f0f2 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -1,6 +1,6 @@
#include "visual_script_flow_control.h"
#include "os/keyboard.h"
-#include "globals.h"
+#include "global_config.h"
//////////////////////////////////////////
@@ -81,18 +81,18 @@ bool VisualScriptReturn::is_return_value_enabled() const {
void VisualScriptReturn::_bind_methods() {
- ClassDB::bind_method(_MD("set_return_type","type"),&VisualScriptReturn::set_return_type);
- ClassDB::bind_method(_MD("get_return_type"),&VisualScriptReturn::get_return_type);
- ClassDB::bind_method(_MD("set_enable_return_value","enable"),&VisualScriptReturn::set_enable_return_value);
- ClassDB::bind_method(_MD("is_return_value_enabled"),&VisualScriptReturn::is_return_value_enabled);
+ ClassDB::bind_method(D_METHOD("set_return_type","type"),&VisualScriptReturn::set_return_type);
+ ClassDB::bind_method(D_METHOD("get_return_type"),&VisualScriptReturn::get_return_type);
+ ClassDB::bind_method(D_METHOD("set_enable_return_value","enable"),&VisualScriptReturn::set_enable_return_value);
+ ClassDB::bind_method(D_METHOD("is_return_value_enabled"),&VisualScriptReturn::is_return_value_enabled);
String argt="Any";
for(int i=1;i<Variant::VARIANT_MAX;i++) {
argt+=","+Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"return_value/enabled"),_SCS("set_enable_return_value"),_SCS("is_return_value_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"return_value/type",PROPERTY_HINT_ENUM,argt),_SCS("set_return_type"),_SCS("get_return_type"));
+ 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");
}
@@ -544,10 +544,10 @@ int VisualScriptSequence::get_steps() const {
void VisualScriptSequence::_bind_methods() {
- ClassDB::bind_method(_MD("set_steps","steps"),&VisualScriptSequence::set_steps);
- ClassDB::bind_method(_MD("get_steps"),&VisualScriptSequence::get_steps);
+ ClassDB::bind_method(D_METHOD("set_steps","steps"),&VisualScriptSequence::set_steps);
+ ClassDB::bind_method(D_METHOD("get_steps"),&VisualScriptSequence::get_steps);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"steps",PROPERTY_HINT_RANGE,"1,64,1"),_SCS("set_steps"),_SCS("get_steps"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"steps",PROPERTY_HINT_RANGE,"1,64,1"),"set_steps","get_steps");
}
@@ -1893,11 +1893,11 @@ VisualScriptNodeInstance* VisualScriptTypeCast::instance(VisualScriptInstance* p
void VisualScriptTypeCast::_bind_methods() {
- ClassDB::bind_method(_MD("set_base_type","type"),&VisualScriptTypeCast::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptTypeCast::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","type"),&VisualScriptTypeCast::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptTypeCast::get_base_type);
- ClassDB::bind_method(_MD("set_base_script","path"),&VisualScriptTypeCast::set_base_script);
- ClassDB::bind_method(_MD("get_base_script"),&VisualScriptTypeCast::get_base_script);
+ ClassDB::bind_method(D_METHOD("set_base_script","path"),&VisualScriptTypeCast::set_base_script);
+ ClassDB::bind_method(D_METHOD("get_base_script"),&VisualScriptTypeCast::get_base_script);
List<String> script_extensions;
@@ -1912,8 +1912,8 @@ void VisualScriptTypeCast::_bind_methods() {
script_ext_hint+="*."+E->get();
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_script",PROPERTY_HINT_FILE,script_ext_hint),_SCS("set_base_script"),_SCS("get_base_script"));
+ 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");
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 9f3ba8a8cb..fd91385f9c 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -4,7 +4,7 @@
#include "scene/main/node.h"
#include "visual_script_nodes.h"
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
//////////////////////////////////////////
////////////////CALL//////////////////////
@@ -396,7 +396,7 @@ void VisualScriptFunctionCall::_update_method_cache() {
}
-// print_line("BASE: "+String(type)+" FUNC: "+String(function));
+ //print_line("BASE: "+String(type)+" FUNC: "+String(function));
MethodBind *mb = ClassDB::get_method(type,function);
if (mb) {
use_default_args=mb->get_default_argument_count();
@@ -687,38 +687,38 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo& property) const
void VisualScriptFunctionCall::_bind_methods() {
- ClassDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptFunctionCall::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptFunctionCall::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","base_type"),&VisualScriptFunctionCall::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptFunctionCall::get_base_type);
- ClassDB::bind_method(_MD("set_base_script","base_script"),&VisualScriptFunctionCall::set_base_script);
- ClassDB::bind_method(_MD("get_base_script"),&VisualScriptFunctionCall::get_base_script);
+ ClassDB::bind_method(D_METHOD("set_base_script","base_script"),&VisualScriptFunctionCall::set_base_script);
+ ClassDB::bind_method(D_METHOD("get_base_script"),&VisualScriptFunctionCall::get_base_script);
- ClassDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptFunctionCall::set_basic_type);
- ClassDB::bind_method(_MD("get_basic_type"),&VisualScriptFunctionCall::get_basic_type);
+ ClassDB::bind_method(D_METHOD("set_basic_type","basic_type"),&VisualScriptFunctionCall::set_basic_type);
+ ClassDB::bind_method(D_METHOD("get_basic_type"),&VisualScriptFunctionCall::get_basic_type);
- ClassDB::bind_method(_MD("set_singleton","singleton"),&VisualScriptFunctionCall::set_singleton);
- ClassDB::bind_method(_MD("get_singleton"),&VisualScriptFunctionCall::get_singleton);
+ ClassDB::bind_method(D_METHOD("set_singleton","singleton"),&VisualScriptFunctionCall::set_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton"),&VisualScriptFunctionCall::get_singleton);
- ClassDB::bind_method(_MD("set_function","function"),&VisualScriptFunctionCall::set_function);
- ClassDB::bind_method(_MD("get_function"),&VisualScriptFunctionCall::get_function);
+ ClassDB::bind_method(D_METHOD("set_function","function"),&VisualScriptFunctionCall::set_function);
+ ClassDB::bind_method(D_METHOD("get_function"),&VisualScriptFunctionCall::get_function);
- ClassDB::bind_method(_MD("set_call_mode","mode"),&VisualScriptFunctionCall::set_call_mode);
- ClassDB::bind_method(_MD("get_call_mode"),&VisualScriptFunctionCall::get_call_mode);
+ ClassDB::bind_method(D_METHOD("set_call_mode","mode"),&VisualScriptFunctionCall::set_call_mode);
+ ClassDB::bind_method(D_METHOD("get_call_mode"),&VisualScriptFunctionCall::get_call_mode);
- ClassDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptFunctionCall::set_base_path);
- ClassDB::bind_method(_MD("get_base_path"),&VisualScriptFunctionCall::get_base_path);
+ ClassDB::bind_method(D_METHOD("set_base_path","base_path"),&VisualScriptFunctionCall::set_base_path);
+ ClassDB::bind_method(D_METHOD("get_base_path"),&VisualScriptFunctionCall::get_base_path);
- ClassDB::bind_method(_MD("set_use_default_args","amount"),&VisualScriptFunctionCall::set_use_default_args);
- ClassDB::bind_method(_MD("get_use_default_args"),&VisualScriptFunctionCall::get_use_default_args);
+ ClassDB::bind_method(D_METHOD("set_use_default_args","amount"),&VisualScriptFunctionCall::set_use_default_args);
+ ClassDB::bind_method(D_METHOD("get_use_default_args"),&VisualScriptFunctionCall::get_use_default_args);
- ClassDB::bind_method(_MD("_set_argument_cache","argument_cache"),&VisualScriptFunctionCall::_set_argument_cache);
- ClassDB::bind_method(_MD("_get_argument_cache"),&VisualScriptFunctionCall::_get_argument_cache);
+ ClassDB::bind_method(D_METHOD("_set_argument_cache","argument_cache"),&VisualScriptFunctionCall::_set_argument_cache);
+ ClassDB::bind_method(D_METHOD("_get_argument_cache"),&VisualScriptFunctionCall::_get_argument_cache);
- ClassDB::bind_method(_MD("set_rpc_call_mode","mode"),&VisualScriptFunctionCall::set_rpc_call_mode);
- ClassDB::bind_method(_MD("get_rpc_call_mode"),&VisualScriptFunctionCall::get_rpc_call_mode);
+ ClassDB::bind_method(D_METHOD("set_rpc_call_mode","mode"),&VisualScriptFunctionCall::set_rpc_call_mode);
+ ClassDB::bind_method(D_METHOD("get_rpc_call_mode"),&VisualScriptFunctionCall::get_rpc_call_mode);
- ClassDB::bind_method(_MD("set_validate","enable"),&VisualScriptFunctionCall::set_validate);
- ClassDB::bind_method(_MD("get_validate"),&VisualScriptFunctionCall::get_validate);
+ ClassDB::bind_method(D_METHOD("set_validate","enable"),&VisualScriptFunctionCall::set_validate);
+ ClassDB::bind_method(D_METHOD("get_validate"),&VisualScriptFunctionCall::get_validate);
String bt;
for(int i=0;i<Variant::VARIANT_MAX;i++) {
@@ -743,17 +743,17 @@ void VisualScriptFunctionCall::_bind_methods() {
- ADD_PROPERTY(PropertyInfo(Variant::INT,"function/call_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance,Basic Type,Singleton"),_SCS("set_call_mode"),_SCS("get_call_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/base_script",PROPERTY_HINT_FILE,script_ext_hint),_SCS("set_base_script"),_SCS("get_base_script"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/singleton"),_SCS("set_singleton"),_SCS("get_singleton"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"function/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"function/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"function/argument_cache",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_argument_cache"),_SCS("_get_argument_cache"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/function"),_SCS("set_function"),_SCS("get_function")); //when set, if loaded properly, will override argument count.
- ADD_PROPERTY(PropertyInfo(Variant::INT,"function/use_default_args"),_SCS("set_use_default_args"),_SCS("get_use_default_args"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"function/validate"),_SCS("set_validate"),_SCS("get_validate"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"rpc/call_mode",PROPERTY_HINT_ENUM,"Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"),_SCS("set_rpc_call_mode"),_SCS("get_rpc_call_mode")); //when set, if loaded properly, will override argument count.
+ 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.
BIND_CONSTANT( CALL_MODE_SELF );
BIND_CONSTANT( CALL_MODE_NODE_PATH);
@@ -1453,29 +1453,29 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
void VisualScriptPropertySet::_bind_methods() {
- ClassDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptPropertySet::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptPropertySet::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","base_type"),&VisualScriptPropertySet::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptPropertySet::get_base_type);
- ClassDB::bind_method(_MD("set_base_script","base_script"),&VisualScriptPropertySet::set_base_script);
- ClassDB::bind_method(_MD("get_base_script"),&VisualScriptPropertySet::get_base_script);
+ ClassDB::bind_method(D_METHOD("set_base_script","base_script"),&VisualScriptPropertySet::set_base_script);
+ ClassDB::bind_method(D_METHOD("get_base_script"),&VisualScriptPropertySet::get_base_script);
- ClassDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptPropertySet::set_basic_type);
- ClassDB::bind_method(_MD("get_basic_type"),&VisualScriptPropertySet::get_basic_type);
+ ClassDB::bind_method(D_METHOD("set_basic_type","basic_type"),&VisualScriptPropertySet::set_basic_type);
+ ClassDB::bind_method(D_METHOD("get_basic_type"),&VisualScriptPropertySet::get_basic_type);
- ClassDB::bind_method(_MD("_set_type_cache","type_cache"),&VisualScriptPropertySet::_set_type_cache);
- ClassDB::bind_method(_MD("_get_type_cache"),&VisualScriptPropertySet::_get_type_cache);
+ ClassDB::bind_method(D_METHOD("_set_type_cache","type_cache"),&VisualScriptPropertySet::_set_type_cache);
+ ClassDB::bind_method(D_METHOD("_get_type_cache"),&VisualScriptPropertySet::_get_type_cache);
- ClassDB::bind_method(_MD("set_event_type","event_type"),&VisualScriptPropertySet::set_event_type);
- ClassDB::bind_method(_MD("get_event_type"),&VisualScriptPropertySet::get_event_type);
+ ClassDB::bind_method(D_METHOD("set_event_type","event_type"),&VisualScriptPropertySet::set_event_type);
+ ClassDB::bind_method(D_METHOD("get_event_type"),&VisualScriptPropertySet::get_event_type);
- ClassDB::bind_method(_MD("set_property","property"),&VisualScriptPropertySet::set_property);
- ClassDB::bind_method(_MD("get_property"),&VisualScriptPropertySet::get_property);
+ ClassDB::bind_method(D_METHOD("set_property","property"),&VisualScriptPropertySet::set_property);
+ ClassDB::bind_method(D_METHOD("get_property"),&VisualScriptPropertySet::get_property);
- ClassDB::bind_method(_MD("set_call_mode","mode"),&VisualScriptPropertySet::set_call_mode);
- ClassDB::bind_method(_MD("get_call_mode"),&VisualScriptPropertySet::get_call_mode);
+ ClassDB::bind_method(D_METHOD("set_call_mode","mode"),&VisualScriptPropertySet::set_call_mode);
+ ClassDB::bind_method(D_METHOD("get_call_mode"),&VisualScriptPropertySet::get_call_mode);
- ClassDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptPropertySet::set_base_path);
- ClassDB::bind_method(_MD("get_base_path"),&VisualScriptPropertySet::get_base_path);
+ 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);
@@ -1507,14 +1507,14 @@ 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"),_SCS("set_call_mode"),_SCS("get_call_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_script",PROPERTY_HINT_FILE,script_ext_hint),_SCS("set_base_script"),_SCS("get_base_script"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/type_cache",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_type_cache"),_SCS("_get_type_cache"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/event_type",PROPERTY_HINT_ENUM,et),_SCS("set_event_type"),_SCS("get_event_type"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"property/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/property"),_SCS("set_property"),_SCS("get_property"));
+ 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::INT,"property/event_type",PROPERTY_HINT_ENUM,et),"set_event_type","get_event_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");
BIND_CONSTANT( CALL_MODE_SELF );
BIND_CONSTANT( CALL_MODE_NODE_PATH);
@@ -2117,30 +2117,30 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const {
void VisualScriptPropertyGet::_bind_methods() {
- ClassDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptPropertyGet::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptPropertyGet::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","base_type"),&VisualScriptPropertyGet::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptPropertyGet::get_base_type);
- ClassDB::bind_method(_MD("set_base_script","base_script"),&VisualScriptPropertyGet::set_base_script);
- ClassDB::bind_method(_MD("get_base_script"),&VisualScriptPropertyGet::get_base_script);
+ ClassDB::bind_method(D_METHOD("set_base_script","base_script"),&VisualScriptPropertyGet::set_base_script);
+ ClassDB::bind_method(D_METHOD("get_base_script"),&VisualScriptPropertyGet::get_base_script);
- ClassDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptPropertyGet::set_basic_type);
- ClassDB::bind_method(_MD("get_basic_type"),&VisualScriptPropertyGet::get_basic_type);
+ ClassDB::bind_method(D_METHOD("set_basic_type","basic_type"),&VisualScriptPropertyGet::set_basic_type);
+ ClassDB::bind_method(D_METHOD("get_basic_type"),&VisualScriptPropertyGet::get_basic_type);
- ClassDB::bind_method(_MD("_set_type_cache","type_cache"),&VisualScriptPropertyGet::_set_type_cache);
- ClassDB::bind_method(_MD("_get_type_cache"),&VisualScriptPropertyGet::_get_type_cache);
+ ClassDB::bind_method(D_METHOD("_set_type_cache","type_cache"),&VisualScriptPropertyGet::_set_type_cache);
+ ClassDB::bind_method(D_METHOD("_get_type_cache"),&VisualScriptPropertyGet::_get_type_cache);
- ClassDB::bind_method(_MD("set_event_type","event_type"),&VisualScriptPropertyGet::set_event_type);
- ClassDB::bind_method(_MD("get_event_type"),&VisualScriptPropertyGet::get_event_type);
+ ClassDB::bind_method(D_METHOD("set_event_type","event_type"),&VisualScriptPropertyGet::set_event_type);
+ ClassDB::bind_method(D_METHOD("get_event_type"),&VisualScriptPropertyGet::get_event_type);
- ClassDB::bind_method(_MD("set_property","property"),&VisualScriptPropertyGet::set_property);
- ClassDB::bind_method(_MD("get_property"),&VisualScriptPropertyGet::get_property);
+ ClassDB::bind_method(D_METHOD("set_property","property"),&VisualScriptPropertyGet::set_property);
+ ClassDB::bind_method(D_METHOD("get_property"),&VisualScriptPropertyGet::get_property);
- ClassDB::bind_method(_MD("set_call_mode","mode"),&VisualScriptPropertyGet::set_call_mode);
- ClassDB::bind_method(_MD("get_call_mode"),&VisualScriptPropertyGet::get_call_mode);
+ ClassDB::bind_method(D_METHOD("set_call_mode","mode"),&VisualScriptPropertyGet::set_call_mode);
+ ClassDB::bind_method(D_METHOD("get_call_mode"),&VisualScriptPropertyGet::get_call_mode);
- ClassDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptPropertyGet::set_base_path);
- ClassDB::bind_method(_MD("get_base_path"),&VisualScriptPropertyGet::get_base_path);
+ 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);
String bt;
for(int i=0;i<Variant::VARIANT_MAX;i++) {
@@ -2170,14 +2170,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"),_SCS("set_call_mode"),_SCS("get_call_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_script",PROPERTY_HINT_FILE,script_ext_hint),_SCS("set_base_script"),_SCS("get_base_script"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/type_cache",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_type_cache"),_SCS("_get_type_cache"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"property/event_type",PROPERTY_HINT_ENUM,et),_SCS("set_event_type"),_SCS("get_event_type"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"property/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/property"),_SCS("set_property"),_SCS("get_property"));
+ 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::INT,"property/event_type",PROPERTY_HINT_ENUM,et),"set_event_type","get_event_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");
BIND_CONSTANT( CALL_MODE_SELF );
BIND_CONSTANT( CALL_MODE_NODE_PATH);
@@ -2420,11 +2420,11 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo& property) const {
void VisualScriptEmitSignal::_bind_methods() {
- ClassDB::bind_method(_MD("set_signal","name"),&VisualScriptEmitSignal::set_signal);
- ClassDB::bind_method(_MD("get_signal"),&VisualScriptEmitSignal::get_signal);
+ 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"),_SCS("set_signal"),_SCS("get_signal"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"signal/signal"),"set_signal","get_signal");
}
@@ -2508,7 +2508,7 @@ void register_visual_script_func_nodes() {
VisualScriptLanguage::singleton->add_register_func("functions/get",create_node_generic<VisualScriptPropertyGet>);
//VisualScriptLanguage::singleton->add_register_func("functions/call_script/call_self",create_script_call_node<VisualScriptScriptCall::CALL_MODE_SELF>);
-// VisualScriptLanguage::singleton->add_register_func("functions/call_script/call_node",create_script_call_node<VisualScriptScriptCall::CALL_MODE_NODE_PATH>);
+ //VisualScriptLanguage::singleton->add_register_func("functions/call_script/call_node",create_script_call_node<VisualScriptScriptCall::CALL_MODE_NODE_PATH>);
VisualScriptLanguage::singleton->add_register_func("functions/emit_signal",create_node_generic<VisualScriptEmitSignal>);
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index c9e24fc9dc..f01284feba 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -1,6 +1,6 @@
#include "visual_script_nodes.h"
#include "global_constants.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/main/scene_main_loop.h"
#include "os/os.h"
#include "scene/main/node.h"
@@ -539,11 +539,11 @@ Variant::Type VisualScriptOperator::get_typed() const {
void VisualScriptOperator::_bind_methods() {
- ClassDB::bind_method(_MD("set_operator","op"),&VisualScriptOperator::set_operator);
- ClassDB::bind_method(_MD("get_operator"),&VisualScriptOperator::get_operator);
+ ClassDB::bind_method(D_METHOD("set_operator","op"),&VisualScriptOperator::set_operator);
+ ClassDB::bind_method(D_METHOD("get_operator"),&VisualScriptOperator::get_operator);
- ClassDB::bind_method(_MD("set_typed","type"),&VisualScriptOperator::set_typed);
- ClassDB::bind_method(_MD("get_typed"),&VisualScriptOperator::get_typed);
+ ClassDB::bind_method(D_METHOD("set_typed","type"),&VisualScriptOperator::set_typed);
+ ClassDB::bind_method(D_METHOD("get_typed"),&VisualScriptOperator::get_typed);
String types;
for(int i=0;i<Variant::OP_MAX;i++) {
@@ -557,8 +557,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),_SCS("set_operator"),_SCS("get_operator"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"typed_value/typed",PROPERTY_HINT_ENUM,argt),_SCS("set_typed"),_SCS("get_typed"));
+ 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");
}
@@ -717,11 +717,11 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo& property) const {
void VisualScriptVariableGet::_bind_methods() {
- ClassDB::bind_method(_MD("set_variable","name"),&VisualScriptVariableGet::set_variable);
- ClassDB::bind_method(_MD("get_variable"),&VisualScriptVariableGet::get_variable);
+ 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"),_SCS("set_variable"),_SCS("get_variable"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"variable/name"),"set_variable","get_variable");
}
@@ -853,11 +853,11 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo& property) const {
void VisualScriptVariableSet::_bind_methods() {
- ClassDB::bind_method(_MD("set_variable","name"),&VisualScriptVariableSet::set_variable);
- ClassDB::bind_method(_MD("get_variable"),&VisualScriptVariableSet::get_variable);
+ 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"),_SCS("set_variable"),_SCS("get_variable"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"variable/name"),"set_variable","get_variable");
}
@@ -995,11 +995,11 @@ void VisualScriptConstant::_validate_property(PropertyInfo& property) const {
void VisualScriptConstant::_bind_methods() {
- ClassDB::bind_method(_MD("set_constant_type","type"),&VisualScriptConstant::set_constant_type);
- ClassDB::bind_method(_MD("get_constant_type"),&VisualScriptConstant::get_constant_type);
+ ClassDB::bind_method(D_METHOD("set_constant_type","type"),&VisualScriptConstant::set_constant_type);
+ ClassDB::bind_method(D_METHOD("get_constant_type"),&VisualScriptConstant::get_constant_type);
- ClassDB::bind_method(_MD("set_constant_value","value"),&VisualScriptConstant::set_constant_value);
- ClassDB::bind_method(_MD("get_constant_value"),&VisualScriptConstant::get_constant_value);
+ 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);
String argt="Null";
for(int i=1;i<Variant::VARIANT_MAX;i++) {
@@ -1007,8 +1007,8 @@ void VisualScriptConstant::_bind_methods() {
}
- ADD_PROPERTY(PropertyInfo(Variant::INT,"constant/type",PROPERTY_HINT_ENUM,argt),_SCS("set_constant_type"),_SCS("get_constant_type"));
- ADD_PROPERTY(PropertyInfo(Variant::NIL,"constant/value"),_SCS("set_constant_value"),_SCS("get_constant_value"));
+ 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");
}
@@ -1123,11 +1123,11 @@ Ref<Resource> VisualScriptPreload::get_preload() const{
void VisualScriptPreload::_bind_methods() {
- ClassDB::bind_method(_MD("set_preload","resource"),&VisualScriptPreload::set_preload);
- ClassDB::bind_method(_MD("get_preload"),&VisualScriptPreload::get_preload);
+ ClassDB::bind_method(D_METHOD("set_preload","resource"),&VisualScriptPreload::set_preload);
+ ClassDB::bind_method(D_METHOD("get_preload"),&VisualScriptPreload::get_preload);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"resource",PROPERTY_HINT_RESOURCE_TYPE,"Resource"),_SCS("set_preload"),_SCS("get_preload"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"resource",PROPERTY_HINT_RESOURCE_TYPE,"Resource"),"set_preload","get_preload");
}
@@ -1425,8 +1425,8 @@ VisualScriptNodeInstance* VisualScriptGlobalConstant::instance(VisualScriptInsta
void VisualScriptGlobalConstant::_bind_methods() {
- ClassDB::bind_method(_MD("set_global_constant","index"),&VisualScriptGlobalConstant::set_global_constant);
- ClassDB::bind_method(_MD("get_global_constant"),&VisualScriptGlobalConstant::get_global_constant);
+ ClassDB::bind_method(D_METHOD("set_global_constant","index"),&VisualScriptGlobalConstant::set_global_constant);
+ ClassDB::bind_method(D_METHOD("get_global_constant"),&VisualScriptGlobalConstant::get_global_constant);
String cc;
@@ -1436,7 +1436,7 @@ void VisualScriptGlobalConstant::_bind_methods() {
cc+=",";
cc+=GlobalConstants::get_global_constant_name(i);
}
- ADD_PROPERTY(PropertyInfo(Variant::INT,"constant",PROPERTY_HINT_ENUM,cc),_SCS("set_global_constant"),_SCS("get_global_constant"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"constant",PROPERTY_HINT_ENUM,cc),"set_global_constant","get_global_constant");
}
VisualScriptGlobalConstant::VisualScriptGlobalConstant() {
@@ -1563,14 +1563,14 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo& property) const
void VisualScriptClassConstant::_bind_methods() {
- ClassDB::bind_method(_MD("set_class_constant","name"),&VisualScriptClassConstant::set_class_constant);
- ClassDB::bind_method(_MD("get_class_constant"),&VisualScriptClassConstant::get_class_constant);
+ ClassDB::bind_method(D_METHOD("set_class_constant","name"),&VisualScriptClassConstant::set_class_constant);
+ ClassDB::bind_method(D_METHOD("get_class_constant"),&VisualScriptClassConstant::get_class_constant);
- ClassDB::bind_method(_MD("set_base_type","name"),&VisualScriptClassConstant::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptClassConstant::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","name"),&VisualScriptClassConstant::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptClassConstant::get_base_type);
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,""),_SCS("set_class_constant"),_SCS("get_class_constant"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"base_type",PROPERTY_HINT_TYPE_STRING,"Object"),"set_base_type","get_base_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,""),"set_class_constant","get_class_constant");
}
VisualScriptClassConstant::VisualScriptClassConstant() {
@@ -1703,11 +1703,11 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo& property) c
void VisualScriptBasicTypeConstant::_bind_methods() {
- ClassDB::bind_method(_MD("set_basic_type","name"),&VisualScriptBasicTypeConstant::set_basic_type);
- ClassDB::bind_method(_MD("get_basic_type"),&VisualScriptBasicTypeConstant::get_basic_type);
+ ClassDB::bind_method(D_METHOD("set_basic_type","name"),&VisualScriptBasicTypeConstant::set_basic_type);
+ ClassDB::bind_method(D_METHOD("get_basic_type"),&VisualScriptBasicTypeConstant::get_basic_type);
- ClassDB::bind_method(_MD("set_basic_type_constant","name"),&VisualScriptBasicTypeConstant::set_basic_type_constant);
- ClassDB::bind_method(_MD("get_basic_type_constant"),&VisualScriptBasicTypeConstant::get_basic_type_constant);
+ ClassDB::bind_method(D_METHOD("set_basic_type_constant","name"),&VisualScriptBasicTypeConstant::set_basic_type_constant);
+ ClassDB::bind_method(D_METHOD("get_basic_type_constant"),&VisualScriptBasicTypeConstant::get_basic_type_constant);
String argt="Null";
@@ -1715,8 +1715,8 @@ void VisualScriptBasicTypeConstant::_bind_methods() {
argt+=","+Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY(PropertyInfo(Variant::INT,"basic_type",PROPERTY_HINT_ENUM,argt),_SCS("set_basic_type"),_SCS("get_basic_type"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,""),_SCS("set_basic_type_constant"),_SCS("get_basic_type_constant"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"basic_type",PROPERTY_HINT_ENUM,argt),"set_basic_type","get_basic_type");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,""),"set_basic_type_constant","get_basic_type_constant");
}
VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() {
@@ -1738,6 +1738,8 @@ const char* VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX]={
"PI/2",
"E",
"Sqrt2",
+ "INF",
+ "NAN"
};
double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX]={
@@ -1746,7 +1748,9 @@ double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX]={
Math_PI*2,
Math_PI*0.5,
2.71828182845904523536,
- Math::sqrt(2.0)
+ Math::sqrt(2.0),
+ Math_INF,
+ Math_NAN
};
@@ -1831,8 +1835,8 @@ VisualScriptNodeInstance* VisualScriptMathConstant::instance(VisualScriptInstanc
void VisualScriptMathConstant::_bind_methods() {
- ClassDB::bind_method(_MD("set_math_constant","which"),&VisualScriptMathConstant::set_math_constant);
- ClassDB::bind_method(_MD("get_math_constant"),&VisualScriptMathConstant::get_math_constant);
+ ClassDB::bind_method(D_METHOD("set_math_constant","which"),&VisualScriptMathConstant::set_math_constant);
+ ClassDB::bind_method(D_METHOD("get_math_constant"),&VisualScriptMathConstant::get_math_constant);
String cc;
@@ -1842,7 +1846,7 @@ void VisualScriptMathConstant::_bind_methods() {
cc+=",";
cc+=const_name[i];
}
- ADD_PROPERTY(PropertyInfo(Variant::INT,"constant",PROPERTY_HINT_ENUM,cc),_SCS("set_math_constant"),_SCS("get_math_constant"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"constant",PROPERTY_HINT_ENUM,cc),"set_math_constant","get_math_constant");
}
VisualScriptMathConstant::VisualScriptMathConstant() {
@@ -1953,8 +1957,8 @@ VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output
void VisualScriptEngineSingleton::_bind_methods() {
- ClassDB::bind_method(_MD("set_singleton","name"),&VisualScriptEngineSingleton::set_singleton);
- ClassDB::bind_method(_MD("get_singleton"),&VisualScriptEngineSingleton::get_singleton);
+ ClassDB::bind_method(D_METHOD("set_singleton","name"),&VisualScriptEngineSingleton::set_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton"),&VisualScriptEngineSingleton::get_singleton);
String cc;
@@ -1971,7 +1975,7 @@ void VisualScriptEngineSingleton::_bind_methods() {
cc+=E->get().name;
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,cc),_SCS("set_singleton"),_SCS("get_singleton"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,cc),"set_singleton","get_singleton");
}
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
@@ -2190,10 +2194,10 @@ void VisualScriptSceneNode::_validate_property(PropertyInfo& property) const {
void VisualScriptSceneNode::_bind_methods() {
- ClassDB::bind_method(_MD("set_node_path","path"),&VisualScriptSceneNode::set_node_path);
- ClassDB::bind_method(_MD("get_node_path"),&VisualScriptSceneNode::get_node_path);
+ ClassDB::bind_method(D_METHOD("set_node_path","path"),&VisualScriptSceneNode::set_node_path);
+ ClassDB::bind_method(D_METHOD("get_node_path"),&VisualScriptSceneNode::get_node_path);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_node_path"),_SCS("get_node_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),"set_node_path","get_node_path");
}
VisualScriptSceneNode::VisualScriptSceneNode() {
@@ -2401,10 +2405,10 @@ VisualScriptNodeInstance* VisualScriptResourcePath::instance(VisualScriptInstanc
void VisualScriptResourcePath::_bind_methods() {
- ClassDB::bind_method(_MD("set_resource_path","path"),&VisualScriptResourcePath::set_resource_path);
- ClassDB::bind_method(_MD("get_resource_path"),&VisualScriptResourcePath::get_resource_path);
+ ClassDB::bind_method(D_METHOD("set_resource_path","path"),&VisualScriptResourcePath::set_resource_path);
+ ClassDB::bind_method(D_METHOD("get_resource_path"),&VisualScriptResourcePath::get_resource_path);
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"path",PROPERTY_HINT_FILE),_SCS("set_resource_path"),_SCS("get_resource_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"path",PROPERTY_HINT_FILE),"set_resource_path","get_resource_path");
}
VisualScriptResourcePath::VisualScriptResourcePath() {
@@ -3001,18 +3005,18 @@ VisualScriptNodeInstance* VisualScriptComment::instance(VisualScriptInstance* p_
void VisualScriptComment::_bind_methods() {
- ClassDB::bind_method(_MD("set_title","title"),&VisualScriptComment::set_title);
- ClassDB::bind_method(_MD("get_title"),&VisualScriptComment::get_title);
+ ClassDB::bind_method(D_METHOD("set_title","title"),&VisualScriptComment::set_title);
+ ClassDB::bind_method(D_METHOD("get_title"),&VisualScriptComment::get_title);
- ClassDB::bind_method(_MD("set_description","description"),&VisualScriptComment::set_description);
- ClassDB::bind_method(_MD("get_description"),&VisualScriptComment::get_description);
+ ClassDB::bind_method(D_METHOD("set_description","description"),&VisualScriptComment::set_description);
+ ClassDB::bind_method(D_METHOD("get_description"),&VisualScriptComment::get_description);
- ClassDB::bind_method(_MD("set_size","size"),&VisualScriptComment::set_size);
- ClassDB::bind_method(_MD("get_size"),&VisualScriptComment::get_size);
+ ClassDB::bind_method(D_METHOD("set_size","size"),&VisualScriptComment::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"),&VisualScriptComment::get_size);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"description",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_description"),_SCS("get_description"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"size"),_SCS("set_size"),_SCS("get_size"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),"set_title","get_title");
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"description",PROPERTY_HINT_MULTILINE_TEXT),"set_description","get_description");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"size"),"set_size","get_size");
}
@@ -3140,14 +3144,14 @@ VisualScriptNodeInstance* VisualScriptConstructor::instance(VisualScriptInstance
void VisualScriptConstructor::_bind_methods() {
- ClassDB::bind_method(_MD("set_constructor_type","type"),&VisualScriptConstructor::set_constructor_type);
- ClassDB::bind_method(_MD("get_constructor_type"),&VisualScriptConstructor::get_constructor_type);
+ ClassDB::bind_method(D_METHOD("set_constructor_type","type"),&VisualScriptConstructor::set_constructor_type);
+ ClassDB::bind_method(D_METHOD("get_constructor_type"),&VisualScriptConstructor::get_constructor_type);
- ClassDB::bind_method(_MD("set_constructor","constructor"),&VisualScriptConstructor::set_constructor);
- ClassDB::bind_method(_MD("get_constructor"),&VisualScriptConstructor::get_constructor);
+ ClassDB::bind_method(D_METHOD("set_constructor","constructor"),&VisualScriptConstructor::set_constructor);
+ ClassDB::bind_method(D_METHOD("get_constructor"),&VisualScriptConstructor::get_constructor);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"type",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_constructor_type"),_SCS("get_constructor_type"));
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"constructor",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_constructor"),_SCS("get_constructor"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"type",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_constructor_type","get_constructor_type");
+ ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"constructor",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_constructor","get_constructor");
}
@@ -3283,19 +3287,19 @@ VisualScriptNodeInstance* VisualScriptLocalVar::instance(VisualScriptInstance* p
void VisualScriptLocalVar::_bind_methods() {
- ClassDB::bind_method(_MD("set_var_name","name"),&VisualScriptLocalVar::set_var_name);
- ClassDB::bind_method(_MD("get_var_name"),&VisualScriptLocalVar::get_var_name);
+ ClassDB::bind_method(D_METHOD("set_var_name","name"),&VisualScriptLocalVar::set_var_name);
+ ClassDB::bind_method(D_METHOD("get_var_name"),&VisualScriptLocalVar::get_var_name);
- ClassDB::bind_method(_MD("set_var_type","type"),&VisualScriptLocalVar::set_var_type);
- ClassDB::bind_method(_MD("get_var_type"),&VisualScriptLocalVar::get_var_type);
+ ClassDB::bind_method(D_METHOD("set_var_type","type"),&VisualScriptLocalVar::set_var_type);
+ ClassDB::bind_method(D_METHOD("get_var_type"),&VisualScriptLocalVar::get_var_type);
String argt="Any";
for(int i=1;i<Variant::VARIANT_MAX;i++) {
argt+=","+Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"variable/name"),_SCS("set_var_name"),_SCS("get_var_name"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"variable/type",PROPERTY_HINT_ENUM,argt),_SCS("set_var_type"),_SCS("get_var_type"));
+ 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");
}
@@ -3420,19 +3424,19 @@ VisualScriptNodeInstance* VisualScriptLocalVarSet::instance(VisualScriptInstance
void VisualScriptLocalVarSet::_bind_methods() {
- ClassDB::bind_method(_MD("set_var_name","name"),&VisualScriptLocalVarSet::set_var_name);
- ClassDB::bind_method(_MD("get_var_name"),&VisualScriptLocalVarSet::get_var_name);
+ ClassDB::bind_method(D_METHOD("set_var_name","name"),&VisualScriptLocalVarSet::set_var_name);
+ ClassDB::bind_method(D_METHOD("get_var_name"),&VisualScriptLocalVarSet::get_var_name);
- ClassDB::bind_method(_MD("set_var_type","type"),&VisualScriptLocalVarSet::set_var_type);
- ClassDB::bind_method(_MD("get_var_type"),&VisualScriptLocalVarSet::get_var_type);
+ ClassDB::bind_method(D_METHOD("set_var_type","type"),&VisualScriptLocalVarSet::set_var_type);
+ ClassDB::bind_method(D_METHOD("get_var_type"),&VisualScriptLocalVarSet::get_var_type);
String argt="Any";
for(int i=1;i<Variant::VARIANT_MAX;i++) {
argt+=","+Variant::get_type_name(Variant::Type(i));
}
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"variable/name"),_SCS("set_var_name"),_SCS("get_var_name"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"variable/type",PROPERTY_HINT_ENUM,argt),_SCS("set_var_type"),_SCS("get_var_type"));
+ 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");
}
@@ -3615,7 +3619,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo& property) const {
al.push_back(name);
}
- al.sort();;
+ al.sort();
for(int i=0;i<al.size();i++) {
if (actions!=String())
@@ -3630,14 +3634,14 @@ void VisualScriptInputAction::_validate_property(PropertyInfo& property) const {
void VisualScriptInputAction::_bind_methods() {
- ClassDB::bind_method(_MD("set_action_name","name"),&VisualScriptInputAction::set_action_name);
- ClassDB::bind_method(_MD("get_action_name"),&VisualScriptInputAction::get_action_name);
+ ClassDB::bind_method(D_METHOD("set_action_name","name"),&VisualScriptInputAction::set_action_name);
+ ClassDB::bind_method(D_METHOD("get_action_name"),&VisualScriptInputAction::get_action_name);
- ClassDB::bind_method(_MD("set_action_mode","mode"),&VisualScriptInputAction::set_action_mode);
- ClassDB::bind_method(_MD("get_action_mode"),&VisualScriptInputAction::get_action_mode);
+ ClassDB::bind_method(D_METHOD("set_action_mode","mode"),&VisualScriptInputAction::set_action_mode);
+ ClassDB::bind_method(D_METHOD("get_action_mode"),&VisualScriptInputAction::get_action_mode);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),_SCS("set_action_name"),_SCS("get_action_name"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Pressed,Released,JustPressed,JustReleased"),_SCS("set_action_mode"),_SCS("get_action_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),"set_action_name","get_action_name");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Pressed,Released,JustPressed,JustReleased"),"set_action_mode","get_action_mode");
}
@@ -3705,7 +3709,7 @@ String VisualScriptDeconstruct::get_category() const {
void VisualScriptDeconstruct::_update_elements() {
- elements.clear();;
+ elements.clear();
Variant v;
if (type==Variant::INPUT_EVENT) {
InputEvent ie;
@@ -3834,14 +3838,14 @@ void VisualScriptDeconstruct::_validate_property(PropertyInfo& property) const {
void VisualScriptDeconstruct::_bind_methods() {
- ClassDB::bind_method(_MD("set_deconstruct_type","type"),&VisualScriptDeconstruct::set_deconstruct_type);
- ClassDB::bind_method(_MD("get_deconstruct_type"),&VisualScriptDeconstruct::get_deconstruct_type);
+ ClassDB::bind_method(D_METHOD("set_deconstruct_type","type"),&VisualScriptDeconstruct::set_deconstruct_type);
+ ClassDB::bind_method(D_METHOD("get_deconstruct_type"),&VisualScriptDeconstruct::get_deconstruct_type);
- ClassDB::bind_method(_MD("set_deconstruct_input_type","input_type"),&VisualScriptDeconstruct::set_deconstruct_input_type);
- ClassDB::bind_method(_MD("get_deconstruct_input_type"),&VisualScriptDeconstruct::get_deconstruct_input_type);
+ ClassDB::bind_method(D_METHOD("set_deconstruct_input_type","input_type"),&VisualScriptDeconstruct::set_deconstruct_input_type);
+ ClassDB::bind_method(D_METHOD("get_deconstruct_input_type"),&VisualScriptDeconstruct::get_deconstruct_input_type);
- ClassDB::bind_method(_MD("_set_elem_cache","_cache"),&VisualScriptDeconstruct::_set_elem_cache);
- ClassDB::bind_method(_MD("_get_elem_cache"),&VisualScriptDeconstruct::_get_elem_cache);
+ ClassDB::bind_method(D_METHOD("_set_elem_cache","_cache"),&VisualScriptDeconstruct::_set_elem_cache);
+ ClassDB::bind_method(D_METHOD("_get_elem_cache"),&VisualScriptDeconstruct::_get_elem_cache);
String argt="Any";
for(int i=1;i<Variant::VARIANT_MAX;i++) {
@@ -3850,9 +3854,9 @@ void VisualScriptDeconstruct::_bind_methods() {
String iet="None,Key,MouseMotion,MouseButton,JoypadMotion,JoypadButton,ScreenTouch,ScreenDrag,Action";
- ADD_PROPERTY( PropertyInfo(Variant::INT,"type",PROPERTY_HINT_ENUM,argt),_SCS("set_deconstruct_type"),_SCS("get_deconstruct_type"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"input_type",PROPERTY_HINT_ENUM,iet),_SCS("set_deconstruct_input_type"),_SCS("get_deconstruct_input_type"));
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"elem_cache",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_elem_cache"),_SCS("_get_elem_cache"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"type",PROPERTY_HINT_ENUM,argt),"set_deconstruct_type","get_deconstruct_type");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"input_type",PROPERTY_HINT_ENUM,iet),"set_deconstruct_input_type","get_deconstruct_input_type");
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"elem_cache",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_elem_cache","_get_elem_cache");
}
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 7a06fbf5e8..25d07ccb86 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -467,7 +467,9 @@ public:
MATH_CONSTANT_HALF_PI,
MATH_CONSTANT_E,
MATH_CONSTANT_SQRT2,
- MATH_CONSTANT_MAX,
+ MATH_CONSTANT_INF,
+ MATH_CONSTANT_NAN,
+ MATH_CONSTANT_MAX
};
private:
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 8b251e667c..c079606674 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -157,14 +157,14 @@ void VisualScriptYield::_validate_property(PropertyInfo& property) const {
void VisualScriptYield::_bind_methods() {
- ClassDB::bind_method(_MD("set_yield_mode","mode"),&VisualScriptYield::set_yield_mode);
- ClassDB::bind_method(_MD("get_yield_mode"),&VisualScriptYield::get_yield_mode);
+ ClassDB::bind_method(D_METHOD("set_yield_mode","mode"),&VisualScriptYield::set_yield_mode);
+ ClassDB::bind_method(D_METHOD("get_yield_mode"),&VisualScriptYield::get_yield_mode);
- ClassDB::bind_method(_MD("set_wait_time","sec"),&VisualScriptYield::set_wait_time);
- ClassDB::bind_method(_MD("get_wait_time"),&VisualScriptYield::get_wait_time);
+ ClassDB::bind_method(D_METHOD("set_wait_time","sec"),&VisualScriptYield::set_wait_time);
+ ClassDB::bind_method(D_METHOD("get_wait_time"),&VisualScriptYield::get_wait_time);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Frame,FixedFrame,Time",PROPERTY_USAGE_NOEDITOR),_SCS("set_yield_mode"),_SCS("get_yield_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wait_time"),_SCS("set_wait_time"),_SCS("get_wait_time"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Frame,FixedFrame,Time",PROPERTY_USAGE_NOEDITOR),"set_yield_mode","get_yield_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wait_time"),"set_wait_time","get_wait_time");
BIND_CONSTANT( YIELD_FRAME );
@@ -468,17 +468,17 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo& property) const {
void VisualScriptYieldSignal::_bind_methods() {
- ClassDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptYieldSignal::set_base_type);
- ClassDB::bind_method(_MD("get_base_type"),&VisualScriptYieldSignal::get_base_type);
+ ClassDB::bind_method(D_METHOD("set_base_type","base_type"),&VisualScriptYieldSignal::set_base_type);
+ ClassDB::bind_method(D_METHOD("get_base_type"),&VisualScriptYieldSignal::get_base_type);
- ClassDB::bind_method(_MD("set_signal","signal"),&VisualScriptYieldSignal::set_signal);
- ClassDB::bind_method(_MD("get_signal"),&VisualScriptYieldSignal::get_signal);
+ ClassDB::bind_method(D_METHOD("set_signal","signal"),&VisualScriptYieldSignal::set_signal);
+ ClassDB::bind_method(D_METHOD("get_signal"),&VisualScriptYieldSignal::get_signal);
- ClassDB::bind_method(_MD("set_call_mode","mode"),&VisualScriptYieldSignal::set_call_mode);
- ClassDB::bind_method(_MD("get_call_mode"),&VisualScriptYieldSignal::get_call_mode);
+ ClassDB::bind_method(D_METHOD("set_call_mode","mode"),&VisualScriptYieldSignal::set_call_mode);
+ ClassDB::bind_method(D_METHOD("get_call_mode"),&VisualScriptYieldSignal::get_call_mode);
- ClassDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptYieldSignal::set_base_path);
- ClassDB::bind_method(_MD("get_base_path"),&VisualScriptYieldSignal::get_base_path);
+ ClassDB::bind_method(D_METHOD("set_base_path","base_path"),&VisualScriptYieldSignal::set_base_path);
+ ClassDB::bind_method(D_METHOD("get_base_path"),&VisualScriptYieldSignal::get_base_path);
@@ -490,10 +490,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"),_SCS("set_call_mode"),_SCS("get_call_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"signal/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"signal/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"signal/signal"),_SCS("set_signal"),_SCS("get_signal"));
+ 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");
BIND_CONSTANT( CALL_MODE_SELF );
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index 7abcd0a8b7..98920954a4 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -78,7 +78,7 @@ int AudioStreamPlaybackOGGVorbis::_ov_seek_func(void *_f,ogg_int64_t offs, int w
}
int AudioStreamPlaybackOGGVorbis::_ov_close_func(void *_f) {
-// printf("close %p\n",_f);
+ //printf("close %p\n",_f);
if (!_f)
return 0;
FileAccess *fa=(FileAccess*)_f;
@@ -141,7 +141,7 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t* p_bufer,int p_frames) {
int errv = ov_open_callbacks(f,&vf,NULL,0,_ov_callbacks);
if (errv!=0) {
playing=false;
- break;; // :(
+ break; // :(
}
if (loop_restart_time) {
@@ -419,7 +419,7 @@ void ResourceFormatLoaderAudioStreamOGGVorbis::get_recognized_extensions(List<St
}
String ResourceFormatLoaderAudioStreamOGGVorbis::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="ogg")
+ if (p_path.get_extension().to_lower()=="ogg")
return "AudioStreamOGGVorbis";
return "";
}
diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py
index fb920482f5..ef5daca05c 100644
--- a/modules/vorbis/config.py
+++ b/modules/vorbis/config.py
@@ -1,6 +1,7 @@
def can_build(platform):
- return True
+# return True
+ return False
def configure(env):
diff --git a/modules/webm/config.py b/modules/webm/config.py
index fb920482f5..ef5daca05c 100644
--- a/modules/webm/config.py
+++ b/modules/webm/config.py
@@ -1,6 +1,7 @@
def can_build(platform):
- return True
+# return True
+ return False
def configure(env):
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index d132e89690..d4995ad798 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -35,7 +35,7 @@
#include "../theora/yuv2rgb.h"
#include "os/file_access.h"
-#include "globals.h"
+#include "global_config.h"
#include <string.h>
@@ -415,7 +415,7 @@ bool ResourceFormatLoaderVideoStreamWebm::handles_type(const String &p_type) con
String ResourceFormatLoaderVideoStreamWebm::get_resource_type(const String &p_path) const {
- const String exl = p_path.extension().to_lower();
+ const String exl = p_path.get_extension().to_lower();
if (exl == "webm")
return "VideoStreamWebm";
return "";
diff --git a/modules/webp/SCsub b/modules/webp/SCsub
index 92f34c4da1..aa3486a2c5 100644
--- a/modules/webp/SCsub
+++ b/modules/webp/SCsub
@@ -9,108 +9,118 @@ env_webp = env_modules.Clone()
if (env['builtin_libwebp'] != 'no'):
thirdparty_dir = "#thirdparty/libwebp/"
thirdparty_sources = [
- "enc/webpenc.c",
- "enc/near_lossless.c",
- "enc/frame.c",
- "enc/alpha.c",
- "enc/picture_csp.c",
- "enc/vp8l.c",
- "enc/picture_psnr.c",
- "enc/delta_palettization.c",
- "enc/syntax.c",
- "enc/backward_references.c",
- "enc/token.c",
- "enc/analysis.c",
- "enc/iterator.c",
- "enc/picture_tools.c",
- "enc/picture_rescale.c",
- "enc/config.c",
- "enc/tree.c",
- "enc/cost.c",
- "enc/picture.c",
- "enc/quant.c",
- "enc/filter.c",
- "enc/histogram.c",
- "utils/rescaler.c",
- "utils/filters.c",
- "utils/quant_levels_dec.c",
- "utils/huffman.c",
- "utils/thread.c",
- "utils/quant_levels.c",
- "utils/bit_writer.c",
- "utils/bit_reader.c",
- "utils/random.c",
- "utils/utils.c",
- "utils/huffman_encode.c",
- "utils/color_cache.c",
- "mux/muxinternal.c",
- "mux/muxread.c",
- "mux/anim_encode.c",
- "mux/muxedit.c",
- "dec/webp.c",
- "dec/frame.c",
- "dec/alpha.c",
- "dec/vp8l.c",
- "dec/io.c",
- "dec/vp8.c",
- "dec/idec.c",
- "dec/tree.c",
- "dec/buffer.c",
- "dec/quant.c",
- "demux/demux.c",
+ "dec/alpha_dec.c",
+ "dec/buffer_dec.c",
+ "dec/frame_dec.c",
+ "dec/idec_dec.c",
+ "dec/io_dec.c",
+ "dec/quant_dec.c",
+ "dec/tree_dec.c",
+ "dec/vp8_dec.c",
+ "dec/vp8l_dec.c",
+ "dec/webp_dec.c",
"demux/anim_decode.c",
- "dsp/yuv.c",
- "dsp/filters_sse2.c",
- "dsp/dec_sse41.c",
- "dsp/rescaler.c",
- "dsp/lossless_sse2.c",
- "dsp/alpha_processing_sse41.c",
- "dsp/alpha_processing_sse2.c",
- "dsp/filters.c",
- "dsp/upsampling_mips_dsp_r2.c",
- "dsp/dec_neon.c",
- "dsp/enc_neon.c",
- "dsp/lossless_enc_mips32.c",
- "dsp/lossless_enc_sse2.c",
- "dsp/upsampling.c",
- "dsp/lossless_enc_neon.c",
+ "demux/demux.c",
"dsp/alpha_processing.c",
+ "dsp/alpha_processing_mips_dsp_r2.c",
+ "dsp/alpha_processing_neon.c",
+ "dsp/alpha_processing_sse2.c",
+ "dsp/alpha_processing_sse41.c",
+ "dsp/argb.c",
+ "dsp/argb_mips_dsp_r2.c",
+ "dsp/argb_sse2.c",
+ "dsp/cost.c",
+ "dsp/cost_mips32.c",
+ "dsp/cost_mips_dsp_r2.c",
"dsp/cost_sse2.c",
+ "dsp/cpu.c",
+ "dsp/dec.c",
+ "dsp/dec_clip_tables.c",
"dsp/dec_mips32.c",
+ "dsp/dec_mips_dsp_r2.c",
+ "dsp/dec_msa.c",
+ "dsp/dec_neon.c",
+ "dsp/dec_sse2.c",
+ "dsp/dec_sse41.c",
"dsp/enc_avx2.c",
- "dsp/rescaler_mips32.c",
"dsp/enc.c",
- "dsp/lossless_enc_sse41.c",
- "dsp/cost_mips32.c",
- "dsp/lossless_mips_dsp_r2.c",
- "dsp/filters_mips_dsp_r2.c",
- "dsp/upsampling_neon.c",
- "dsp/alpha_processing_mips_dsp_r2.c",
+ "dsp/enc_mips32.c",
"dsp/enc_mips_dsp_r2.c",
- "dsp/lossless.c",
- "dsp/yuv_mips_dsp_r2.c",
- "dsp/cost_mips_dsp_r2.c",
- "dsp/argb.c",
- "dsp/dec_sse2.c",
- "dsp/rescaler_sse2.c",
+ "dsp/enc_msa.c",
+ "dsp/enc_neon.c",
+ "dsp/enc_sse2.c",
"dsp/enc_sse41.c",
- "dsp/argb_mips_dsp_r2.c",
+ "dsp/filters.c",
+ "dsp/filters_mips_dsp_r2.c",
+ "dsp/filters_msa.c",
+ "dsp/filters_neon.c",
+ "dsp/filters_sse2.c",
+ "dsp/lossless.c",
+ "dsp/lossless_enc.c",
+ "dsp/lossless_enc_mips32.c",
"dsp/lossless_enc_mips_dsp_r2.c",
- "dsp/dec_clip_tables.c",
- "dsp/yuv_mips32.c",
- "dsp/cpu.c",
- "dsp/dec.c",
- "dsp/argb_sse2.c",
+ "dsp/lossless_enc_msa.c",
+ "dsp/lossless_enc_neon.c",
+ "dsp/lossless_enc_sse2.c",
+ "dsp/lossless_enc_sse41.c",
+ "dsp/lossless_mips_dsp_r2.c",
+ "dsp/lossless_msa.c",
"dsp/lossless_neon.c",
- "dsp/lossless_enc.c",
- "dsp/enc_mips32.c",
- "dsp/cost.c",
+ "dsp/lossless_sse2.c",
+ "dsp/rescaler.c",
+ "dsp/rescaler_mips32.c",
"dsp/rescaler_mips_dsp_r2.c",
- "dsp/dec_mips_dsp_r2.c",
+ "dsp/rescaler_msa.c",
"dsp/rescaler_neon.c",
- "dsp/yuv_sse2.c",
- "dsp/enc_sse2.c",
+ "dsp/rescaler_sse2.c",
+ "dsp/upsampling.c",
+ "dsp/upsampling_mips_dsp_r2.c",
+ "dsp/upsampling_msa.c",
+ "dsp/upsampling_neon.c",
"dsp/upsampling_sse2.c",
+ "dsp/yuv.c",
+ "dsp/yuv_mips32.c",
+ "dsp/yuv_mips_dsp_r2.c",
+ "dsp/yuv_sse2.c",
+ "enc/alpha_enc.c",
+ "enc/analysis_enc.c",
+ "enc/backward_references_enc.c",
+ "enc/config_enc.c",
+ "enc/cost_enc.c",
+ "enc/delta_palettization_enc.c",
+ "enc/filter_enc.c",
+ "enc/frame_enc.c",
+ "enc/histogram_enc.c",
+ "enc/iterator_enc.c",
+ "enc/near_lossless_enc.c",
+ "enc/picture_csp_enc.c",
+ "enc/picture_enc.c",
+ "enc/picture_psnr_enc.c",
+ "enc/picture_rescale_enc.c",
+ "enc/picture_tools_enc.c",
+ "enc/predictor_enc.c",
+ "enc/quant_enc.c",
+ "enc/syntax_enc.c",
+ "enc/token_enc.c",
+ "enc/tree_enc.c",
+ "enc/vp8l_enc.c",
+ "enc/webp_enc.c",
+ "mux/anim_encode.c",
+ "mux/muxedit.c",
+ "mux/muxinternal.c",
+ "mux/muxread.c",
+ "utils/bit_reader_utils.c",
+ "utils/bit_writer_utils.c",
+ "utils/color_cache_utils.c",
+ "utils/filters_utils.c",
+ "utils/huffman_encode_utils.c",
+ "utils/huffman_utils.c",
+ "utils/quant_levels_dec_utils.c",
+ "utils/quant_levels_utils.c",
+ "utils/random_utils.c",
+ "utils/rescaler_utils.c",
+ "utils/thread_utils.c",
+ "utils/utils.c",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index 8c57eaaab6..415223c1da 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -27,9 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_driver_jandroid.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "os/os.h"
#include "thread_jandroid.h"
+
#ifndef ANDROID_NATIVE_ACTIVITY
AudioDriverAndroid* AudioDriverAndroid::s_ad=NULL;
@@ -71,7 +73,7 @@ Error AudioDriverAndroid::init(){
}
*/
-// Android_JNI_SetupThread();
+ //Android_JNI_SetupThread();
// __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
@@ -199,9 +201,9 @@ int AudioDriverAndroid::get_mix_rate() const {
return mix_rate;
}
-AudioDriverSW::OutputFormat AudioDriverAndroid::get_output_format() const{
+AudioDriver::SpeakerMode AudioDriverAndroid::get_speaker_mode() const{
- return OUTPUT_STEREO;
+ return SPEAKER_MODE_STEREO;
}
void AudioDriverAndroid::lock(){
diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h
index 01ce31be8f..f485df2001 100644
--- a/platform/android/audio_driver_jandroid.h
+++ b/platform/android/audio_driver_jandroid.h
@@ -29,12 +29,13 @@
#ifndef AUDIO_DRIVER_ANDROID_H
#define AUDIO_DRIVER_ANDROID_H
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
+
#ifndef ANDROID_NATIVE_ACTIVITY
#include "java_glue.h"
-class AudioDriverAndroid : public AudioDriverSW {
+class AudioDriverAndroid : public AudioDriver {
static Mutex *mutex;
@@ -65,7 +66,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const ;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index 5e3cfcbbab..2ec80f23c3 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -27,11 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_driver_opensl.h"
-#include <string.h>
-
-
-
+#include <string.h>
#define MAX_NUMBER_INTERFACES 3
#define MAX_NUMBER_OUTPUT_DEVICES 6
@@ -108,7 +105,7 @@ void AudioDriverOpenSL::_buffer_callbacks(
AudioDriverOpenSL *ad = (AudioDriverOpenSL*)pContext;
-// ad->_buffer_callback(queueItf,eventFlags,pBuffer,bufferSize,dataUsed);
+ //ad->_buffer_callback(queueItf,eventFlags,pBuffer,bufferSize,dataUsed);
ad->_buffer_callback(queueItf);
}
@@ -271,8 +268,8 @@ void AudioDriverOpenSL::start(){
ERR_FAIL_COND( res !=SL_RESULT_SUCCESS );
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, BUFFER_COUNT};
-// bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
-// bufferQueue.numBuffers = BUFFER_COUNT; /* Four buffers in our buffer queue */
+ //bufferQueue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
+ //bufferQueue.numBuffers = BUFFER_COUNT; /* Four buffers in our buffer queue */
/* Setup the format of the content in the buffer queue */
pcm.formatType = SL_DATAFORMAT_PCM;
pcm.numChannels = 2;
@@ -295,7 +292,7 @@ void AudioDriverOpenSL::start(){
audioSink.pLocator = (void *)&locator_outputmix;
audioSink.pFormat = NULL;
/* Initialize the context for Buffer queue callbacks */
-// cntxt.pDataBase = (void*)&pcmData;
+ //cntxt.pDataBase = (void*)&pcmData;
//cntxt.pData = cntxt.pDataBase;
//cntxt.size = sizeof(pcmData);
/* Set arrays required[] and iidArray[] for SEEK interface
@@ -373,9 +370,9 @@ int AudioDriverOpenSL::get_mix_rate() const {
return 44100;
}
-AudioDriverSW::OutputFormat AudioDriverOpenSL::get_output_format() const{
+AudioDriver::SpeakerMode AudioDriverOpenSL::get_speaker_mode() const{
- return OUTPUT_STEREO;
+ return SPEAKER_MODE_STEREO;
}
void AudioDriverOpenSL::lock(){
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index 8839d20bab..1baaa95052 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -29,15 +29,13 @@
#ifndef AUDIO_DRIVER_OPENSL_H
#define AUDIO_DRIVER_OPENSL_H
-
-
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "os/mutex.h"
-#include <SLES/OpenSLES.h>
-#include "SLES/OpenSLES_Android.h"
+#include <SLES/OpenSLES.h>
+#include <SLES/OpenSLES_Android.h>
-class AudioDriverOpenSL : public AudioDriverSW {
+class AudioDriverOpenSL : public AudioDriver {
bool active;
Mutex *mutex;
@@ -94,7 +92,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const ;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 873eef0566..c46a15bd12 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -52,11 +52,10 @@ android {
java.srcDirs = ['src'
$$GRADLE_JAVA_DIRS$$
]
- resources.srcDirs = [
+ res.srcDirs = [
'res'
$$GRADLE_RES_DIRS$$
]
- res.srcDirs = ['res']
// libs.srcDirs = ['libs']
aidl.srcDirs = [
'aidl'
diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp
index f1a488cec2..82b2761bb0 100644
--- a/platform/android/dir_access_android.cpp
+++ b/platform/android/dir_access_android.cpp
@@ -37,16 +37,16 @@ DirAccess *DirAccessAndroid::create_fs() {
return memnew(DirAccessAndroid);
}
-bool DirAccessAndroid::list_dir_begin() {
+Error DirAccessAndroid::list_dir_begin() {
list_dir_end();
AAssetDir* aad = AAssetManager_openDir(FileAccessAndroid::asset_manager,current_dir.utf8().get_data());
if (!aad)
- return true; //nothing
+ return ERR_CANT_OPEN; //nothing
- return false;
+ return OK;
}
String DirAccessAndroid::get_next(){
@@ -192,6 +192,6 @@ DirAccessAndroid::DirAccessAndroid() {
DirAccessAndroid::~DirAccessAndroid() {
- list_dir_end();;
+ list_dir_end();
}
#endif
diff --git a/platform/android/dir_access_android.h b/platform/android/dir_access_android.h
index 15c29a9a02..72611ceb59 100644
--- a/platform/android/dir_access_android.h
+++ b/platform/android/dir_access_android.h
@@ -49,7 +49,7 @@ class DirAccessAndroid : public DirAccess {
public:
- virtual bool list_dir_begin(); ///< This starts dir listing
+ virtual Error list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index bbd041f6c7..2528b18248 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -47,7 +47,7 @@ DirAccess *DirAccessJAndroid::create_fs() {
return memnew(DirAccessJAndroid);
}
-bool DirAccessJAndroid::list_dir_begin() {
+Error DirAccessJAndroid::list_dir_begin() {
list_dir_end();
JNIEnv *env = ThreadAndroid::get_env();
@@ -55,11 +55,11 @@ bool DirAccessJAndroid::list_dir_begin() {
jstring js = env->NewStringUTF(current_dir.utf8().get_data());
int res = env->CallIntMethod(io,_dir_open,js);
if (res<=0)
- return true;
+ return ERR_CANT_OPEN;
id=res;
- return false;
+ return OK;
}
String DirAccessJAndroid::get_next(){
@@ -257,7 +257,7 @@ void DirAccessJAndroid::setup( jobject p_io) {
__android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _dir_is_dir ok!!");
}
-// (*env)->CallVoidMethod(env,obj,aMethodID, myvar);
+ //(*env)->CallVoidMethod(env,obj,aMethodID, myvar);
}
diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h
index bfd7912aaf..5db32b945c 100644
--- a/platform/android/dir_access_jandroid.h
+++ b/platform/android/dir_access_jandroid.h
@@ -58,7 +58,7 @@ class DirAccessJAndroid : public DirAccess {
public:
- virtual bool list_dir_begin(); ///< This starts dir listing
+ virtual Error list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
virtual bool current_is_hidden() const;
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index e836258e04..1d1ee25622 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -29,16 +29,16 @@
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/android/logo.h"
#include <string.h>
-
+#if 0
static const char* android_perms[]={
"ACCESS_CHECKIN_PROPERTIES",
@@ -729,17 +729,17 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
}
-// print_line("String "+itos(i)+": "+string_table[i]);
+ //print_line("String "+itos(i)+": "+string_table[i]);
}
for(uint32_t i=string_end;i<(ofs+size);i++) {
stable_extra.push_back(p_manifest[i]);
}
-// printf("stable extra: %i\n",int(stable_extra.size()));
+ //printf("stable extra: %i\n",int(stable_extra.size()));
string_table_ends=ofs+size;
-// print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));
+ //print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));
} break;
case CHUNK_XML_START_TAG: {
@@ -752,7 +752,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
String tname=string_table[name];
-// printf("NSPACE: %i\n",nspace);
+ //printf("NSPACE: %i\n",nspace);
//printf("NAME: %i (%s)\n",name,tname.utf8().get_data());
//printf("CHECK: %x\n",check);
uint32_t attrcount=decode_uint32(&p_manifest[iofs+20]);
@@ -1523,7 +1523,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
if (dpos==-1)
continue;
d=d.substr(0,dpos).strip_edges();
- // print_line("found devuce: "+d);
+ //print_line("found devuce: "+d);
ldevices.push_back(d);
}
@@ -1602,8 +1602,8 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
}
d.name=vendor+" "+device;
- // print_line("name: "+d.name);
- // print_line("description: "+d.description);
+ //print_line("name: "+d.name);
+ //print_line("description: "+d.description);
}
@@ -1748,6 +1748,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
args.push_back("shell");
args.push_back("am");
args.push_back("start");
+ args.push_back("--user 0");
args.push_back("-a");
args.push_back("android.intent.action.MAIN");
args.push_back("-n");
@@ -1864,10 +1865,12 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const {
if (apk_expansion) {
- //if (apk_expansion_salt=="") {
- // valid=false;
- // err+="Invalid SALT for apk expansion.\n";
- //}
+ /*
+ if (apk_expansion_salt=="") {
+ valid=false;
+ err+="Invalid SALT for apk expansion.\n";
+ }
+ */
if (apk_expansion_pkey=="") {
valid=false;
err+="Invalid public key for apk expansion.\n";
@@ -1889,9 +1892,11 @@ EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
memdelete(device_thread);
}
+#endif
void register_android_exporter() {
+#if 0
String exe_ext=OS::get_singleton()->get_name()=="Windows"?"exe":"";
EDITOR_DEF("export/android/adb","");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/adb",PROPERTY_HINT_GLOBAL_FILE,exe_ext));
@@ -1910,6 +1915,6 @@ void register_android_exporter() {
Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) );
EditorImportExport::get_singleton()->add_export_platform(exporter);
-
+#endif
}
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index 4755f1d029..a4e9c191e9 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -236,7 +236,7 @@ void FileAccessJAndroid::setup( jobject p_io) {
__android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _file_close ok!!");
}
-// (*env)->CallVoidMethod(env,obj,aMethodID, myvar);
+ //(*env)->CallVoidMethod(env,obj,aMethodID, myvar);
}
diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp
index 52b59b2dc1..01daac9260 100644
--- a/platform/android/globals/global_defaults.cpp
+++ b/platform/android/globals/global_defaults.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
-#include "globals.h"
+#include "global_config.h"
void register_android_global_defaults() {
@@ -35,7 +35,7 @@ void register_android_global_defaults() {
/* GLOBAL_DEF("rasterizer.Android/use_fragment_lighting",false);
GLOBAL_DEF("rasterizer.Android/fp16_framebuffer",false);
GLOBAL_DEF("display.Android/driver","GLES2");
-// GLOBAL_DEF("rasterizer.Android/trilinear_mipmap_filter",false);
+ //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"));
*/
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index c4d1a85c5f..83d5a413c0 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -43,7 +43,7 @@
#include <unistd.h>
#include <stdlib.h>
#include "os_android.h"
-#include "globals.h"
+#include "global_config.h"
#include "main/main.h"
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "godot", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "godot", __VA_ARGS__))
@@ -535,29 +535,33 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
case AMOTION_EVENT_ACTION_DOWN: {
engine->os->process_touch(0,0,touchvec);
- //System.out.printf("action down at: %f,%f\n", event.getX(),event.getY());
+ //System.out.printf("action down at: %f,%f\n", event.getX(),event.getY());
} break;
case AMOTION_EVENT_ACTION_MOVE: {
engine->os->process_touch(1,0,touchvec);
- //for(int i=0;i<event.getPointerCount();i++) {
- // System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
- //}
+ /*
+ for(int i=0;i<event.getPointerCount();i++) {
+ System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
+ }
+ */
} break;
case AMOTION_EVENT_ACTION_POINTER_UP: {
engine->os->process_touch(4,pidx,touchvec);
- //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
+ //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case AMOTION_EVENT_ACTION_POINTER_DOWN: {
engine->os->process_touch(3,pidx,touchvec);
- //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
+ //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case AMOTION_EVENT_ACTION_CANCEL:
case AMOTION_EVENT_ACTION_UP: {
engine->os->process_touch(2,0,touchvec);
- //for(int i=0;i<event.getPointerCount();i++) {
- // System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
- //}
+ /*
+ for(int i=0;i<event.getPointerCount();i++) {
+ System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
+ }
+ */
} break;
}
@@ -638,8 +642,8 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
} break;
case APP_CMD_INIT_WINDOW:
- //The window is being shown, get it ready.
- // LOGI("INIT WINDOW");
+ //The window is being shown, get it ready.
+ //LOGI("INIT WINDOW");
if (engine->app->window != NULL) {
if (engine->os==NULL) {
@@ -647,7 +651,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
//do initialization here, when there's OpenGL! hackish but the only way
engine->os = new OS_Android(_gfx_init,engine);
- // char *args[]={"-test","gui",NULL};
+ //char *args[]={"-test","gui",NULL};
__android_log_print(ANDROID_LOG_INFO,"godot","pre asdasd setup...");
#if 0
Error err = Main::setup("apk",2,args);
@@ -722,15 +726,15 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
engine->animating=1;
engine_draw_frame(engine);
}
- break;
+ break;
case APP_CMD_TERM_WINDOW:
- // The window is being hidden or closed, clean it up.
- // LOGI("TERM WINDOW");
- engine_term_display(engine);
- break;
+ // The window is being hidden or closed, clean it up.
+ //LOGI("TERM WINDOW");
+ engine_term_display(engine);
+ break;
case APP_CMD_GAINED_FOCUS:
- // When our app gains focus, we start monitoring the accelerometer.
- if (engine->accelerometerSensor != NULL) {
+ // When our app gains focus, we start monitoring the accelerometer.
+ if (engine->accelerometerSensor != NULL) {
ASensorEventQueue_enableSensor(engine->sensorEventQueue,
engine->accelerometerSensor);
// We'd like to get 60 events per second (in us).
@@ -833,7 +837,7 @@ void android_main(struct android_app* state) {
// Process this event.
if (source != NULL) {
- // LOGI("process\n");
+ // LOGI("process\n");
source->process(state, source);
} else {
nullmax--;
@@ -883,12 +887,12 @@ void android_main(struct android_app* state) {
return;
}
-// LOGI("end\n");
+ // LOGI("end\n");
}
-// LOGI("engine animating? %i\n",engine.animating);
+ // LOGI("engine animating? %i\n",engine.animating);
if (engine.animating) {
//do os render
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 94d29a3350..610f707b47 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -257,8 +257,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
public void onVideoInit(boolean use_gl2) {
-// mView = new GodotView(getApplication(),io,use_gl2);
-// setContentView(mView);
+ //mView = new GodotView(getApplication(),io,use_gl2);
+ //setContentView(mView);
layout = new FrameLayout(this);
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
@@ -582,7 +582,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
initializeGodot();
- // instanceSingleton( new GodotFacebook(this) );
+ //instanceSingleton( new GodotFacebook(this) );
}
@@ -804,9 +804,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
} break;
case MotionEvent.ACTION_MOVE: {
GodotLib.touch(1,0,evcount,arr);
- //for(int i=0;i<event.getPointerCount();i++) {
- // System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
- //}
+ /*
+ for(int i=0;i<event.getPointerCount();i++) {
+ System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
+ }
+ */
} break;
case MotionEvent.ACTION_POINTER_UP: {
final int indexPointUp = event.getActionIndex();
@@ -822,9 +824,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
GodotLib.touch(2,0,evcount,arr);
- //for(int i=0;i<event.getPointerCount();i++) {
- // System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
- //}
+ /*
+ for(int i=0;i<event.getPointerCount();i++) {
+ System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
+ }
+ */
} break;
}
@@ -866,9 +870,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
return mPaymentsManager;
}
-// public void setPaymentsManager(PaymentsManager mPaymentsManager) {
-// this.mPaymentsManager = mPaymentsManager;
-// };
+ /*
+ public void setPaymentsManager(PaymentsManager mPaymentsManager) {
+ this.mPaymentsManager = mPaymentsManager;
+ }
+ */
// Audio
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
index 878528f7c7..fba082e80d 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
@@ -57,7 +57,7 @@ public class GodotDownloaderService extends DownloaderService {
Log.d("GODOT", "getting public key:" + prefs.getString("store_public_key", null));
return prefs.getString("store_public_key", null);
-// return BASE64_PUBLIC_KEY;
+ //return BASE64_PUBLIC_KEY;
}
/**
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index db67144bcc..4cfe295835 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -265,7 +265,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
if (keyCode == KeyEvent.KEYCODE_BACK) {
GodotLib.quit();
// press 'back' button should not terminate program
- // normal handle 'back' event in game logic
+ //normal handle 'back' event in game logic
return true;
}
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index 80cded6fb5..3c8207fae1 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -49,7 +49,6 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
// ===========================================================
private final GodotView mView;
private final GodotEditText mEdit;
- private String mText;
private String mOriginText;
// ===========================================================
@@ -81,52 +80,28 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
@Override
public void afterTextChanged(final Editable s) {
- if (this.isFullScreenEdit()) {
- return;
- }
- //if (BuildConfig.DEBUG) {
- //Log.d(TAG, "afterTextChanged: " + s);
- //}
- int nModified = s.length() - this.mText.length();
- if (nModified > 0) {
- final String insertText = s.subSequence(this.mText.length(), s.length()).toString();
- for(int i = 0; i < insertText.length(); i++) {
- int ch = insertText.codePointAt(i);
- GodotLib.key(0, ch, true);
- GodotLib.key(0, ch, false);
- }
- /*
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "insertText(" + insertText + ")");
- }
- */
- } else {
- for (; nModified < 0; ++nModified) {
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
- GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
- /*
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "deleteBackward");
- }
- */
- }
- }
- this.mText = s.toString();
}
@Override
public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) {
- /*
- if (BuildConfig.DEBUG) {
- Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after);
+ //Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after);
+
+ for (int i=0;i<count;i++){
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true);
+ GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false);
}
- */
- this.mText = pCharSequence.toString();
}
@Override
public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) {
+ //Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before);
+
+ for (int i=start;i<start+count;i++){
+ int ch = pCharSequence.charAt(i);
+ GodotLib.key(0, ch, true);
+ GodotLib.key(0, ch, false);
+ }
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
index 13a24994f8..67293df2a8 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
@@ -47,19 +47,19 @@ abstract public class ConsumeTask {
public void consume(final String sku){
-// Log.d("XXX", "Consuming product " + sku);
+ //Log.d("XXX", "Consuming product " + sku);
PaymentsCache pc = new PaymentsCache(context);
Boolean isBlocked = pc.getConsumableFlag("block", sku);
String _token = pc.getConsumableValue("token", sku);
-// Log.d("XXX", "token " + _token);
+ //Log.d("XXX", "token " + _token);
if(!isBlocked && _token == null){
-// _token = "inapp:"+context.getPackageName()+":android.test.purchased";
-// Log.d("XXX", "Consuming product " + sku + " with token " + _token);
+ //_token = "inapp:"+context.getPackageName()+":android.test.purchased";
+ //Log.d("XXX", "Consuming product " + sku + " with token " + _token);
}else if(!isBlocked){
-// Log.d("XXX", "It is not blocked ¿?");
+ //Log.d("XXX", "It is not blocked ¿?");
return;
}else if(_token == null){
-// Log.d("XXX", "No token available");
+ //Log.d("XXX", "No token available");
this.error("No token for sku:" + sku);
return;
}
@@ -69,9 +69,9 @@ abstract public class ConsumeTask {
@Override
protected String doInBackground(String... params) {
try {
-// Log.d("XXX", "Requesting to release item.");
+ //Log.d("XXX", "Requesting to release item.");
int response = mService.consumePurchase(3, context.getPackageName(), token);
-// Log.d("XXX", "release response code: " + response);
+ //Log.d("XXX", "release response code: " + response);
if(response == 0 || response == 8){
return null;
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
index 20feaef581..dfa363ed75 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
@@ -60,9 +60,9 @@ abstract public class GenericConsumeTask extends AsyncTask<String, String, Strin
@Override
protected String doInBackground(String... params) {
try {
-// Log.d("godot", "Requesting to consume an item with token ." + token);
+ //Log.d("godot", "Requesting to consume an item with token ." + token);
int response = mService.consumePurchase(3, context.getPackageName(), token);
-// Log.d("godot", "consumePurchase response: " + response);
+ //Log.d("godot", "consumePurchase response: " + response);
if(response == 0 || response == 8){
return null;
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
index 1aa210265d..3850453a77 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
@@ -56,29 +56,29 @@ abstract public class HandlePurchaseTask {
public void handlePurchaseRequest(int resultCode, Intent data){
-// Log.d("XXX", "Handling purchase response");
-// int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
+ //Log.d("XXX", "Handling purchase response");
+ //int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
PaymentsCache pc = new PaymentsCache(context);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
-// Log.d("XXX", "Purchase data:" + purchaseData);
+ //Log.d("XXX", "Purchase data:" + purchaseData);
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
//Log.d("XXX", "Purchase signature:" + dataSignature);
if (resultCode == Activity.RESULT_OK) {
try {
-// Log.d("SARLANGA", purchaseData);
+ //Log.d("SARLANGA", purchaseData);
JSONObject jo = new JSONObject(purchaseData);
-// String sku = jo.getString("productId");
-// alert("You have bought the " + sku + ". Excellent choice, aventurer!");
-// String orderId = jo.getString("orderId");
-// String packageName = jo.getString("packageName");
+ //String sku = jo.getString("productId");
+ //alert("You have bought the " + sku + ". Excellent choice, aventurer!");
+ //String orderId = jo.getString("orderId");
+ //String packageName = jo.getString("packageName");
String productId = jo.getString("productId");
-// Long purchaseTime = jo.getLong("purchaseTime");
-// Integer state = jo.getInt("purchaseState");
+ //Long purchaseTime = jo.getLong("purchaseTime");
+ //Integer state = jo.getInt("purchaseState");
String developerPayload = jo.getString("developerPayload");
String purchaseToken = jo.getString("purchaseToken");
@@ -86,7 +86,7 @@ abstract public class HandlePurchaseTask {
error("Untrusted callback");
return;
}
-// Log.d("XXX", "Este es el product ID:" + productId);
+ //Log.d("XXX", "Este es el product ID:" + productId);
pc.setConsumableValue("ticket_signautre", productId, dataSignature);
pc.setConsumableValue("ticket", productId, purchaseData);
pc.setConsumableFlag("block", productId, true);
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
index 88fd1a0fe4..4678dae1b3 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
@@ -59,14 +59,14 @@ public class PaymentsCache {
SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(sku, value);
-// Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
+ //Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
editor.commit();
}
public String getConsumableValue(String set, String sku){
SharedPreferences sharedPref = context.getSharedPreferences(
"consumables_" + set, Context.MODE_PRIVATE);
-// Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
+ //Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
return sharedPref.getString(sku, null);
}
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
index d154ef0c78..5ad96b35ee 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
@@ -63,18 +63,20 @@ abstract public class PurchaseTask {
Log.d("XXX", "Starting purchase for: " + sku);
PaymentsCache pc = new PaymentsCache(context);
Boolean isBlocked = pc.getConsumableFlag("block", sku);
-// if(isBlocked){
-// Log.d("XXX", "Is awaiting payment confirmation");
-// error("Awaiting payment confirmation");
-// return;
-// }
+ /*
+ if(isBlocked){
+ Log.d("XXX", "Is awaiting payment confirmation");
+ error("Awaiting payment confirmation");
+ return;
+ }
+ */
final String hash = transactionId;
Bundle buyIntentBundle;
try {
buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash );
} catch (RemoteException e) {
-// Log.d("XXX", "Error: " + e.getMessage());
+ //Log.d("XXX", "Error: " + e.getMessage());
error(e.getMessage());
return;
}
@@ -87,7 +89,7 @@ abstract public class PurchaseTask {
}else if( rc instanceof Long){
responseCode = (int)((Long)rc).longValue();
}
-// Log.d("XXX", "Buy intent response code: " + responseCode);
+ //Log.d("XXX", "Buy intent response code: " + responseCode);
if(responseCode == 1 || responseCode == 3 || responseCode == 4){
canceled();
return;
@@ -102,12 +104,12 @@ abstract public class PurchaseTask {
pc.setConsumableValue("validation_hash", sku, hash);
try {
if(context == null){
-// Log.d("XXX", "No context!");
+ //Log.d("XXX", "No context!");
}
if(pendingIntent == null){
-// Log.d("XXX", "No pending intent");
+ //Log.d("XXX", "No pending intent");
}
-// Log.d("XXX", "Starting activity for purchase!");
+ //Log.d("XXX", "Starting activity for purchase!");
context.startIntentSenderForResult(
pendingIntent.getIntentSender(),
PaymentsManager.REQUEST_CODE_FOR_PURCHASE,
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
index c74269890d..60a43a9070 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
@@ -56,13 +56,13 @@ abstract public class ReleaseAllConsumablesTask {
public void consumeItAll(){
try{
-// Log.d("godot", "consumeItall for " + context.getPackageName());
+ //Log.d("godot", "consumeItall for " + context.getPackageName());
Bundle bundle = mService.getPurchases(3, context.getPackageName(), "inapp",null);
for (String key : bundle.keySet()) {
- Object value = bundle.get(key);
-// Log.d("godot", String.format("%s %s (%s)", key,
-// value.toString(), value.getClass().getName()));
+ Object value = bundle.get(key);
+ //Log.d("godot", String.format("%s %s (%s)", key,
+ //value.toString(), value.getClass().getName()));
}
@@ -73,13 +73,13 @@ abstract public class ReleaseAllConsumablesTask {
if (myPurchases == null || myPurchases.size() == 0){
-// Log.d("godot", "No purchases!");
+ //Log.d("godot", "No purchases!");
notRequired();
return;
}
-// Log.d("godot", "# products to be consumed:" + myPurchases.size());
+ //Log.d("godot", "# products to be consumed:" + myPurchases.size());
for (int i=0;i<myPurchases.size();i++)
{
@@ -89,7 +89,7 @@ abstract public class ReleaseAllConsumablesTask {
String sku = inappPurchaseData.getString("productId");
String token = inappPurchaseData.getString("purchaseToken");
String signature = mySignatures.get(i);
-// Log.d("godot", "A punto de consumir un item con token:" + token + "\n" + receipt);
+ //Log.d("godot", "A punto de consumir un item con token:" + token + "\n" + receipt);
new GenericConsumeTask(context, mService, sku, receipt,signature, token) {
@Override
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
index dafab13ad7..f09bcbf9a4 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
@@ -79,14 +79,14 @@ abstract public class ValidateTask {
param.put("ticket", pc.getConsumableValue("ticket", sku));
param.put("purchaseToken", pc.getConsumableValue("token", sku));
param.put("sku", sku);
-// Log.d("XXX", "Haciendo request a " + url);
-// Log.d("XXX", "ticket: " + pc.getConsumableValue("ticket", sku));
-// Log.d("XXX", "purchaseToken: " + pc.getConsumableValue("token", sku));
-// Log.d("XXX", "sku: " + sku);
+ //Log.d("XXX", "Haciendo request a " + url);
+ //Log.d("XXX", "ticket: " + pc.getConsumableValue("ticket", sku));
+ //Log.d("XXX", "purchaseToken: " + pc.getConsumableValue("token", sku));
+ //Log.d("XXX", "sku: " + sku);
param.put("package", context.getApplicationContext().getPackageName());
HttpRequester requester = new HttpRequester();
String jsonResponse = requester.post(param);
-// Log.d("XXX", "Validation response:\n"+jsonResponse);
+ //Log.d("XXX", "Validation response:\n"+jsonResponse);
return jsonResponse;
}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
index 9dd08a9563..faefbbd2c6 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
@@ -78,12 +78,12 @@ public class HttpRequester {
private long cttl=0;
public HttpRequester(){
-// Log.d("XXX", "Creando http request sin contexto");
+ //Log.d("XXX", "Creando http request sin contexto");
}
public HttpRequester(Context context){
this.context=context;
-// Log.d("XXX", "Creando http request con contexto");
+ //Log.d("XXX", "Creando http request con contexto");
}
public String post(RequestParams params){
@@ -99,7 +99,7 @@ public class HttpRequester {
public String get(RequestParams params){
String response = getResponseFromCache(params.getUrl());
if(response == null){
-// Log.d("XXX", "Cache miss!");
+ //Log.d("XXX", "Cache miss!");
HttpGet httpget = new HttpGet(params.getUrl());
long timeInit = new Date().getTime();
response = request(httpget);
@@ -117,7 +117,7 @@ public class HttpRequester {
}
private String request(HttpUriRequest request){
-// Log.d("XXX", "Haciendo request a: " + request.getURI() );
+ //Log.d("XXX", "Haciendo request a: " + request.getURI() );
Log.d("PPP", "Haciendo request a: " + request.getURI() );
long init = new Date().getTime();
HttpClient httpclient = getNewHttpClient();
@@ -128,10 +128,10 @@ public class HttpRequester {
try {
HttpResponse response = httpclient.execute(request);
Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI() );
-// Log.d("XXX1", "Status:" + response.getStatusLine().toString());
+ //Log.d("XXX1", "Status:" + response.getStatusLine().toString());
if(response.getStatusLine().getStatusCode() == 200){
String strResponse = EntityUtils.toString(response.getEntity());
-// Log.d("XXX2", strResponse);
+ //Log.d("XXX2", strResponse);
return strResponse;
}else{
Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity()));
@@ -192,7 +192,7 @@ public class HttpRequester {
public void saveResponseIntoCache(String request, String response){
if(context == null){
-// Log.d("XXX", "No context, cache failed!");
+ //Log.d("XXX", "No context, cache failed!");
return;
}
SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE);
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 296ac0a831..2923ef6a91 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -562,7 +562,7 @@ JavaObject::~JavaObject(){
void JavaClassWrapper::_bind_methods() {
- ClassDB::bind_method(_MD("wrap:JavaClass","name"),&JavaClassWrapper::wrap);
+ ClassDB::bind_method(D_METHOD("wrap:JavaClass","name"),&JavaClassWrapper::wrap);
}
@@ -1240,7 +1240,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String& p_class) {
//args[i] = _jobject_to_variant(env, obj);
-// print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type()));
+ //print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type()));
};
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index a691e60575..41558cf86a 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -36,7 +36,7 @@
#include "file_access_android.h"
#include "dir_access_jandroid.h"
#include "audio_driver_jandroid.h"
-#include "globals.h"
+#include "global_config.h"
#include "thread_jandroid.h"
#include "core/os/keyboard.h"
#include "java_class_wrapper.h"
@@ -802,7 +802,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e
env->GetJavaVM(&jvm);
_godot_instance=env->NewGlobalRef(activity);
-// _godot_instance=activity;
+ //_godot_instance=activity;
__android_log_print(ANDROID_LOG_INFO,"godot","***************** HELLO FROM JNI!!!!!!!!");
@@ -879,7 +879,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e
if (!rawString) {
__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is null\n",i);
} else {
- // __android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
+ //__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
if (strcmp(rawString,"-main_pack")==0)
use_apk_expansion=true;
@@ -1151,8 +1151,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv * env, j
pointer_events.push_back(jpe);
input_mutex->unlock();
- //if (os_android)
-// os_android->process_touch(ev,pointer,points);
+ /*
+ if (os_android)
+ os_android->process_touch(ev,pointer,points);
+ */
}
@@ -1753,7 +1755,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
args[i] = _jobject_to_variant(env, obj);
env->DeleteLocalRef(obj);
-// print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type()));
+ //print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type()));
};
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 55fe3f21a0..2290571735 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -27,19 +27,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_android.h"
-#include "drivers/gles2/rasterizer_gles2.h"
+#include "drivers/gles2/rasterizer_gles2.h"
#include "core/io/file_access_buffered_fa.h"
#include "drivers/unix/file_access_unix.h"
#include "drivers/unix/dir_access_unix.h"
-
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
-
#include "file_access_android.h"
-
-#include "core/globals.h"
+#include "core/global_config.h"
#ifdef ANDROID_NATIVE_ACTIVITY
#include "file_access_android.h"
@@ -129,7 +126,7 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
if (gfx_init_func)
gfx_init_func(gfx_init_ud,use_gl2);
- AudioDriverManagerSW::add_driver(&audio_driver_android);
+ AudioDriverManager::add_driver(&audio_driver_android);
RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
@@ -147,26 +144,13 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
visual_server->init();
visual_server->cursor_set_visible(false, 0);
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
ERR_PRINT("Initializing audio failed.");
}
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
-
- audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true);
- audio_server->init();
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
-
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
- //
physics_server = memnew( PhysicsServerSW );
physics_server->init();
//physics_2d_server = memnew( Physics2DServerSW );
@@ -399,7 +383,7 @@ void OS_Android::process_event(InputEvent p_event) {
void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) {
-// print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
+ //print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
switch(p_what) {
case 0: { //gesture begin
@@ -482,8 +466,8 @@ void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>&
ev.mouse_motion.x=p_points[0].pos.x;
ev.mouse_motion.y=p_points[0].pos.y;
input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
- ev.mouse_motion.speed_x=input->get_mouse_speed().x;
- ev.mouse_motion.speed_y=input->get_mouse_speed().y;
+ ev.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ ev.mouse_motion.speed_y=input->get_last_mouse_speed().y;
ev.mouse_motion.relative_x=p_points[0].pos.x-last_mouse.x;
ev.mouse_motion.relative_y=p_points[0].pos.y-last_mouse.y;
last_mouse=p_points[0].pos;
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 9ed7ba5fac..bf1db57ba5 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -33,31 +33,20 @@
#include "drivers/unix/os_unix.h"
#include "os/main_loop.h"
#include "servers/physics/physics_server_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
#include "main/input_default.h"
-
-//#ifdef USE_JAVA_FILE_ACCESS
-
+#include "audio_driver_jandroid.h"
+#include "audio_driver_opensl.h"
#ifdef ANDROID_NATIVE_ACTIVITY
-
#include <android/sensor.h>
#include <android/log.h>
#include <android_native_app_glue.h>
-
-#else
-
-
#endif
-#include "audio_driver_jandroid.h"
-#include "audio_driver_opensl.h"
-
typedef void (*GFXInitFunc)(void *ud,bool gl2);
typedef int (*OpenURIFunc)(const String&);
typedef String (*GetDataDirFunc)();
@@ -118,10 +107,6 @@ private:
Rasterizer *rasterizer;
VisualServer *visual_server;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp
index 7b5c0800a8..b6ea0bc267 100644
--- a/platform/bb10/audio_driver_bb10.cpp
+++ b/platform/bb10/audio_driver_bb10.cpp
@@ -44,7 +44,7 @@ Error AudioDriverBB10::init(const char* p_name) {
samples_out = NULL;
mix_rate = 44100;
- output_format = OUTPUT_STEREO;
+ speaker_mode = SPEAKER_MODE_STEREO;
char* dev_name;
if (p_name == NULL) {
@@ -70,7 +70,7 @@ Error AudioDriverBB10::init(const char* p_name) {
ERR_FAIL_COND_V(!(cinfo.formats & SND_PCM_FMT_S16_LE), FAILED);
printf("voices %i\n", cinfo.max_voices);
- output_format = cinfo.max_voices >= 2 ? OUTPUT_STEREO : OUTPUT_MONO;
+ speaker_mode = SPEAKER_MODE_STEREO;
snd_pcm_channel_params_t cp;
zeromem(&cp, sizeof(cp));
@@ -84,7 +84,7 @@ Error AudioDriverBB10::init(const char* p_name) {
cp.buf.block.frags_min = 1;
cp.format.interleave = 1;
cp.format.rate = mix_rate;
- cp.format.voices = output_format == OUTPUT_MONO ? 1 : 2;
+ cp.format.voices = speaker_mode;
cp.format.format = SND_PCM_SFMT_S16_LE;
ret = snd_pcm_plugin_params(pcm_handle, &cp);
@@ -121,7 +121,7 @@ void AudioDriverBB10::thread_func(void* p_udata) {
AudioDriverBB10* ad = (AudioDriverBB10*)p_udata;
- int channels = (ad->output_format == OUTPUT_MONO ? 1 : 2);
+ int channels = speaker_mode;
int frame_count = ad->sample_buf_count / channels;
int bytes_out = frame_count * channels * 2;
@@ -204,16 +204,18 @@ int AudioDriverBB10::get_mix_rate() const {
return mix_rate;
};
-AudioDriverSW::OutputFormat AudioDriverBB10::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverBB10::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
};
+
void AudioDriverBB10::lock() {
if (!thread)
return;
mutex->lock();
};
+
void AudioDriverBB10::unlock() {
if (!thread)
diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h
index 738bcf2619..efb98b1b91 100644
--- a/platform/bb10/audio_driver_bb10.h
+++ b/platform/bb10/audio_driver_bb10.h
@@ -26,14 +26,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "core/os/thread.h"
#include "core/os/mutex.h"
#include <sys/asoundlib.h>
-class AudioDriverBB10 : public AudioDriverSW {
+class AudioDriverBB10 : public AudioDriver {
Thread* thread;
Mutex* mutex;
@@ -47,7 +47,7 @@ class AudioDriverBB10 : public AudioDriverSW {
static void thread_func(void* p_udata);
int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
int pcm_frag_size;
int pcm_max_frags;
@@ -67,7 +67,7 @@ public:
virtual Error init(const char* p_name);
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/bb10/bbutil.c b/platform/bb10/bbutil.c
index fce52c5b81..ab3dcf69b2 100644
--- a/platform/bb10/bbutil.c
+++ b/platform/bb10/bbutil.c
@@ -426,7 +426,7 @@ get_window_group_id()
int bbutil_rotate_screen_surface(int angle) {
- int rc, rotation, skip = 1, temp;;
+ int rc, rotation, skip = 1, temp;
EGLint interval = 1;
int size[2];
diff --git a/platform/bb10/bbutil.h b/platform/bb10/bbutil.h
index c2a4c5a7f5..77f4402fbd 100644
--- a/platform/bb10/bbutil.h
+++ b/platform/bb10/bbutil.h
@@ -13,7 +13,11 @@ extern "C" {
extern EGLDisplay egl_disp;
extern EGLSurface egl_surf;
-enum RENDERING_API {GL_ES_1 = EGL_OPENGL_ES_BIT, GL_ES_2 = EGL_OPENGL_ES2_BIT, VG = EGL_OPENVG_BIT};
+enum RENDERING_API {
+ GL_ES_1 = EGL_OPENGL_ES_BIT,
+ GL_ES_2 = EGL_OPENGL_ES2_BIT,
+ VG = EGL_OPENVG_BIT
+};
/**
* Initializes EGL, GL and loads a default font
diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp
index cc994c8f24..2643c96576 100644
--- a/platform/bb10/export/export.cpp
+++ b/platform/bb10/export/export.cpp
@@ -29,18 +29,18 @@
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/bb10/logo.h"
#include "io/xml_parser.h"
#define MAX_DEVICES 5
-
+#if 0
class EditorExportPlatformBB10 : public EditorExportPlatform {
GDCLASS( EditorExportPlatformBB10,EditorExportPlatform );
@@ -803,9 +803,9 @@ EditorExportPlatformBB10::~EditorExportPlatformBB10() {
memdelete(device_thread);
}
-
+#endif
void register_bb10_exporter() {
-
+#if 0
EDITOR_DEF("export/blackberry/host_tools","");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"export/blackberry/host_tools",PROPERTY_HINT_GLOBAL_DIR));
EDITOR_DEF("export/blackberry/debug_token","");
@@ -824,6 +824,7 @@ void register_bb10_exporter() {
Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>( memnew(EditorExportPlatformBB10) );
EditorImportExport::get_singleton()->add_export_platform(exporter);
-
+#endif
}
+
diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp
index ed40355eb5..728707628b 100644
--- a/platform/bb10/os_bb10.cpp
+++ b/platform/bb10/os_bb10.cpp
@@ -31,22 +31,21 @@
#include "drivers/gles2/rasterizer_gles2.h"
#include "servers/visual/visual_server_raster.h"
#include "core/os/dir_access.h"
-
-#include "core/globals.h"
+#include "core/global_config.h"
#include "main/main.h"
#include "bbutil.h"
+#include "core/os/keyboard.h"
+
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
-#include "core/os/keyboard.h"
-
-#include "bps/bps.h"
-#include "bps/screen.h"
-#include "bps/navigator.h"
-#include "bps/accelerometer.h"
-#include "bps/orientation.h"
-#include "bps/virtualkeyboard.h"
-#include "bps/audiodevice.h"
+#include <bps/bps.h>
+#include <bps/screen.h>
+#include <bps/navigator.h>
+#include <bps/accelerometer.h>
+#include <bps/orientation.h>
+#include <bps/virtualkeyboard.h>
+#include <bps/audiodevice.h>
#ifdef BB10_SCORELOOP_ENABLED
#include "modules/scoreloop/scoreloop_bb10.h"
@@ -141,18 +140,6 @@ void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
audio_driver->set_singleton();
audio_driver->init(NULL);
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
- audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false);
- audio_server->init();
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
-
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
- //
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
@@ -185,19 +172,11 @@ void OSBB10::finalize() {
memdelete(main_loop);
main_loop=NULL;
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
-
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
visual_server->finish();
memdelete(visual_server);
@@ -376,8 +355,8 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x;
ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y;
input->set_mouse_pos(Point2(ievent.mouse_motion.x,ievent.mouse_motion.y));
- ievent.mouse_motion.speed_x=input->get_mouse_speed().x;
- ievent.mouse_motion.speed_y=input->get_mouse_speed().y;
+ ievent.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ ievent.mouse_motion.speed_y=input->get_last_mouse_speed().y;
ievent.mouse_motion.relative_x = mrel.x;
ievent.mouse_motion.relative_y = mrel.y;
ievent.mouse_motion.button_mask = 1; // pressed
diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h
index 8011550987..9cf2091d49 100644
--- a/platform/bb10/os_bb10.h
+++ b/platform/bb10/os_bb10.h
@@ -34,9 +34,7 @@
#include "os/main_loop.h"
#include "main/input_default.h"
#include "servers/physics/physics_server_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/visual/rasterizer.h"
#include "audio_driver_bb10.h"
@@ -44,8 +42,7 @@
#include <screen/screen.h>
#include <sys/platform.h>
-#include "bps/event.h"
-
+#include <bps/event.h>
#include <stdint.h>
class OSBB10 : public OS_Unix {
@@ -58,11 +55,6 @@ class OSBB10 : public OS_Unix {
Rasterizer *rasterizer;
VisualServer *visual_server;
-// AudioDriverPSP audio_driver_psp;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
AudioDriverBB10* audio_driver;
diff --git a/platform/bb10/payment_service.cpp b/platform/bb10/payment_service.cpp
index 3138dc2c1d..131c9712a5 100644
--- a/platform/bb10/payment_service.cpp
+++ b/platform/bb10/payment_service.cpp
@@ -38,11 +38,11 @@ extern char* launch_dir_ptr;
void PaymentService::_bind_methods() {
- ClassDB::bind_method(_MD("request_product_info"),&PaymentService::request_product_info);
- ClassDB::bind_method(_MD("purchase"),&PaymentService::purchase);
+ ClassDB::bind_method(D_METHOD("request_product_info"),&PaymentService::request_product_info);
+ ClassDB::bind_method(D_METHOD("purchase"),&PaymentService::purchase);
- ClassDB::bind_method(_MD("get_pending_event_count"),&PaymentService::get_pending_event_count);
- ClassDB::bind_method(_MD("pop_pending_event"),&PaymentService::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"),&PaymentService::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"),&PaymentService::pop_pending_event);
};
Error PaymentService::request_product_info(Variant p_params) {
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
index 2af93061f8..bd485214c8 100644
--- a/platform/haiku/audio_driver_media_kit.cpp
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -30,7 +30,7 @@
#ifdef MEDIA_KIT_ENABLED
-#include "globals.h"
+#include "global_config.h"
int32_t* AudioDriverMediaKit::samples_in = NULL;
@@ -38,7 +38,7 @@ Error AudioDriverMediaKit::init() {
active = false;
mix_rate = 44100;
- output_format = OUTPUT_STEREO;
+ speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
@@ -99,8 +99,8 @@ int AudioDriverMediaKit::get_mix_rate() const {
return mix_rate;
}
-AudioDriverSW::OutputFormat AudioDriverMediaKit::get_output_format() const {
- return output_format;
+AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const {
+ return speaker_mode;
}
void AudioDriverMediaKit::lock() {
diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h
index fbf6bc20de..ce760f8dd7 100644
--- a/platform/haiku/audio_driver_media_kit.h
+++ b/platform/haiku/audio_driver_media_kit.h
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#ifdef MEDIA_KIT_ENABLED
@@ -36,7 +36,7 @@
#include <kernel/image.h> // needed for image_id
#include <SoundPlayer.h>
-class AudioDriverMediaKit : public AudioDriverSW {
+class AudioDriverMediaKit : public AudioDriver {
Mutex* mutex;
BSoundPlayer* player;
@@ -45,7 +45,7 @@ class AudioDriverMediaKit : public AudioDriverSW {
static void PlayBuffer(void* cookie, void* buffer, size_t size, const media_raw_audio_format& format);
unsigned int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
unsigned int buffer_size;
int channels;
@@ -60,7 +60,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index 1def361367..e7ff65e3ba 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -145,10 +145,12 @@ void HaikuDirectWindow::HandleMouseButton(BMessage* message) {
last_buttons_state = buttons;
// TODO: implement the mouse_mode checks
- //if (mouse_mode == MOUSE_MODE_CAPTURED) {
- // event.xbutton.x=last_mouse_pos.x;
- // event.xbutton.y=last_mouse_pos.y;
- //}
+ /*
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ event.xbutton.x=last_mouse_pos.x;
+ event.xbutton.y=last_mouse_pos.y;
+ }
+ */
InputEvent mouse_event;
mouse_event.ID = ++event_id;
@@ -219,8 +221,8 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage* message) {
input->set_mouse_pos(pos);
motion_event.mouse_motion.global_x = pos.x;
motion_event.mouse_motion.global_y = pos.y;
- motion_event.mouse_motion.speed_x = input->get_mouse_speed().x;
- motion_event.mouse_motion.speed_y = input->get_mouse_speed().y;
+ motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x;
+ motion_event.mouse_motion.speed_y = input->get_last_mouse_speed().y;
motion_event.mouse_motion.relative_x = rel.x;
motion_event.mouse_motion.relative_y = rel.y;
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index 10e1b055be..9f218aeff4 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -40,7 +40,7 @@
OS_Haiku::OS_Haiku() {
#ifdef MEDIA_KIT_ENABLED
- AudioDriverManagerSW::add_driver(&driver_media_kit);
+ AudioDriverManager::add_driver(&driver_media_kit);
#endif
};
@@ -119,9 +119,11 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
ERR_FAIL_COND(!visual_server);
// TODO: enable multithreaded VS
- //if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
- // visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
- //}
+ /*
+ if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
+ visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
+ }
+ */
input = memnew(InputDefault);
window->SetInput(input);
@@ -136,20 +138,11 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
//physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) {
ERR_PRINT("Initializing audio failed.");
}
-
- sample_manager = memnew(SampleManagerMallocSW);
- audio_server = memnew(AudioServerSW(sample_manager));
- audio_server->init();
-
- spatial_sound_server = memnew(SpatialSoundServerSW);
- spatial_sound_server->init();
- spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
- spatial_sound_2d_server->init();
}
void OS_Haiku::finalize() {
@@ -159,17 +152,6 @@ void OS_Haiku::finalize() {
main_loop = NULL;
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
-
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
-
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index fc873f49ad..531c7a56c3 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -34,12 +34,8 @@
#include "servers/visual/rasterizer.h"
#include "servers/physics_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "main/input_default.h"
-
#include "audio_driver_media_kit.h"
#include "context_gl_haiku.h"
#include "haiku_application.h"
@@ -57,10 +53,6 @@ private:
VideoMode current_video_mode;
PhysicsServer* physics_server;
Physics2DServer* physics_2d_server;
- AudioServerSW* audio_server;
- SampleManagerMallocSW* sample_manager;
- SpatialSoundServerSW* spatial_sound_server;
- SpatialSound2DServerSW* spatial_sound_2d_server;
#ifdef MEDIA_KIT_ENABLED
AudioDriverMediaKit driver_media_kit;
diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h
index 09c401b329..1b2ca42ab6 100644
--- a/platform/iphone/app_delegate.h
+++ b/platform/iphone/app_delegate.h
@@ -30,11 +30,11 @@
#import "gl_view.h"
#import "view_controller.h"
-@interface AppDelegate : NSObject <UIApplicationDelegate, UIAccelerometerDelegate, GLViewDelegate> {
+#import <CoreMotion/CoreMotion.h>
+
+@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
//@property (strong, nonatomic) UIWindow *window;
ViewController* view_controller;
- UIAccelerationValue accel[3];
- UIAccelerationValue last_accel[3];
};
@property (strong, nonatomic) UIWindow *window;
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index feb87e742f..1c47801b8e 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -30,7 +30,7 @@
#import "gl_view.h"
#include "os_iphone.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "main/main.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
@@ -84,6 +84,9 @@ extern char** gargv;
extern int iphone_main(int, int, int, char**);
extern void iphone_finish();
+CMMotionManager *motionManager;
+bool motionInitialised;
+
static ViewController* mainViewController = nil;
+ (ViewController*) getViewController
{
@@ -193,9 +196,58 @@ static int frame_count = 0;
}; break; // no fallthrough
default: {
-
if (OSIPhone::get_singleton()) {
- OSIPhone::get_singleton()->update_accelerometer(accel[0], accel[1], accel[2]);
+// OSIPhone::get_singleton()->update_accelerometer(accel[0], accel[1], accel[2]);
+ if (motionInitialised) {
+ // Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
+ // See Apple reference pages for more details:
+ // https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
+
+ // Apple splits our accelerometer date into a gravity and user movement component. We add them back together
+ CMAcceleration gravity = motionManager.deviceMotion.gravity;
+ CMAcceleration acceleration = motionManager.deviceMotion.userAcceleration;
+
+ ///@TODO We don't seem to be getting data here, is my device broken or is this code incorrect?
+ CMMagneticField magnetic = motionManager.deviceMotion.magneticField.field;
+
+ ///@TODO we can access rotationRate as a CMRotationRate variable (processed date) or CMGyroData (raw data), have to see what works best
+ CMRotationRate rotation = motionManager.deviceMotion.rotationRate;
+
+ // Adjust for screen orientation.
+ // [[UIDevice currentDevice] orientation] changes even if we've fixed our orientation which is not
+ // a good thing when you're trying to get your user to move the screen in all directions and want consistent output
+
+ ///@TODO Using [[UIApplication sharedApplication] statusBarOrientation] is a bit of a hack. Godot obviously knows the orientation so maybe we
+ // can use that instead? (note that left and right seem swapped)
+
+ switch ([[UIApplication sharedApplication] statusBarOrientation]) {
+ case UIDeviceOrientationLandscapeLeft: {
+ OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(-(acceleration.y + gravity.y), (acceleration.x + gravity.x), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(-magnetic.y, magnetic.x, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x, rotation.z);
+ }; break;
+ case UIDeviceOrientationLandscapeRight: {
+ OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer((acceleration.y + gravity.y), -(acceleration.x + gravity.x), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(magnetic.y, -magnetic.x, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x, rotation.z);
+ }; break;
+ case UIDeviceOrientationPortraitUpsideDown: {
+ OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(-(acceleration.x + gravity.x), (acceleration.y + gravity.y), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(-magnetic.x, magnetic.y, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y, rotation.z);
+ }; break;
+ default: { // assume portrait
+ OSIPhone::get_singleton()->update_gravity(gravity.x, gravity.y, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y, rotation.z);
+ }; break;
+ };
+ }
+
bool quit_request = OSIPhone::get_singleton()->iterate();
};
@@ -232,12 +284,12 @@ static int frame_count = 0;
//glView.autoresizesSubviews = YES;
//[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];
- int backingWidth;
- int backingHeight;
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+ int backingWidth;
+ int backingHeight;
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
- iphone_main(backingWidth, backingHeight, gargc, gargv);
+ iphone_main(backingWidth, backingHeight, gargc, gargv);
view_controller = [[ViewController alloc] init];
view_controller.view = glView;
@@ -253,11 +305,14 @@ static int frame_count = 0;
[window makeKeyAndVisible];
//Configure and start accelerometer
- last_accel[0] = 0;
- last_accel[1] = 0;
- last_accel[2] = 0;
- [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / kAccelerometerFrequency)];
- [[UIAccelerometer sharedAccelerometer] setDelegate:self];
+ if (!motionInitialised) {
+ motionManager = [[CMMotionManager alloc] init];
+ if (motionManager.deviceMotionAvailable) {
+ motionManager.deviceMotionUpdateInterval = 1.0/70.0;
+ [motionManager startDeviceMotionUpdates];
+ motionInitialised = YES;
+ };
+ };
//OSIPhone::screen_width = rect.size.width - rect.origin.x;
//OSIPhone::screen_height = rect.size.height - rect.origin.y;
@@ -297,12 +352,23 @@ static int frame_count = 0;
- (void)applicationWillTerminate:(UIApplication*)application {
printf("********************* will terminate\n");
+
+ if (motionInitialised) {
+ ///@TODO is this the right place to clean this up?
+ [motionManager stopDeviceMotionUpdates];
+ [motionManager release];
+ motionManager = nil;
+ motionInitialised = NO;
+ };
+
iphone_finish();
};
- (void)applicationDidEnterBackground:(UIApplication *)application
{
printf("********************* did enter background\n");
+ ///@TODO maybe add pause motionManager? and where would we unpause it?
+
if (OS::get_singleton()->get_main_loop())
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
[view_controller.view stopAnimation];
@@ -340,13 +406,6 @@ static int frame_count = 0;
};
}
-- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration {
- //Use a basic low-pass filter to only keep the gravity in the accelerometer values
- accel[0] = acceleration.x; // * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
- accel[1] = acceleration.y; // * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);
- accel[2] = acceleration.z; // * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);
-}
-
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];
diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp
index 556576cdc3..eda3897841 100644
--- a/platform/iphone/audio_driver_iphone.cpp
+++ b/platform/iphone/audio_driver_iphone.cpp
@@ -155,8 +155,8 @@ int AudioDriverIphone::get_mix_rate() const {
return 44100;
};
-AudioDriverSW::OutputFormat AudioDriverIphone::get_output_format() const {
- return OUTPUT_STEREO;
+AudioDriver::SpeakerMode AudioDriverIphone::get_speaker_mode() const {
+ return SPEAKER_MODE_STEREO;
};
void AudioDriverIphone::lock() {
diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h
index cbcb0cffce..4c0cbfcb22 100644
--- a/platform/iphone/audio_driver_iphone.h
+++ b/platform/iphone/audio_driver_iphone.h
@@ -26,11 +26,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "servers/audio/audio_server_sw.h"
+
+#include "servers/audio_server.h"
#include <AudioUnit/AudioUnit.h>
-class AudioDriverIphone : public AudioDriverSW {
+class AudioDriverIphone : public AudioDriver {
AudioComponentInstance audio_unit;
bool active;
@@ -56,7 +57,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index b92b64e9f1..20fa45d708 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -62,13 +62,13 @@ def configure(env):
env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -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"] == "arm64"): # arm64
env["bits"] = "64"
- env['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 -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=5.1.1 -isysroot $IPHONESDK')
+ env['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 -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK')
env.Append(CPPFLAGS=['-DNEED_LONG_INT'])
env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
else: # armv7
env["arch"] = "arm"
env["bits"] = "32"
- env['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 -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=5.1.1 -MMD -MT dependencies -isysroot $IPHONESDK')
+ env['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 -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot $IPHONESDK -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK')
if (env["arch"] == "x86"):
env['IPHONEPLATFORM'] = 'iPhoneSimulator'
@@ -83,6 +83,7 @@ def configure(env):
'-framework', 'CoreAudio',
'-framework', 'CoreGraphics',
'-framework', 'CoreMedia',
+ '-framework', 'CoreMotion',
'-framework', 'Foundation',
'-framework', 'Security',
'-framework', 'UIKit',
@@ -93,7 +94,7 @@ def configure(env):
'-F$IPHONESDK',
])
elif (env["arch"] == "arm64"):
- env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1',
+ env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=7.0',
'-isysroot', '$IPHONESDK',
#'-stdlib=libc++',
'-framework', 'Foundation',
@@ -109,9 +110,10 @@ def configure(env):
'-framework', 'MediaPlayer',
'-framework', 'AVFoundation',
'-framework', 'CoreMedia',
+ '-framework', 'CoreMotion',
])
else:
- env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=5.1.1',
+ env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=7.0',
'-isysroot', '$IPHONESDK',
'-framework', 'Foundation',
'-framework', 'UIKit',
@@ -126,6 +128,7 @@ def configure(env):
'-framework', 'MediaPlayer',
'-framework', 'AVFoundation',
'-framework', 'CoreMedia',
+ '-framework', 'CoreMotion',
])
if env['game_center'] == 'yes':
diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm
index 03ee327d65..4cfa64ae4b 100644
--- a/platform/iphone/game_center.mm
+++ b/platform/iphone/game_center.mm
@@ -48,18 +48,18 @@ extern "C" {
GameCenter* GameCenter::instance = NULL;
void GameCenter::_bind_methods() {
- ClassDB::bind_method(_MD("connect"),&GameCenter::connect);
- ClassDB::bind_method(_MD("is_connected"),&GameCenter::is_connected);
-
- ClassDB::bind_method(_MD("post_score"),&GameCenter::post_score);
- ClassDB::bind_method(_MD("award_achievement"),&GameCenter::award_achievement);
- ClassDB::bind_method(_MD("reset_achievements"),&GameCenter::reset_achievements);
- ClassDB::bind_method(_MD("request_achievements"),&GameCenter::request_achievements);
- ClassDB::bind_method(_MD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions);
- ClassDB::bind_method(_MD("show_game_center"),&GameCenter::show_game_center);
-
- ClassDB::bind_method(_MD("get_pending_event_count"),&GameCenter::get_pending_event_count);
- ClassDB::bind_method(_MD("pop_pending_event"),&GameCenter::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("connect"),&GameCenter::connect);
+ ClassDB::bind_method(D_METHOD("is_connected"),&GameCenter::is_connected);
+
+ ClassDB::bind_method(D_METHOD("post_score"),&GameCenter::post_score);
+ ClassDB::bind_method(D_METHOD("award_achievement"),&GameCenter::award_achievement);
+ ClassDB::bind_method(D_METHOD("reset_achievements"),&GameCenter::reset_achievements);
+ ClassDB::bind_method(D_METHOD("request_achievements"),&GameCenter::request_achievements);
+ ClassDB::bind_method(D_METHOD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions);
+ ClassDB::bind_method(D_METHOD("show_game_center"),&GameCenter::show_game_center);
+
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"),&GameCenter::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"),&GameCenter::pop_pending_event);
};
@@ -182,11 +182,11 @@ void GameCenter::request_achievement_descriptions() {
ret["type"] = "achievement_descriptions";
if (error == nil) {
ret["result"] = "ok";
- StringArray names;
- StringArray titles;
- StringArray unachieved_descriptions;
- StringArray achieved_descriptions;
- IntArray maximum_points;
+ PoolStringArray names;
+ PoolStringArray titles;
+ PoolStringArray unachieved_descriptions;
+ PoolStringArray achieved_descriptions;
+ PoolIntArray maximum_points;
Array hidden;
Array replayable;
@@ -239,8 +239,8 @@ void GameCenter::request_achievements() {
ret["type"] = "achievements";
if (error == nil) {
ret["result"] = "ok";
- StringArray names;
- RealArray percentages;
+ PoolStringArray names;
+ PoolRealArray percentages;
for (int i=0; i<[achievements count]; i++) {
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 3df29c5178..adc76a622e 100755
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -31,7 +31,7 @@
#import <OpenGLES/EAGLDrawable.h>
#include "os_iphone.h"
#include "core/os/keyboard.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "servers/audio_server.h"
#import "gl_view.h"
@@ -274,7 +274,7 @@ static void clear_touches() {
nil];
// Create our EAGLContext, and if successful make it current and create our framebuffer.
- context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+ context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer])
{
diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp
index 76b5c9aa01..bf716c36f0 100755
--- a/platform/iphone/globals/global_defaults.cpp
+++ b/platform/iphone/globals/global_defaults.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "global_defaults.h"
-#include "globals.h"
+#include "global_config.h"
void register_iphone_global_defaults() {
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm
index de70bb7e14..a9b23baaeb 100644
--- a/platform/iphone/icloud.mm
+++ b/platform/iphone/icloud.mm
@@ -44,14 +44,14 @@ extern "C" {
ICloud* ICloud::instance = NULL;
void ICloud::_bind_methods() {
- ClassDB::bind_method(_MD("remove_key"),&ICloud::remove_key);
- ClassDB::bind_method(_MD("set_key_values"),&ICloud::set_key_values);
- ClassDB::bind_method(_MD("get_key_value"),&ICloud::get_key_value);
- ClassDB::bind_method(_MD("synchronize_key_values"),&ICloud::synchronize_key_values);
- ClassDB::bind_method(_MD("get_all_key_values"),&ICloud::get_all_key_values);
-
- ClassDB::bind_method(_MD("get_pending_event_count"),&ICloud::get_pending_event_count);
- ClassDB::bind_method(_MD("pop_pending_event"),&ICloud::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("remove_key"),&ICloud::remove_key);
+ ClassDB::bind_method(D_METHOD("set_key_values"),&ICloud::set_key_values);
+ ClassDB::bind_method(D_METHOD("get_key_value"),&ICloud::get_key_value);
+ ClassDB::bind_method(D_METHOD("synchronize_key_values"),&ICloud::synchronize_key_values);
+ ClassDB::bind_method(D_METHOD("get_all_key_values"),&ICloud::get_all_key_values);
+
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"),&ICloud::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"),&ICloud::pop_pending_event);
};
int ICloud::get_pending_event_count() {
@@ -78,12 +78,12 @@ Variant nsobject_to_variant(NSObject* object) {
return String::utf8(str != NULL ? str : "");
}
else if ([object isKindOfClass:[NSData class]]) {
- ByteArray ret;
+ PoolByteArray ret;
NSData* data = (NSData*)object;
if ([data length] > 0) {
ret.resize([data length]);
{
- ByteArray::Write w = ret.write();
+ PoolByteArray::Write w = ret.write();
copymem(w.ptr(), [data bytes], [data length]);
}
}
@@ -199,9 +199,9 @@ NSObject* variant_to_nsobject(Variant v) {
}
return result;
}
- else if (v.get_type() == Variant::RAW_ARRAY) {
- ByteArray arr = v;
- ByteArray::Read r = arr.read();
+ else if (v.get_type() == Variant::POOL_BYTE_ARRAY) {
+ PoolByteArray arr = v;
+ PoolByteArray::Read r = arr.read();
NSData* result = [NSData dataWithBytes:r.ptr() length:arr.size()];
return result;
}
@@ -333,7 +333,7 @@ ICloud::ICloud() {
Dictionary ret;
ret["type"] = "key_value_changed";
- //StringArray result_keys;
+ //PoolStringArray result_keys;
//Array result_values;
Dictionary keyValues;
String reason = "";
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index 49026ceb0a..b63d7b42ab 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -66,13 +66,13 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
InAppStore* InAppStore::instance = NULL;
void InAppStore::_bind_methods() {
- ClassDB::bind_method(_MD("request_product_info"),&InAppStore::request_product_info);
- ClassDB::bind_method(_MD("purchase"),&InAppStore::purchase);
+ ClassDB::bind_method(D_METHOD("request_product_info"),&InAppStore::request_product_info);
+ ClassDB::bind_method(D_METHOD("purchase"),&InAppStore::purchase);
- ClassDB::bind_method(_MD("get_pending_event_count"),&InAppStore::get_pending_event_count);
- ClassDB::bind_method(_MD("pop_pending_event"),&InAppStore::pop_pending_event);
- ClassDB::bind_method(_MD("finish_transaction"),&InAppStore::finish_transaction);
- ClassDB::bind_method(_MD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction);
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"),&InAppStore::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"),&InAppStore::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("finish_transaction"),&InAppStore::finish_transaction);
+ ClassDB::bind_method(D_METHOD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction);
};
@interface ProductsDelegate : NSObject<SKProductsRequestDelegate> {
@@ -89,11 +89,11 @@ void InAppStore::_bind_methods() {
Dictionary ret;
ret["type"] = "product_info";
ret["result"] = "ok";
- StringArray titles;
- StringArray descriptions;
- RealArray prices;
- StringArray ids;
- StringArray localized_prices;
+ PoolStringArray titles;
+ PoolStringArray descriptions;
+ PoolRealArray prices;
+ PoolStringArray ids;
+ PoolStringArray localized_prices;
for (int i=0; i<[products count]; i++) {
@@ -114,7 +114,7 @@ void InAppStore::_bind_methods() {
ret["ids"] = ids;
ret["localized_prices"] = localized_prices;
- StringArray invalid_ids;
+ PoolStringArray invalid_ids;
for (NSString* ipid in response.invalidProductIdentifiers) {
@@ -134,7 +134,7 @@ Error InAppStore::request_product_info(Variant p_params) {
Dictionary params = p_params;
ERR_FAIL_COND_V(!params.has("product_ids"), ERR_INVALID_PARAMETER);
- StringArray pids = params["product_ids"];
+ PoolStringArray pids = params["product_ids"];
printf("************ request product info! %i\n", pids.size());
NSMutableArray* array = [[[NSMutableArray alloc] initWithCapacity:pids.size()] autorelease];
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index a068d4aa31..4aca85dafc 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -32,7 +32,7 @@
void iOS::_bind_methods() {
- ClassDB::bind_method(_MD("get_rate_url","app_id"),&iOS::get_rate_url);
+ ClassDB::bind_method(D_METHOD("get_rate_url","app_id"),&iOS::get_rate_url);
};
String iOS::get_rate_url(int p_app_id) const {
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 1d12501aea..816e456838 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -30,11 +30,9 @@
#include "os_iphone.h"
-#include "drivers/gles2/rasterizer_gles2.h"
-
-
+#include "drivers/gles3/rasterizer_gles3.h"
#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+//#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
#include "audio_driver_iphone.h"
@@ -42,7 +40,7 @@
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/io/file_access_pack.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "sem_iphone.h"
@@ -109,16 +107,17 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical", false)?1:0) << PortraitDown);
supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical_flipped", false)?1:0) << PortraitUp);
- rasterizer_gles22 = memnew( RasterizerGLES2(false, false, false) );
- rasterizer = rasterizer_gles22;
- rasterizer_gles22->set_base_framebuffer(gl_view_base_fb);
+ RasterizerGLES3::register_config();
+ RasterizerGLES3::make_current();
+ RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
- visual_server = memnew( VisualServerRaster(rasterizer) );
+ visual_server = memnew( VisualServerRaster() );
+ /*
+ FIXME: Reimplement threaded rendering? Or remove?
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
-
visual_server = memnew(VisualServerWrapMT(visual_server, false));
};
- visual_server->init();
+ */
visual_server->init();
visual_server->cursor_set_visible(false, 0);
@@ -127,16 +126,7 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au
audio_driver->set_singleton();
audio_driver->init();
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
- audio_server->init();
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
-
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
- //
+ // init physics servers
physics_server = memnew( PhysicsServerSW );
physics_server->init();
//physics_2d_server = memnew( Physics2DServerSW );
@@ -148,28 +138,28 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au
/*
#ifdef IOS_SCORELOOP_ENABLED
scoreloop = memnew(ScoreloopIOS);
- Globals::get_singleton()->add_singleton(Globals::Singleton("Scoreloop", scoreloop));
+ GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("Scoreloop", scoreloop));
scoreloop->connect();
#endif
*/
#ifdef GAME_CENTER_ENABLED
game_center = memnew(GameCenter);
- Globals::get_singleton()->add_singleton(Globals::Singleton("GameCenter", game_center));
+ GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("GameCenter", game_center));
game_center->connect();
#endif
#ifdef STOREKIT_ENABLED
store_kit = memnew(InAppStore);
- Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", store_kit));
+ GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("InAppStore", store_kit));
#endif
#ifdef ICLOUD_ENABLED
icloud = memnew(ICloud);
- Globals::get_singleton()->add_singleton(Globals::Singleton("ICloud", icloud));
+ GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("ICloud", icloud));
//icloud->connect();
#endif
- Globals::get_singleton()->add_singleton(Globals::Singleton("iOS", memnew(iOS)));
+ GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("iOS", memnew(iOS)));
};
MainLoop *OSIPhone::get_main_loop() const {
@@ -294,8 +284,8 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
};
input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
- ev.mouse_motion.speed_x=input->get_mouse_speed().x;
- ev.mouse_motion.speed_y=input->get_mouse_speed().y;
+ ev.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ ev.mouse_motion.speed_y=input->get_last_mouse_speed().y;
ev.mouse_motion.button_mask = 1; // pressed
queue_event(ev);
@@ -323,9 +313,14 @@ void OSIPhone::touches_cancelled() {
static const float ACCEL_RANGE = 1;
+void OSIPhone::update_gravity(float p_x, float p_y, float p_z) {
+ input->set_gravity(Vector3(p_x, p_y, p_z));
+};
+
void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
- input->set_accelerometer(Vector3(p_x / (float)ACCEL_RANGE, p_y / (float)ACCEL_RANGE, -p_z / (float)ACCEL_RANGE));
+ // Found out the Z should not be negated! Pass as is!
+ input->set_accelerometer(Vector3(p_x / (float)ACCEL_RANGE, p_y / (float)ACCEL_RANGE, p_z / (float)ACCEL_RANGE));
/*
if (p_x != last_accel.x) {
@@ -364,7 +359,13 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
*/
};
+void OSIPhone::update_magnetometer(float p_x, float p_y, float p_z) {
+ input->set_magnetometer(Vector3(p_x, p_y, p_z));
+};
+void OSIPhone::update_gyroscope(float p_x, float p_y, float p_z) {
+ input->set_gyroscope(Vector3(p_x, p_y, p_z));
+};
void OSIPhone::delete_main_loop() {
@@ -383,7 +384,7 @@ void OSIPhone::finalize() {
visual_server->finish();
memdelete(visual_server);
- memdelete(rasterizer);
+// memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
@@ -391,14 +392,8 @@ void OSIPhone::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
-
memdelete(input);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
};
void OSIPhone::set_mouse_show(bool p_show) { };
@@ -445,9 +440,8 @@ bool OSIPhone::can_draw() const {
int OSIPhone::set_base_framebuffer(int p_fb) {
- if (rasterizer_gles22) {
- rasterizer_gles22->set_base_framebuffer(p_fb);
- };
+ RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
+
return 0;
};
@@ -531,7 +525,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:/", Globals::get_singleton()->get_resource_path());
+ p_path = p_path.replace("res:/", GlobalConfig::get_singleton()->get_resource_path());
}
} else if (p_path.begins_with("user://"))
p_path = p_path.replace("user:/", get_data_dir());
@@ -568,10 +562,8 @@ void OSIPhone::native_video_stop() {
OSIPhone::OSIPhone(int width, int height) {
- rasterizer_gles22 = NULL;
main_loop = NULL;
visual_server = NULL;
- rasterizer = NULL;
VideoMode vm;
vm.fullscreen = true;
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 331b20afbf..65dcc884bb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -39,10 +39,7 @@
#include "servers/physics/physics_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "main/input_default.h"
#include "game_center.h"
#include "in_app_store.h"
@@ -50,7 +47,7 @@
class AudioDriverIphone;
-class RasterizerGLES2;
+// class RasterizerGLES2;
class OSIPhone : public OS_Unix {
@@ -71,18 +68,13 @@ private:
uint8_t supported_orientations;
- Rasterizer *rasterizer;
-
- RasterizerGLES2* rasterizer_gles22;
+// Rasterizer *rasterizer;
+// RasterizerGLES2* rasterizer_gles22;
VisualServer *visual_server;
PhysicsServer* physics_server;
Physics2DServer *physics_2d_server;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
AudioDriverIphone* audio_driver;
#ifdef GAME_CENTER_ENABLED
@@ -152,7 +144,10 @@ public:
int set_base_framebuffer(int p_fb);
+ void update_gravity(float p_x, float p_y, float p_z);
void update_accelerometer(float p_x, float p_y, float p_z);
+ void update_magnetometer(float p_x, float p_y, float p_z);
+ void update_gyroscope(float p_x, float p_y, float p_z);
static OSIPhone* get_singleton();
diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h
index c8468f0152..64e9388910 100644
--- a/platform/iphone/platform_config.h
+++ b/platform/iphone/platform_config.h
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include <alloca.h>
-#define GLES2_INCLUDE_H <ES2/gl.h>
-
+// #define GLES2_INCLUDE_H <ES2/gl.h>
+#define GLES3_INCLUDE_H <ES3/gl.h>
#define PLATFORM_REFCOUNT
diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp
index ee0457cfb1..b8f3dd0d05 100644
--- a/platform/iphone/rasterizer_iphone.cpp
+++ b/platform/iphone/rasterizer_iphone.cpp
@@ -30,7 +30,7 @@
#include "rasterizer_iphone.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include <stdio.h>
_FORCE_INLINE_ static void _gl_load_transform(const Transform& tr) {
diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h
index cec367e2fa..299a11e895 100644
--- a/platform/iphone/rasterizer_iphone.h
+++ b/platform/iphone/rasterizer_iphone.h
@@ -688,7 +688,7 @@ public:
virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color);
virtual RID multimesh_get_mesh(RID p_multimesh) const;
- virtual AABB multimesh_get_aabb(RID p_multimesh) const;;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const;
virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const;
virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const;
@@ -846,7 +846,7 @@ public:
virtual void canvas_begin();
virtual void canvas_set_transparency(float p_transparency);
- virtual void canvas_set_rect(const Rect2& p_rect, bool p_clip);;
+ virtual void canvas_set_rect(const Rect2& p_rect, bool p_clip);
virtual void canvas_draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width);
virtual void canvas_draw_rect(const Rect2& p_rect, bool p_region, const Rect2& p_source,bool p_tile,RID p_texture,const Color& p_modulate);
virtual void canvas_draw_style_box(const Rect2& p_rect, RID p_texture,const float *p_margins, bool p_draw_center=true);
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index 5d5cd1590a..bd7b0c304d 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -2,6 +2,9 @@
Import('env')
+env.Tool('textfile')
+env.Tool('zip')
+
javascript_files = [
"os_javascript.cpp",
"audio_driver_javascript.cpp",
@@ -21,17 +24,26 @@ for x in javascript_files:
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""])
env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
-build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")
-
-def make_html_shell(target, source, env):
- html_path = target[0].rstr()
- assert html_path[:4] == 'bin/'
- assert html_path[-5:] == '.html'
- basename = html_path[4:-5]
- with open(html_path, 'r+') as html_file:
- fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE')
- html_file.seek(0)
- html_file.truncate()
- html_file.write(fixed_html)
-
-env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file"))
+html_file = env.Program('#bin/godot', 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)
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index 579cbaed3c..bff01d7c37 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -27,20 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_driver_javascript.h"
-#include <string.h>
-
-
-
-
+#include <string.h>
#define MAX_NUMBER_INTERFACES 3
#define MAX_NUMBER_OUTPUT_DEVICES 6
/* Structure for passing information to callback function */
-
-
//AudioDriverJavaScript* AudioDriverJavaScript::s_ad=NULL;
const char* AudioDriverJavaScript::get_name() const {
@@ -53,36 +47,45 @@ Error AudioDriverJavaScript::init(){
return OK;
}
+
void AudioDriverJavaScript::start(){
}
+
int AudioDriverJavaScript::get_mix_rate() const {
return 44100;
}
-AudioDriverSW::OutputFormat AudioDriverJavaScript::get_output_format() const{
- return OUTPUT_STEREO;
+AudioDriver::SpeakerMode AudioDriverJavaScript::get_speaker_mode() const{
+
+ return SPEAKER_MODE_STEREO;
}
+
void AudioDriverJavaScript::lock(){
- //if (active && mutex)
- // mutex->lock();
+ /*
+ if (active && mutex)
+ mutex->lock();
+ */
}
+
void AudioDriverJavaScript::unlock() {
- //if (active && mutex)
- // mutex->unlock();
+ /*
+ if (active && mutex)
+ mutex->unlock();
+ */
}
+
void AudioDriverJavaScript::finish(){
}
-
AudioDriverJavaScript::AudioDriverJavaScript()
{
}
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h
index 528b45569d..4c2064663a 100644
--- a/platform/javascript/audio_driver_javascript.h
+++ b/platform/javascript/audio_driver_javascript.h
@@ -29,21 +29,19 @@
#ifndef AUDIO_DRIVER_JAVASCRIPT_H
#define AUDIO_DRIVER_JAVASCRIPT_H
+#include "servers/audio_server.h"
-#include "servers/audio/audio_server_sw.h"
#include "os/mutex.h"
-class AudioDriverJavaScript : public AudioDriverSW {
+class AudioDriverJavaScript : public AudioDriver {
public:
- void set_singleton();
-
virtual const char* get_name() const;
virtual Error init();
virtual void start();
virtual int get_mix_rate() const ;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp
index d1fba030a5..bb238ede0c 100644
--- a/platform/javascript/audio_server_javascript.cpp
+++ b/platform/javascript/audio_server_javascript.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_server_javascript.h"
-
+#if 0
#include "emscripten.h"
AudioMixer *AudioServerJavascript::get_mixer() {
@@ -198,14 +198,15 @@ RID AudioServerJavascript::voice_create(){
voice->positional=false;
voice->active=false;
+ /* clang-format off */
EM_ASM_( {
- _as_voices[$0]=null;
- _as_voice_gain[$0]=_as_audioctx.createGain();
- _as_voice_pan[$0]=_as_audioctx.createStereoPanner();
- _as_voice_gain[$0].connect(_as_voice_pan[$0]);
- _as_voice_pan[$0].connect(_as_audioctx.destination);
-
- },voice_base);
+ _as_voices[$0] = null;
+ _as_voice_gain[$0] = _as_audioctx.createGain();
+ _as_voice_pan[$0] = _as_audioctx.createStereoPanner();
+ _as_voice_gain[$0].connect(_as_voice_pan[$0]);
+ _as_voice_pan[$0].connect(_as_audioctx.destination);
+ }, voice_base);
+ /* clang-format on */
voice_base++;
@@ -227,27 +228,29 @@ void AudioServerJavascript::voice_play(RID p_voice, RID p_sample){
//create sample if not created
ERR_FAIL_COND(sample->tmp_data.size()==0);
sample->index=sample_base;
- EM_ASM_( {
- _as_samples[$0]=_as_audioctx.createBuffer($1,$2,$3);
- },sample_base,sample->stereo?2:1,sample->length,sample->mix_rate);
+ /* clang-format off */
+ EM_ASM_({
+ _as_samples[$0] = _as_audioctx.createBuffer($1, $2, $3);
+ }, sample_base, sample->stereo ? 2 : 1, sample->length, sample->mix_rate);
+ /* clang-format on */
sample_base++;
int chans = sample->stereo?2:1;
for(int i=0;i<chans;i++) {
-
-
+ /* clang-format off */
EM_ASM_({
- _as_edited_buffer=_as_samples[$0].getChannelData($1);
- },sample->index,i);
-
+ _as_edited_buffer = _as_samples[$0].getChannelData($1);
+ }, sample->index, i);
+ /* clang-format on */
for(int j=0;j<sample->length;j++) {
-
+ /* clang-format off */
EM_ASM_({
- _as_edited_buffer[$0]=$1;
- },j,sample->tmp_data[j*chans+i]);
+ _as_edited_buffer[$0] = $1;
+ }, j, sample->tmp_data[j * chans + i]);
+ /* clang-format on */
}
}
@@ -263,26 +266,27 @@ void AudioServerJavascript::voice_play(RID p_voice, RID p_sample){
float freq_diff = Math::log(float(voice->mix_rate)/float(voice->sample_mix_rate))/Math::log(2.0);
int detune = int(freq_diff*1200.0);
- EM_ASM_( {
- if (_as_voices[$0]!==null) {
- _as_voices[$0].stop(); //stop and byebye
- }
- _as_voices[$0]=_as_audioctx.createBufferSource();
- _as_voices[$0].connect(_as_voice_gain[$0]);
- _as_voices[$0].buffer=_as_samples[$1];
- _as_voices[$0].loopStart.value=$1;
- _as_voices[$0].loopEnd.value=$2;
- _as_voices[$0].loop.value=$3;
- _as_voices[$0].detune.value=$6;
- _as_voice_pan[$0].pan.value=$4;
- _as_voice_gain[$0].gain.value=$5;
- _as_voices[$0].start();
- _as_voices[$0].onended=function() {
- _as_voices[$0].disconnect(_as_voice_gain[$0]);
- _as_voices[$0]=null;
- }
-
- },voice->index,sample->index,sample->mix_rate*sample->loop_begin,sample->mix_rate*sample->loop_end,sample->loop_format!=SAMPLE_LOOP_NONE,voice->pan,voice->volume*fx_volume_scale,detune);
+ /* clang-format off */
+ EM_ASM_({
+ if (_as_voices[$0] !== null) {
+ _as_voices[$0].stop(); //stop and byebye
+ }
+ _as_voices[$0] = _as_audioctx.createBufferSource();
+ _as_voices[$0].connect(_as_voice_gain[$0]);
+ _as_voices[$0].buffer = _as_samples[$1];
+ _as_voices[$0].loopStart.value = $1;
+ _as_voices[$0].loopEnd.value = $2;
+ _as_voices[$0].loop.value = $3;
+ _as_voices[$0].detune.value = $6;
+ _as_voice_pan[$0].pan.value = $4;
+ _as_voice_gain[$0].gain.value = $5;
+ _as_voices[$0].start();
+ _as_voices[$0].onended = function() {
+ _as_voices[$0].disconnect(_as_voice_gain[$0]);
+ _as_voices[$0] = null;
+ }
+ }, voice->index, sample->index, sample->mix_rate * sample->loop_begin, sample->mix_rate * sample->loop_end, sample->loop_format != SAMPLE_LOOP_NONE, voice->pan, voice->volume * fx_volume_scale, detune);
+ /* clang-format on */
voice->active=true;
}
@@ -295,11 +299,11 @@ void AudioServerJavascript::voice_set_volume(RID p_voice, float p_volume){
voice->volume=p_volume;
if (voice->active) {
- EM_ASM_( {
-
- _as_voice_gain[$0].gain.value=$1;
-
- },voice->index,voice->volume*fx_volume_scale);
+ /* clang-format off */
+ EM_ASM_({
+ _as_voice_gain[$0].gain.value = $1;
+ }, voice->index, voice->volume * fx_volume_scale);
+ /* clang-format on */
}
}
@@ -313,11 +317,11 @@ void AudioServerJavascript::voice_set_pan(RID p_voice, float p_pan, float p_dept
voice->pan_height=height;
if (voice->active) {
- EM_ASM_( {
-
- _as_voice_pan[$0].pan.value=$1;
-
- },voice->index,voice->pan);
+ /* clang-format off */
+ EM_ASM_({
+ _as_voice_pan[$0].pan.value = $1;
+ }, voice->index, voice->pan);
+ /* clang-format on */
}
}
void AudioServerJavascript::voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance, float p_gain){
@@ -340,11 +344,11 @@ void AudioServerJavascript::voice_set_mix_rate(RID p_voice, int p_mix_rate){
float freq_diff = Math::log(float(voice->mix_rate)/float(voice->sample_mix_rate))/Math::log(2.0);
int detune = int(freq_diff*1200.0);
- EM_ASM_( {
-
- _as_voices[$0].detune.value=$1;
-
- },voice->index,detune);
+ /* clang-format off */
+ EM_ASM_({
+ _as_voices[$0].detune.value = $1;
+ }, voice->index, detune);
+ /* clang-format on */
}
}
void AudioServerJavascript::voice_set_positional(RID p_voice, bool p_positional){
@@ -419,14 +423,15 @@ void AudioServerJavascript::voice_stop(RID p_voice){
ERR_FAIL_COND(!voice);
if (voice->active) {
-
- EM_ASM_( {
- if (_as_voices[$0]!==null) {
- _as_voices[$0].stop();
- _as_voices[$0].disconnect(_as_voice_gain[$0]);
- _as_voices[$0]=null;
- }
- },voice->index);
+ /* clang-format off */
+ EM_ASM_({
+ if (_as_voices[$0] !== null) {
+ _as_voices[$0].stop();
+ _as_voices[$0].disconnect(_as_voice_gain[$0]);
+ _as_voices[$0] = null;
+ }
+ }, voice->index);
+ /* clang-format on */
voice->active=false;
}
@@ -524,22 +529,25 @@ void AudioServerJavascript::free(RID p_id){
ERR_FAIL_COND(!voice);
if (voice->active) {
- EM_ASM_( {
- if (_as_voices[$0]!==null) {
+ /* clang-format off */
+ EM_ASM_({
+ if (_as_voices[$0] !== null) {
_as_voices[$0].stop();
- _as_voices[$0].disconnect(_as_voice_gain[$0]);
+ _as_voices[$0].disconnect(_as_voice_gain[$0]);
}
- },voice->index);
+ }, voice->index);
+ /* clang-format on */
}
- EM_ASM_( {
+ /* clang-format off */
+ EM_ASM_({
delete _as_voices[$0];
_as_voice_gain[$0].disconnect(_as_voice_pan[$0]);
delete _as_voice_gain[$0];
_as_voice_pan[$0].disconnect(_as_audioctx.destination);
delete _as_voice_pan[$0];
-
- },voice->index);
+ }, voice->index);
+ /* clang-format on */
voice_owner.free(p_id);
memdelete(voice);
@@ -549,10 +557,11 @@ void AudioServerJavascript::free(RID p_id){
Sample *sample = sample_owner.get(p_id);
ERR_FAIL_COND(!sample);
- EM_ASM_( {
+ /* clang-format off */
+ EM_ASM_({
delete _as_samples[$0];
-
- },sample->index);
+ }, sample->index);
+ /* clang-format on */
sample_owner.free(p_id);
memdelete(sample);
@@ -594,21 +603,20 @@ void AudioServerJavascript::mix_to_js(int p_frames) {
int tomix=MIN(todo,INTERNAL_BUFFER_SIZE);
driver_process_chunk(tomix);
-
+ /* clang-format off */
EM_ASM_({
-
- var data = HEAPF32.subarray($0/4, $0/4 + $2*2);
+ var data = HEAPF32.subarray($0 / 4, $0 / 4 + $2 * 2);
for (var channel = 0; channel < _as_output_buffer.numberOfChannels; channel++) {
var outputData = _as_output_buffer.getChannelData(channel);
// Loop through samples
for (var sample = 0; sample < $2; sample++) {
// make output equal to the same as the input
- outputData[sample+$1] = data[sample*2+channel];
+ outputData[sample + $1] = data[sample * 2 + channel];
}
}
-
- },internal_buffer,offset,tomix);
+ }, internal_buffer, offset, tomix);
+ /* clang-format on */
todo-=tomix;
offset+=tomix;
@@ -617,9 +625,13 @@ void AudioServerJavascript::mix_to_js(int p_frames) {
void AudioServerJavascript::init(){
- //EM_ASM(
-// console.log('server is '+audio_server);
-// );
+ /*
+ // clang-format off
+ EM_ASM(
+ console.log('server is ' + audio_server);
+ );
+ // clang-format on
+ */
//int latency = GLOBAL_DEF("javascript/audio_latency",16384);
@@ -632,19 +644,19 @@ void AudioServerJavascript::init(){
int buffer_latency=16384;
+ /* clang-format off */
EM_ASM_( {
-
_as_script_node = _as_audioctx.createScriptProcessor($0, 0, 2);
_as_script_node.connect(_as_audioctx.destination);
console.log(_as_script_node.bufferSize);
-
_as_script_node.onaudioprocess = function(audioProcessingEvent) {
// The output buffer contains the samples that will be modified and played
_as_output_buffer = audioProcessingEvent.outputBuffer;
audio_server_mix_function(_as_output_buffer.getChannelData(0).length);
}
- },buffer_latency);
+ }, buffer_latency);
+ /* clang-format on */
}
@@ -811,23 +823,28 @@ AudioServerJavascript::AudioServerJavascript() {
singleton=this;
sample_base=1;
voice_base=1;
+ /* clang-format off */
EM_ASM(
- _as_samples={};
- _as_voices={};
- _as_voice_pan={};
- _as_voice_gain={};
+ _as_samples = {};
+ _as_voices = {};
+ _as_voice_pan = {};
+ _as_voice_gain = {};
_as_audioctx = new (window.AudioContext || window.webkitAudioContext)();
audio_server_mix_function = Module.cwrap('audio_server_mix_function', 'void', ['number']);
);
+ /* clang-format on */
+ /* clang-format off */
webaudio_mix_rate = EM_ASM_INT_V(
- return _as_audioctx.sampleRate;
- );
+ return _as_audioctx.sampleRate;
+ );
+ /* clang-format on */
print_line("WEBAUDIO MIX RATE: "+itos(webaudio_mix_rate));
event_voice_scale=1.0;
fx_volume_scale=1.0;
stream_volume_scale=1.0;
}
+#endif
diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h
index 8e61e94dfc..2f48e7e79e 100644
--- a/platform/javascript/audio_server_javascript.h
+++ b/platform/javascript/audio_server_javascript.h
@@ -28,8 +28,7 @@
/*************************************************************************/
#ifndef AUDIO_SERVER_JAVASCRIPT_H
#define AUDIO_SERVER_JAVASCRIPT_H
-
-
+#if 0
#include "servers/audio_server.h"
class AudioServerJavascript : public AudioServer {
@@ -224,3 +223,4 @@ public:
};
#endif // AUDIO_SERVER_JAVASCRIPT_H
+#endif
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 2cb6874000..799b550899 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -12,11 +12,7 @@ def get_name():
def can_build():
-
- import os
- if (not os.environ.has_key("EMSCRIPTEN_ROOT")):
- return False
- return True
+ return os.environ.has_key("EMSCRIPTEN_ROOT")
def get_opts():
@@ -37,31 +33,41 @@ def get_flags():
]
+def create(env):
+ # remove Windows' .exe suffix
+ return env.Clone(PROGSUFFIX='')
+
+
+def escape_sources_backslashes(target, source, env, for_signature):
+ return [path.replace('\\','\\\\') for path in env.GetBuildPath(source)]
+
+def escape_target_backslashes(target, source, env, for_signature):
+ return env.GetBuildPath(target[0]).replace('\\','\\\\')
+
+
def configure(env):
env['ENV'] = os.environ
- env.use_windows_spawn_fix('javascript')
env.Append(CPPPATH=['#platform/javascript'])
- em_path = os.environ["EMSCRIPTEN_ROOT"]
-
- env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH']
- env['CC'] = em_path + '/emcc'
- env['CXX'] = em_path + '/emcc'
- #env['AR'] = em_path+"/emar"
- env['AR'] = em_path + "/emcc"
- env['ARFLAGS'] = "-o"
+ env.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT'])
+ env['CC'] = 'emcc'
+ env['CXX'] = 'em++'
+ env['LINK'] = 'emcc'
+ env['RANLIB'] = 'emranlib'
+ # 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
+ # need to escape backslashes for this
+ env['ESCAPED_SOURCES'] = escape_sources_backslashes
+ env['ESCAPED_TARGET'] = escape_target_backslashes
+ env['ARCOM'] = '${TEMPFILE("%s")}' % env['ARCOM'].replace('$SOURCES', '$ESCAPED_SOURCES').replace('$TARGET', '$ESCAPED_TARGET')
-# env['RANLIB'] = em_path+"/emranlib"
- env['RANLIB'] = em_path + "/emcc"
env['OBJSUFFIX'] = '.bc'
env['LIBSUFFIX'] = '.bc'
- env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
- env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
-
-# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2'])
-
-# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ")
if (env["target"] == "release"):
env.Append(CCFLAGS=['-O2'])
@@ -79,10 +85,7 @@ def configure(env):
# 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', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
- env.Append(CPPFLAGS=['-DGLES2_ENABLED'])
- env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS'])
- env.Append(CPPFLAGS=['-s', 'FULL_ES2=1'])
-# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
+ env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
if env['wasm'] == 'yes':
env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
@@ -92,7 +95,7 @@ def configure(env):
# what is set during compilation, check TOTAL_MEMORY in Emscripten's
# src/settings.js for the default.
env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
- env["PROGSUFFIX"] += ".webassembly"
+ env.extra_suffix = '.webassembly' + env.extra_suffix
else:
env.Append(CPPFLAGS=['-s', 'ASM_JS=1'])
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
@@ -102,14 +105,7 @@ def configure(env):
env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
env.Append(LINKFLAGS=['-O2'])
+ env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
# env.Append(LINKFLAGS=['-g4'])
- # print "CCCOM is:", env.subst('$CCCOM')
- # print "P: ", env['p'], " Platofrm: ", env['platform']
-
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.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index c151bff45c..2657eaddb5 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -29,15 +29,18 @@
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/javascript/logo.h"
#include "string.h"
+
+
+#if 0
class EditorExportPlatformJavaScript : public EditorExportPlatform {
GDCLASS( EditorExportPlatformJavaScript,EditorExportPlatform );
@@ -181,8 +184,8 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St
String current_line = lines[i];
current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024));
current_line = current_line.replace("$GODOT_BASE",p_name);
- current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/width"));
- current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/height"));
+ current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/window/width"));
+ current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/window/height"));
current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) GlobalConfig::get_singleton()->get("application/name"));
current_line = current_line.replace("$GODOT_HEAD_INCLUDE",html_head_include);
current_line = current_line.replace("$GODOT_STYLE_FONT_FAMILY",html_font_family);
@@ -265,7 +268,7 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool
FileAccess *f=FileAccess::open(p_path.get_base_dir()+"/data.pck",FileAccess::WRITE);
if (!f) {
- EditorNode::add_io_error("Could not create file for writing:\n"+p_path.basename()+"_files.js");
+ EditorNode::add_io_error("Could not create file for writing:\n"+p_path.get_basename()+"_files.js");
return ERR_FILE_CANT_WRITE;
}
Error err = save_pack(f);
@@ -307,32 +310,32 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool
if (file=="godot.html") {
- _fix_html(data,p_path.get_file().basename(), p_debug);
+ _fix_html(data,p_path.get_file().get_basename(), p_debug);
file=p_path.get_file();
}
if (file=="godotfs.js") {
_fix_files(data,len);
- file=p_path.get_file().basename()+"fs.js";
+ file=p_path.get_file().get_basename()+"fs.js";
}
if (file=="godot.js") {
- file=p_path.get_file().basename()+".js";
+ file=p_path.get_file().get_basename()+".js";
}
if (file=="godot.asm.js") {
- file=p_path.get_file().basename()+".asm.js";
+ file=p_path.get_file().get_basename()+".asm.js";
}
if (file=="godot.mem") {
- file=p_path.get_file().basename()+".mem";
+ file=p_path.get_file().get_basename()+".mem";
}
if (file=="godot.wasm") {
- file=p_path.get_file().basename()+".wasm";
+ file=p_path.get_file().get_basename()+".wasm";
}
String dst = p_path.get_base_dir().plus_file(file);
@@ -377,7 +380,7 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
logo->create_from_image(img);
max_memory=3;
html_title="";
- html_font_family="arial,sans-serif";
+ html_font_family="'Droid Sans',arial,sans-serif";
html_controls_enabled=true;
pack_mode=PACK_SINGLE_FILE;
}
@@ -414,13 +417,14 @@ EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
}
-
+#endif
void register_javascript_exporter() {
- Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) );
- EditorImportExport::get_singleton()->add_export_platform(exporter);
+ //Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) );
+ //EditorImportExport::get_singleton()->add_export_platform(exporter);
}
+
diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html
index 3170d2bb9e..65f3b4a340 100644
--- a/platform/javascript/godot_shell.html
+++ b/platform/javascript/godot_shell.html
@@ -3,14 +3,14 @@
<head>
<meta charset="utf-8" />
<title>$GODOT_HEAD_TITLE</title>
- $GODOT_HEAD_INCLUDE
+$GODOT_HEAD_INCLUDE
<style type="text/css">
body {
margin: 0;
border: 0 none;
padding: 0;
text-align: center;
- background-color: black;
+ background-color: #222226;
font-family: $GODOT_STYLE_FONT_FAMILY;
}
@@ -71,7 +71,7 @@
margin: 0;
border: 0 none;
padding: 0;
- background-color: #111;
+ background-color: #0c0c0c;
}
#canvas {
@@ -81,6 +81,7 @@
* calculate cursor coordinates correctly */
border: 0 none;
padding: 0;
+ color: white;
}
@@ -101,6 +102,8 @@
}
#status {
+ line-height: 1.3;
+ cursor: pointer;
visibility: visible;
padding: 4px 6px;
}
@@ -123,7 +126,7 @@
-ms-user-select: none;
}
- #container:hover > #controls {
+ :hover > #controls {
opacity: 1.0;
transition: opacity 60ms ease-in-out;
}
@@ -135,223 +138,289 @@
margin-right: 2px;
}
+ #controls > label > input {
+ vertical-align: middle;
+ }
+
#controls > label > input[type="checkbox"] {
/* override user agent style */
margin-left: 0;
}
- label > input {
- vertical-align: middle;
- }
-
- #display-output { display: none; }
+ #output-toggle { display: none; }
/* Debug output
* ============ */
- #output {
+ #output-panel {
display: none;
- margin: 6px auto;
- border: 2px groove grey;
- padding: 4px;
- outline: none;
+ max-width: $GODOT_CANVAS_WIDTHpx;
+ font-size: small;
+ margin: 6px auto 0;
+ padding: 0 4px 4px;
text-align: left;
+ line-height: 2.2;
+ }
+
+ #output-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ #output-container {
+ padding: 6px;
+ background-color: #2c2a32;
+ box-shadow: inset 0 0 1px 1px #232127;
+ color: #bbb;
+ }
+
+ #output-scroll {
+ line-height: 1;
+ height: 12em;
+ overflow-y: scroll;
white-space: pre-wrap;
font-size: small;
- color: #eee;
- background-color: black;
font-family: "Lucida Console", Monaco, monospace;
}
- /* Export style include
- * ==================== */
+/* Export style include
+ * ==================== */
+
+$GODOT_STYLE_INCLUDE
- $GODOT_STYLE_INCLUDE
</style>
</head>
<body>
<div id="container">
<canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
- HTML5 canvas appears to be unsupported in the current browser.<br />Please try updating or use a different browser.
+ HTML5 canvas appears to be unsupported in the current browser.<br />
+ Please try updating or use a different browser.
</canvas>
<div id="status-container">
- <span id="status" class="godot" onclick="this.style.visibility='hidden';">Loading page...</span>
+ <span id="status" class="godot" onclick="this.style.visibility='hidden';">Downloading page...</span>
</div>
<div id="controls" class="godot">
- <label id="display-output"><input id="output-toggle" type="checkbox" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />display output</label>
+ <label id="output-toggle"><input type="checkbox" checked="checked" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />Display Output</label>
<!-- hidden until implemented
- <label><input id="lock-cursor" type="checkbox" autocomplete="off" />lock cursor</label>
- <label><input id="resize-canvas" type="checkbox" autocomplete="off" />resize canvas</label>
+ <label><input class="postRun-enable" type="checkbox" disabled="disabled" autocomplete="off" />lock cursor</label>
+ <label><input class="postRun-enable" type="checkbox" disabled="disabled" autocomplete="off" onchange="Presentation.setCanvasMaximized(this.checked);" />maximize</label>
-->
- <button id="fullscreen" class="godot" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.goFullscreen();">fullscreen</button>
+ <button id="fullscreen" class="godot postRun-enable" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.requestFullscreen();">Fullscreen</button>
</div>
</div>
- <!-- Firefox adds extra space to textarea, but shouldn't matter too much https://bugzilla.mozilla.org/show_bug.cgi?id=33654 -->
- <textarea id="output" rows="10" cols="100" readonly="readonly" style="resize:none"></textarea>
+ <div id="output-panel" class="godot">
+ <div id="output-header">
+ Output:
+ <button class="godot" type="button" autocomplete="off" onclick="Presentation.clearOutput();">Clear</button>
+ </div>
+ <div id="output-container"><div id="output-scroll"></div></div>
+ </div>
+ <!-- Scripts -->
<script type="text/javascript">//<![CDATA[
var Presentation = (function() {
var statusElement = document.getElementById("status");
- var outputElement = document.getElementById("output");
- var doneLoading = false;
-
- function onLoaded() {
- doneLoading = true;
- var fullscreenButtonElement = document.getElementById("fullscreen");
- fullscreenButtonElement.disabled = false;
- }
+ var canvasElement = document.getElementById("canvas");
var presentation = {
- statusElement: statusElement,
- outputElement: outputElement,
- setOutputVisible: function setOutputVisible(visible) {
- outputElement.style.display = (visible?"block":"none");
+ postRun: [
+ function() {
+ var elements = document.getElementsByClassName("postRun-enable");
+ Array.prototype.slice.call(elements).forEach(function(element) {
+ element.disabled = false;
+ });
+ }
+ ],
+ requestFullscreen: function requestFullscreen() {
+ if (typeof Module !== "undefined" && Module.requestFullscreen) {
+ Module.requestFullscreen(false, false);
+ }
+ },
+ /*
+ requestPointerlock: function requestPointerlock() {
+ if (typeof Module !== "undefined" && Module.requestPointerlock) {
+ Module.requestPointerlock(false, false);
+ }
},
+ setCanvasMaximized: function setCanvasMaximized(enabled) {
+ if (typeof Module !== "undefined" && Module.setCanvasMaximized) {
+ Module.setCanvasMaximized(enabled);
+ }
+ },
+ */
setStatusVisible: function setStatusVisible(visible) {
statusElement.style.visibility = (visible?"visible":"hidden");
},
setStatus: function setStatus(text) {
- if (!text || text.length === 0) {
- Presentation.setStatusVisible(false);
- onLoaded();
- } else {
- Presentation.setStatusVisible(true);
- statusElement.innerHTML = text;
+ if (text.length === 0) {
+ // emscripten sets empty string as status after "Running..."
+ // per timeout, but another status may have been set by then
+ if (Presentation.setStatus.lastText === "Running...")
+ Presentation.setStatusVisible(false);
+ return;
}
+ Presentation.setStatus.lastText = text;
+ while (statusElement.lastChild) {
+ statusElement.removeChild(statusElement.lastChild);
+ }
+ var lines = text.split("\n");
+ lines.forEach(function(line, index) {
+ statusElement.appendChild(document.createTextNode(line));
+ statusElement.appendChild(document.createElement("br"));
+ });
+ var closeNote = document.createElement("span");
+ closeNote.style.fontSize = "small";
+ closeNote.textContent = "click to close";
+ statusElement.appendChild(closeNote);
+ Presentation.setStatusVisible(true);
+ },
+ isWebGL2Available: function isWebGL2Available() {
+ var context;
+ try {
+ context = canvasElement.getContext("webgl2") || canvasElement.getContext("experimental-webgl2");
+ } catch (e) {}
+ return !!context;
},
- goFullscreen: function goFullscreen() {
- if (doneLoading) Module.requestFullScreen(false, false);
- }
};
+ window.onerror = function(event) { presentation.setStatus("Failure during start-up\nSee JavaScript console") };
+
if ($GODOT_CONTROLS_ENABLED) { // controls enabled
- (function() {
- var controlsElement = document.getElementById("controls");
- controlsElement.style.visibility="visible";
- })();
+ document.getElementById("controls").style.visibility="visible";
}
if ($GODOT_DEBUG_ENABLED) { // debugging enabled
- (function() {
- var outputToggleLabel = document.getElementById("display-output");
- var outputToggle = document.getElementById("output-toggle");
-
- outputElement.value = ""; // clear browser cache
- outputElement.style.display = "block";
- outputToggle.checked = true;
- outputToggleLabel.style.display = "inline";
-
- presentation.print = function print(text) {
- if (outputElement.value.length !== 0)
- outputElement.value += "\n";
- outputElement.value += text;
- outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom
- };
- })();
+ var outputRoot = document.getElementById("output-panel");
+ var outputElement = document.getElementById("output-scroll");
+ var outputToggle = document.getElementById("output-toggle");
+ const maxOutputMessages = 400;
+
+ presentation.setOutputVisible = function setOutputVisible(visible) {
+ outputRoot.style.display = (visible?"block":"none");
+ };
+ presentation.clearOutput = function clearOutput() {
+ while (outputElement.firstChild) {
+ outputElement.firstChild.remove();
+ }
+ };
+
+ presentation.setOutputVisible(true);
+ outputToggle.style.display = "inline";
+
+ presentation.print = function print(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ if (text.length <= 0) return;
+ while (outputElement.childElementCount >= maxOutputMessages) {
+ outputElement.firstChild.remove();
+ }
+ var msg = document.createElement("div");
+ if (String.prototype.trim.call(text).startsWith("**ERROR**")
+ || String.prototype.trim.call(text).startsWith("**EXCEPTION**")) {
+ msg.style.color = "#d44";
+ } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
+ msg.style.color = "#ccc000";
+ } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
+ msg.style.color = "#c6d";
+ }
+ msg.textContent = text;
+ var scrollToBottom = outputElement.scrollHeight - (outputElement.clientHeight + outputElement.scrollTop) < 10;
+ outputElement.appendChild(msg);
+ if (scrollToBottom) {
+ outputElement.scrollTop = outputElement.scrollHeight;
+ }
+ };
+
+ presentation.postRun.push(function() {
+ window.onerror = function(event) { presentation.print("**EXCEPTION**:", event) };
+ });
+
+ } else {
+ presentation.postRun.push(function() { window.onerror = null; });
}
return presentation;
})();
// Emscripten interface
- var Module = (function() {
- var print = (function() {
- if (typeof Presentation.print === "function") {
- return function print(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- console.log(text);
- Presentation.print(text);
- };
- } else {
- return function print(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- console.log(text);
- };
+ var Module = {
+ TOTAL_MEMORY: $GODOT_TMEM,
+ postRun: (function() {
+ if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) {
+ return Presentation.postRun;
}
- })();
-
- var canvas = (function() {
- var canvasElement = document.getElementById("canvas");
-
+ })(),
+ print: function print(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ console.log(text);
+ if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
+ Presentation.print(text);
+ }
+ },
+ printErr: function printErr(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ console.error(text);
+ if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
+ Presentation.print("**ERROR**:", text)
+ }
+ },
+ canvas: (function() {
+ var canvas = document.getElementById("canvas");
// As a default initial behavior, pop up an alert when WebGL context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
- canvasElement.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
-
- return canvasElement;
- })();
-
- var setStatus = (function() {
- if (typeof Presentation.setStatus === "function")
- return function setStatus(text) {
- if (!Module.setStatus.last)
- Module.setStatus.last = { time: Date.now(), text: "" };
- if (text === Module.setStatus.text)
- return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- Presentation.setStatus(text);
- };
- else
- return function setStatus(text) {
- if (!Module.setStatus.last)
- Module.setStatus.last = { time: Date.now(), text: "" };
- if (text === Module.setStatus.text)
- return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- };
- })();
-
- return {
- TOTAL_MEMORY: 268435456,
- preRun: [],
- postRun: [],
- print: print,
- printErr: function printErr(text) {
- if (arguments.length > 1)
- text = Array.prototype.slice.call(arguments).join(" ");
- if (0) { // XXX disabled for safety `if (typeof dump == "function")`
- dump(text + "\n"); // fast, straight to the real console
- } else {
- console.error(text);
- }
- },
- canvas: canvas,
- setStatus: setStatus,
- totalDependencies: 0,
- monitorRunDependencies: function monitorRunDependencies(left) {
- this.totalDependencies = Math.max(this.totalDependencies, left);
- Module.setStatus(left ? "Preparing... (" + (this.totalDependencies-left) + "/" + this.totalDependencies + ")" : "All downloads complete.");
+ canvas.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
+ return canvas;
+
+ })(),
+ setStatus: function setStatus(text) {
+ var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
+ var now = Date.now();
+ if (m) {
+ if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
+ return;
+ text = m[1];
}
- };
- })();
+ if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") {
+ Presentation.setStatus(text);
+ }
+ }
+ };
- Presentation.setStatus("Downloading...");
+ if (!Presentation.isWebGL2Available()) {
+ Presentation.setStatus("WebGL2 appears to be unsupported in the current browser.\nPlease try updating or use a different browser.");
+ Presentation.preventLoading = true;
+ } else {
+ Presentation.setStatus("Downloading...");
+ }
- window.onerror = function(event) {
- // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
- Module.setStatus("Exception thrown, see JavaScript console");
- Module.setStatus = function(text) {
- if (text) Module.printErr("[post-exception status] " + text);
- };
- };
+ if (Presentation.preventLoading) {
+ // prevent *fs.js and Emscripten's SCRIPT placeholder from loading any files
+ Presentation._XHR_send = XMLHttpRequest.prototype.send;
+ XMLHttpRequest.prototype.send = function() {};
+ Presentation._Node_appendChild = Node.prototype.appendChild;
+ Node.prototype.appendChild = function(node) {
+ if (!(node instanceof HTMLScriptElement)) {
+ return Presentation._Node_appendChild.call(this, node);
+ }
+ }
+ }
//]]></script>
<script type="text/javascript" src="$GODOT_BASEfs.js"></script>
- {{{ SCRIPT }}}
+{{{ SCRIPT }}}
+ <script type="text/javascript">
+ if (Presentation.preventLoading) {
+ XMLHttpRequest.prototype.send = Presentation._XHR_send;
+ Node.prototype.appendChild = Presentation._Node_appendChild;
+ }
+ </script>
</body>
</html>
diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp
index 7bbe0ae99b..d84c8bf040 100644
--- a/platform/javascript/javascript_eval.cpp
+++ b/platform/javascript/javascript_eval.cpp
@@ -41,6 +41,7 @@ JavaScript *JavaScript::get_singleton() {
Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
union { int i; double d; char* s; } js_data[4];
+ /* clang-format off */
Variant::Type return_type = static_cast<Variant::Type>(EM_ASM_INT({
var eval_ret;
@@ -49,8 +50,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
// indirect eval call grants global execution context
var global_eval = eval;
eval_ret = global_eval(UTF8ToString($2));
- }
- else {
+ } else {
eval_ret = eval(UTF8ToString($2));
}
} catch (e) {
@@ -125,6 +125,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
return 0; // NIL
}, js_data, sizeof *js_data, p_code.utf8().get_data(), p_use_global_exec_context));
+ /* clang-format on */
switch(return_type) {
case Variant::BOOL:
@@ -136,7 +137,9 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
case Variant::STRING:
{
String str = String::utf8(js_data->s);
+ /* clang-format off */
EM_ASM_({ _free($0); }, js_data->s);
+ /* clang-format on */
return str;
}
case Variant::VECTOR2:
@@ -153,7 +156,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
void JavaScript::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false);
+ ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false);
}
JavaScript::JavaScript() {
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 4c47594810..076f93f0df 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -140,10 +140,9 @@ static void _godot_draw(void) {
extern "C" {
-void main_after_fs_sync(int value) {
+void main_after_fs_sync() {
start_step=1;
- printf("FS SYNCHED!\n");
}
}
@@ -152,16 +151,15 @@ int main(int argc, char *argv[]) {
/* Initialize the window */
- printf("let it go!\n");
+ printf("let it go dude!\n");
glutInit(&argc, argv);
os = new OS_JavaScript(_gfx_init,NULL,NULL);
#if 0
char *args[]={"-test","gui","-v",NULL};
Error err = Main::setup("apk",3,args);
#else
-// char *args[]={"-v",NULL};//
-// Error err = Main::setup("",1,args);
- Error err = Main::setup("",0,NULL);
+ char *args[]={"-main_pack","data.pck",NULL}; //pass location of main pack manually, because it wont get an executable name
+ Error err = Main::setup("",2,args);
#endif
ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility
@@ -178,26 +176,27 @@ int main(int argc, char *argv[]) {
glutDisplayFunc(_godot_draw);
//glutSpecialFunc(gears_special);
-
-
- //mount persistent filesystem
- EM_ASM(
- FS.mkdir('/userfs');
- FS.mount(IDBFS, {}, '/userfs');
-
-
-
- // sync from persisted state into memory and then
- // run the 'test' function
- FS.syncfs(true, function (err) {
- assert(!err);
- console.log("done syncinc!");
- _after_sync_cb = Module.cwrap('main_after_fs_sync', 'void',['number']);
- _after_sync_cb(0);
-
- });
-
- );
+ //mount persistent file system
+ /* clang-format off */
+ EM_ASM(
+ FS.mkdir('/userfs');
+ FS.mount(IDBFS, {}, '/userfs');
+
+ // sync from persistent state into memory and then
+ // run the 'main_after_fs_sync' function
+ FS.syncfs(true, function(err) {
+
+ if (err) {
+ Module.setStatus('Failed to load persistent data\nPlease allow (third-party) cookies');
+ Module.printErr('Failed to populate IDB file system: ' + err.message);
+ Module.exit();
+ } else {
+ Module.print('Successfully populated IDB file system');
+ ccall('main_after_fs_sync', 'void', []);
+ }
+ });
+ );
+ /* clang-format on */
glutMainLoop();
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 47c8ea89d7..201008b1db 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -27,27 +27,27 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_javascript.h"
-#include "drivers/gles2/rasterizer_gles2.h"
+
+#include "drivers/gles3/rasterizer_gles3.h"
#include "core/io/file_access_buffered_fa.h"
#include "drivers/unix/file_access_unix.h"
#include "drivers/unix/dir_access_unix.h"
-
#include "servers/visual/visual_server_raster.h"
-
#include "main/main.h"
-
-#include "core/globals.h"
-#include "stdlib.h"
-#include "emscripten.h"
+#include "core/global_config.h"
#include "dom_keys.h"
+#include <stdlib.h>
+#include <emscripten.h>
+
int OS_JavaScript::get_video_driver_count() const {
return 1;
}
+
const char * OS_JavaScript::get_video_driver_name(int p_driver) const {
- return "GLES2";
+ return "GLES3";
}
OS::VideoMode OS_JavaScript::get_default_video_mode() const {
@@ -215,6 +215,7 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int
// find locale, emscripten only sets "C"
char locale_ptr[16];
+ /* clang-format off */
EM_ASM_({
var locale = "";
if (Module.locale) {
@@ -230,56 +231,26 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int
locale = locale.split('.')[0];
stringToUTF8(locale, $0, 16);
}, locale_ptr);
+ /* clang-format on */
setenv("LANG", locale_ptr, true);
print_line("Init Audio");
- AudioDriverManagerSW::add_driver(&audio_driver_javascript);
+ AudioDriverManager::add_driver(&audio_driver_javascript);
+ audio_driver_javascript.set_singleton();
+ if (audio_driver_javascript.init() != OK) {
- if (true) {
- RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,false,false,false) );;
- rasterizer_gles22->set_use_framebuffers(false); //not supported by emscripten
- if (gl_extensions)
- rasterizer_gles22->set_extensions(gl_extensions);
- rasterizer = rasterizer_gles22;
- } else {
-// rasterizer = memnew( RasterizerGLES1(true, false) );
+ ERR_PRINT("Initializing audio failed.");
}
+ RasterizerGLES3::register_config();
+ RasterizerGLES3::make_current();
+
print_line("Init VS");
- visual_server = memnew( VisualServerRaster(rasterizer) );
- visual_server->init();
+ visual_server = memnew( VisualServerRaster() );
visual_server->cursor_set_visible(false, 0);
- /*AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
-
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
-
- ERR_PRINT("Initializing audio failed.");
- }*/
-
- print_line("Init SM");
-
- //sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerJavascript );
-
- print_line("Init Mixer");
-
- //audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false);
- audio_server->init();
-
- print_line("Init SoundServer");
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
-
- print_line("Init SpatialSoundServer");
-
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
- //
print_line("Init Physicsserver");
physics_server = memnew( PhysicsServerSW );
@@ -311,6 +282,8 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int
javascript_eval = memnew(JavaScript);
GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("JavaScript", javascript_eval));
#endif
+
+ visual_server->init();
}
void OS_JavaScript::set_main_loop( MainLoop * p_main_loop ) {
@@ -332,9 +305,11 @@ void OS_JavaScript::finalize() {
void OS_JavaScript::alert(const String& p_alert,const String& p_title) {
+ /* clang-format off */
EM_ASM_({
window.alert(UTF8ToString($0));
}, p_alert.utf8().get_data());
+ /* clang-format on */
}
@@ -366,9 +341,11 @@ int OS_JavaScript::get_mouse_button_state() const {
void OS_JavaScript::set_window_title(const String& p_title) {
+ /* clang-format off */
EM_ASM_({
document.title = UTF8ToString($0);
}, p_title.utf8().get_data());
+ /* clang-format on */
}
//interesting byt not yet
@@ -424,8 +401,10 @@ void OS_JavaScript::set_window_maximized(bool p_enabled) {
set_window_fullscreen(false);
}
else {
+ /* clang-format off */
video_mode.width = EM_ASM_INT_V(return window.innerWidth);
video_mode.height = EM_ASM_INT_V(return window.innerHeight);
+ /* clang-format on */
emscripten_set_canvas_size(video_mode.width, video_mode.height);
}
}
@@ -444,7 +423,9 @@ void OS_JavaScript::set_window_fullscreen(bool p_enable) {
// _browser_resize_callback or _fullscreen_change_callback
EMSCRIPTEN_RESULT result;
if (p_enable) {
+ /* clang-format off */
EM_ASM(Module.requestFullscreen(false, false););
+ /* clang-format on */
}
else {
result = emscripten_exit_fullscreen();
@@ -502,19 +483,15 @@ bool OS_JavaScript::main_loop_iterate() {
time_to_save_sync-=elapsed;
- print_line("elapsed "+itos(elapsed)+" tts "+itos(time_to_save_sync));
-
if (time_to_save_sync<0) {
//time to sync, for real
- // run 'success'
- print_line("DOING SYNCH!");
+ /* clang-format off */
EM_ASM(
- FS.syncfs(function (err) {
- assert(!err);
- console.log("Synched!");
- //ccall('success', 'v');
- });
+ FS.syncfs(function(err) {
+ if (err) { Module.printErr('Failed to save IDB file system: ' + err.message); }
+ });
);
+ /* clang-format on */
}
@@ -561,7 +538,7 @@ void OS_JavaScript::push_input(const InputEvent& p_ev) {
void OS_JavaScript::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) {
-// print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
+ //print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size()));
switch(p_what) {
case 0: { //gesture begin
@@ -644,8 +621,8 @@ void OS_JavaScript::process_touch(int p_what,int p_pointer, const Vector<TouchPo
ev.mouse_motion.x=p_points[0].pos.x;
ev.mouse_motion.y=p_points[0].pos.y;
input->set_mouse_pos(Point2(ev.mouse_motion.x,ev.mouse_motion.y));
- ev.mouse_motion.speed_x=input->get_mouse_speed().x;
- ev.mouse_motion.speed_y=input->get_mouse_speed().y;
+ ev.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ ev.mouse_motion.speed_y=input->get_last_mouse_speed().y;
ev.mouse_motion.relative_x=p_points[0].pos.x-last_mouse.x;
ev.mouse_motion.relative_y=p_points[0].pos.y-last_mouse.y;
last_mouse=p_points[0].pos;
@@ -782,18 +759,12 @@ void OS_JavaScript::main_loop_request_quit() {
main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
}
-void OS_JavaScript::reload_gfx() {
-
- if (gfx_init_func)
- gfx_init_func(gfx_init_ud,use_gl2,video_mode.width,video_mode.height,video_mode.fullscreen);
- if (rasterizer)
- rasterizer->reload_vram();
-}
-
Error OS_JavaScript::shell_open(String p_uri) {
+ /* clang-format off */
EM_ASM_({
window.open(UTF8ToString($0), '_blank');
}, p_uri.utf8().get_data());
+ /* clang-format on */
return OK;
}
@@ -804,8 +775,10 @@ String OS_JavaScript::get_resource_dir() const {
String OS_JavaScript::get_data_dir() const {
- //if (get_data_dir_func)
- // return get_data_dir_func();
+ /*
+ if (get_data_dir_func)
+ return get_data_dir_func();
+ */
return "/userfs";
//return GlobalConfig::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
};
@@ -888,7 +861,6 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Get
main_loop=NULL;
last_id=1;
gl_extensions=NULL;
- rasterizer=NULL;
window_maximized=false;
get_data_dir_func=p_get_data_dir_func;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 370322e93d..582f128ce8 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -33,17 +33,16 @@
#include "drivers/unix/os_unix.h"
#include "os/main_loop.h"
#include "servers/physics/physics_server_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/visual/rasterizer.h"
#include "audio_server_javascript.h"
#include "audio_driver_javascript.h"
#include "main/input_default.h"
-#include "emscripten/html5.h"
#include "javascript_eval.h"
+#include <emscripten/html5.h>
+
typedef void (*GFXInitFunc)(void *ud,bool gl2,int w, int h, bool fs);
typedef String (*GetDataDirFunc)();
@@ -69,12 +68,7 @@ private:
int64_t time_to_save_sync;
int64_t last_sync_time;
- Rasterizer *rasterizer;
VisualServer *visual_server;
- AudioServerJavascript *audio_server;
- //SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
AudioDriverJavaScript audio_driver_javascript;
@@ -168,8 +162,6 @@ public:
void set_opengl_extensions(const char* p_gl_extensions);
- void reload_gfx();
-
virtual Error shell_open(String p_uri);
virtual String get_data_dir() const;
String get_executable_path() const;
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index 87901f6ec4..4ad3a5b8fc 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -157,8 +157,8 @@ int AudioDriverOSX::get_mix_rate() const {
return 44100;
};
-AudioDriverSW::OutputFormat AudioDriverOSX::get_output_format() const {
- return OUTPUT_STEREO;
+AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const {
+ return SPEAKER_MODE_STEREO;
};
void AudioDriverOSX::lock() {
diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h
index 19b396de57..9e9bb63726 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/platform/osx/audio_driver_osx.h
@@ -31,11 +31,11 @@
#ifndef AUDIO_DRIVER_OSX_H
#define AUDIO_DRIVER_OSX_H
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include <AudioUnit/AudioUnit.h>
-class AudioDriverOSX : public AudioDriverSW {
+class AudioDriverOSX : public AudioDriver {
AudioComponentInstance audio_unit;
bool active;
@@ -61,7 +61,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 1cb41cede2..69973dc95d 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -29,17 +29,17 @@
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
#include "io/resource_saver.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/osx/logo.h"
#include "string.h"
-
+#if 0
class EditorExportPlatformOSX : public EditorExportPlatform {
@@ -536,13 +536,14 @@ EditorExportPlatformOSX::~EditorExportPlatformOSX() {
}
-
+#endif
void register_osx_exporter() {
-
+#if 0
Ref<EditorExportPlatformOSX> exporter = Ref<EditorExportPlatformOSX>( memnew(EditorExportPlatformOSX) );
EditorImportExport::get_singleton()->add_export_platform(exporter);
-
+#endif
}
+
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index 5d25017aa6..98bcc8dc73 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -275,7 +275,6 @@ void JoypadOSX::_device_removed(int p_id) {
input->joy_connection_changed(p_id, false, "");
device_list[device].free();
device_list.remove(device);
- attached_devices[p_id] = false;
}
static String _hex_str(uint8_t p_byte) {
@@ -307,7 +306,7 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad* p_joy) {
}
name = c_name;
- int id = get_free_joy_id();
+ int id = input->get_unused_joy_id();
ERR_FAIL_COND_V(id == -1, false);
p_joy->id = id;
int vendor = 0;
@@ -510,16 +509,6 @@ void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
FFEffectStop(joy->ff_object);
}
-int JoypadOSX::get_free_joy_id() {
- for (int i = 0; i < JOYPADS_MAX; i++) {
- if (!attached_devices[i]) {
- attached_devices[i] = true;
- return i;
- }
- }
- return -1;
-}
-
int JoypadOSX::get_joy_index(int p_id) const {
for (int i = 0; i < device_list.size(); i++) {
if (device_list[i].id == p_id) return i;
@@ -582,10 +571,6 @@ JoypadOSX::JoypadOSX()
self = this;
input = (InputDefault*)Input::get_singleton();
- for (int i = 0; i < JOYPADS_MAX; i++) {
- attached_devices[i] = false;
- }
-
int okay = 1;
const void *vals[] = {
(void *) create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay),
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index aafd82880d..71a0335316 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -95,14 +95,11 @@ private:
InputDefault *input;
IOHIDManagerRef hid_manager;
- bool attached_devices[JOYPADS_MAX];
Vector<joypad> device_list;
bool have_device(IOHIDDeviceRef p_device) const;
bool configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy);
-
- int get_free_joy_id();
int get_joy_index(int p_id) const;
void poll_joypads() const;
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index fc64c2b867..d8c35472f2 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -38,10 +38,7 @@
// #include "servers/visual/visual_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics_server.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/alsa/audio_driver_alsa.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
@@ -59,7 +56,7 @@ class OS_OSX : public OS_Unix {
public:
bool force_quit;
// rasterizer seems to no longer be given to visual server, its using GLES3 directly?
-// Rasterizer *rasterizer;
+ //Rasterizer *rasterizer;
VisualServer *visual_server;
List<String> args;
@@ -72,10 +69,6 @@ public:
IP_Unix *ip_unix;
AudioDriverOSX audio_driver_osx;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
InputDefault *input;
JoypadOSX *joypad_osx;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index a66f6abba5..7108d94b5b 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -148,36 +148,36 @@ static int button_mask=0;
- (void)applicationDidHide:(NSNotification *)notification
{
- /* _Godotwindow* window;
-
- for (window = _Godot.windowListHead; window; window = window->next)
- _GodotInputWindowVisibility(window, GL_FALSE);
+ /*
+ _Godotwindow* window;
+ for (window = _Godot.windowListHead; window; window = window->next)
+ _GodotInputWindowVisibility(window, GL_FALSE);
*/
}
- (void)applicationDidUnhide:(NSNotification *)notification
{
/*
- _Godotwindow* window;
+ _Godotwindow* window;
- for (window = _Godot.windowListHead; window; window = window->next)
- {
+ for (window = _Godot.windowListHead; window; window = window->next)
+ {
if ([window_object isVisible])
_GodotInputWindowVisibility(window, GL_TRUE);
- }
- */
+ }
+ */
}
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
{
- //_GodotInputMonitorChange();
+ //_GodotInputMonitorChange();
}
@end
@interface GodotWindowDelegate : NSObject
{
- // _Godotwindow* window;
+ //_Godotwindow* window;
}
@end
@@ -187,7 +187,7 @@ static int button_mask=0;
- (BOOL)windowShouldClose:(id)sender
{
- //_GodotInputWindowCloseRequest(window);
+ //_GodotInputWindowCloseRequest(window);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
return NO;
@@ -207,38 +207,42 @@ static int button_mask=0;
OS_OSX::singleton->window_size.height=fbRect.size.height*OS_OSX::singleton->display_scale;
- // _GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
- // _GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
- //_GodotInputWindowDamage(window);
+ /*
+ _GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
+ _GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
+ _GodotInputWindowDamage(window);
- //if (window->cursorMode == Godot_CURSOR_DISABLED)
- // centerCursor(window);
+ if (window->cursorMode == Godot_CURSOR_DISABLED)
+ centerCursor(window);
+ */
}
- (void)windowDidMove:(NSNotification *)notification
{
- // [window->nsgl.context update];
+ /*
+ [window->nsgl.context update];
- // int x, y;
- // _GodotPlatformGetWindowPos(window, &x, &y);
- // _GodotInputWindowPos(window, x, y);
+ int x, y;
+ _GodotPlatformGetWindowPos(window, &x, &y);
+ _GodotInputWindowPos(window, x, y);
- //if (window->cursorMode == Godot_CURSOR_DISABLED)
- // centerCursor(window);
+ if (window->cursorMode == Godot_CURSOR_DISABLED)
+ centerCursor(window);
+ */
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
- // _GodotInputWindowFocus(window, GL_TRUE);
- // _GodotPlatformSetCursorMode(window, window->cursorMode);
+ //_GodotInputWindowFocus(window, GL_TRUE);
+ //_GodotPlatformSetCursorMode(window, window->cursorMode);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
}
- (void)windowDidResignKey:(NSNotification *)notification
{
- // _GodotInputWindowFocus(window, GL_FALSE);
- // _GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
+ //_GodotInputWindowFocus(window, GL_FALSE);
+ //_GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
}
@@ -273,16 +277,18 @@ static int button_mask=0;
+ (void)initialize
{
- if (self == [GodotContentView class])
- {
- /* if (_glfw.ns.cursor == nil)
+ if (self == [GodotContentView class])
{
- NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
- _glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
- hotSpot:NSZeroPoint];
- [data release];
- }*/
- }
+ /*
+ if (_glfw.ns.cursor == nil)
+ {
+ NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
+ _glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
+ hotSpot:NSZeroPoint];
+ [data release];
+ }
+ */
+ }
}
- (id)init
@@ -993,7 +999,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
}
-// [window_object setTitle:[NSString stringWithUTF8String:"GodotEnginies"]];
+ //[window_object setTitle:[NSString stringWithUTF8String:"GodotEnginies"]];
[window_object setContentView:window_view];
[window_object setDelegate:window_delegate];
[window_object setAcceptsMouseMovedEvents:YES];
@@ -1019,7 +1025,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
ADD_ATTR(NSOpenGLPFADoubleBuffer);
ADD_ATTR(NSOpenGLPFAClosestPolicy);
-// we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
+ //we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
@@ -1077,43 +1083,32 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
- AudioDriverManagerSW::add_driver(&audio_driver_osx);
+ AudioDriverManager::add_driver(&audio_driver_osx);
// only opengl support here...
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
-// rasterizer = instance_RasterizerGLES2();
-// visual_server = memnew( VisualServerRaster(rasterizer) );
+ //rasterizer = instance_RasterizerGLES2();
+ //visual_server = memnew( VisualServerRaster(rasterizer) );
visual_server = memnew( VisualServerRaster );
// FIXME: Reimplement threaded rendering? Or remove?
-// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
-//
-// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
-// }
+ /*
+ if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
+ visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
+ }
+ */
visual_server->init();
visual_server->cursor_set_visible(false, 0);
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
ERR_PRINT("Initializing audio failed.");
}
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
-
- audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false);
- audio_server->init();
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
-
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
@@ -1160,22 +1155,12 @@ void OS_OSX::finalize() {
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
delete_main_loop();
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
memdelete(joypad_osx);
memdelete(input);
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
-
visual_server->finish();
memdelete(visual_server);
-// memdelete(rasterizer);
+ //memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
@@ -1730,10 +1715,10 @@ void OS_OSX::run() {
set_window_fullscreen(true);
}
-// uint64_t last_ticks=get_ticks_usec();
+ //uint64_t last_ticks=get_ticks_usec();
-// int frames=0;
-// uint64_t frame=0;
+ //int frames=0;
+ //uint64_t frame=0;
while (!force_quit) {
@@ -1780,7 +1765,8 @@ String OS_OSX::get_joy_guid(int p_device) const {
OS_OSX* OS_OSX::singleton=NULL;
OS_OSX::OS_OSX() {
-
+
+ mouse_mode=OS::MOUSE_MODE_VISIBLE;
main_loop=NULL;
singleton=this;
autoreleasePool = [[NSAutoreleasePool alloc] init];
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index e35ad1adf8..d691ae35bd 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -61,9 +61,9 @@ void OS_Server::initialize(const VideoMode& p_desired,int p_video_driver,int p_a
//visual_server = memnew( VisualServerRaster(rasterizer) );
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
ERR_PRINT("Initializing audio failed.");
}
@@ -103,9 +103,11 @@ void OS_Server::finalize() {
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
memdelete(sample_manager);
@@ -235,7 +237,7 @@ void OS_Server::run() {
OS_Server::OS_Server() {
- AudioDriverManagerSW::add_driver(&driver_dummy);
+ AudioDriverManager::add_driver(&driver_dummy);
//adriver here
grab=false;
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index 6aa1b9e14b..2b6225c48d 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -29,17 +29,13 @@
#ifndef OS_SERVER_H
#define OS_SERVER_H
-
#include "main/input_default.h"
#include "drivers/unix/os_unix.h"
#include "servers/visual_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/audio/audio_driver_dummy.h"
#include "servers/physics_server.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
@@ -51,7 +47,7 @@
class OS_Server : public OS_Unix {
-// Rasterizer *rasterizer;
+ //Rasterizer *rasterizer;
VisualServer *visual_server;
VideoMode current_videomode;
List<String> args;
@@ -66,11 +62,6 @@ class OS_Server : public OS_Unix {
virtual void delete_main_loop();
IP_Unix *ip_unix;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
-
bool force_quit;
InputDefault *input;
diff --git a/platform/uwp/app.h b/platform/uwp/app.h
index 6df9c5699e..fd6fc950a7 100644
--- a/platform/uwp/app.h
+++ b/platform/uwp/app.h
@@ -32,38 +32,41 @@
#include <wrl.h>
-#include "os_uwp.h"
#include "GLES2/gl2.h"
+#include "os_uwp.h"
+
+/** clang-format does not play nice with this C++/CX hybrid, needs investigation. */
+/* clang-format off */
namespace GodotUWP
{
- ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
- {
- public:
- App();
-
- // IFrameworkView Methods.
- virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
- virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
- virtual void Load(Platform::String^ entryPoint);
- virtual void Run();
- virtual void Uninitialize();
+ ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
+ {
+ public:
+ App();
+
+ // IFrameworkView Methods.
+ virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
+ virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
+ virtual void Load(Platform::String^ entryPoint);
+ virtual void Run();
+ virtual void Uninitialize();
property Windows::Foundation::EventRegistrationToken MouseMovedToken {
- Windows::Foundation::EventRegistrationToken get() { return this->mouseMovedToken; }
- void set(Windows::Foundation::EventRegistrationToken p_token) { this->mouseMovedToken = p_token; }
- };
+ Windows::Foundation::EventRegistrationToken get() { return this->mouseMovedToken; }
+ void set(Windows::Foundation::EventRegistrationToken p_token) { this->mouseMovedToken = p_token; }
+ }
- private:
+ private:
void RecreateRenderer();
- // Application lifecycle event handlers.
- void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
+ // Application lifecycle event handlers.
+ void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
- // Window event handlers.
- void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
- void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
- void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
+ // Window event handlers.
+ void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
+ void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
+ void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
void pointer_event(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args, bool p_pressed, bool p_is_wheel = false);
void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
@@ -81,20 +84,20 @@ namespace GodotUWP
void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args);
- void UpdateWindowSize(Windows::Foundation::Size size);
- void InitializeEGL(Windows::UI::Core::CoreWindow^ window);
- void CleanupEGL();
+ void UpdateWindowSize(Windows::Foundation::Size size);
+ void InitializeEGL(Windows::UI::Core::CoreWindow^ window);
+ void CleanupEGL();
char** get_command_line(unsigned int* out_argc);
- bool mWindowClosed;
- bool mWindowVisible;
- GLsizei mWindowWidth;
- GLsizei mWindowHeight;
+ bool mWindowClosed;
+ bool mWindowVisible;
+ GLsizei mWindowWidth;
+ GLsizei mWindowHeight;
- EGLDisplay mEglDisplay;
- EGLContext mEglContext;
- EGLSurface mEglSurface;
+ EGLDisplay mEglDisplay;
+ EGLContext mEglContext;
+ EGLSurface mEglSurface;
CoreWindow^ window;
OSUWP* os;
@@ -103,6 +106,7 @@ namespace GodotUWP
int last_touch_y[32];
int number_of_contacts;
Windows::Foundation::Point last_mouse_pos;
- };
-
+ }
}
+
+/* clang-format on */
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 1844df5eef..4966489188 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -65,7 +65,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************/
-
+#if 0
#include "version.h"
#include "export.h"
#include "object.h"
@@ -79,7 +79,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "io/sha256.h"
#include "io/base64.h"
#include "bind/core_bind.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/marshalls.h"
#include <zlib.h>
@@ -612,15 +612,13 @@ void AppxPackager::make_content_types() {
for (int i = 0; i < file_metadata.size(); i++) {
- String ext = file_metadata[i].name.extension();
+ String ext = file_metadata[i].name.get_extension();
if (types.has(ext)) continue;
types[ext] = content_type(ext);
- tmp_file->store_string("<Default Extension=\"" + ext +
- "\" ContentType=\""
- + types[ext] + "\" />");
+ tmp_file->store_string("<Default Extension=\"" + ext + "\" ContentType=\"" + types[ext] + "\" />");
}
// Appx signature file
@@ -1174,9 +1172,9 @@ Error AppxPackager::MakeIndirectDataContent(asn1::SPCIndirectDataContent &idc) {
MakeSPCInfoValue(*infoValue);
ASN1_TYPE* value =
- EncodedASN1::FromItem<asn1::SPCInfoValue,
- asn1::i2d_SPCInfoValue>(infoValue)
- .ToSequenceType();
+ EncodedASN1::FromItem<asn1::SPCInfoValue,
+ asn1::i2d_SPCInfoValue>(infoValue)
+ .ToSequenceType();
{
Vector<uint8_t> digest;
@@ -1202,8 +1200,10 @@ Error AppxPackager::add_attributes(PKCS7_SIGNER_INFO * p_signer_info) {
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();
+ ASN1_STRING* opus_value =
+ EncodedASN1::FromItem<asn1::SPCSpOpusInfo,
+ asn1::i2d_SPCSpOpusInfo>(opus)
+ .ToSequenceString();
if (!PKCS7_add_signed_attribute(
p_signer_info,
@@ -1237,8 +1237,9 @@ Error AppxPackager::add_attributes(PKCS7_SIGNER_INFO * p_signer_info) {
statement_type->type = OBJ_nid2obj(NID_ms_code_ind);
ASN1_STRING* statement_type_value =
- EncodedASN1::FromItem<asn1::SPCStatementType, asn1::i2d_SPCStatementType>(statement_type)
- .ToSequenceString();
+ EncodedASN1::FromItem<asn1::SPCStatementType,
+ asn1::i2d_SPCStatementType>(statement_type)
+ .ToSequenceString();
if (!PKCS7_add_signed_attribute(
p_signer_info,
@@ -2383,9 +2384,11 @@ EditorExportPlatformUWP::EditorExportPlatformUWP() {
EditorExportPlatformUWP::~EditorExportPlatformUWP() {}
-
+#endif
void register_uwp_exporter() {
-
+#if 0
Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP));
EditorImportExport::get_singleton()->add_export_platform(exporter);
+#endif
}
+
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 90505b409a..5d81ac44c0 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -33,10 +33,12 @@
ref class JoypadUWP sealed {
+ /** clang-format breaks this, it does not understand this token. */
+ /* clang-format off */
internal:
-
void register_events();
uint32_t process_controllers(uint32_t p_last_id);
+ /* clang-format on */
JoypadUWP();
JoypadUWP(InputDefault* p_input);
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 34977bc048..61b8a1c240 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -36,16 +36,12 @@
#include "main/main.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/dir_access_windows.h"
-
-
#include "servers/visual/visual_server_raster.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/visual/visual_server_wrap_mt.h"
-
+#include "servers/audio_server.h"
+//#include "servers/visual/visual_server_wrap_mt.h"
#include "os/memory_pool_dynamic_prealloc.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/marshalls.h"
-
#include "platform/windows/packet_peer_udp_winsock.h"
#include "platform/windows/stream_peer_winsock.h"
#include "platform/windows/tcp_server_winsock.h"
@@ -145,13 +141,14 @@ void OSUWP::set_keep_screen_on(bool p_enabled) {
int OSUWP::get_audio_driver_count() const {
- return AudioDriverManagerSW::get_driver_count();
+ return AudioDriverManager::get_driver_count();
}
+
const char * OSUWP::get_audio_driver_name(int p_driver) const {
- AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver);
+ AudioDriver* driver = AudioDriverManager::get_driver(p_driver);
ERR_FAIL_COND_V( !driver, "" );
- return AudioDriverManagerSW::get_driver(p_driver)->get_name();
+ return AudioDriverManager::get_driver(p_driver)->get_name();
}
static MemoryPoolStatic *mempool_static=NULL;
@@ -288,23 +285,13 @@ void OSUWP::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio
joypad = ref new JoypadUWP(input);
joypad->register_events();
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
ERR_PRINT("Initializing audio failed.");
}
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
-
- audio_server->init();
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
managed_object->update_clipboard();
Clipboard::ContentChanged += ref new EventHandler<Platform::Object^>(managed_object, &ManagedType::on_clipboard_changed);
@@ -407,19 +394,11 @@ void OSUWP::finalize() {
if (rasterizer)
memdelete(rasterizer);
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
-
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
memdelete(input);
@@ -969,7 +948,7 @@ OSUWP::OSUWP() {
mouse_mode_changed = CreateEvent(NULL, TRUE, FALSE, L"os_mouse_mode_changed");
- AudioDriverManagerSW::add_driver(&audio_driver);
+ AudioDriverManager::add_driver(&audio_driver);
}
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 82376dd2f6..f65aa2d8d9 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -34,28 +34,19 @@
#include "servers/visual_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics/physics_server_sw.h"
-
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "drivers/xaudio2/audio_driver_xaudio2.h"
-
#include "gl_context_egl.h"
-
#include "core/math/math_2d.h"
#include "core/ustring.h"
+#include "main/input_default.h"
+#include "joypad_uwp.h"
#include <windows.h>
-
#include <io.h>
-
#include <fcntl.h>
#include <stdio.h>
-#include "main/input_default.h"
-
-#include "joypad_uwp.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -119,10 +110,6 @@ private:
MainLoop *main_loop;
AudioDriverXAudio2 audio_driver;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
MouseMode mouse_mode;
bool alt_mem;
@@ -157,9 +144,12 @@ private:
void on_magnetometer_reading_changed(Windows::Devices::Sensors::Magnetometer^ sender, Windows::Devices::Sensors::MagnetometerReadingChangedEventArgs^ args);
void on_gyroscope_reading_changed(Windows::Devices::Sensors::Gyrometer^ sender, Windows::Devices::Sensors::GyrometerReadingChangedEventArgs^ args);
+ /** clang-format breaks this, it does not understand this token. */
+ /* clang-format off */
internal:
ManagedType() { alert_close_handle = false; }
property OSUWP* os;
+ /* clang-format on */
};
ManagedType^ managed_object;
Windows::Devices::Sensors::Accelerometer^ accelerometer;
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index 6b60ade5f0..7a81dfef77 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -199,7 +199,7 @@ Error ContextGL_Win::initialize() {
}
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT");
-// glWrapperInit(wrapper_get_proc_address);
+ //glWrapperInit(wrapper_get_proc_address);
return OK;
}
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index 1ad61844d0..1c827a93b0 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -28,10 +28,11 @@
/*************************************************************************/
#include "export.h"
#include "platform/windows/logo.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
void register_windows_exporter() {
+#if 0
Image img(_windows_logo);
Ref<ImageTexture> logo = memnew( ImageTexture );
logo->create_from_image(img);
@@ -48,5 +49,6 @@ void register_windows_exporter() {
EditorImportExport::get_singleton()->add_export_platform(exporter);
}
-
+#endif
}
+
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index 6ea23ebb28..4c1eeb425a 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -87,16 +87,6 @@ bool JoypadWindows::have_device(const GUID &p_guid) {
return false;
}
-int JoypadWindows::check_free_joy_slot() const {
-
- for (int i = 0; i < JOYPADS_MAX; i++) {
-
- if (!attached_joypads[i])
- return i;
- }
- return -1;
-}
-
// adapted from SDL2, works a lot better than the MSDN version
bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
@@ -146,7 +136,7 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE* instance) {
HRESULT hr;
- int num = check_free_joy_slot();
+ int num = input->get_unused_joy_id();
if (have_device(instance->guidInstance) || num == -1)
return false;
@@ -249,7 +239,7 @@ BOOL CALLBACK JoypadWindows::enumCallback(const DIDEVICEINSTANCE* instance, void
JoypadWindows* self = (JoypadWindows*)pContext;
- if (self->is_xinput_device(&instance->guidProduct)) {;
+ if (self->is_xinput_device(&instance->guidProduct)) {
return DIENUM_CONTINUE;
}
self->setup_dinput_joypad(instance);
@@ -296,7 +286,7 @@ void JoypadWindows::probe_joypads() {
dwResult = xinput_get_state(i, &x_joypads[i].state);
if ( dwResult == ERROR_SUCCESS) {
- int id = check_free_joy_slot();
+ int id = input->get_unused_joy_id();
if (id != -1 && !x_joypads[i].attached) {
x_joypads[i].attached = true;
diff --git a/platform/windows/joypad.h b/platform/windows/joypad.h
index 63eee8c015..d6670c90db 100644
--- a/platform/windows/joypad.h
+++ b/platform/windows/joypad.h
@@ -132,7 +132,6 @@ private:
void load_xinput();
void unload_xinput();
- int check_free_joy_slot() const;
unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad);
bool have_device(const GUID &p_guid);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 6256cb58e0..0ef964522b 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -30,30 +30,25 @@
#include "os_windows.h"
#include "drivers/gles3/rasterizer_gles3.h"
-
#include "drivers/windows/thread_windows.h"
#include "drivers/windows/semaphore_windows.h"
#include "drivers/windows/mutex_windows.h"
#include "drivers/windows/rw_lock_windows.h"
-#include "main/main.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/dir_access_windows.h"
-
-
#include "servers/visual/visual_server_raster.h"
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
//#include "servers/visual/visual_server_wrap_mt.h"
-
+#include "main/main.h"
#include "tcp_server_winsock.h"
#include "packet_peer_udp_winsock.h"
#include "stream_peer_winsock.h"
#include "lang_table.h"
-
-#include "globals.h"
+#include "global_config.h"
#include "io/marshalls.h"
#include "joypad.h"
-#include "shlobj.h"
+#include <shlobj.h>
#include <regstr.h>
#include <process.h>
@@ -158,13 +153,13 @@ OS::VideoMode OS_Windows::get_default_video_mode() const {
int OS_Windows::get_audio_driver_count() const {
- return AudioDriverManagerSW::get_driver_count();
+ return AudioDriverManager::get_driver_count();
}
const char * OS_Windows::get_audio_driver_name(int p_driver) const {
- AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver);
+ AudioDriver* driver = AudioDriverManager::get_driver(p_driver);
ERR_FAIL_COND_V( !driver, "" );
- return AudioDriverManagerSW::get_driver(p_driver)->get_name();
+ return AudioDriverManager::get_driver(p_driver)->get_name();
}
@@ -259,6 +254,25 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) // Check For Windows Messages
{
+ case WM_SETFOCUS:
+ {
+ window_has_focus = true;
+ // Re-capture cursor if we're in one of the capture modes
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
+ SetCapture(hWnd);
+ }
+ break;
+ }
+ case WM_KILLFOCUS:
+ {
+ window_has_focus = false;
+
+ // Release capture if we're in one of the capture modes
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
+ ReleaseCapture();
+ }
+ break;
+ }
case WM_ACTIVATE: // Watch For Window Activate Message
{
minimized = HIWORD(wParam) != 0;
@@ -271,19 +285,17 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
alt_mem=false;
control_mem=false;
shift_mem=false;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
RECT clipRect;
GetClientRect(hWnd, &clipRect);
ClientToScreen(hWnd, (POINT*) &clipRect.left);
ClientToScreen(hWnd, (POINT*) &clipRect.right);
ClipCursor(&clipRect);
SetCapture(hWnd);
-
}
} else {
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
alt_mem=false;
-
};
return 0; // Return To The Message Loop
@@ -350,6 +362,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
+ // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
+ if (!window_has_focus && mouse_mode==MOUSE_MODE_CAPTURED)
+ break;
/*
LPARAM extra = GetMessageExtraInfo();
if (IsPenEvent(extra)) {
@@ -381,18 +396,19 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
mm.button_mask|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
mm.x=GET_X_LPARAM(lParam);
mm.y=GET_Y_LPARAM(lParam);
-
+
if (mouse_mode==MOUSE_MODE_CAPTURED) {
Point2i c(video_mode.width/2,video_mode.height/2);
+ old_x = c.x;
+ old_y = c.y;
+
if (Point2i(mm.x,mm.y)==c) {
center=c;
return 0;
}
Point2i ncenter(mm.x,mm.y);
- mm.x = old_x + (mm.x-center.x);
- mm.y = old_y + (mm.y-center.y);
center=ncenter;
POINT pos = { (int) c.x, (int) c.y };
ClientToScreen(hWnd, &pos);
@@ -401,8 +417,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
input->set_mouse_pos(Point2(mm.x,mm.y));
- mm.speed_x=input->get_mouse_speed().x;
- mm.speed_y=input->get_mouse_speed().y;
+ mm.speed_x=input->get_last_mouse_speed().x;
+ mm.speed_y=input->get_last_mouse_speed().y;
if (old_invalid) {
@@ -415,7 +431,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
mm.relative_y=mm.y-old_y;
old_x=mm.x;
old_y=mm.y;
- if (main_loop)
+ if (window_has_focus && main_loop)
input->parse_input_event(event);
@@ -635,8 +651,10 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
gr_mem=alt_mem;
}
- //if (wParam==VK_WIN) TODO wtf is this?
- // meta_mem=uMsg==WM_KEYDOWN;
+ /*
+ if (wParam==VK_WIN) TODO wtf is this?
+ meta_mem=uMsg==WM_KEYDOWN;
+ */
} //fallthrough
@@ -717,9 +735,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
joypad->probe_joypads();
} break;
case WM_SETCURSOR: {
-
if(LOWORD(lParam) == HTCLIENT) {
- if(mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED) {
+ if(window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) {
//Hide the cursor
if(hCursor == NULL)
hCursor = SetCursor(NULL);
@@ -951,7 +968,7 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
main_loop=NULL;
outside=true;
-
+ window_has_focus=true;
WNDCLASSEXW wc;
video_mode=p_desired;
@@ -1076,21 +1093,16 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
-#else
- // FIXME: Does DX support still work now that rasterizer is no longer used?
-#ifdef DX9_ENABLED
- rasterizer = memnew( RasterizerDX9(hWnd) );
-#endif
#endif
visual_server = memnew( VisualServerRaster );
// FIXME: Reimplement threaded rendering? Or remove?
-// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
-//
-// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
-// }
+ /*
+ if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
+ visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
+ }
+ */
- //
physics_server = memnew( PhysicsServerSW );
physics_server->init();
@@ -1122,23 +1134,13 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
input = memnew( InputDefault );
joypad = memnew (JoypadWindows(input, &hWnd));
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
ERR_PRINT("Initializing audio failed.");
}
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
-
- audio_server->init();
-
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
-
TRACKMOUSEEVENT tme;
tme.cbSize=sizeof(TRACKMOUSEEVENT);
tme.dwFlags=TME_LEAVE;
@@ -1253,6 +1255,10 @@ void OS_Windows::finalize() {
main_loop=NULL;
+ for (int i = 0; i < get_audio_driver_count(); i++) {
+ AudioDriverManager::get_driver(i)->finish();
+ }
+
memdelete(joypad);
memdelete(input);
@@ -1262,26 +1268,16 @@ void OS_Windows::finalize() {
if (gl_context)
memdelete(gl_context);
#endif
- if (rasterizer)
- memdelete(rasterizer);
if (user_proc) {
SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
};
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
-
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
-
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
physics_server->finish();
memdelete(physics_server);
@@ -1290,8 +1286,8 @@ void OS_Windows::finalize() {
memdelete(physics_2d_server);
monitor_info.clear();
-
}
+
void OS_Windows::finalize_core() {
memdelete(process_map);
@@ -1321,18 +1317,10 @@ void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) {
MultiByteToWideChar(CP_UTF8,0,buf,len,wbuf,wlen);
wbuf[wlen]=0;
-// Recent MinGW and MSVC compilers seem to disagree on the case here
-#ifdef __MINGW32__
- if (p_stderr)
- fwprintf(stderr, L"%S", wbuf);
- else
- wprintf(L"%S", wbuf);
-#else // MSVC
if (p_stderr)
- fwprintf(stderr, L"%s", wbuf);
+ fwprintf(stderr, L"%ls", wbuf);
else
- wprintf(L"%s", wbuf);
-#endif
+ wprintf(L"%ls", wbuf);
#ifdef STDOUT_FILE
//vwfprintf(stdo,p_format,p_list);
@@ -1355,17 +1343,17 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) {
if (mouse_mode==p_mode)
return;
mouse_mode=p_mode;
- if (p_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
RECT clipRect;
GetClientRect(hWnd, &clipRect);
ClientToScreen(hWnd, (POINT*) &clipRect.left);
ClientToScreen(hWnd, (POINT*) &clipRect.right);
ClipCursor(&clipRect);
- SetCapture(hWnd);
center=Point2i(video_mode.width/2,video_mode.height/2);
POINT pos = { (int) center.x, (int) center.y };
ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
+ if (mouse_mode==MOUSE_MODE_CAPTURED)
+ SetCursorPos(pos.x, pos.y);
} else {
ReleaseCapture();
ClipCursor(NULL);
@@ -1608,7 +1596,7 @@ void OS_Windows::set_window_fullscreen(bool p_enabled){
*/
}
-// MoveWindow(hWnd,r.left,r.top,p_size.x,p_size.y,TRUE);
+ //MoveWindow(hWnd,r.left,r.top,p_size.x,p_size.y,TRUE);
}
@@ -1980,13 +1968,13 @@ Error OS_Windows::execute(const String& p_path, const List<String>& p_arguments,
String argss;
argss="\"\""+p_path+"\"";
+
+ for (const List<String>::Element* E=p_arguments.front(); E; E=E->next()) {
- for(int i=0;i<p_arguments.size();i++) {
-
- argss+=String(" \"")+p_arguments[i]+"\"";
+ argss+=String(" \"")+E->get()+"\"";
}
-// print_line("ARGS: "+argss);
+ //print_line("ARGS: "+argss);
//argss+"\"";
//argss+=" 2>nul";
@@ -2405,6 +2393,11 @@ bool OS_Windows::is_vsync_enabled() const{
return true;
}
+bool OS_Windows::check_feature_support(const String& p_feature) {
+
+ return VisualServer::get_singleton()->has_os_feature(p_feature);
+
+}
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
@@ -2428,10 +2421,10 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
user_proc = NULL;
#ifdef RTAUDIO_ENABLED
- AudioDriverManagerSW::add_driver(&driver_rtaudio);
+ AudioDriverManager::add_driver(&driver_rtaudio);
#endif
#ifdef XAUDIO2_ENABLED
- AudioDriverManagerSW::add_driver(&driver_xaudio2);
+ AudioDriverManager::add_driver(&driver_xaudio2);
#endif
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 7ca89e6366..73a2d5f451 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -35,29 +35,24 @@
#include "servers/visual_server.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics/physics_server_sw.h"
-
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
+#include "servers/audio_server.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#ifdef XAUDIO2_ENABLED
#include "drivers/xaudio2/audio_driver_xaudio2.h"
#endif
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "drivers/unix/ip_unix.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
-
#include "main/input_default.h"
+#include "key_mapping_win.h"
-#include <windows.h>
-#include "key_mapping_win.h"
+#include <windows.h>
#include <windowsx.h>
#include <io.h>
-
#include <fcntl.h>
#include <stdio.h>
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -97,7 +92,6 @@ class OS_Windows : public OS {
ContextGL_Win *gl_context;
#endif
VisualServer *visual_server;
- Rasterizer *rasterizer;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
int pressrc;
@@ -116,11 +110,6 @@ class OS_Windows : public OS {
WNDPROC user_proc;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
-
MouseMode mouse_mode;
bool alt_mem;
bool gr_mem;
@@ -128,6 +117,7 @@ class OS_Windows : public OS {
bool control_mem;
bool meta_mem;
bool force_quit;
+ bool window_has_focus;
uint32_t last_button_state;
CursorShape cursor_shape;
@@ -295,6 +285,8 @@ public:
virtual void set_use_vsync(bool p_enable);
virtual bool is_vsync_enabled() const;
+ virtual bool check_feature_support(const String& p_feature);
+
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
index ef497c428d..276b9b6634 100644
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ b/platform/windows/packet_peer_udp_winsock.cpp
@@ -73,10 +73,15 @@ Error PacketPeerUDPWinsock::get_packet(const uint8_t **r_buffer,int &r_buffer_si
}
Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer,int p_buffer_size){
+ ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED);
+
+ if(sock_type==IP::TYPE_NONE)
+ sock_type = peer_addr.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+
int sock = _get_socket();
ERR_FAIL_COND_V( sock == -1, FAILED );
struct sockaddr_storage addr;
- size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, ip_type);
+ size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, sock_type);
_set_blocking(true);
@@ -114,15 +119,22 @@ void PacketPeerUDPWinsock::_set_blocking(bool p_blocking) {
};
}
-Error PacketPeerUDPWinsock::listen(int p_port, int p_recv_buffer_size) {
+Error PacketPeerUDPWinsock::listen(int p_port, IP_Address p_bind_address, int p_recv_buffer_size) {
+
+ ERR_FAIL_COND_V(sockfd!=-1,ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(),ERR_INVALID_PARAMETER);
+
+ sock_type = IP::TYPE_ANY;
+
+ if(p_bind_address.is_valid())
+ sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
- close();
int sock = _get_socket();
if (sock == -1 )
return ERR_CANT_CREATE;
struct sockaddr_storage addr = {0};
- size_t addr_size = _set_listen_sockaddr(&addr, p_port, ip_type, NULL);
+ size_t addr_size = _set_listen_sockaddr(&addr, p_port, sock_type, IP_Address());
if (bind(sock, (struct sockaddr*)&addr, addr_size) == -1 ) {
close();
@@ -141,7 +153,8 @@ void PacketPeerUDPWinsock::close(){
if (sockfd != -1)
::closesocket(sockfd);
sockfd=-1;
- rb.resize(8);
+ sock_type = IP::TYPE_NONE;
+ rb.resize(16);
queue_count=0;
}
@@ -152,6 +165,9 @@ Error PacketPeerUDPWinsock::wait() {
}
Error PacketPeerUDPWinsock::_poll(bool p_wait) {
+ if (sockfd==-1) {
+ return FAILED;
+ }
_set_blocking(p_wait);
@@ -159,7 +175,7 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) {
struct sockaddr_storage from = {0};
int len = sizeof(struct sockaddr_storage);
int ret;
- while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), 0, (struct sockaddr*)&from, &len)) > 0) {
+ while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-24, 0)), 0, (struct sockaddr*)&from, &len)) > 0) {
uint32_t port = 0;
@@ -238,16 +254,18 @@ int PacketPeerUDPWinsock::get_packet_port() const{
int PacketPeerUDPWinsock::_get_socket() {
+ ERR_FAIL_COND_V(sock_type==IP::TYPE_NONE,-1);
+
if (sockfd != -1)
return sockfd;
- sockfd = _socket_create(ip_type, SOCK_DGRAM, IPPROTO_UDP);
+ sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP);
return sockfd;
}
-void PacketPeerUDPWinsock::set_send_address(const IP_Address& p_address,int p_port) {
+void PacketPeerUDPWinsock::set_dest_address(const IP_Address& p_address,int p_port) {
peer_addr=p_address;
peer_port=p_port;
@@ -271,7 +289,8 @@ PacketPeerUDPWinsock::PacketPeerUDPWinsock() {
packet_port=0;
queue_count=0;
peer_port=0;
- ip_type = IP::TYPE_ANY;
+ sock_type = IP::TYPE_NONE;
+ rb.resize(16);
}
PacketPeerUDPWinsock::~PacketPeerUDPWinsock() {
diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h
index 2199115889..dcd9da9a79 100644
--- a/platform/windows/packet_peer_udp_winsock.h
+++ b/platform/windows/packet_peer_udp_winsock.h
@@ -46,6 +46,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
mutable int packet_port;
mutable int queue_count;
int sockfd;
+ IP::Type sock_type;
IP_Address peer_addr;
int peer_port;
@@ -67,7 +68,7 @@ public:
virtual int get_max_packet_size() const;
- virtual Error listen(int p_port, int p_recv_buffer_size=65536);
+ virtual Error listen(int p_port, IP_Address p_bind_address=IP_Address("*"), int p_recv_buffer_size=65536);
virtual void close();
virtual Error wait();
virtual bool is_listening() const;
@@ -75,7 +76,7 @@ public:
virtual IP_Address get_packet_address() const;
virtual int get_packet_port() const;
- virtual void set_send_address(const IP_Address& p_address,int p_port);
+ virtual void set_dest_address(const IP_Address& p_address,int p_port);
static void make_default();
PacketPeerUDPWinsock();
diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp
index a48a02c7a7..106eb6a5f5 100644
--- a/platform/windows/stream_peer_winsock.cpp
+++ b/platform/windows/stream_peer_winsock.cpp
@@ -78,17 +78,12 @@ Error StreamPeerWinsock::_block(int p_sockfd, bool p_read, bool p_write) const {
return ret < 0 ? FAILED : OK;
};
-Error StreamPeerWinsock::_poll_connection(bool p_block) const {
+Error StreamPeerWinsock::_poll_connection() const {
ERR_FAIL_COND_V(status != STATUS_CONNECTING || sockfd == INVALID_SOCKET, FAILED);
- if (p_block) {
-
- _block(sockfd, false, true);
- };
-
struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, ip_type);
+ size_t addr_size = _set_sockaddr(&their_addr, peer_host, peer_port, sock_type);
if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == SOCKET_ERROR) {
@@ -98,7 +93,7 @@ Error StreamPeerWinsock::_poll_connection(bool p_block) const {
return OK;
};
- if (errno == WSAEINPROGRESS || errno == WSAEALREADY) {
+ if (err == WSAEINPROGRESS || err == WSAEALREADY) {
return OK;
}
@@ -122,7 +117,7 @@ Error StreamPeerWinsock::write(const uint8_t* p_data,int p_bytes, int &r_sent, b
if (status != STATUS_CONNECTED) {
- if (_poll_connection(p_block) != OK) {
+ if (_poll_connection() != OK) {
return FAILED;
};
@@ -136,20 +131,18 @@ Error StreamPeerWinsock::write(const uint8_t* p_data,int p_bytes, int &r_sent, b
int data_to_send = p_bytes;
const uint8_t *offset = p_data;
if (sockfd == -1) return FAILED;
- errno = 0;
int total_sent = 0;
while (data_to_send) {
int sent_amount = send(sockfd, (const char*)offset, data_to_send, 0);
- //printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno);
if (sent_amount == -1) {
if (WSAGetLastError() != WSAEWOULDBLOCK) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -175,14 +168,14 @@ Error StreamPeerWinsock::write(const uint8_t* p_data,int p_bytes, int &r_sent, b
Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block) {
- if (!is_connected()) {
+ if (!is_connected_to_host()) {
return FAILED;
};
if (status != STATUS_CONNECTED) {
- if (_poll_connection(p_block) != OK) {
+ if (_poll_connection() != OK) {
return FAILED;
};
@@ -195,7 +188,6 @@ Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bo
int to_read = p_bytes;
int total_read = 0;
- errno = 0;
while (to_read) {
@@ -206,7 +198,7 @@ Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bo
if (WSAGetLastError() != WSAEWOULDBLOCK) {
perror("shit?");
- disconnect();
+ disconnect_from_host();
ERR_PRINT("Server disconnected!\n");
return FAILED;
};
@@ -218,7 +210,7 @@ Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bo
};
_block(sockfd, true, false);
} else if (read == 0) {
- disconnect();
+ disconnect_from_host();
return ERR_FILE_EOF;
} else {
@@ -257,14 +249,14 @@ Error StreamPeerWinsock::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_
StreamPeerTCP::Status StreamPeerWinsock::get_status() const {
if (status == STATUS_CONNECTING) {
- _poll_connection(false);
+ _poll_connection();
};
return status;
};
-bool StreamPeerWinsock::is_connected() const {
+bool StreamPeerWinsock::is_connected_to_host() const {
if (status == STATUS_NONE || status == STATUS_ERROR) {
@@ -277,11 +269,12 @@ bool StreamPeerWinsock::is_connected() const {
return (sockfd!=INVALID_SOCKET);
};
-void StreamPeerWinsock::disconnect() {
+void StreamPeerWinsock::disconnect_from_host() {
if (sockfd != INVALID_SOCKET)
closesocket(sockfd);
sockfd=INVALID_SOCKET;
+ sock_type = IP::TYPE_NONE;
status = STATUS_NONE;
@@ -289,23 +282,24 @@ void StreamPeerWinsock::disconnect() {
peer_port = 0;
};
-void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type) {
+void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type) {
- ip_type = p_ip_type;
sockfd = p_sockfd;
+ sock_type = p_sock_type;
status = STATUS_CONNECTING;
peer_host = p_host;
peer_port = p_port;
};
-Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) {
+Error StreamPeerWinsock::connect_to_host(const IP_Address& p_host, uint16_t p_port) {
- ERR_FAIL_COND_V( p_host == IP_Address(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V( !p_host.is_valid(), ERR_INVALID_PARAMETER);
- sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
+ sock_type = p_host.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+ sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == INVALID_SOCKET) {
ERR_PRINT("Socket creation failed!");
- disconnect();
+ disconnect_from_host();
//perror("socket");
return FAILED;
};
@@ -313,18 +307,18 @@ Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) {
unsigned long par = 1;
if (ioctlsocket(sockfd, FIONBIO, &par)) {
perror("setting non-block mode");
- disconnect();
+ disconnect_from_host();
return FAILED;
};
struct sockaddr_storage their_addr;
- size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, ip_type);
+ size_t addr_size = _set_sockaddr(&their_addr, p_host, p_port, sock_type);
if (::connect(sockfd, (struct sockaddr *)&their_addr,addr_size) == SOCKET_ERROR) {
if (WSAGetLastError() != WSAEWOULDBLOCK) {
ERR_PRINT("Connection to remote host failed!");
- disconnect();
+ disconnect_from_host();
return FAILED;
};
status = STATUS_CONNECTING;
@@ -339,7 +333,7 @@ Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) {
};
void StreamPeerWinsock::set_nodelay(bool p_enabled) {
- ERR_FAIL_COND(!is_connected());
+ ERR_FAIL_COND(!is_connected_to_host());
int flag=p_enabled?1:0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(int));
}
@@ -365,15 +359,15 @@ uint16_t StreamPeerWinsock::get_connected_port() const {
StreamPeerWinsock::StreamPeerWinsock() {
+ sock_type = IP::TYPE_NONE;
sockfd = INVALID_SOCKET;
status = STATUS_NONE;
peer_port = 0;
- ip_type = IP::TYPE_ANY;
};
StreamPeerWinsock::~StreamPeerWinsock() {
- disconnect();
+ disconnect_from_host();
};
diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h
index e17a7167e1..7cf60fc10e 100644
--- a/platform/windows/stream_peer_winsock.h
+++ b/platform/windows/stream_peer_winsock.h
@@ -41,12 +41,13 @@ class StreamPeerWinsock : public StreamPeerTCP {
protected:
mutable Status status;
+ IP::Type sock_type;
int sockfd;
Error _block(int p_sockfd, bool p_read, bool p_write) const;
- Error _poll_connection(bool p_block) const;
+ Error _poll_connection() const;
IP_Address peer_host;
int peer_port;
@@ -58,7 +59,7 @@ protected:
public:
- virtual Error connect(const IP_Address& p_host, uint16_t p_port);
+ virtual Error connect_to_host(const IP_Address& p_host, uint16_t p_port);
virtual Error put_data(const uint8_t* p_data,int p_bytes);
virtual Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
@@ -68,14 +69,14 @@ public:
virtual int get_available_bytes() const;
- void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_ip_type);
+ void set_socket(int p_sockfd, IP_Address p_host, int p_port, IP::Type p_sock_type);
virtual IP_Address get_connected_host() const;
virtual uint16_t get_connected_port() const;
- virtual bool is_connected() const;
+ virtual bool is_connected_to_host() const;
virtual Status get_status() const;
- virtual void disconnect();
+ virtual void disconnect_from_host();
static void make_default();
static void cleanup();
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index 1c3682adfa..883741b115 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -63,10 +63,20 @@ void TCPServerWinsock::cleanup() {
};
-Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_hosts) {
+Error TCPServerWinsock::listen(uint16_t p_port,const IP_Address p_bind_address) {
+
+ ERR_FAIL_COND_V(listen_sockfd!=-1,ERR_ALREADY_IN_USE);
+ ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
int sockfd;
- sockfd = _socket_create(ip_type, SOCK_STREAM, IPPROTO_TCP);
+ sock_type = IP::TYPE_ANY;
+
+ // If the bind address is valid use its type as the socket type
+ if (p_bind_address.is_valid())
+ sock_type = p_bind_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6;
+
+
+ sockfd = _socket_create(sock_type, SOCK_STREAM, IPPROTO_TCP);
ERR_FAIL_COND_V(sockfd == INVALID_SOCKET, FAILED);
unsigned long par = 1;
@@ -77,7 +87,7 @@ Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_ho
};
struct sockaddr_storage my_addr;
- size_t addr_size = _set_listen_sockaddr(&my_addr, p_port, ip_type, p_accepted_hosts);
+ size_t addr_size = _set_listen_sockaddr(&my_addr, p_port, sock_type, p_bind_address);
int reuse=1;
if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) {
@@ -150,7 +160,7 @@ Ref<StreamPeerTCP> TCPServerWinsock::take_connection() {
int port;
_set_ip_addr_port(ip, port, &their_addr);
- conn->set_socket(fd, ip, port, ip_type);
+ conn->set_socket(fd, ip, port, sock_type);
return conn;
};
@@ -162,13 +172,14 @@ void TCPServerWinsock::stop() {
};
listen_sockfd = -1;
+ sock_type = IP::TYPE_NONE;
};
TCPServerWinsock::TCPServerWinsock() {
listen_sockfd = INVALID_SOCKET;
- ip_type = IP::TYPE_ANY;
+ sock_type = IP::TYPE_NONE;
};
TCPServerWinsock::~TCPServerWinsock() {
diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h
index 5c544436a7..afbd1e9c87 100644
--- a/platform/windows/tcp_server_winsock.h
+++ b/platform/windows/tcp_server_winsock.h
@@ -34,12 +34,13 @@
class TCPServerWinsock : public TCP_Server {
int listen_sockfd;
+ IP::Type sock_type;
static TCP_Server* _create();
public:
- virtual Error listen(uint16_t p_port,const List<String> *p_accepted_hosts=NULL);
+ virtual Error listen(uint16_t p_port, const IP_Address p_bind_address=IP_Address("*"));
virtual bool is_connection_available() const;
virtual Ref<StreamPeerTCP> take_connection();
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 4adb47938c..caa5e4fc89 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -88,7 +88,7 @@ Error ContextGL_X11::initialize() {
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
-// const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
+ //const char *extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
@@ -130,13 +130,6 @@ Error ContextGL_X11::initialize() {
x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &swa);
ERR_FAIL_COND_V(!x11_window,ERR_UNCONFIGURED);
XMapWindow(x11_display, x11_window);
- while(true) {
- // wait for mapnotify (window created)
- XEvent e;
- XNextEvent(x11_display, &e);
- if (e.type == MapNotify)
- break;
- }
//};
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index efe377ad92..efea700224 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/x11/context_gl_x11.h
@@ -48,7 +48,7 @@ class ContextGL_X11 : public ContextGL {
ContextGL_X11_Private *p;
OS::VideoMode default_video_mode;
-// ::Colormap x11_colormap;
+ //::Colormap x11_colormap;
::Display *x11_display;
::Window& x11_window;
bool double_buffer;
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index b5f6359d21..89cf639114 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -61,6 +61,7 @@ def get_opts():
('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_lto', 'Use link time optimization', 'no'),
('pulseaudio', 'Detect & Use pulseaudio', 'yes'),
('udev', 'Use udev for gamepad connection callbacks', 'no'),
('debug_release', 'Add debug symbols to release version', 'no'),
@@ -97,12 +98,12 @@ def configure(env):
env.extra_suffix = ".llvm"
if (env["use_sanitizer"] == "yes"):
- env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
if (env["use_leak_sanitizer"] == "yes"):
- env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
@@ -111,22 +112,28 @@ def configure(env):
# env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
# env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
- if (env["target"] == "release"):
+ 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.Append(CCFLAGS=['-g2'])
- else:
- env.Append(CCFLAGS=['-O3', '-ffast-math'])
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+ env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
if (env["debug_release"] == "yes"):
- env.Append(CCFLAGS=['-g2'])
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Prepend(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env.ParseConfig('pkg-config x11 --cflags --libs')
env.ParseConfig('pkg-config xinerama --cflags --libs')
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index c1af323453..5c7f98c1f3 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -28,11 +28,27 @@
/*************************************************************************/
#include "export.h"
#include "platform/x11/logo.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "scene/resources/texture.h"
+
+
void register_x11_exporter() {
+ Ref<EditorExportPlatformPC> platform;
+ platform.instance();
+
+ Image img(_x11_logo);
+ Ref<ImageTexture> logo;
+ logo.instance();
+ logo->create_from_image(img);
+ platform->set_logo(logo);
+ platform->set_name("Linux/X11");
+ platform->set_extension("");
+
+ EditorExport::get_singleton()->add_export_platform(platform);
+
+ #if 0
Image img(_x11_logo);
Ref<ImageTexture> logo = memnew( ImageTexture );
logo->create_from_image(img);
@@ -49,4 +65,6 @@ void register_x11_exporter() {
EditorImportExport::get_singleton()->add_export_platform(exporter);
}
+ #endif
}
+
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index f85ba17020..adb919c2f1 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -26,6 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include <unistd.h>
+#include <limits.h>
+#include <stdlib.h>
+
#include "main/main.h"
#include "os_x11.h"
@@ -33,6 +37,9 @@ int main(int argc, char* argv[]) {
OS_X11 os;
+ char *cwd = (char*)malloc(PATH_MAX);
+ getcwd(cwd, PATH_MAX);
+
Error err = Main::setup(argv[0],argc-1,&argv[1]);
if (err!=OK)
return 255;
@@ -41,5 +48,8 @@ int main(int argc, char* argv[]) {
os.run(); // it is actually the OS that decides how to run
Main::cleanup();
+ chdir(cwd);
+ free(cwd);
+
return os.get_exit_code();
}
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index 362999661e..bdbd2912a6 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -219,15 +219,6 @@ void JoypadLinux::monitor_joypads() {
}
}
-int JoypadLinux::get_free_joy_slot() const {
-
- for (int i = 0; i < JOYPADS_MAX; i++) {
-
- if (joypads[i].fd == -1) return i;
- }
- return -1;
-}
-
int JoypadLinux::get_joy_from_path(String p_path) const {
for (int i = 0; i < JOYPADS_MAX; i++) {
@@ -329,7 +320,7 @@ void JoypadLinux::setup_joypad_properties(int p_id) {
void JoypadLinux::open_joypad(const char *p_path) {
- int joy_num = get_free_joy_slot();
+ int joy_num = input->get_unused_joy_id();
int fd = open(p_path, O_RDWR | O_NONBLOCK);
if (fd != -1 && joy_num != -1) {
diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h
index 18ad199f6b..310f5c1488 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -81,7 +81,6 @@ private:
static void joy_thread_func(void *p_user);
int get_joy_from_path(String path) const;
- int get_free_joy_slot() const;
void setup_joypad_properties(int p_id);
void close_joypad(int p_id = -1);
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 7b92ed95de..d25fe40c4d 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/x11/key_mapping_x11.cpp
@@ -90,8 +90,8 @@ static _XTranslatePair _xkeysym_to_keycode[]={
{ XK_Begin, KEY_CLEAR },
{ XK_Insert, KEY_INSERT },
{ XK_Delete, KEY_DELETE },
-// { XK_KP_Equal, KEY_EQUAL },
-// { XK_KP_Separator, KEY_COMMA },
+ //{ XK_KP_Equal, KEY_EQUAL },
+ //{ XK_KP_Separator, KEY_COMMA },
{ XK_KP_Decimal, KEY_KP_PERIOD },
{ XK_KP_Delete, KEY_KP_PERIOD },
{ XK_KP_Enter, KEY_KP_ENTER },
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 9a4b19f2db..a4ed08f330 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -82,14 +82,14 @@ OS::VideoMode OS_X11::get_default_video_mode() const {
}
int OS_X11::get_audio_driver_count() const {
- return AudioDriverManagerSW::get_driver_count();
+ return AudioDriverManager::get_driver_count();
}
const char *OS_X11::get_audio_driver_name(int p_driver) const {
- AudioDriverSW* driver = AudioDriverManagerSW::get_driver(p_driver);
+ AudioDriver* driver = AudioDriverManager::get_driver(p_driver);
ERR_FAIL_COND_V( !driver, "" );
- return AudioDriverManagerSW::get_driver(p_driver)->get_name();
+ return AudioDriverManager::get_driver(p_driver)->get_name();
}
void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
@@ -269,21 +269,21 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
XFree(xsh);
}
- AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
+ AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
audio_driver_index=p_audio_driver;
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
bool success=false;
audio_driver_index=-1;
- for(int i=0;i<AudioDriverManagerSW::get_driver_count();i++) {
+ for(int i=0;i<AudioDriverManager::get_driver_count();i++) {
if (i==p_audio_driver)
continue;
- AudioDriverManagerSW::get_driver(i)->set_singleton();
- if (AudioDriverManagerSW::get_driver(i)->init()==OK) {
+ AudioDriverManager::get_driver(i)->set_singleton();
+ if (AudioDriverManager::get_driver(i)->init()==OK) {
success=true;
- print_line("Audio Driver Failed: "+String(AudioDriverManagerSW::get_driver(p_audio_driver)->get_name()));
- print_line("Using alternate audio driver: "+String(AudioDriverManagerSW::get_driver(i)->get_name()));
+ print_line("Audio Driver Failed: "+String(AudioDriverManager::get_driver(p_audio_driver)->get_name()));
+ print_line("Using alternate audio driver: "+String(AudioDriverManager::get_driver(i)->get_name()));
audio_driver_index=i;
break;
}
@@ -294,13 +294,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
}
- sample_manager = memnew( SampleManagerMallocSW );
- audio_server = memnew( AudioServerSW(sample_manager) );
- audio_server->init();
- spatial_sound_server = memnew( SpatialSoundServerSW );
- spatial_sound_server->init();
- spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
- spatial_sound_2d_server->init();
ERR_FAIL_COND(!visual_server);
@@ -457,6 +450,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
physics_2d_server->init();
input = memnew( InputDefault );
+
+ window_has_focus = true; // Set focus to true at init
#ifdef JOYDEV_ENABLED
joypad = memnew( JoypadLinux(input));
#endif
@@ -469,25 +464,21 @@ void OS_X11::finalize() {
memdelete(main_loop);
main_loop=NULL;
- spatial_sound_server->finish();
- memdelete(spatial_sound_server);
- spatial_sound_2d_server->finish();
- memdelete(spatial_sound_2d_server);
+ for (int i = 0; i < get_audio_driver_count(); i++) {
+ AudioDriverManager::get_driver(i)->finish();
+ }
- //if (debugger_connection_console) {
-// memdelete(debugger_connection_console);
-//}
+ /*
+ if (debugger_connection_console) {
+ memdelete(debugger_connection_console);
+ }
+ */
#ifdef JOYDEV_ENABLED
memdelete(joypad);
#endif
memdelete(input);
- memdelete(sample_manager);
-
- audio_server->finish();
- memdelete(audio_server);
-
visual_server->finish();
memdelete(visual_server);
//memdelete(rasterizer);
@@ -523,6 +514,7 @@ void OS_X11::finalize() {
args.clear();
+
}
@@ -531,17 +523,21 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
if (p_mode==mouse_mode)
return;
- if (mouse_mode==MOUSE_MODE_CAPTURED)
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED)
XUngrabPointer(x11_display, CurrentTime);
- if (mouse_mode!=MOUSE_MODE_VISIBLE && p_mode==MOUSE_MODE_VISIBLE)
- XUndefineCursor(x11_display,x11_window);
- if (p_mode!=MOUSE_MODE_VISIBLE && mouse_mode==MOUSE_MODE_VISIBLE) {
- XDefineCursor(x11_display,x11_window,null_cursor);
+
+ // The only modes that show a cursor are VISIBLE and CONFINED
+ bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
+
+ if (showCursor) {
+ XUndefineCursor(x11_display,x11_window); // show cursor
+ } else {
+ XDefineCursor(x11_display,x11_window,null_cursor); // hide cursor
}
mouse_mode=p_mode;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) {
while(true) {
//flush pending motion events
@@ -559,11 +555,10 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
}
}
- if (XGrabPointer(x11_display, x11_window, True,
- ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask, GrabModeAsync, GrabModeAsync,
- x11_window, None, CurrentTime) !=
- GrabSuccess) {
+ if (XGrabPointer(
+ x11_display, x11_window, True,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime) != GrabSuccess) {
ERR_PRINT("NO GRAB");
}
@@ -783,13 +778,31 @@ void OS_X11::set_window_position(const Point2& p_position) {
}
Size2 OS_X11::get_window_size() const {
- XWindowAttributes xwa;
- XGetWindowAttributes(x11_display, x11_window, &xwa);
- return Size2i(xwa.width, xwa.height);
+ // Use current_videomode width and height instead of XGetWindowAttributes
+ // since right after a XResizeWindow the attributes may not be updated yet
+ return Size2i(current_videomode.width, current_videomode.height);
}
void OS_X11::set_window_size(const Size2 p_size) {
+ // If window resizable is disabled we need to update the attributes first
+ if (is_window_resizable() == false) {
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = p_size.x;
+ xsh->max_width = p_size.x;
+ xsh->min_height = p_size.y;
+ xsh->max_height = p_size.y;
+ XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
+ }
+
+ // Resize the window
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
+
+ // Update our videomode width and height
+ current_videomode.width = p_size.x;
+ current_videomode.height = p_size.y;
}
void OS_X11::set_window_fullscreen(bool p_enabled) {
@@ -803,15 +816,15 @@ bool OS_X11::is_window_fullscreen() const {
void OS_X11::set_window_resizable(bool p_enabled) {
XSizeHints *xsh;
+ Size2 size = get_window_size();
+
xsh = XAllocSizeHints();
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
if(!p_enabled) {
- XWindowAttributes xwa;
- XGetWindowAttributes(x11_display,x11_window,&xwa);
- xsh->min_width = xwa.width;
- xsh->max_width = xwa.width;
- xsh->min_height = xwa.height;
- xsh->max_height = xwa.height;
+ 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);
@@ -1228,7 +1241,7 @@ static Property read_property(Display* p_display, Window p_window, Atom p_proper
}while(bytes_after != 0);
- Property p = {ret, actual_format, nitems, actual_type};
+ Property p = {ret, actual_format, (int)nitems, actual_type};
return p;
}
@@ -1268,6 +1281,10 @@ void OS_X11::process_xevents() {
do_mouse_warp=false;
+
+ // Is the current mouse mode one where it needs to be grabbed.
+ bool mouse_mode_grab = mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED;
+
while (XPending(x11_display) > 0) {
XEvent event;
XNextEvent(x11_display, &event);
@@ -1286,35 +1303,45 @@ void OS_X11::process_xevents() {
minimized = (visibility->state == VisibilityFullyObscured);
} break;
case LeaveNotify: {
-
- if (main_loop && mouse_mode!=MOUSE_MODE_CAPTURED)
+ if (main_loop && !mouse_mode_grab)
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
if (input)
input->set_mouse_in_window(false);
} break;
case EnterNotify: {
-
- if (main_loop && mouse_mode!=MOUSE_MODE_CAPTURED)
+ if (main_loop && !mouse_mode_grab)
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
if (input)
input->set_mouse_in_window(true);
} break;
case FocusIn:
minimized = false;
+ window_has_focus = true;
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
- XGrabPointer(x11_display, x11_window, True,
- ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask, GrabModeAsync, GrabModeAsync,
- x11_window, None, CurrentTime);
+ if (mouse_mode_grab) {
+ // Show and update the cursor if confined and the window regained focus.
+ if (mouse_mode==MOUSE_MODE_CONFINED)
+ XUndefineCursor(x11_display, x11_window);
+ else if (mouse_mode==MOUSE_MODE_CAPTURED) // or re-hide it in captured mode
+ XDefineCursor(x11_display, x11_window, null_cursor);
+
+ XGrabPointer(
+ x11_display, x11_window, True,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+ GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
}
break;
case FocusOut:
+ window_has_focus = false;
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode_grab) {
//dear X11, I try, I really try, but you never work, you do whathever you want.
+ if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ // Show the cursor if we're in captured mode so it doesn't look weird.
+ XUndefineCursor(x11_display, x11_window);
+ }
XUngrabPointer(x11_display, CurrentTime);
}
break;
@@ -1334,7 +1361,7 @@ void OS_X11::process_xevents() {
/* exit in case of a mouse button press */
last_timestamp=event.xbutton.time;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
event.xbutton.x=last_mouse_pos.x;
event.xbutton.y=last_mouse_pos.y;
}
@@ -1357,7 +1384,6 @@ void OS_X11::process_xevents() {
mouse_event.mouse_button.pressed=(event.type==ButtonPress);
-
if (event.type==ButtonPress && event.xbutton.button==1) {
uint64_t diff = get_ticks_usec()/1000 - last_click_ms;
@@ -1391,7 +1417,6 @@ void OS_X11::process_xevents() {
// PLEASE DO ME A FAVOR AND DIE DROWNED IN A FECAL
// MOUNTAIN BECAUSE THAT'S WHERE YOU BELONG.
-
while(true) {
if (mouse_mode==MOUSE_MODE_CAPTURED && event.xmotion.x==current_videomode.width/2 && event.xmotion.y==current_videomode.height/2) {
//this is likely the warp event since it was warped here
@@ -1433,7 +1458,7 @@ void OS_X11::process_xevents() {
Point2i new_center = pos;
pos = last_mouse_pos + ( pos - center );
center=new_center;
- do_mouse_warp=true;
+ do_mouse_warp=window_has_focus; // warp the cursor if we're focused in
#else
//Dear X11, thanks for making my life miserable
@@ -1467,8 +1492,8 @@ void OS_X11::process_xevents() {
input->set_mouse_pos(pos);
motion_event.mouse_motion.global_x=pos.x;
motion_event.mouse_motion.global_y=pos.y;
- motion_event.mouse_motion.speed_x=input->get_mouse_speed().x;
- motion_event.mouse_motion.speed_y=input->get_mouse_speed().y;
+ motion_event.mouse_motion.speed_x=input->get_last_mouse_speed().x;
+ motion_event.mouse_motion.speed_y=input->get_last_mouse_speed().y;
motion_event.mouse_motion.relative_x=rel.x;
motion_event.mouse_motion.relative_y=rel.y;
@@ -1476,8 +1501,11 @@ void OS_X11::process_xevents() {
last_mouse_pos=pos;
// printf("rel: %d,%d\n", rel.x, rel.y );
-
- input->parse_input_event( motion_event);
+ // Don't propagate the motion event unless we have focus
+ // this is so that the relative motion doesn't get messed up
+ // after we regain focus.
+ if (window_has_focus || !mouse_mode_grab)
+ input->parse_input_event( motion_event);
} break;
case KeyPress:
@@ -1923,10 +1951,10 @@ void OS_X11::run() {
main_loop->init();
-// uint64_t last_ticks=get_ticks_usec();
+ //uint64_t last_ticks=get_ticks_usec();
-// int frames=0;
-// uint64_t frame=0;
+ //int frames=0;
+ //uint64_t frame=0;
while (!force_quit) {
@@ -1982,20 +2010,20 @@ void OS_X11::set_context(int p_context) {
OS_X11::OS_X11() {
#ifdef RTAUDIO_ENABLED
- AudioDriverManagerSW::add_driver(&driver_rtaudio);
+ AudioDriverManager::add_driver(&driver_rtaudio);
#endif
#ifdef PULSEAUDIO_ENABLED
- AudioDriverManagerSW::add_driver(&driver_pulseaudio);
+ AudioDriverManager::add_driver(&driver_pulseaudio);
#endif
#ifdef ALSA_ENABLED
- AudioDriverManagerSW::add_driver(&driver_alsa);
+ AudioDriverManager::add_driver(&driver_alsa);
#endif
- if(AudioDriverManagerSW::get_driver_count() == 0){
+ if(AudioDriverManager::get_driver_count() == 0){
WARN_PRINT("No sound driver found... Defaulting to dummy driver");
- AudioDriverManagerSW::add_driver(&driver_dummy);
+ AudioDriverManager::add_driver(&driver_dummy);
}
minimized = false;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index bf676b5edf..3ec358f103 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -37,10 +37,7 @@
//#include "servers/visual/visual_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
#include "servers/physics_server.h"
-#include "servers/audio/audio_server_sw.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
+#include "servers/audio_server.h"
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/alsa/audio_driver_alsa.h"
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
@@ -135,14 +132,9 @@ class OS_X11 : public OS_Unix {
virtual void delete_main_loop();
IP_Unix *ip_unix;
- AudioServerSW *audio_server;
- SampleManagerMallocSW *sample_manager;
- SpatialSoundServerSW *spatial_sound_server;
- SpatialSound2DServerSW *spatial_sound_2d_server;
-
bool force_quit;
bool minimized;
-
+ bool window_has_focus;
bool do_mouse_warp;
const char *cursor_theme;
diff --git a/prop_renames.txt b/prop_renames.txt
deleted file mode 100644
index 9821a32b68..0000000000
--- a/prop_renames.txt
+++ /dev/null
@@ -1,524 +0,0 @@
-[Object]
-script/script = script
-
-[Node]
-pause/pause_mode = pause_mode
-
-[Control]
-
-anchor/left = anchor_left
-anchor/right = anchor_right
-anchor/bottom = anchor_bottom
-anchor/top = anchor_top
-
-focus_neighbour/left=focus_neighbour_left
-focus_neighbour/right=focus_neighbour_right
-focus_neighbour/bottom=focus_neighbour_bottom
-focus_neighbour/top=focus_neighbour_top
-focus/ignore_mouse = focus_ignore_mouse
-focus/stop_mouse = focus_stop_mouse
-
-size_flags/horizontal = size_flags_horizontal
-size_flags/vertical = size_flags_vertical
-size_flags/stretch_ratio = size_flags_stretch_ratio
-theme/theme = theme
-
-[CanvasItem]
-
-visibility/visible = visible
-visibility/behind_parent = show_behind_parent
-visibility/on_top = show_on_top
-visibility/light_mask = light_mask
-material/material = material
-material/use_parent = use_parent_material
-
-
-[Resource]
-
-resource/path = resource_path
-resource/name = resource_name
-
-
-[Area2D]
-
-collision/layers = collision_layers
-collision/mask = collision_mask
-
-[Camera2D]
-
-limit/left = limit_left
-limit/right = limit_right
-limit/bottom = limit_bottom
-limit/top = limit_top
-limit/smoothed = limit_smoothed
-
-draw_margin/h_enabled = draw_margin_h_enabled
-draw_margin/v_enabled = draw_margin_v_enabled
-
-smoothing/enable = smoothing_enabled
-smoothing/speed = smoothing_speed
-
-drag_margin/left = drag_margin_left
-drag_margin/top = drag_margin_top
-drag_margin/right = drag_margin_right
-drag_margin/bottom = drag_margin_bottom
-
-[CollisionObject2D]
-
-input/pickable = input_pickable
-
-[Joint2D]
-
-bias/bias = bias
-collision/exclude_nodes = disable_collision
-
-[Light2D]
-
-range/height = range_height
-range/z_min = range_z_min
-range/z_max = range_z_max
-range/layer_max = range_layer_max
-range/item_cull_mask = range_item_cull_max
-
-shadow/enabled = shadow_enabled
-shadow/color = shadow_color
-shadow/buffer_size = shadow_buffer_size
-shadow/gradient_length = shadow_gradient_length
-shadow/filter = shadow_filter
-shadow/item_cull_mask = shadow_item_cull_mask
-
-[Node2D]
-
-transform/pos = position
-transform/rot = rotation
-transform/scale = scale
-z/z = z
-z/relative = z_as_relative
-
-[ParallaxBackground]
-
-scroll/offset = scroll_offset
-scroll/base_offset = scroll_base_offset
-scroll/base_scale = scroll_base_scale
-scroll/limit_begin = scroll_limit_begin
-scroll/limit_end = scroll_limit_end
-scroll/ignore_camera_zoom = scroll_ignore_camera_zoom
-
-[ParallaxLayer]
-
-motion/scale = motion_scale
-motion/offset = motion_offset
-motion/mirroring = motion_mirroring
-
-[PhysicsBody2D]
-
-collision/layers = collision_layers
-collision/mask = collision_mask
-
-[Polygon2D]
-
-texture/texture = texture
-texture/offset = texture_offset
-texture/rotation = texture_rotation
-texture/scale = texture_scale
-
-invert/enable = invert_enable
-invert/border = invert_border
-
-[SamplePlayer2D]
-
-config/polyphony = polyphony
-config/samples = samples
-config/pitch_random = random_pitch
-
-[SoundPlayer2D]
-
-params/volume_db = volume_db
-params/pitch_scale = pitch_scale
-params/attenuation/min_distance = attenuation_min_distance
-params/attenuation/max_distance = attenuation_max_distance
-params/attenuation/distance_exp = attenuation_distance_exp
-
-[TileMap]
-
-cell/size = cell_size
-cell/quadrant_size = cell_quadrant_size
-cell/half_offset = cell_half_offset
-cell/tile_origin = cell_tile_origin
-cell/y_sort = cell_y_sort
-
-collision/use_kinematic = collision_use_kinematic
-collision/friction = collision_friction
-collision/bounce = collision_bounce
-collision/layers = collision_layers
-collision/mask = collision_mask
-
-occluder/light_mask = occluder_light_mask
-
-[VisibilityEnabler2D]
-
-enabler/pause_animations = pause_animations
-enabler/freeze_bodies = freeze_bodies
-enabler/pause_particles = pause_particles
-enabler/pause_animated_sprites = pause_animated_sprites
-enabler/process_parent = process_parent
-enabler/fixed_process_parent = fixed_process_parent
-
-
-[YSort]
-
-sort/enabled = sort_enabled
-
-
-[Area]
-
-collision/layers = collision_layers
-collision/mask = collision_mask
-
-
-[CollisionObject]
-
-input/ray_pickable = input_ray_pickable
-input/capture_on_drag = input_capture_on_drag
-
-[Light]
-
-light/color = light_color
-light/energy = light_energy
-light/negative = light_negative
-light/specular = light_specular
-light/cull_mask = light_cull_mask
-
-shadow/enabled = shadow_enabled
-shadow/color = shadow_color
-shadow/bias = shadow_bias
-shadow/max_distance = shadow_max_distance
-editor/editor_only = editor_only
-
-[DirectionalLight]
-
-directional_shadow/mode = directional_shadow_mode
-directional_shadow/split_1 = directional_shadow_split_1
-directional_shadow/split_2 = directional_shadow_split_2
-directional_shadow/split_3 = directional_shadow_split_3
-directional_shadow/blend_splits = directional_shadow_blend_splits
-directional_shadow/normal_bias = directional_shadow_normal_bias
-directional_shadow/bias_split_scale = directional_shadow_bias_split_scale
-
-[OmniLight]
-
-omni/range = omni_range
-omni/attenuation = omni_attenuation
-omni/shadow_mode = omni_shadow_mode
-omni/shadow_detail = omni_shadow_detail
-
-[SpotLight]
-
-spot/range = spot_range
-spot/attenuation = spot_attenuation
-spot/angle = spot_angle
-spot/spot_attenuation = spot_angle_attenuation
-
-[MeshInstance]
-
-mesh/mesh = mesh
-mesh/skeleton = skeleton
-
-
-[PhysicsBody]
-
-collision/layers = collision_layers
-collision/mask = collision_mask
-
-[Quad]
-
-quad/axis = axis
-quad/size = size
-quad/offset = offset
-quad/centered = centered
-
-[Spatial]
-
-transform/local = transform
-transform/transiation = translation
-transform/rotation = rotation
-transform/scale = scale
-visibility/visible = visible
-
-[SpatialPlayer]
-
-params/volume_db = volume_db
-params/pitch_scale = pitch_scale
-params/attenuation/min_distance = attenuation_min_distance
-params/attenuation/max_distance = attenuation_max_distance
-params/attenuation/distance_exp = attenuation_distance_exp
-params/emission_cone/degrees = emission_cone_degrees
-params/emission_cone/attenuation_db = emission_cone_attenuation_db
-
-[SpatialSamplePlayer]
-
-config/polyphony = polyphony
-config/samples = samples
-
-[Sprite3D]
-
-flags/transparent = transparent
-flags/shaded = shaded
-flags/alpha_cut = alpha_cut
-
-[VehicleWheel]
-
-type/traction = use_as_traction
-type/steering = use_as_steering
-
-wheel/radius = wheel_radius
-wheel/rest_length = wheel_rest_length
-wheel/friction_slip = wheel_friction_sleep
-
-suspension/travel = suspension_travel
-suspension/stiffness = suspension_stiffness
-suspension/max_force = suspension_max_force
-damping/compression = damping_compression
-damping/relaxation = damping_relaxation
-
-[VehicleBody]
-
-motion/engine_force = engine_force
-motion/breake = breake
-motion/steering = steering
-body/mass = mass
-body/friction = friction
-
-[VisibilityEnabler]
-
-enabler/pause_animations = pause_animations
-enabler/freeze_bodies = freeze_bodies
-
-[GeometryInstance]
-
-geometry/material_override = material_override
-geometry/cast_shadow = cast_shadow
-geometry/extra_cull_margin = extra_cull_margin
-geometry/billboard = use_as_billboard
-geometry/billboard_y = use_as_y_billboard
-geometry/depth_scale = use_depth_scale
-geometry/visible_in_all_rooms = visible_in_all_rooms
-geometry/use_baked_light = use_in_baked_light
-
-
-
-[AnimationPlayer]
-
-playback/process_mode = playback_process_mode
-playback/default_blend_time = playback_default_blend_time
-root/root = root_node
-
-[AnimationTreePlayer]
-
-playback/process_mode = playback_process_mode
-
-[EventPlayer]
-
-stream/stream = stream
-stream/play = play
-stream/loop = loop
-stream/volume_db = volume_db
-stream/pitch_scale = pitch_scale
-stream/tempo_scale = tempo_scale
-stream/autoplay = autoplay
-stream/paused = paused
-
-[StreamPlayer]
-
-stream/stream = stream
-stream/play = play
-stream/loop = loop
-stream/volume_db = volume_db
-stream/autoplay = autoplay
-stream/paused = paused
-stream/loop_restart_time = loop_restart_time
-stream/buffering_ms = buffering_ms
-
-[SpatialStreamPlayer]
-
-stream/stream = stream
-stream/play = play
-stream/loop = loop
-stream/volume_db = volume_db
-stream/autoplay = autoplay
-stream/paused = paused
-stream/loop_restart_time = loop_restart_time
-stream/buffering_ms = buffering_ms
-
-[WindowDialog]
-
-window/title = window_title
-
-[AcceptDialog]
-
-dialog/text = dialog_text
-dialog/hide_on_ok = dialog_hide_on_ok
-
-[LineEdit]
-
-placeholder/text = placeholder_text
-placeholder/alpha = placeholder_alpha
-caret/caret_blink = caret_blink
-caret/caret_blink_speed = caret_blink_speed
-
-[Patch9Frame]
-
-patch_margin/left = patch_margin_left
-patch_margin/right = patch_margin_right
-patch_margin/top = patch_margin_top
-patch_margin/bottom = patch_margin_bottom
-
-
-[Popup]
-
-popup/exclusive = popup_exclusive
-
-[ProgressBar]
-
-percent/visible = percent_visible
-
-[Range]
-
-range/min = min_value
-range/max = max_value
-range/step = step
-range/page = page
-range/value = value
-range/exp_edit = exp_edit
-range/rounded = rounded
-
-
-[RigidBody2D]
-
-velocity/linear = linear_velocity
-velocity/angular = angular_velocity
-damp_override_linear = linear_damp
-damp_override_angular = angular_damp
-
-
-[RigidBody]
-
-velocity/linear = linear_velocity
-velocity/angular = angular_velocity
-damp_override_linear = linear_damp
-damp_override_angular = angular_damp
-
-[Tween]
-
-playback/process_mode = playback_process_mode
-
-[RichTextLabel]
-
-bbcode/enabled = bbcode_enabled
-bbcode/bbcode = bbcode_text
-
-[ScrollContainer]
-
-scroll/horizontal = scroll_horizontal
-scroll/vertical = scroll_vertical
-
-[SplitContainer]
-
-split/offset = split_offset
-split/collapsed = collapsed
-split/dragger_visibility = dragger_visibility
-
-[TextEdit]
-
-caret/block_caret = caret_block_mode
-caret/caret_blink = caret_blink
-caret/caret_blink_speed = caret_blink_speed
-
-[TextureButton]
-
-textures/normal = texture_normal
-textures/pressed = texture_pressed
-textures/hover = texture_hover
-textures/disabled = texture_disabled
-textures/focused = texture_focused
-textures/click_mask = texture_click_mask
-params/scale = texture_scale
-params/modulate = self_modulate
-
-[TextureProgress]
-
-texture/under = texture_under
-texture/over = texture_over
-texture/progress = texture_progress
-mode = fill_mode
-radial_fill/initial_angle = radial_initial_angle
-radial_fill/fill_degrees = radial_fill_degrees
-radial_fill/center_offset = radial_center_offset
-
-[VideoPlayer]
-
-stream/audio_track = audio_track
-stream/stream = stream
-stream/volume_db = volume_db
-stream/autoplay = stream_autoplay
-stream/paused = stream_paused
-
-[DynamicFont]
-
-font/size = size
-extra_spacing/top = extra_spacing_top
-extra_spacing/bottom = extra_spacing_bottom
-extra_spacing/char = extra_spacing_char
-extra_spacing/space = extra_spacing_space
-font/use_mipmaps = use_mipmaps
-font/use_filter = use_filter
-font/font=font_data
-
-[StyleBox]
-
-content_margin/left = content_margin_left
-content_margin/right = content_margin_right
-content_margin/bottom = content_margin_bottom
-content_margin/top = content_margin_top
-
-
-[StyleBoxTexture]
-
-margin/left = margin_left
-margin/top = margin_top
-margin/bottom = margin_bottom
-margin/right = margin_right
-
-expand_margin/left = expand_margin_left
-expand_margin/top = expand_margin_top
-expand_margin/bottom = expand_margin_bottom
-expand_margin/right = expand_margin_right
-
-modulate/color = modulate_color
-
-
-[AnimatedSprite]
-
-modulate = self_modulate
-
-[Sprite]
-
-modulate = self_modulate
-
-[Patch9Frame]
-
-modulate = self_modulate
-
-[TextureFrame]
-
-modulate = self_modulate
-
-
-
-
-
-
-
-
-
-
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 4300c25e9f..faecbf3e6d 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -222,34 +222,34 @@ void SpriteFrames::_set_animations(const Array& p_animations) {
void SpriteFrames::_bind_methods() {
- ClassDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation);
- ClassDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation);
- ClassDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation);
- ClassDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation);
+ ClassDB::bind_method(D_METHOD("add_animation","anim"),&SpriteFrames::add_animation);
+ ClassDB::bind_method(D_METHOD("has_animation","anim"),&SpriteFrames::has_animation);
+ ClassDB::bind_method(D_METHOD("remove_animation","anim"),&SpriteFrames::remove_animation);
+ ClassDB::bind_method(D_METHOD("rename_animation","anim","newname"),&SpriteFrames::rename_animation);
- ClassDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed);
- ClassDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed);
+ ClassDB::bind_method(D_METHOD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed);
+ ClassDB::bind_method(D_METHOD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed);
- ClassDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop);
- ClassDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop);
+ 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(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1));
- ClassDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count);
- ClassDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame);
- ClassDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame);
- ClassDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame);
- ClassDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear);
- ClassDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all);
+ ClassDB::bind_method(D_METHOD("add_frame","anim","frame","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("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);
- ClassDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames);
- ClassDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames);
+ ClassDB::bind_method(D_METHOD("_set_frames"),&SpriteFrames::_set_frames);
+ ClassDB::bind_method(D_METHOD("_get_frames"),&SpriteFrames::_get_frames);
- ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"frames",PROPERTY_HINT_NONE,"",0),_SCS("_set_frames"),_SCS("_get_frames")); //compatibility
+ ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"frames",PROPERTY_HINT_NONE,"",0),"_set_frames","_get_frames"); //compatibility
- ClassDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations);
- ClassDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations);
+ ClassDB::bind_method(D_METHOD("_set_animations"),&SpriteFrames::_set_animations);
+ ClassDB::bind_method(D_METHOD("_get_animations"),&SpriteFrames::_get_animations);
- ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"animations",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_animations"),_SCS("_get_animations")); //compatibility
+ ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"animations",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_animations","_get_animations"); //compatibility
}
@@ -417,7 +417,7 @@ void AnimatedSprite::_notification(int p_what) {
if (centered)
ofs-=s/2;
- if (OS::get_singleton()->get_use_pixel_snap()) {
+ if (Engine::get_singleton()->get_use_pixel_snap()) {
ofs=ofs.floor();
}
Rect2 dst_rect(ofs,s);
@@ -429,7 +429,7 @@ void AnimatedSprite::_notification(int p_what) {
//texture->draw_rect(ci,dst_rect,false,modulate);
texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()));
-// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
+ //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;
}
@@ -653,48 +653,48 @@ String AnimatedSprite::get_configuration_warning() const {
void AnimatedSprite::_bind_methods() {
- ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames);
- ClassDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames);
+ ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames);
+ ClassDB::bind_method(D_METHOD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames);
- ClassDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation);
- ClassDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation);
+ ClassDB::bind_method(D_METHOD("set_animation","animation"),&AnimatedSprite::set_animation);
+ ClassDB::bind_method(D_METHOD("get_animation"),&AnimatedSprite::get_animation);
- ClassDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing);
- ClassDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing);
+ ClassDB::bind_method(D_METHOD("_set_playing","playing"),&AnimatedSprite::_set_playing);
+ ClassDB::bind_method(D_METHOD("_is_playing"),&AnimatedSprite::_is_playing);
- ClassDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName()));
- ClassDB::bind_method(_MD("stop"),&AnimatedSprite::stop);
- ClassDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing);
+ ClassDB::bind_method(D_METHOD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName()));
+ ClassDB::bind_method(D_METHOD("stop"),&AnimatedSprite::stop);
+ ClassDB::bind_method(D_METHOD("is_playing"),&AnimatedSprite::is_playing);
- ClassDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered);
- ClassDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered","centered"),&AnimatedSprite::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"),&AnimatedSprite::is_centered);
- ClassDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&AnimatedSprite::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&AnimatedSprite::get_offset);
- ClassDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h);
- ClassDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"),&AnimatedSprite::is_flipped_h);
- ClassDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v);
- ClassDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"),&AnimatedSprite::is_flipped_v);
- ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame);
- ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame","frame"),&AnimatedSprite::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"),&AnimatedSprite::get_frame);
- ClassDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
+ ClassDB::bind_method(D_METHOD("_res_changed"),&AnimatedSprite::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("animation_finished"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
- ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), _SCS("_set_playing"),_SCS("_is_playing"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), "set_sprite_frames","get_sprite_frames");
+ ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), "set_animation","get_animation");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), "_set_playing","_is_playing");
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), "set_centered","is_centered");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), "set_offset","get_offset");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), "set_flip_h","is_flipped_h");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), "set_flip_v","is_flipped_v");
}
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 96c5bea137..55c7716b6b 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -419,7 +419,7 @@ void Area2D::_notification(int p_what) {
}
-void Area2D::set_enable_monitoring(bool p_enable) {
+void Area2D::set_monitoring(bool p_enable) {
if (p_enable==monitoring)
@@ -444,7 +444,7 @@ void Area2D::set_enable_monitoring(bool p_enable) {
}
}
-bool Area2D::is_monitoring_enabled() const {
+bool Area2D::is_monitoring() const {
return monitoring;
}
@@ -588,62 +588,62 @@ bool Area2D::get_layer_mask_bit(int p_bit) const{
void Area2D::_bind_methods() {
- ClassDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
- ClassDB::bind_method(_MD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
+ ClassDB::bind_method(D_METHOD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
+ ClassDB::bind_method(D_METHOD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
- ClassDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
- ClassDB::bind_method(_MD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
+ ClassDB::bind_method(D_METHOD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
+ ClassDB::bind_method(D_METHOD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
- ClassDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
- ClassDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("get_space_override_mode"),&Area2D::get_space_override_mode);
- ClassDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point);
- ClassDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point);
+ ClassDB::bind_method(D_METHOD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point);
+ ClassDB::bind_method(D_METHOD("is_gravity_a_point"),&Area2D::is_gravity_a_point);
- ClassDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale);
- ClassDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale);
- ClassDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector);
- ClassDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector);
+ ClassDB::bind_method(D_METHOD("set_gravity_vector","vector"),&Area2D::set_gravity_vector);
+ ClassDB::bind_method(D_METHOD("get_gravity_vector"),&Area2D::get_gravity_vector);
- ClassDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity);
- ClassDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity","gravity"),&Area2D::set_gravity);
+ ClassDB::bind_method(D_METHOD("get_gravity"),&Area2D::get_gravity);
- ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp);
- ClassDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"),&Area2D::get_linear_damp);
- ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp);
- ClassDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"),&Area2D::get_angular_damp);
- ClassDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority);
- ClassDB::bind_method(_MD("get_priority"),&Area2D::get_priority);
+ ClassDB::bind_method(D_METHOD("set_priority","priority"),&Area2D::set_priority);
+ ClassDB::bind_method(D_METHOD("get_priority"),&Area2D::get_priority);
- ClassDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
- ClassDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"),&Area2D::get_collision_mask);
- ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&Area2D::get_layer_mask);
- ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit);
- ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit);
- ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit);
- ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit);
- ClassDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring);
- ClassDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled);
+ ClassDB::bind_method(D_METHOD("set_monitoring","enable"),&Area2D::set_monitoring);
+ ClassDB::bind_method(D_METHOD("is_monitoring"),&Area2D::is_monitoring);
- ClassDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable);
- ClassDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable);
+ ClassDB::bind_method(D_METHOD("set_monitorable","enable"),&Area2D::set_monitorable);
+ ClassDB::bind_method(D_METHOD("is_monitorable"),&Area2D::is_monitorable);
- ClassDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
- ClassDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
+ ClassDB::bind_method(D_METHOD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
+ ClassDB::bind_method(D_METHOD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
- ClassDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body);
- ClassDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area);
+ ClassDB::bind_method(D_METHOD("overlaps_body","body"),&Area2D::overlaps_body);
+ ClassDB::bind_method(D_METHOD("overlaps_area","area"),&Area2D::overlaps_area);
- ClassDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout);
- ClassDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout);
+ ClassDB::bind_method(D_METHOD("_body_inout"),&Area2D::_body_inout);
+ ClassDB::bind_method(D_METHOD("_area_inout"),&Area2D::_area_inout);
ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
@@ -657,26 +657,26 @@ void Area2D::_bind_methods() {
ADD_SIGNAL( MethodInfo("area_exited",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.001"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),"set_space_override_mode","get_space_override_mode");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),"set_gravity_is_point","is_gravity_a_point");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),"set_gravity_distance_scale","get_gravity_distance_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),"set_gravity_vector","get_gravity_vector");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.001"),"set_gravity","get_gravity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),"set_linear_damp","get_linear_damp");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),"set_angular_damp","get_angular_damp");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),"set_priority","get_priority");
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),"set_monitoring","is_monitoring");
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),"set_monitorable","is_monitorable");
ADD_GROUP("Collision","collision_");
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_layer_mask","get_layer_mask");
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_collision_mask","get_collision_mask");
}
Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_create(),true) {
space_override=SPACE_OVERRIDE_DISABLED;
- set_gravity(98);;
+ set_gravity(98);
set_gravity_vector(Vector2(0,1));
gravity_is_point=false;
gravity_distance_scale=0;
@@ -688,7 +688,7 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
monitorable=false;
collision_mask=1;
layer_mask=1;
- set_enable_monitoring(true);
+ set_monitoring(true);
set_monitorable(true);
}
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index e1adc16666..68bada707b 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -153,8 +153,8 @@ public:
void set_priority(real_t p_priority);
real_t get_priority() const;
- void set_enable_monitoring(bool p_enable);
- bool is_monitoring_enabled() const;
+ void set_monitoring(bool p_enable);
+ bool is_monitoring() const;
void set_monitorable(bool p_enable);
bool is_monitorable() const;
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index bbeed322b1..eaa33fe70a 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -77,14 +77,14 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const{
void BackBufferCopy::_bind_methods() {
- ClassDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect);
- ClassDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect);
+ ClassDB::bind_method(D_METHOD("set_rect","rect"),&BackBufferCopy::set_rect);
+ ClassDB::bind_method(D_METHOD("get_rect"),&BackBufferCopy::get_rect);
- ClassDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
- ClassDB::bind_method(_MD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
+ ClassDB::bind_method(D_METHOD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
+ ClassDB::bind_method(D_METHOD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"copy_mode",PROPERTY_HINT_ENUM,"Disabled,Rect,Viewport"),_SCS("set_copy_mode"),_SCS("get_copy_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"copy_mode",PROPERTY_HINT_ENUM,"Disabled,Rect,Viewport"),"set_copy_mode","get_copy_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),"set_rect","get_rect");
BIND_CONSTANT( COPY_MODE_DISABLED );
BIND_CONSTANT( COPY_MODE_RECT );
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 6c387c610f..9ae2315867 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -52,7 +52,7 @@ void Camera2D::_update_scroll() {
if (viewport) {
viewport->set_canvas_transform( xform );
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
};
}
@@ -145,7 +145,7 @@ Transform2D Camera2D::get_camera_transform() {
float c = smoothing*get_fixed_process_delta_time();
smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
ret_camera_pos=smoothed_camera_pos;
- // camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
+ //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
ret_camera_pos=smoothed_camera_pos=camera_pos;
@@ -252,7 +252,7 @@ void Camera2D::_notification(int p_what) {
canvas = get_canvas();
- RID vp = viewport->get_viewport();
+ RID vp = viewport->get_viewport_rid();
group_name = "__cameras_"+itos(vp.get_id());
canvas_group_name ="__cameras_c"+itos(canvas.get_id());
@@ -375,7 +375,7 @@ void Camera2D::make_current() {
if (!is_inside_tree()) {
current=true;
} else {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this);
}
}
@@ -383,7 +383,7 @@ void Camera2D::clear_current() {
current=false;
if (is_inside_tree()) {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
}
}
@@ -573,7 +573,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
else
viewport=get_viewport();
- RID vp = viewport->get_viewport();
+ RID vp = viewport->get_viewport_rid();
group_name = "__cameras_"+itos(vp.get_id());
canvas_group_name ="__cameras_c"+itos(canvas.get_id());
add_to_group(group_name);
@@ -590,92 +590,92 @@ Node* Camera2D::get_custom_viewport() const {
void Camera2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&Camera2D::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&Camera2D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&Camera2D::get_offset);
- ClassDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode);
- ClassDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode);
+ ClassDB::bind_method(D_METHOD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode);
+ ClassDB::bind_method(D_METHOD("get_anchor_mode"),&Camera2D::get_anchor_mode);
- ClassDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating);
- ClassDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
+ ClassDB::bind_method(D_METHOD("set_rotating","rotating"),&Camera2D::set_rotating);
+ ClassDB::bind_method(D_METHOD("is_rotating"),&Camera2D::is_rotating);
- ClassDB::bind_method(_MD("make_current"),&Camera2D::make_current);
- ClassDB::bind_method(_MD("clear_current"),&Camera2D::clear_current);
- ClassDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
+ ClassDB::bind_method(D_METHOD("make_current"),&Camera2D::make_current);
+ ClassDB::bind_method(D_METHOD("clear_current"),&Camera2D::clear_current);
+ ClassDB::bind_method(D_METHOD("_make_current"),&Camera2D::_make_current);
- ClassDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll);
+ ClassDB::bind_method(D_METHOD("_update_scroll"),&Camera2D::_update_scroll);
- ClassDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current);
- ClassDB::bind_method(_MD("is_current"),&Camera2D::is_current);
+ ClassDB::bind_method(D_METHOD("_set_current","current"),&Camera2D::_set_current);
+ ClassDB::bind_method(D_METHOD("is_current"),&Camera2D::is_current);
- ClassDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit);
- ClassDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit);
+ ClassDB::bind_method(D_METHOD("set_limit","margin","limit"),&Camera2D::set_limit);
+ ClassDB::bind_method(D_METHOD("get_limit","margin"),&Camera2D::get_limit);
- ClassDB::bind_method(_MD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled);
- ClassDB::bind_method(_MD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled);
+ ClassDB::bind_method(D_METHOD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled);
+ ClassDB::bind_method(D_METHOD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled);
- ClassDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled);
- ClassDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled);
+ ClassDB::bind_method(D_METHOD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled);
+ ClassDB::bind_method(D_METHOD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled);
- ClassDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled);
- ClassDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled);
+ ClassDB::bind_method(D_METHOD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled);
+ ClassDB::bind_method(D_METHOD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled);
- ClassDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset);
- ClassDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset);
+ ClassDB::bind_method(D_METHOD("set_v_offset","ofs"),&Camera2D::set_v_offset);
+ ClassDB::bind_method(D_METHOD("get_v_offset"),&Camera2D::get_v_offset);
- ClassDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset);
- ClassDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset);
+ ClassDB::bind_method(D_METHOD("set_h_offset","ofs"),&Camera2D::set_h_offset);
+ ClassDB::bind_method(D_METHOD("get_h_offset"),&Camera2D::get_h_offset);
- ClassDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin);
- ClassDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin);
+ ClassDB::bind_method(D_METHOD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin);
+ ClassDB::bind_method(D_METHOD("get_drag_margin","margin"),&Camera2D::get_drag_margin);
- ClassDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos);
- ClassDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
+ ClassDB::bind_method(D_METHOD("get_camera_pos"),&Camera2D::get_camera_pos);
+ ClassDB::bind_method(D_METHOD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
- ClassDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
- ClassDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
+ ClassDB::bind_method(D_METHOD("set_zoom","zoom"),&Camera2D::set_zoom);
+ ClassDB::bind_method(D_METHOD("get_zoom"),&Camera2D::get_zoom);
- ClassDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
- ClassDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
+ ClassDB::bind_method(D_METHOD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
+ ClassDB::bind_method(D_METHOD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
- ClassDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
- ClassDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
+ ClassDB::bind_method(D_METHOD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
+ ClassDB::bind_method(D_METHOD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
- ClassDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
- ClassDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
+ ClassDB::bind_method(D_METHOD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
+ ClassDB::bind_method(D_METHOD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
- ClassDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
- ClassDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing);
- ClassDB::bind_method(_MD("align"),&Camera2D::align);
+ ClassDB::bind_method(D_METHOD("force_update_scroll"),&Camera2D::force_update_scroll);
+ ClassDB::bind_method(D_METHOD("reset_smoothing"),&Camera2D::reset_smoothing);
+ ClassDB::bind_method(D_METHOD("align"),&Camera2D::align);
- ClassDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
+ ClassDB::bind_method(D_METHOD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),"set_offset","get_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),"set_anchor_mode","get_anchor_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),"set_rotating","is_rotating");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),"_set_current","is_current");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),"set_zoom","get_zoom") ;
ADD_GROUP("Limit","limit_");
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit_smoothed"),_SCS("set_limit_smoothing_enabled"),_SCS("is_limit_smoothing_enabled") );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_left"),"set_limit","get_limit",MARGIN_LEFT);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_top"),"set_limit","get_limit",MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_right"),"set_limit","get_limit",MARGIN_RIGHT);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_bottom"),"set_limit","get_limit",MARGIN_BOTTOM);
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit_smoothed"),"set_limit_smoothing_enabled","is_limit_smoothing_enabled") ;
ADD_GROUP("Draw Margin","draw_margin_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_h_enabled"),"set_h_drag_enabled","is_h_drag_enabled") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_v_enabled"),"set_v_drag_enabled","is_v_drag_enabled") ;
ADD_GROUP("Smoothing","smoothing_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing_enabled"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing_speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing_enabled"),"set_enable_follow_smoothing","is_follow_smoothing_enabled") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing_speed"),"set_follow_smoothing","get_follow_smoothing") ;
ADD_GROUP("Drag Margin","drag_margin_");
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_left",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_drag_margin","get_drag_margin",MARGIN_LEFT);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_top",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_drag_margin","get_drag_margin",MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_right",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_drag_margin","get_drag_margin",MARGIN_RIGHT);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_drag_margin","get_drag_margin",MARGIN_BOTTOM);
BIND_CONSTANT( ANCHOR_MODE_DRAG_CENTER );
@@ -713,5 +713,6 @@ Camera2D::Camera2D() {
v_drag_enabled=true;
h_ofs=0;
v_ofs=0;
+ set_notify_transform(true);
}
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index b7d9ba7860..4f7acf7f97 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -135,10 +135,10 @@ Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{
void CanvasItemMaterial::_bind_methods() {
- ClassDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
- ClassDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
- ClassDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
- ClassDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
+ ClassDB::bind_method(D_METHOD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
+ ClassDB::bind_method(D_METHOD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
+ ClassDB::bind_method(D_METHOD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
+ ClassDB::bind_method(D_METHOD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
@@ -182,7 +182,7 @@ CanvasItemMaterial::~CanvasItemMaterial(){
-bool CanvasItem::is_visible() const {
+bool CanvasItem::is_visible_in_tree() const {
if (!is_inside_tree())
return false;
@@ -190,7 +190,7 @@ bool CanvasItem::is_visible() const {
const CanvasItem *p=this;
while(p) {
- if (p->hidden)
+ if (!p->visible)
return false;
p=p->get_parent_item();
}
@@ -199,13 +199,6 @@ bool CanvasItem::is_visible() const {
return true;
}
-bool CanvasItem::is_hidden() const {
-
- /*if (!is_inside_scene())
- return false;*/
-
- return hidden;
-}
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
@@ -221,7 +214,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
- if (c && !c->hidden) //should the toplevels stop propagation? i think so but..
+ if (c && c->visible) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
}
@@ -231,10 +224,10 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
void CanvasItem::show() {
- if (!hidden)
+ if (visible)
return;
- hidden=false;
+ visible=true;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true);
if (!is_inside_tree())
@@ -247,10 +240,10 @@ void CanvasItem::show() {
void CanvasItem::hide() {
- if (hidden)
+ if (!visible)
return;
- hidden=true;
+ visible=false;
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
if (!is_inside_tree())
@@ -260,16 +253,6 @@ void CanvasItem::hide() {
_change_notify("visibility/visible");
}
-void CanvasItem::set_hidden(bool p_hidden) {
-
- if (hidden == p_hidden) {
- return;
- }
-
- _set_visible_(!p_hidden);
-}
-
-
Variant CanvasItem::edit_get_state() const {
@@ -306,7 +289,7 @@ void CanvasItem::_update_callback() {
VisualServer::get_singleton()->canvas_item_clear(get_canvas_item());
//todo updating = true - only allow drawing here
- if (is_visible()) { //todo optimize this!!
+ if (is_visible_in_tree()) { //todo optimize this!!
if (first_draw) {
notification(NOTIFICATION_VISIBILITY_CHANGED);
first_draw=false;
@@ -411,7 +394,7 @@ void CanvasItem::_enter_canvas() {
else
get_viewport()->gui_reset_canvas_sort_index();
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
@@ -461,7 +444,7 @@ void CanvasItem::_notification(int p_what) {
break;
if (group!="") {
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
@@ -495,16 +478,16 @@ void CanvasItem::_notification(int p_what) {
}
}
-void CanvasItem::_set_visible_(bool p_visible) {
+void CanvasItem::set_visible(bool p_visible) {
if (p_visible)
show();
else
hide();
}
-bool CanvasItem::_is_visible_() const {
+bool CanvasItem::is_visible() const {
- return !is_hidden();
+ return visible;
}
@@ -764,12 +747,12 @@ float CanvasItem::draw_char(const Ref<Font>& p_font,const Point2& p_pos, const S
void CanvasItem::_notify_transform(CanvasItem *p_node) {
- if (p_node->xform_change.in_list() && p_node->global_invalid)
+ if (/*p_node->xform_change.in_list() &&*/ p_node->global_invalid)
return; //nothing to do
p_node->global_invalid=true;
- if (!p_node->xform_change.in_list()) {
+ if (p_node->notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
if (p_node->is_inside_tree())
get_tree()->xform_change_list.add(&p_node->xform_change);
@@ -835,7 +818,7 @@ Ref<World2D> CanvasItem::get_world_2d() const {
RID CanvasItem::get_viewport_rid() const {
ERR_FAIL_COND_V(!is_inside_tree(),RID());
- return get_viewport()->get_viewport();
+ return get_viewport()->get_viewport_rid();
}
void CanvasItem::set_block_transform_notify(bool p_enable) {
@@ -922,101 +905,105 @@ Vector2 CanvasItem::get_local_mouse_pos() const{
void CanvasItem::_bind_methods() {
- ClassDB::bind_method(_MD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self);
- ClassDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
- ClassDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
- ClassDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
-
- ClassDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
- ClassDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
- ClassDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
- ClassDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);
-
- ClassDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect);
- ClassDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect);
- //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
-
- ClassDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);
-
- ClassDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
- ClassDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
- ClassDB::bind_method(_MD("show"),&CanvasItem::show);
- ClassDB::bind_method(_MD("hide"),&CanvasItem::hide);
- ClassDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden);
-
- ClassDB::bind_method(_MD("update"),&CanvasItem::update);
-
- ClassDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
- ClassDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
-
- ClassDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
- ClassDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask);
-
- ClassDB::bind_method(_MD("set_modulate","modulate"),&CanvasItem::set_modulate);
- ClassDB::bind_method(_MD("get_modulate"),&CanvasItem::get_modulate);
- ClassDB::bind_method(_MD("set_self_modulate","self_modulate"),&CanvasItem::set_self_modulate);
- ClassDB::bind_method(_MD("get_self_modulate"),&CanvasItem::get_self_modulate);
-
- ClassDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
- ClassDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
-
- ClassDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
- ClassDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
- //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
-
- ClassDB::bind_method(_MD("draw_line","from","to","color","width","antialiased"),&CanvasItem::draw_line,DEFVAL(1.0),DEFVAL(false));
- ClassDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
- ClassDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
- ClassDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
- ClassDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ClassDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ClassDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
- ClassDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0));
- ClassDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ClassDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));
-
- ClassDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
- ClassDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix);
- ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
- ClassDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
- ClassDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
- ClassDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
- ClassDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
- ClassDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
- ClassDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
- ClassDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
- ClassDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
- ClassDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
- //ClassDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
-
- ClassDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
- ClassDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
-
- ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
- ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
-
- ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
+ ClassDB::bind_method(D_METHOD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self);
+ ClassDB::bind_method(D_METHOD("_update_callback"),&CanvasItem::_update_callback);
+
+ ClassDB::bind_method(D_METHOD("edit_set_state","state"),&CanvasItem::edit_set_state);
+ ClassDB::bind_method(D_METHOD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
+ ClassDB::bind_method(D_METHOD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
+ ClassDB::bind_method(D_METHOD("edit_rotate","degrees"),&CanvasItem::edit_rotate);
+
+ ClassDB::bind_method(D_METHOD("get_item_rect"),&CanvasItem::get_item_rect);
+ ClassDB::bind_method(D_METHOD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect);
+ //ClassDB::bind_method(D_METHOD("get_transform"),&CanvasItem::get_transform);
+
+ 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("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);
+ ClassDB::bind_method(D_METHOD("hide"),&CanvasItem::hide);
+
+ ClassDB::bind_method(D_METHOD("update"),&CanvasItem::update);
+
+ ClassDB::bind_method(D_METHOD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
+ ClassDB::bind_method(D_METHOD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
+
+ ClassDB::bind_method(D_METHOD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
+ ClassDB::bind_method(D_METHOD("get_light_mask"),&CanvasItem::get_light_mask);
+
+ ClassDB::bind_method(D_METHOD("set_modulate","modulate"),&CanvasItem::set_modulate);
+ ClassDB::bind_method(D_METHOD("get_modulate"),&CanvasItem::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_self_modulate","self_modulate"),&CanvasItem::set_self_modulate);
+ ClassDB::bind_method(D_METHOD("get_self_modulate"),&CanvasItem::get_self_modulate);
+
+ ClassDB::bind_method(D_METHOD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
+ ClassDB::bind_method(D_METHOD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
+
+ ClassDB::bind_method(D_METHOD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
+ ClassDB::bind_method(D_METHOD("_is_on_top"),&CanvasItem::_is_on_top);
+ //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_rect","rect","color"),&CanvasItem::draw_rect);
+ ClassDB::bind_method(D_METHOD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
+ ClassDB::bind_method(D_METHOD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
+ ClassDB::bind_method(D_METHOD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
+ ClassDB::bind_method(D_METHOD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0));
+ ClassDB::bind_method(D_METHOD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));
+
+ ClassDB::bind_method(D_METHOD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
+ ClassDB::bind_method(D_METHOD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix);
+ ClassDB::bind_method(D_METHOD("get_transform"),&CanvasItem::get_transform);
+ ClassDB::bind_method(D_METHOD("get_global_transform"),&CanvasItem::get_global_transform);
+ ClassDB::bind_method(D_METHOD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
+ ClassDB::bind_method(D_METHOD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
+ ClassDB::bind_method(D_METHOD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
+ ClassDB::bind_method(D_METHOD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
+ ClassDB::bind_method(D_METHOD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
+ ClassDB::bind_method(D_METHOD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
+ 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_viewport"),&CanvasItem::get_viewport);
+
+ ClassDB::bind_method(D_METHOD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
+ ClassDB::bind_method(D_METHOD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
+
+ ClassDB::bind_method(D_METHOD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
+ ClassDB::bind_method(D_METHOD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
+
+ ClassDB::bind_method(D_METHOD("set_notify_local_transform","enable"),&CanvasItem::set_notify_local_transform);
+ ClassDB::bind_method(D_METHOD("is_local_transform_notification_enabled"),&CanvasItem::is_local_transform_notification_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_notify_transform","enable"),&CanvasItem::set_notify_transform);
+ ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"),&CanvasItem::is_transform_notification_enabled);
+
+ ClassDB::bind_method(D_METHOD("make_canvas_pos_local","screen_point"),
&CanvasItem::make_canvas_pos_local);
- ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
+ ClassDB::bind_method(D_METHOD("make_input_local","event"),&CanvasItem::make_input_local);
BIND_VMETHOD(MethodInfo("_draw"));
ADD_GROUP("Visibility","");
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
- ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
- ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"self_modulate"), _SCS("set_self_modulate"),_SCS("get_self_modulate") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"show_behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER), _SCS("set_light_mask"),_SCS("get_light_mask") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), "set_visible","is_visible") ;
+ ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"modulate"), "set_modulate","get_modulate") ;
+ ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"self_modulate"), "set_self_modulate","get_self_modulate") ;
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"show_behind_parent"), "set_draw_behind_parent","is_draw_behind_parent_enabled") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_on_top",PROPERTY_HINT_NONE,"",0), "_set_on_top","_is_on_top") ; //compatibility
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask","get_light_mask") ;
ADD_GROUP("Material","");
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"use_parent_material"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), "set_material","get_material") ;
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"use_parent_material"), "set_use_parent_material","get_use_parent_material") ;
//exporting these two things doesn't really make much sense i think
- //ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
- //ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
+ //ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), "set_as_toplevel","is_set_as_toplevel") ;
+ //ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),"set_transform_notify","is_transform_notify_enabled");
ADD_SIGNAL( MethodInfo("draw") );
ADD_SIGNAL( MethodInfo("visibility_changed") );
@@ -1081,6 +1068,15 @@ bool CanvasItem::is_local_transform_notification_enabled() const {
return notify_local_transform;
}
+
+void CanvasItem::set_notify_transform(bool p_enable) {
+ notify_transform=p_enable;
+}
+
+bool CanvasItem::is_transform_notification_enabled() const {
+ return notify_transform;
+}
+
int CanvasItem::get_canvas_layer() const {
if (canvas_layer)
@@ -1110,7 +1106,7 @@ CanvasItem::CanvasItem() : xform_change(this) {
canvas_item=VisualServer::get_singleton()->canvas_item_create();
- hidden=false;
+ visible=true;
pending_update=false;
modulate=Color(1,1,1,1);
self_modulate=Color(1,1,1,1);
@@ -1118,12 +1114,13 @@ CanvasItem::CanvasItem() : xform_change(this) {
first_draw=false;
drawing=false;
behind=false;
- block_transform_notify=false;
-// viewport=NULL;
+ block_transform_notify=false;
+ //viewport=NULL;
canvas_layer=NULL;
use_parent_material=false;
global_invalid=true;
notify_local_transform=false;
+ notify_transform=false;
light_mask=1;
C=NULL;
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index fded547275..9688b873c0 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -109,7 +109,7 @@ private:
int light_mask;
bool first_draw;
- bool hidden;
+ bool visible;
bool pending_update;
bool toplevel;
bool drawing;
@@ -117,6 +117,7 @@ private:
bool behind;
bool use_parent_material;
bool notify_local_transform;
+ bool notify_transform;
Ref<CanvasItemMaterial> material;
@@ -128,8 +129,6 @@ private:
void _propagate_visibility_changed(bool p_visible);
- void _set_visible_(bool p_visible);
- bool _is_visible_() const;
void _update_callback();
@@ -173,11 +172,11 @@ public:
/* VISIBILITY */
+ void set_visible(bool p_visible);
bool is_visible() const;
- bool is_hidden() const;
+ bool is_visible_in_tree() const;
void show();
void hide();
- void set_hidden(bool p_hidden);
void update();
@@ -256,6 +255,9 @@ public:
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
+ void set_notify_transform(bool p_enable);
+ bool is_transform_notification_enabled() const;
+
int get_canvas_layer() const;
CanvasItem();
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 583f03eab1..ecc11ea60f 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -33,7 +33,7 @@ void CanvasModulate::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
@@ -42,13 +42,13 @@ void CanvasModulate::_notification(int p_what) {
} else if (p_what==NOTIFICATION_EXIT_CANVAS) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id()));
}
} else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
} else {
@@ -62,10 +62,10 @@ void CanvasModulate::_notification(int p_what) {
void CanvasModulate::_bind_methods(){
- ClassDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color);
- ClassDB::bind_method(_MD("get_color"),&CanvasModulate::get_color);
+ ClassDB::bind_method(D_METHOD("set_color","color"),&CanvasModulate::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"),&CanvasModulate::get_color);
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),"set_color","get_color");
}
@@ -83,7 +83,7 @@ Color CanvasModulate::get_color() const {
String CanvasModulate::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
List<Node*> nodes;
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 3d90346209..f9e1cc0bd7 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -212,7 +212,7 @@ void CollisionObject2D::_mouse_exit() {
void CollisionObject2D::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = this->pickable && is_inside_tree() && is_visible();
+ bool pickable = this->pickable && is_inside_tree() && is_visible_in_tree();
if (area)
Physics2DServer::get_singleton()->area_set_pickable(rid,pickable);
else
@@ -221,20 +221,20 @@ void CollisionObject2D::_update_pickable() {
void CollisionObject2D::_bind_methods() {
- ClassDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Transform2D()));
- ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count);
- ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape);
- ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform);
- ClassDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger);
- ClassDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape);
- ClassDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform);
- ClassDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger);
- ClassDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape);
- ClassDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes);
- ClassDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid);
-
- ClassDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
- ClassDB::bind_method(_MD("is_pickable"),&CollisionObject2D::is_pickable);
+ ClassDB::bind_method(D_METHOD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Transform2D()));
+ ClassDB::bind_method(D_METHOD("get_shape_count"),&CollisionObject2D::get_shape_count);
+ ClassDB::bind_method(D_METHOD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape);
+ ClassDB::bind_method(D_METHOD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform);
+ ClassDB::bind_method(D_METHOD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger);
+ ClassDB::bind_method(D_METHOD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape);
+ ClassDB::bind_method(D_METHOD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform);
+ ClassDB::bind_method(D_METHOD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger);
+ ClassDB::bind_method(D_METHOD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape);
+ ClassDB::bind_method(D_METHOD("clear_shapes"),&CollisionObject2D::clear_shapes);
+ ClassDB::bind_method(D_METHOD("get_rid"),&CollisionObject2D::get_rid);
+
+ ClassDB::bind_method(D_METHOD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
+ ClassDB::bind_method(D_METHOD("is_pickable"),&CollisionObject2D::is_pickable);
BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
@@ -243,7 +243,7 @@ void CollisionObject2D::_bind_methods() {
ADD_SIGNAL( MethodInfo("mouse_exited"));
ADD_GROUP("Pickable","input_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_pickable"),_SCS("set_pickable"),_SCS("is_pickable"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_pickable"),"set_pickable","is_pickable");
ADD_GROUP("","");
}
@@ -282,7 +282,7 @@ void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape)
else
Physics2DServer::get_singleton()->body_set_shape(get_rid(),p_shape_idx,p_shape->get_rid());
-// _update_shapes();
+ //_update_shapes();
}
void CollisionObject2D::set_shape_transform(int p_shape_idx, const Transform2D& p_transform) {
@@ -295,7 +295,7 @@ void CollisionObject2D::set_shape_transform(int p_shape_idx, const Transform2D&
else
Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(),p_shape_idx,p_transform);
-// _update_shapes();
+ //_update_shapes();
}
Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const {
@@ -348,6 +348,8 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
rid=p_rid;
area=p_area;
pickable=true;
+ set_notify_transform(true);
+
if (p_area) {
Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
@@ -363,6 +365,7 @@ CollisionObject2D::CollisionObject2D() {
//owner=
+ set_notify_transform(true);
}
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 04f096f229..85241a79e0 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -243,6 +243,7 @@ void CollisionPolygon2D::set_polygon(const Vector<Point2>& p_polygon) {
_update_parent();
}
update();
+ update_configuration_warning();
}
Vector<Point2> CollisionPolygon2D::get_polygon() const {
@@ -313,26 +314,26 @@ String CollisionPolygon2D::get_configuration_warning() const {
void CollisionPolygon2D::_bind_methods() {
- ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object);
- ClassDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
- ClassDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon);
+ ClassDB::bind_method(D_METHOD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object);
+ ClassDB::bind_method(D_METHOD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"),&CollisionPolygon2D::get_polygon);
- ClassDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
- ClassDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
+ ClassDB::bind_method(D_METHOD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
+ ClassDB::bind_method(D_METHOD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
- ClassDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
- ClassDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger);
+ ClassDB::bind_method(D_METHOD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
+ ClassDB::bind_method(D_METHOD("is_trigger"),&CollisionPolygon2D::is_trigger);
- ClassDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
- ClassDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range);
+ ClassDB::bind_method(D_METHOD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
+ ClassDB::bind_method(D_METHOD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range);
- ClassDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape);
- ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),"set_build_mode","get_build_mode");
+ 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");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),"set_trigger","is_trigger");
}
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index a92065d6fb..37a49577b5 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -159,6 +159,7 @@ void CollisionShape2D::set_shape(const Ref<Shape2D>& p_shape) {
if (shape.is_valid())
shape->connect("changed",this,"_shape_changed");
+ update_configuration_warning();
}
Ref<Shape2D> CollisionShape2D::get_shape() const {
@@ -217,21 +218,21 @@ String CollisionShape2D::get_configuration_warning() const {
void CollisionShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape);
- ClassDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape);
- ClassDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed);
- ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object);
- ClassDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger);
- ClassDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger);
+ 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("_shape_changed"),&CollisionShape2D::_shape_changed);
+ ClassDB::bind_method(D_METHOD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object);
+ ClassDB::bind_method(D_METHOD("set_trigger","enable"),&CollisionShape2D::set_trigger);
+ ClassDB::bind_method(D_METHOD("is_trigger"),&CollisionShape2D::is_trigger);
- ClassDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index);
- ClassDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index);
+ ClassDB::bind_method(D_METHOD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index);
+ ClassDB::bind_method(D_METHOD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index);
- ClassDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index);
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_shape_index"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),"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");
}
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 987672df38..6754eb3981 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -128,22 +128,22 @@ bool Joint2D::get_exclude_nodes_from_collision() const{
void Joint2D::_bind_methods() {
- ClassDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a );
- ClassDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a );
+ ClassDB::bind_method( D_METHOD("set_node_a","node"), &Joint2D::set_node_a );
+ ClassDB::bind_method( D_METHOD("get_node_a"), &Joint2D::get_node_a );
- ClassDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b );
- ClassDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b );
+ ClassDB::bind_method( D_METHOD("set_node_b","node"), &Joint2D::set_node_b );
+ ClassDB::bind_method( D_METHOD("get_node_b"), &Joint2D::get_node_b );
- ClassDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias );
- ClassDB::bind_method( _MD("get_bias"), &Joint2D::get_bias );
+ ClassDB::bind_method( D_METHOD("set_bias","bias"), &Joint2D::set_bias );
+ ClassDB::bind_method( D_METHOD("get_bias"), &Joint2D::get_bias );
- ClassDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
- ClassDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
+ ClassDB::bind_method( D_METHOD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
+ ClassDB::bind_method( D_METHOD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disable_collision"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), "set_node_a","get_node_a") ;
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), "set_node_b","get_node_b") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), "set_bias","get_bias") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disable_collision"), "set_exclude_nodes_from_collision","get_exclude_nodes_from_collision") ;
}
@@ -225,10 +225,10 @@ real_t PinJoint2D::get_softness() const {
void PinJoint2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness);
- ClassDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness);
+ ClassDB::bind_method(D_METHOD("set_softness","softness"), &PinJoint2D::set_softness);
+ ClassDB::bind_method(D_METHOD("get_softness"), &PinJoint2D::get_softness);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), "set_softness", "get_softness");
}
PinJoint2D::PinJoint2D() {
@@ -321,13 +321,13 @@ real_t GrooveJoint2D::get_initial_offset() const {
void GrooveJoint2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length);
- ClassDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length);
- ClassDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
- ClassDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
+ ClassDB::bind_method(D_METHOD("set_length","length"),&GrooveJoint2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"),&GrooveJoint2D::get_length);
+ ClassDB::bind_method(D_METHOD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
+ ClassDB::bind_method(D_METHOD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_initial_offset"),_SCS("get_initial_offset"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_length","get_length");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_initial_offset","get_initial_offset");
}
GrooveJoint2D::GrooveJoint2D() {
@@ -453,19 +453,19 @@ real_t DampedSpringJoint2D::get_damping() const {
void DampedSpringJoint2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length);
- ClassDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length);
- ClassDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
- ClassDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
- ClassDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
- ClassDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
- ClassDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
- ClassDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping);
+ ClassDB::bind_method(D_METHOD("set_length","length"),&DampedSpringJoint2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"),&DampedSpringJoint2D::get_length);
+ ClassDB::bind_method(D_METHOD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
+ ClassDB::bind_method(D_METHOD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
+ ClassDB::bind_method(D_METHOD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
+ ClassDB::bind_method(D_METHOD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
+ ClassDB::bind_method(D_METHOD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
+ ClassDB::bind_method(D_METHOD("get_damping"),&DampedSpringJoint2D::get_damping);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), _SCS("set_rest_length"),_SCS("get_rest_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE,"0.1,64,0.1"), _SCS("set_stiffness"),_SCS("get_stiffness"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE,"0.01,16,0.01"), _SCS("set_damping"),_SCS("get_damping"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_length","get_length");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), "set_rest_length","get_rest_length");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE,"0.1,64,0.1"), "set_stiffness","get_stiffness");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE,"0.01,16,0.01"), "set_damping","get_damping");
}
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index b9dc8fe130..d7f5a890e8 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -83,7 +83,7 @@ void Light2D::_update_light_visibility() {
}
#endif
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok);
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible_in_tree() && editor_ok);
}
void Light2D::set_enabled( bool p_enabled) {
@@ -365,92 +365,92 @@ String Light2D::get_configuration_warning() const {
void Light2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&Light2D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&Light2D::is_enabled);
- ClassDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only );
- ClassDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only );
+ 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(_MD("set_texture","texture"),&Light2D::set_texture);
- ClassDB::bind_method(_MD("get_texture"),&Light2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","texture"),&Light2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture"),&Light2D::get_texture);
- ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset);
- ClassDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset);
+ 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);
- ClassDB::bind_method(_MD("set_color","color"),&Light2D::set_color);
- ClassDB::bind_method(_MD("get_color"),&Light2D::get_color);
+ ClassDB::bind_method(D_METHOD("set_color","color"),&Light2D::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"),&Light2D::get_color);
- ClassDB::bind_method(_MD("set_height","height"),&Light2D::set_height);
- ClassDB::bind_method(_MD("get_height"),&Light2D::get_height);
+ ClassDB::bind_method(D_METHOD("set_height","height"),&Light2D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"),&Light2D::get_height);
- ClassDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy);
- ClassDB::bind_method(_MD("get_energy"),&Light2D::get_energy);
+ ClassDB::bind_method(D_METHOD("set_energy","energy"),&Light2D::set_energy);
+ ClassDB::bind_method(D_METHOD("get_energy"),&Light2D::get_energy);
- ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale);
- ClassDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale);
+ ClassDB::bind_method(D_METHOD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale);
+ ClassDB::bind_method(D_METHOD("get_texture_scale"),&Light2D::get_texture_scale);
- ClassDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min);
- ClassDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min);
+ ClassDB::bind_method(D_METHOD("set_z_range_min","z"),&Light2D::set_z_range_min);
+ ClassDB::bind_method(D_METHOD("get_z_range_min"),&Light2D::get_z_range_min);
- ClassDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max);
- ClassDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max);
+ ClassDB::bind_method(D_METHOD("set_z_range_max","z"),&Light2D::set_z_range_max);
+ ClassDB::bind_method(D_METHOD("get_z_range_max"),&Light2D::get_z_range_max);
- ClassDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min);
- ClassDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min);
+ ClassDB::bind_method(D_METHOD("set_layer_range_min","layer"),&Light2D::set_layer_range_min);
+ ClassDB::bind_method(D_METHOD("get_layer_range_min"),&Light2D::get_layer_range_min);
- ClassDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max);
- ClassDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max);
+ ClassDB::bind_method(D_METHOD("set_layer_range_max","layer"),&Light2D::set_layer_range_max);
+ ClassDB::bind_method(D_METHOD("get_layer_range_max"),&Light2D::get_layer_range_max);
- ClassDB::bind_method(_MD("set_item_cull_mask","item_cull_mask"),&Light2D::set_item_cull_mask);
- ClassDB::bind_method(_MD("get_item_cull_mask"),&Light2D::get_item_cull_mask);
+ ClassDB::bind_method(D_METHOD("set_item_cull_mask","item_cull_mask"),&Light2D::set_item_cull_mask);
+ ClassDB::bind_method(D_METHOD("get_item_cull_mask"),&Light2D::get_item_cull_mask);
- ClassDB::bind_method(_MD("set_item_shadow_cull_mask","item_shadow_cull_mask"),&Light2D::set_item_shadow_cull_mask);
- ClassDB::bind_method(_MD("get_item_shadow_cull_mask"),&Light2D::get_item_shadow_cull_mask);
+ ClassDB::bind_method(D_METHOD("set_item_shadow_cull_mask","item_shadow_cull_mask"),&Light2D::set_item_shadow_cull_mask);
+ ClassDB::bind_method(D_METHOD("get_item_shadow_cull_mask"),&Light2D::get_item_shadow_cull_mask);
- ClassDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&Light2D::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&Light2D::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&Light2D::get_mode);
- ClassDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
- ClassDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
+ ClassDB::bind_method(D_METHOD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
+ ClassDB::bind_method(D_METHOD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
- ClassDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
- ClassDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
+ ClassDB::bind_method(D_METHOD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
+ ClassDB::bind_method(D_METHOD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
- ClassDB::bind_method(_MD("set_shadow_gradient_length","multiplier"),&Light2D::set_shadow_gradient_length);
- ClassDB::bind_method(_MD("get_shadow_gradient_length"),&Light2D::get_shadow_gradient_length);
+ ClassDB::bind_method(D_METHOD("set_shadow_gradient_length","multiplier"),&Light2D::set_shadow_gradient_length);
+ ClassDB::bind_method(D_METHOD("get_shadow_gradient_length"),&Light2D::get_shadow_gradient_length);
- ClassDB::bind_method(_MD("set_shadow_filter","filter"),&Light2D::set_shadow_filter);
- ClassDB::bind_method(_MD("get_shadow_filter"),&Light2D::get_shadow_filter);
+ ClassDB::bind_method(D_METHOD("set_shadow_filter","filter"),&Light2D::set_shadow_filter);
+ ClassDB::bind_method(D_METHOD("get_shadow_filter"),&Light2D::get_shadow_filter);
- ClassDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
- ClassDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color);
+ ClassDB::bind_method(D_METHOD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
+ ClassDB::bind_method(D_METHOD("get_shadow_color"),&Light2D::get_shadow_color);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),_SCS("set_editor_only"),_SCS("is_editor_only"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),"set_editor_only","is_editor_only");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),"set_texture_offset","get_texture_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),"set_texture_scale","get_texture_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),"set_color","get_color");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),"set_energy","get_energy");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),"set_mode","get_mode");
ADD_GROUP("Range","range_");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"range_height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_cull_mask"),_SCS("get_item_cull_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"range_height",PROPERTY_HINT_RANGE,"-100,100,0.1"),"set_height","get_height");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),"set_z_range_min","get_z_range_min");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),"set_z_range_max","get_z_range_max");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),"set_layer_range_min","get_layer_range_min");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),"set_layer_range_max","get_layer_range_max");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),"set_item_cull_mask","get_item_cull_mask");
ADD_GROUP("Shadow","shadow_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow_enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow_color"),_SCS("set_shadow_color"),_SCS("get_shadow_color"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_gradient_length",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_gradient_length"),_SCS("get_shadow_gradient_length"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_filter",PROPERTY_HINT_ENUM,"None,PCF3,PCF5,PCF9,PCF13"),_SCS("set_shadow_filter"),_SCS("get_shadow_filter"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_shadow_cull_mask"),_SCS("get_item_shadow_cull_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow_enabled"),"set_shadow_enabled","is_shadow_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow_color"),"set_shadow_color","get_shadow_color");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),"set_shadow_buffer_size","get_shadow_buffer_size");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_gradient_length",PROPERTY_HINT_RANGE,"1,4096,0.1"),"set_shadow_gradient_length","get_shadow_gradient_length");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_filter",PROPERTY_HINT_ENUM,"None,PCF3,PCF5,PCF9,PCF13"),"set_shadow_filter","get_shadow_filter");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),"set_item_shadow_cull_mask","get_item_shadow_cull_mask");
BIND_CONSTANT( MODE_ADD );
BIND_CONSTANT( MODE_SUB );
@@ -482,6 +482,7 @@ Light2D::Light2D() {
shadow_color=Color(0,0,0,0);
shadow_filter=SHADOW_FILTER_NONE;
+ set_notify_transform(true);
}
Light2D::~Light2D() {
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 8d447c3e8b..6a024fe330 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -78,18 +78,18 @@ RID OccluderPolygon2D::get_rid() const {
void OccluderPolygon2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed);
- ClassDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed);
+ ClassDB::bind_method(D_METHOD("set_closed","closed"),&OccluderPolygon2D::set_closed);
+ ClassDB::bind_method(D_METHOD("is_closed"),&OccluderPolygon2D::is_closed);
- ClassDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
- ClassDB::bind_method(_MD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
+ ClassDB::bind_method(D_METHOD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
+ ClassDB::bind_method(D_METHOD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
- ClassDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
- ClassDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon);
+ ClassDB::bind_method(D_METHOD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"),&OccluderPolygon2D::get_polygon);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),"set_closed","is_closed");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),"set_cull_mode","get_cull_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),"set_polygon","get_polygon");
BIND_CONSTANT(CULL_DISABLED);
BIND_CONSTANT(CULL_CLOCKWISE);
@@ -123,7 +123,7 @@ void LightOccluder2D::_notification(int p_what) {
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
@@ -132,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) {
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree());
}
if (p_what==NOTIFICATION_DRAW) {
@@ -224,24 +224,25 @@ String LightOccluder2D::get_configuration_warning() const {
void LightOccluder2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
- ClassDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
+ ClassDB::bind_method(D_METHOD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
+ ClassDB::bind_method(D_METHOD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
- ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
- ClassDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
+ ClassDB::bind_method(D_METHOD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
+ ClassDB::bind_method(D_METHOD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
#ifdef DEBUG_ENABLED
ClassDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed);
#endif
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"),_SCS("set_occluder_polygon"),_SCS("get_occluder_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"),"set_occluder_polygon","get_occluder_polygon");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),"set_occluder_light_mask","get_occluder_light_mask");
}
LightOccluder2D::LightOccluder2D() {
occluder=VS::get_singleton()->canvas_light_occluder_create();
mask=1;
+ set_notify_transform(true);
}
LightOccluder2D::~LightOccluder2D() {
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
new file mode 100644
index 0000000000..3da29ef385
--- /dev/null
+++ b/scene/2d/line_2d.cpp
@@ -0,0 +1,307 @@
+#include "line_2d.h"
+#include "core_string_names.h"
+
+
+// Needed so we can bind functions
+VARIANT_ENUM_CAST(LineJointMode)
+VARIANT_ENUM_CAST(LineCapMode)
+VARIANT_ENUM_CAST(LineTextureMode)
+
+
+Line2D::Line2D() : Node2D() {
+ _joint_mode = LINE_JOINT_SHARP;
+ _begin_cap_mode = LINE_CAP_NONE;
+ _end_cap_mode = LINE_CAP_NONE;
+ _width = 10;
+ _default_color = Color(0.4,0.5,1);
+ _sharp_limit = 2.f;
+ _round_precision = 8;
+}
+
+void Line2D::set_points(const PoolVector<Vector2> &p_points) {
+ _points = p_points;
+ update();
+}
+
+void Line2D::set_width(float width) {
+ if(width < 0.0)
+ width = 0.0;
+ _width = width;
+ update();
+}
+
+float Line2D::get_width() const {
+ return _width;
+}
+
+PoolVector<Vector2> Line2D::get_points() const {
+ return _points;
+}
+
+void Line2D::set_point_pos(int i, Vector2 pos) {
+ _points.set(i, pos);
+ update();
+}
+
+Vector2 Line2D::get_point_pos(int i) const {
+ return _points.get(i);
+}
+
+int Line2D::get_point_count() const {
+ return _points.size();
+}
+
+void Line2D::add_point(Vector2 pos) {
+ _points.append(pos);
+ update();
+}
+
+void Line2D::remove_point(int i) {
+ _points.remove(i);
+ update();
+}
+
+void Line2D::set_default_color(Color color) {
+ _default_color = color;
+ update();
+}
+
+Color Line2D::get_default_color() const {
+ return _default_color;
+}
+
+void Line2D::set_gradient(const Ref<ColorRamp>& gradient) {
+
+ // Cleanup previous connection if any
+ if(_gradient.is_valid()) {
+ (**_gradient).disconnect(CoreStringNames::get_singleton()->changed, this, "_gradient_changed");
+ }
+
+ _gradient = gradient;
+
+ // Connect to the gradient so the line will update when the ColorRamp is changed
+ if(_gradient.is_valid()) {
+ (**_gradient).connect(CoreStringNames::get_singleton()->changed, this, "_gradient_changed");
+ }
+
+ update();
+}
+
+Ref<ColorRamp> Line2D::get_gradient() const {
+ return _gradient;
+}
+
+void Line2D::set_texture(const Ref<Texture>& texture) {
+ _texture = texture;
+ update();
+}
+
+Ref<Texture> Line2D::get_texture() const {
+ return _texture;
+}
+
+void Line2D::set_texture_mode(const LineTextureMode mode) {
+ _texture_mode = mode;
+ update();
+}
+
+LineTextureMode Line2D::get_texture_mode() const {
+ return _texture_mode;
+}
+
+void Line2D::set_joint_mode(LineJointMode mode) {
+ _joint_mode = mode;
+ update();
+}
+
+LineJointMode Line2D::get_joint_mode() const {
+ return _joint_mode;
+}
+
+void Line2D::set_begin_cap_mode(LineCapMode mode) {
+ _begin_cap_mode = mode;
+ update();
+}
+
+LineCapMode Line2D::get_begin_cap_mode() const {
+ return _begin_cap_mode;
+}
+
+void Line2D::set_end_cap_mode(LineCapMode mode) {
+ _end_cap_mode = mode;
+ update();
+}
+
+LineCapMode Line2D::get_end_cap_mode() const {
+ return _end_cap_mode;
+}
+
+void Line2D::_notification(int p_what) {
+ switch(p_what) {
+ case NOTIFICATION_DRAW:
+ _draw();
+ break;
+ }
+}
+
+void Line2D::set_sharp_limit(float limit) {
+ if(limit < 0.f)
+ limit = 0.f;
+ _sharp_limit = limit;
+ update();
+}
+
+float Line2D::get_sharp_limit() const {
+ return _sharp_limit;
+}
+
+void Line2D::set_round_precision(int precision) {
+ if(precision < 1)
+ precision = 1;
+ _round_precision = precision;
+ update();
+}
+
+int Line2D::get_round_precision() const {
+ return _round_precision;
+}
+
+void Line2D::_draw() {
+ if(_points.size() <= 1 || _width == 0.f)
+ return;
+
+ // TODO Is this really needed?
+ // Copy points for faster access
+ Vector<Vector2> points;
+ points.resize(_points.size());
+ int len = points.size(); {
+ PoolVector<Vector2>::Read points_read = _points.read();
+ for(int i = 0; i < len; ++i) {
+ points[i] = points_read[i];
+ }
+ }
+
+ // TODO Maybe have it as member rather than copying parameters and allocating memory?
+ LineBuilder lb;
+ lb.points = points;
+ lb.default_color = _default_color;
+ lb.gradient = *_gradient;
+ lb.texture_mode = _texture_mode;
+ lb.joint_mode = _joint_mode;
+ lb.begin_cap_mode = _begin_cap_mode;
+ lb.end_cap_mode = _end_cap_mode;
+ lb.round_precision = _round_precision;
+ lb.sharp_limit = _sharp_limit;
+ lb.width = _width;
+
+ lb.build();
+
+ RID texture_rid;
+ if(_texture.is_valid())
+ texture_rid = (**_texture).get_rid();
+
+ VS::get_singleton()->canvas_item_add_triangle_array(
+ get_canvas_item(),
+ lb.indices,
+ lb.vertices,
+ lb.colors,
+ lb.uvs,
+ texture_rid);
+
+ // DEBUG
+ // Draw wireframe
+// if(lb.indices.size() % 3 == 0) {
+// Color col(0,0,0);
+// for(int i = 0; i < lb.indices.size(); i += 3) {
+// int vi = lb.indices[i];
+// int lbvsize = lb.vertices.size();
+// Vector2 a = lb.vertices[lb.indices[i]];
+// Vector2 b = lb.vertices[lb.indices[i+1]];
+// Vector2 c = lb.vertices[lb.indices[i+2]];
+// draw_line(a, b, col);
+// draw_line(b, c, col);
+// draw_line(c, a, col);
+// }
+// for(int i = 0; i < lb.vertices.size(); ++i) {
+// Vector2 p = lb.vertices[i];
+// draw_rect(Rect2(p.x-1, p.y-1, 2, 2), Color(0,0,0,0.5));
+// }
+// }
+}
+
+void Line2D::_gradient_changed() {
+ update();
+}
+
+// static
+void Line2D::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_points","points"), &Line2D::set_points);
+ ClassDB::bind_method(D_METHOD("get_points"), &Line2D::get_points);
+
+ ClassDB::bind_method(D_METHOD("set_point_pos","i", "pos"), &Line2D::set_point_pos);
+ ClassDB::bind_method(D_METHOD("get_point_pos", "i"), &Line2D::get_point_pos);
+
+ ClassDB::bind_method(D_METHOD("get_point_count"), &Line2D::get_point_count);
+
+ ClassDB::bind_method(D_METHOD("add_point", "pos"), &Line2D::add_point);
+ ClassDB::bind_method(D_METHOD("remove_point", "i"), &Line2D::remove_point);
+
+ ClassDB::bind_method(D_METHOD("set_width","width"), &Line2D::set_width);
+ ClassDB::bind_method(D_METHOD("get_width"), &Line2D::get_width);
+
+ 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_texture", "texture"), &Line2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_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);
+
+ ClassDB::bind_method(D_METHOD("set_joint_mode", "mode"), &Line2D::set_joint_mode);
+ ClassDB::bind_method(D_METHOD("get_joint_mode"), &Line2D::get_joint_mode);
+
+ ClassDB::bind_method(D_METHOD("set_begin_cap_mode", "mode"), &Line2D::set_begin_cap_mode);
+ ClassDB::bind_method(D_METHOD("get_begin_cap_mode"), &Line2D::get_begin_cap_mode);
+
+ ClassDB::bind_method(D_METHOD("set_end_cap_mode", "mode"), &Line2D::set_end_cap_mode);
+ ClassDB::bind_method(D_METHOD("get_end_cap_mode"), &Line2D::get_end_cap_mode);
+
+ ClassDB::bind_method(D_METHOD("set_sharp_limit", "limit"), &Line2D::set_sharp_limit);
+ ClassDB::bind_method(D_METHOD("get_sharp_limit"), &Line2D::get_sharp_limit);
+
+ ClassDB::bind_method(D_METHOD("set_round_precision", "precision"), &Line2D::set_round_precision);
+ ClassDB::bind_method(D_METHOD("get_round_precision"), &Line2D::get_round_precision);
+
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "default_color"), "set_default_color", "get_default_color");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "ColorRamp"), "set_gradient", "get_gradient");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "texture_mode", PROPERTY_HINT_ENUM, "None,Tile" ), "set_texture_mode","get_texture_mode");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "joint_mode", PROPERTY_HINT_ENUM, "Sharp,Bevel,Round" ), "set_joint_mode","get_joint_mode");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "begin_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round" ), "set_begin_cap_mode","get_begin_cap_mode");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "end_cap_mode", PROPERTY_HINT_ENUM, "None,Box,Round" ), "set_end_cap_mode","get_end_cap_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "sharp_limit"), "set_sharp_limit", "get_sharp_limit");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "round_precision"), "set_round_precision", "get_round_precision");
+
+ BIND_CONSTANT(LINE_JOINT_SHARP);
+ BIND_CONSTANT(LINE_JOINT_BEVEL);
+ BIND_CONSTANT(LINE_JOINT_ROUND);
+
+ BIND_CONSTANT(LINE_CAP_NONE);
+ BIND_CONSTANT(LINE_CAP_BOX);
+ BIND_CONSTANT(LINE_CAP_ROUND);
+
+ BIND_CONSTANT(LINE_TEXTURE_NONE);
+ BIND_CONSTANT(LINE_TEXTURE_TILE);
+
+ ClassDB::bind_method(D_METHOD("_gradient_changed"), &Line2D::_gradient_changed);
+
+}
+
+
diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h
new file mode 100644
index 0000000000..f4e2eb7a55
--- /dev/null
+++ b/scene/2d/line_2d.h
@@ -0,0 +1,80 @@
+#ifndef LINE2D_H
+#define LINE2D_H
+
+#include "node_2d.h"
+#include "line_builder.h"
+
+
+class Line2D : public Node2D {
+
+ GDCLASS(Line2D, Node2D)
+
+public:
+ Line2D();
+
+ void set_points(const PoolVector<Vector2> & p_points);
+ PoolVector<Vector2> get_points() const;
+
+ void set_point_pos(int i, Vector2 pos);
+ Vector2 get_point_pos(int i) const;
+
+ int get_point_count() const;
+
+ void add_point(Vector2 pos);
+ void remove_point(int i);
+
+ void set_width(float width);
+ float get_width() const;
+
+ void set_default_color(Color color);
+ Color get_default_color() const;
+
+ void set_gradient(const Ref<ColorRamp>& gradient);
+ Ref<ColorRamp> get_gradient() const;
+
+ void set_texture(const Ref<Texture>& texture);
+ Ref<Texture> get_texture() const;
+
+ void set_texture_mode(const LineTextureMode mode);
+ LineTextureMode get_texture_mode() const;
+
+ void set_joint_mode(LineJointMode mode);
+ LineJointMode get_joint_mode() const;
+
+ void set_begin_cap_mode(LineCapMode mode);
+ LineCapMode get_begin_cap_mode() const;
+
+ void set_end_cap_mode(LineCapMode mode);
+ LineCapMode get_end_cap_mode() const;
+
+ void set_sharp_limit(float limit);
+ float get_sharp_limit() const;
+
+ void set_round_precision(int precision);
+ int get_round_precision() const;
+
+protected:
+ void _notification(int p_what);
+ void _draw();
+
+ static void _bind_methods();
+
+private:
+ void _gradient_changed();
+
+private:
+ PoolVector<Vector2> _points;
+ LineJointMode _joint_mode;
+ LineCapMode _begin_cap_mode;
+ LineCapMode _end_cap_mode;
+ float _width;
+ Color _default_color;
+ Ref<ColorRamp> _gradient;
+ Ref<Texture> _texture;
+ LineTextureMode _texture_mode;
+ float _sharp_limit;
+ int _round_precision;
+
+};
+
+#endif // LINE2D_H
diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp
new file mode 100644
index 0000000000..230f72cccd
--- /dev/null
+++ b/scene/2d/line_builder.cpp
@@ -0,0 +1,563 @@
+#include "line_builder.h"
+
+//----------------------------------------------------------------------------
+// Util
+//----------------------------------------------------------------------------
+
+enum SegmentIntersectionResult {
+ SEGMENT_PARALLEL = 0,
+ SEGMENT_NO_INTERSECT = 1,
+ SEGMENT_INTERSECT = 2
+};
+
+static SegmentIntersectionResult segment_intersection(
+ Vector2 a, Vector2 b, Vector2 c, Vector2 d,
+ Vector2 * out_intersection)
+{
+ // http://paulbourke.net/geometry/pointlineplane/ <-- Good stuff
+ Vector2 cd = d - c;
+ Vector2 ab = b - a;
+ float div = cd.y*ab.x - cd.x*ab.y;
+
+ if(Math::abs(div) > 0.001f) {
+ float ua = (cd.x * (a.y-c.y) - cd.y * (a.x-c.x)) / div;
+ float ub = (ab.x * (a.y-c.y) - ab.y * (a.x-c.x)) / div;
+ *out_intersection = a + ua * ab;
+ if(ua >= 0.f && ua <= 1.f &&
+ ub >= 0.f && ub <= 1.f)
+ return SEGMENT_INTERSECT;
+ return SEGMENT_NO_INTERSECT;
+ }
+
+ return SEGMENT_PARALLEL;
+}
+
+// TODO I'm pretty sure there is an even faster way to swap things
+template <typename T>
+static inline void swap(T & a, T & b) {
+ T tmp = a;
+ a = b;
+ b = tmp;
+}
+
+static float calculate_total_distance(const Vector<Vector2> & points) {
+ float d = 0.f;
+ for(int i = 1; i < points.size(); ++i) {
+ d += points[i].distance_to(points[i-1]);
+ }
+ return d;
+}
+
+static inline Vector2 rotate90(const Vector2 & v) {
+ // Note: the 2D referential is X-right, Y-down
+ return Vector2(v.y, -v.x);
+}
+
+static inline Vector2 interpolate(const Rect2 & r, const Vector2 & v) {
+ return Vector2(
+ Math::lerp(r.get_pos().x, r.get_pos().x + r.get_size().x, v.x),
+ Math::lerp(r.get_pos().y, r.get_pos().y + r.get_size().y, v.y)
+ );
+}
+
+//----------------------------------------------------------------------------
+// LineBuilder
+//----------------------------------------------------------------------------
+
+LineBuilder::LineBuilder() {
+ joint_mode = LINE_JOINT_SHARP;
+ width = 10;
+ default_color = Color(0.4,0.5,1);
+ gradient = NULL;
+ sharp_limit = 2.f;
+ round_precision = 8;
+ begin_cap_mode = LINE_CAP_NONE;
+ end_cap_mode = LINE_CAP_NONE;
+
+ _interpolate_color = false;
+ _last_index[0] = 0;
+ _last_index[1] = 0;
+}
+
+
+void LineBuilder::clear_output() {
+ vertices.clear();
+ colors.clear();
+ indices.clear();
+}
+
+void LineBuilder::build() {
+
+ // Need at least 2 points to draw a line
+ if(points.size() < 2) {
+ clear_output();
+ return;
+ }
+
+ const float hw = width / 2.f;
+ const float hw_sq = hw*hw;
+ const float sharp_limit_sq = sharp_limit * sharp_limit;
+ const int len = points.size();
+
+ // Initial values
+
+ Vector2 pos0 = points[0];
+ Vector2 pos1 = points[1];
+ Vector2 f0 = (pos1 - pos0).normalized();
+ Vector2 u0 = rotate90(f0);
+ Vector2 pos_up0 = pos0 + u0 * hw;
+ Vector2 pos_down0 = pos0 - u0 * hw;
+
+ Color color0;
+ Color color1;
+
+ float current_distance0 = 0.f;
+ float current_distance1 = 0.f;
+ float total_distance;
+ _interpolate_color = gradient != NULL;
+ bool distance_required = _interpolate_color || texture_mode == LINE_TEXTURE_TILE;
+ if(distance_required)
+ total_distance = calculate_total_distance(points);
+ if(_interpolate_color)
+ color0 = gradient->get_color(0);
+ else
+ colors.push_back(default_color);
+
+ float uvx0 = 0.f;
+ float uvx1 = 0.f;
+
+ // Begin cap
+ if(begin_cap_mode == LINE_CAP_BOX) {
+ // Push back first vertices a little bit
+ pos_up0 -= f0 * hw;
+ pos_down0 -= f0 * hw;
+ // The line's outer length will be a little higher due to begin and end caps
+ total_distance += width;
+ current_distance0 += hw;
+ current_distance1 = current_distance0;
+ }
+ else if(begin_cap_mode == LINE_CAP_ROUND) {
+ if(texture_mode == LINE_TEXTURE_TILE) {
+ uvx0 = 0.5f;
+ }
+ new_arc(pos0, pos_up0 - pos0, -Math_PI, color0, Rect2(0.f, 0.f, 1.f, 1.f));
+ total_distance += width;
+ current_distance0 += hw;
+ current_distance1 = current_distance0;
+ }
+
+ strip_begin(pos_up0, pos_down0, color0, uvx0);
+
+ // pos_up0 ------------- pos_up1 --------------------
+ // | |
+ // pos0 - - - - - - - - - pos1 - - - - - - - - - pos2
+ // | |
+ // pos_down0 ------------ pos_down1 ------------------
+ //
+ // i-1 i i+1
+
+ // http://labs.hyperandroid.com/tag/opengl-lines
+ // (not the same implementation but visuals help a lot)
+
+ // For each additional segment
+ for(int i = 1; i < len-1; ++i) {
+
+ pos1 = points[i];
+ Vector2 pos2 = points[i+1];
+
+ Vector2 f1 = (pos2 - pos1).normalized();
+ Vector2 u1 = rotate90(f1);
+
+ // Determine joint orientation
+ const float dp = u0.dot(f1);
+ const Orientation orientation = (dp > 0.f ? UP : DOWN);
+
+ Vector2 inner_normal0, inner_normal1;
+ if(orientation == UP) {
+ inner_normal0 = u0 * hw;
+ inner_normal1 = u1 * hw;
+ }
+ else {
+ inner_normal0 = -u0 * hw;
+ inner_normal1 = -u1 * hw;
+ }
+
+ // ---------------------------
+ // /
+ // 0 / 1
+ // / /
+ // --------------------x------ /
+ // / / (here shown with orientation == DOWN)
+ // / /
+ // / /
+ // / /
+ // 2 /
+ // /
+
+ // Find inner intersection at the joint
+ Vector2 corner_pos_in, corner_pos_out;
+ SegmentIntersectionResult intersection_result = segment_intersection(
+ pos0 + inner_normal0, pos1 + inner_normal0,
+ pos1 + inner_normal1, pos2 + inner_normal1,
+ &corner_pos_in);
+
+ if(intersection_result == SEGMENT_INTERSECT)
+ // Inner parts of the segments intersect
+ corner_pos_out = 2.f * pos1 - corner_pos_in;
+ else {
+ // No intersection, segments are either parallel or too sharp
+ corner_pos_in = pos1 + inner_normal0;
+ corner_pos_out = pos1 - inner_normal0;
+ }
+
+ Vector2 corner_pos_up, corner_pos_down;
+ if(orientation == UP) {
+ corner_pos_up = corner_pos_in;
+ corner_pos_down = corner_pos_out;
+ }
+ else {
+ corner_pos_up = corner_pos_out;
+ corner_pos_down = corner_pos_in;
+ }
+
+ LineJointMode current_joint_mode = joint_mode;
+
+ Vector2 pos_up1, pos_down1;
+ if(intersection_result == SEGMENT_INTERSECT) {
+ // Fallback on bevel if sharp angle is too high (because it would produce very long miters)
+ if(current_joint_mode == LINE_JOINT_SHARP && corner_pos_out.distance_squared_to(pos1) / hw_sq > sharp_limit_sq) {
+ current_joint_mode = LINE_JOINT_BEVEL;
+ }
+ if(current_joint_mode == LINE_JOINT_SHARP) {
+ // In this case, we won't create joint geometry,
+ // The previous and next line quads will directly share an edge.
+ pos_up1 = corner_pos_up;
+ pos_down1 = corner_pos_down;
+ }
+ else {
+ // Bevel or round
+ if(orientation == UP) {
+ pos_up1 = corner_pos_up;
+ pos_down1 = pos1 - u0 * hw;
+ }
+ else {
+ pos_up1 = pos1 + u0 * hw;
+ pos_down1 = corner_pos_down;
+ }
+ }
+ }
+ else {
+ // No intersection: fallback
+ pos_up1 = corner_pos_up;
+ pos_down1 = corner_pos_down;
+ }
+
+ // Add current line body quad
+ // Triangles are clockwise
+ if(distance_required) {
+ current_distance1 += pos0.distance_to(pos1);
+ }
+ if(_interpolate_color) {
+ color1 = gradient->get_color_at_offset(current_distance1 / total_distance);
+ }
+ if(texture_mode == LINE_TEXTURE_TILE) {
+ uvx0 = current_distance0 / width;
+ uvx1 = current_distance1 / width;
+ }
+
+ strip_add_quad(pos_up1, pos_down1, color1, uvx1);
+
+ // Swap vars for use in the next line
+ color0 = color1;
+ u0 = u1;
+ f0 = f1;
+ pos0 = pos1;
+ current_distance0 = current_distance1;
+ if(intersection_result == SEGMENT_INTERSECT) {
+ if(current_joint_mode == LINE_JOINT_SHARP) {
+ pos_up0 = pos_up1;
+ pos_down0 = pos_down1;
+ }
+ else {
+ if(orientation == UP) {
+ pos_up0 = corner_pos_up;
+ pos_down0 = pos1 - u1 * hw;
+ }
+ else {
+ pos_up0 = pos1 + u1 * hw;
+ pos_down0 = corner_pos_down;
+ }
+ }
+ }
+ else {
+ pos_up0 = pos1 + u1 * hw;
+ pos_down0 = pos1 - u1 * hw;
+ }
+ // From this point, bu0 and bd0 concern the next segment
+
+ // Add joint geometry
+ if(current_joint_mode != LINE_JOINT_SHARP) {
+
+ // ________________ cbegin
+ // / \
+ // / \
+ // ____________/_ _ _\ cend
+ // | |
+ // | |
+ // | |
+
+ Vector2 cbegin, cend;
+ if(orientation == UP) {
+ cbegin = pos_down1;
+ cend = pos_down0;
+ }
+ else {
+ cbegin = pos_up1;
+ cend = pos_up0;
+ }
+
+ if(current_joint_mode == LINE_JOINT_BEVEL) {
+ strip_add_tri(cend, orientation);
+ }
+ else if(current_joint_mode == LINE_JOINT_ROUND) {
+ Vector2 vbegin = cbegin - pos1;
+ Vector2 vend = cend - pos1;
+ strip_add_arc(pos1, vend.angle_to(vbegin), orientation);
+ }
+
+ if(intersection_result != SEGMENT_INTERSECT)
+ // In this case the joint is too fucked up to be re-used,
+ // start again the strip with fallback points
+ strip_begin(pos_up0, pos_down0, color1, uvx1);
+ }
+ }
+
+ // Last (or only) segment
+
+ pos1 = points[points.size()-1];
+
+ Vector2 pos_up1 = pos1 + u0 * hw;
+ Vector2 pos_down1 = pos1 - u0 * hw;
+
+ // End cap (box)
+ if(end_cap_mode == LINE_CAP_BOX) {
+ pos_up1 += f0 * hw;
+ pos_down1 += f0 * hw;
+ }
+
+ if(distance_required) {
+ current_distance1 += pos0.distance_to(pos1);
+ }
+ if(_interpolate_color) {
+ color1 = gradient->get_color(gradient->get_points_count()-1);
+ }
+ if(texture_mode == LINE_TEXTURE_TILE) {
+ uvx1 = current_distance1 / width;
+ }
+
+ strip_add_quad(pos_up1, pos_down1, color1, uvx1);
+
+ // End cap (round)
+ if(end_cap_mode == LINE_CAP_ROUND) {
+ // Note: color is not used in case we don't interpolate...
+ Color color = _interpolate_color ? gradient->get_color(gradient->get_points_count()-1) : Color(0,0,0);
+ new_arc(pos1, pos_up1 - pos1, Math_PI, color, Rect2(uvx1-0.5f, 0.f, 1.f, 1.f));
+ }
+}
+
+void LineBuilder::strip_begin(Vector2 up, Vector2 down, Color color, float uvx) {
+ int vi = vertices.size();
+
+ vertices.push_back(up);
+ vertices.push_back(down);
+
+ if(_interpolate_color) {
+ colors.push_back(color);
+ colors.push_back(color);
+ }
+
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ uvs.push_back(Vector2(uvx, 0.f));
+ uvs.push_back(Vector2(uvx, 1.f));
+ }
+
+ _last_index[UP] = vi;
+ _last_index[DOWN] = vi+1;
+}
+
+void LineBuilder::strip_new_quad(Vector2 up, Vector2 down, Color color, float uvx) {
+ int vi = vertices.size();
+
+ vertices.push_back(vertices[_last_index[UP]]);
+ vertices.push_back(vertices[_last_index[DOWN]]);
+ vertices.push_back(up);
+ vertices.push_back(down);
+
+ if(_interpolate_color) {
+ colors.push_back(color);
+ colors.push_back(color);
+ colors.push_back(color);
+ colors.push_back(color);
+ }
+
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ uvs.push_back(uvs[_last_index[UP]]);
+ uvs.push_back(uvs[_last_index[DOWN]]);
+ uvs.push_back(Vector2(uvx, UP));
+ uvs.push_back(Vector2(uvx, DOWN));
+ }
+
+ indices.push_back(vi);
+ indices.push_back(vi+3);
+ indices.push_back(vi+1);
+ indices.push_back(vi);
+ indices.push_back(vi+2);
+ indices.push_back(vi+3);
+
+ _last_index[UP] = vi+2;
+ _last_index[DOWN] = vi+3;
+}
+
+void LineBuilder::strip_add_quad(Vector2 up, Vector2 down, Color color, float uvx) {
+ int vi = vertices.size();
+
+ vertices.push_back(up);
+ vertices.push_back(down);
+
+ if(_interpolate_color) {
+ colors.push_back(color);
+ colors.push_back(color);
+ }
+
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ uvs.push_back(Vector2(uvx, 0.f));
+ uvs.push_back(Vector2(uvx, 1.f));
+ }
+
+ indices.push_back(_last_index[UP]);
+ indices.push_back(vi+1);
+ indices.push_back(_last_index[DOWN]);
+ indices.push_back(_last_index[UP]);
+ indices.push_back(vi);
+ indices.push_back(vi+1);
+
+ _last_index[UP] = vi;
+ _last_index[DOWN] = vi+1;
+}
+
+void LineBuilder::strip_add_tri(Vector2 up, Orientation orientation) {
+ int vi = vertices.size();
+
+ vertices.push_back(up);
+
+ if(_interpolate_color) {
+ colors.push_back(colors[colors.size()-1]);
+ }
+
+ Orientation opposite_orientation = orientation == UP ? DOWN : UP;
+
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ // UVs are just one slice of the texture all along
+ // (otherwise we can't share the bottom vertice)
+ uvs.push_back(uvs[_last_index[opposite_orientation]]);
+ }
+
+ indices.push_back(_last_index[opposite_orientation]);
+ indices.push_back(vi);
+ indices.push_back(_last_index[orientation]);
+
+ _last_index[opposite_orientation] = vi;
+}
+
+void LineBuilder::strip_add_arc(Vector2 center, float angle_delta, Orientation orientation) {
+
+ // Take the two last vertices and extrude an arc made of triangles
+ // that all share one of the initial vertices
+
+ Orientation opposite_orientation = orientation == UP ? DOWN : UP;
+ Vector2 vbegin = vertices[_last_index[opposite_orientation]] - center;
+ float radius = vbegin.length();
+ float angle_step = Math_PI / static_cast<float>(round_precision);
+ float steps = Math::abs(angle_delta) / angle_step;
+
+ if(angle_delta < 0.f)
+ angle_step = -angle_step;
+
+ float t = vbegin.angle_to(Vector2(1, 0));
+ float end_angle = t + angle_delta;
+ Vector2 rpos(0,0);
+
+ // Arc vertices
+ for(int ti = 0; ti < steps; ++ti, t += angle_step) {
+ rpos = center + Vector2(Math::cos(t), Math::sin(t)) * radius;
+ strip_add_tri(rpos, orientation);
+ }
+
+ // Last arc vertice
+ rpos = center + Vector2(Math::cos(end_angle), Math::sin(end_angle)) * radius;
+ strip_add_tri(rpos, orientation);
+}
+
+void LineBuilder::new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect) {
+
+ // Make a standalone arc that doesn't use existing vertices,
+ // with undistorted UVs from withing a square section
+
+ float radius = vbegin.length();
+ float angle_step = Math_PI / static_cast<float>(round_precision);
+ float steps = Math::abs(angle_delta) / angle_step;
+
+ if(angle_delta < 0.f)
+ angle_step = -angle_step;
+
+ float t = vbegin.angle_to(Vector2(1, 0));
+ float end_angle = t + angle_delta;
+ Vector2 rpos(0,0);
+ float tt_begin = -Math_PI / 2.f;
+ float tt = tt_begin;
+
+ // Center vertice
+ int vi = vertices.size();
+ vertices.push_back(center);
+ if(_interpolate_color)
+ colors.push_back(color);
+ if(texture_mode != LINE_TEXTURE_NONE)
+ uvs.push_back(interpolate(uv_rect, Vector2(0.5f, 0.5f)));
+
+ // Arc vertices
+ for(int ti = 0; ti < steps; ++ti, t += angle_step) {
+ Vector2 sc = Vector2(Math::cos(t), Math::sin(t));
+ rpos = center + sc * radius;
+
+ vertices.push_back(rpos);
+ if(_interpolate_color)
+ colors.push_back(color);
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ Vector2 tsc = Vector2(Math::cos(tt), Math::sin(tt));
+ uvs.push_back(interpolate(uv_rect, 0.5f*(tsc+Vector2(1.f,1.f))));
+ tt += angle_step;
+ }
+ }
+
+ // Last arc vertice
+ Vector2 sc = Vector2(Math::cos(end_angle), Math::sin(end_angle));
+ rpos = center + sc * radius;
+ vertices.push_back(rpos);
+ if(_interpolate_color)
+ colors.push_back(color);
+ if(texture_mode != LINE_TEXTURE_NONE) {
+ tt = tt_begin + angle_delta;
+ Vector2 tsc = Vector2(Math::cos(tt), Math::sin(tt));
+ uvs.push_back(interpolate(uv_rect, 0.5f*(tsc+Vector2(1.f,1.f))));
+ }
+
+ // Make up triangles
+ int vi0 = vi;
+ for(int ti = 0; ti < steps; ++ti) {
+ indices.push_back(vi0);
+ indices.push_back(++vi);
+ indices.push_back(vi+1);
+ }
+}
+
+
diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h
new file mode 100644
index 0000000000..73419f88d8
--- /dev/null
+++ b/scene/2d/line_builder.h
@@ -0,0 +1,76 @@
+#ifndef LINE_BUILDER_H
+#define LINE_BUILDER_H
+
+#include "math_2d.h"
+#include "color.h"
+#include "scene/resources/color_ramp.h"
+
+enum LineJointMode {
+ LINE_JOINT_SHARP = 0,
+ LINE_JOINT_BEVEL,
+ LINE_JOINT_ROUND
+};
+
+enum LineCapMode {
+ LINE_CAP_NONE = 0,
+ LINE_CAP_BOX,
+ LINE_CAP_ROUND
+};
+
+enum LineTextureMode {
+ LINE_TEXTURE_NONE = 0,
+ LINE_TEXTURE_TILE
+ // TODO STRETCH mode
+};
+
+class LineBuilder {
+public:
+ // TODO Move in a struct and reference it
+ // Input
+ Vector<Vector2> points;
+ LineJointMode joint_mode;
+ LineCapMode begin_cap_mode;
+ LineCapMode end_cap_mode;
+ float width;
+ Color default_color;
+ ColorRamp* gradient;
+ LineTextureMode texture_mode;
+ float sharp_limit;
+ int round_precision;
+ // TODO offset_joints option (offers alternative implementation of round joints)
+
+ // TODO Move in a struct and reference it
+ // Output
+ Vector<Vector2> vertices;
+ Vector<Color> colors;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
+
+ LineBuilder();
+
+ void build();
+ void clear_output();
+
+private:
+ enum Orientation {
+ UP = 0,
+ DOWN = 1
+ };
+
+ // Triangle-strip methods
+ void strip_begin(Vector2 up, Vector2 down, Color color, float uvx);
+ void strip_new_quad(Vector2 up, Vector2 down, Color color, float uvx);
+ void strip_add_quad(Vector2 up, Vector2 down, Color color, float uvx);
+ void strip_add_tri(Vector2 up, Orientation orientation);
+ void strip_add_arc(Vector2 center, float angle_delta, Orientation orientation);
+
+ void new_arc(Vector2 center, Vector2 vbegin, float angle_delta, Color color, Rect2 uv_rect);
+
+private:
+ bool _interpolate_color;
+ int _last_index[2]; // Index of last up and down vertices of the strip
+
+};
+
+
+#endif // LINE_BUILDER_H
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index 2d0fbf1cfc..7f48749dc3 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -127,7 +127,7 @@ void Navigation2D::_navpoly_link(int p_id) {
C->get().B=&p;
C->get().B_edge=j;
C->get().A->edges[C->get().A_edge].C=&p;
- C->get().A->edges[C->get().A_edge].C_edge=j;;
+ C->get().A->edges[C->get().A_edge].C_edge=j;
p.edges[j].C=C->get().A;
p.edges[j].C_edge=C->get().A_edge;
//connection successful.
@@ -432,7 +432,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
while(!found_route) {
if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ //print_line("NOU OPEN LIST");
break;
}
//check open list
@@ -679,7 +679,7 @@ debug path
path.push_back(begin_point);
- path.invert();;
+ path.invert();
}
return path;
@@ -804,13 +804,13 @@ Object* Navigation2D::get_closest_point_owner(const Vector2& p_point) {
void Navigation2D::_bind_methods() {
- ClassDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform);
- ClassDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove);
+ ClassDB::bind_method(D_METHOD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform);
+ ClassDB::bind_method(D_METHOD("navpoly_remove","id"),&Navigation2D::navpoly_remove);
- ClassDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true));
- ClassDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point);
- ClassDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner);
+ ClassDB::bind_method(D_METHOD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_closest_point","to_point"),&Navigation2D::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner);
}
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 5c1837ad65..9dbbd34ae9 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -137,7 +137,7 @@ PoolVector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
void NavigationPolygon::clear_outlines(){
- outlines.clear();;
+ outlines.clear();
}
void NavigationPolygon::make_polygons_from_outlines(){
@@ -247,32 +247,32 @@ void NavigationPolygon::make_polygons_from_outlines(){
void NavigationPolygon::_bind_methods() {
- ClassDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices);
- ClassDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices);
+ ClassDB::bind_method(D_METHOD("set_vertices","vertices"),&NavigationPolygon::set_vertices);
+ ClassDB::bind_method(D_METHOD("get_vertices"),&NavigationPolygon::get_vertices);
- ClassDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon);
- ClassDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count);
- ClassDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon);
- ClassDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons);
+ ClassDB::bind_method(D_METHOD("add_polygon","polygon"),&NavigationPolygon::add_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon_count"),&NavigationPolygon::get_polygon_count);
+ ClassDB::bind_method(D_METHOD("get_polygon","idx"),&NavigationPolygon::get_polygon);
+ ClassDB::bind_method(D_METHOD("clear_polygons"),&NavigationPolygon::clear_polygons);
- ClassDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline);
- ClassDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index);
- ClassDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count);
- ClassDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline);
- ClassDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline);
- ClassDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline);
- ClassDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines);
- ClassDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines);
+ ClassDB::bind_method(D_METHOD("add_outline","outline"),&NavigationPolygon::add_outline);
+ ClassDB::bind_method(D_METHOD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index);
+ ClassDB::bind_method(D_METHOD("get_outline_count"),&NavigationPolygon::get_outline_count);
+ ClassDB::bind_method(D_METHOD("set_outline","idx","outline"),&NavigationPolygon::set_outline);
+ ClassDB::bind_method(D_METHOD("get_outline","idx"),&NavigationPolygon::get_outline);
+ ClassDB::bind_method(D_METHOD("remove_outline","idx"),&NavigationPolygon::remove_outline);
+ ClassDB::bind_method(D_METHOD("clear_outlines"),&NavigationPolygon::clear_outlines);
+ ClassDB::bind_method(D_METHOD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines);
- ClassDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons);
- ClassDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons);
+ ClassDB::bind_method(D_METHOD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons);
+ ClassDB::bind_method(D_METHOD("_get_polygons"),&NavigationPolygon::_get_polygons);
- ClassDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines);
- ClassDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines);
+ ClassDB::bind_method(D_METHOD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines);
+ ClassDB::bind_method(D_METHOD("_get_outlines"),&NavigationPolygon::_get_outlines);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_outlines"),_SCS("_get_outlines"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_vertices","get_vertices");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_polygons","_get_polygons");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_outlines","_get_outlines");
}
NavigationPolygon::NavigationPolygon() {
@@ -310,7 +310,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
-// update_gizmo();
+ //update_gizmo();
}
bool NavigationPolygonInstance::is_enabled() const {
@@ -459,7 +459,7 @@ void NavigationPolygonInstance::_navpoly_changed() {
String NavigationPolygonInstance::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!navpoly.is_valid()) {
@@ -480,16 +480,16 @@ String NavigationPolygonInstance::get_configuration_warning() const {
void NavigationPolygonInstance::_bind_methods() {
- ClassDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
- ClassDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
- ClassDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&NavigationPolygonInstance::is_enabled);
- ClassDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed);
+ ClassDB::bind_method(D_METHOD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navpoly",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"),_SCS("set_navigation_polygon"),_SCS("get_navigation_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navpoly",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"),"set_navigation_polygon","get_navigation_polygon");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
}
NavigationPolygonInstance::NavigationPolygonInstance() {
@@ -497,5 +497,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() {
navigation=NULL;
nav_id=-1;
enabled=true;
+ set_notify_transform(true);
}
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index fb71a5b536..710f9731c5 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -423,67 +423,67 @@ void Node2D::_bind_methods() {
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ClassDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd);
- ClassDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd);
+ ClassDB::bind_method(D_METHOD("_get_rotd"),&Node2D::_get_rotd);
+ ClassDB::bind_method(D_METHOD("_set_rotd","degrees"),&Node2D::_set_rotd);
- ClassDB::bind_method(_MD("set_position","pos"),&Node2D::set_position);
- ClassDB::bind_method(_MD("set_rotation","radians"),&Node2D::set_rotation);
- ClassDB::bind_method(_MD("set_rotation_in_degrees","degrees"),&Node2D::set_rotation_in_degrees);
- ClassDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale);
+ ClassDB::bind_method(D_METHOD("set_position","pos"),&Node2D::set_position);
+ ClassDB::bind_method(D_METHOD("set_rotation","radians"),&Node2D::set_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation_in_degrees","degrees"),&Node2D::set_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("set_scale","scale"),&Node2D::set_scale);
- ClassDB::bind_method(_MD("get_position"),&Node2D::get_position);
- ClassDB::bind_method(_MD("get_rotation"),&Node2D::get_rotation);
- ClassDB::bind_method(_MD("get_rotation_in_degrees"),&Node2D::get_rotation_in_degrees);
- ClassDB::bind_method(_MD("get_scale"),&Node2D::get_scale);
+ ClassDB::bind_method(D_METHOD("get_position"),&Node2D::get_position);
+ ClassDB::bind_method(D_METHOD("get_rotation"),&Node2D::get_rotation);
+ ClassDB::bind_method(D_METHOD("get_rotation_in_degrees"),&Node2D::get_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("get_scale"),&Node2D::get_scale);
- ClassDB::bind_method(_MD("rotate","radians"),&Node2D::rotate);
- ClassDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
- ClassDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
- ClassDB::bind_method(_MD("translate","offset"),&Node2D::translate);
- ClassDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate);
- ClassDB::bind_method(_MD("scale","ratio"),&Node2D::scale);
+ ClassDB::bind_method(D_METHOD("rotate","radians"),&Node2D::rotate);
+ ClassDB::bind_method(D_METHOD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("translate","offset"),&Node2D::translate);
+ ClassDB::bind_method(D_METHOD("global_translate","offset"),&Node2D::global_translate);
+ ClassDB::bind_method(D_METHOD("scale","ratio"),&Node2D::scale);
- ClassDB::bind_method(_MD("set_global_position","pos"),&Node2D::set_global_position);
- ClassDB::bind_method(_MD("get_global_position"),&Node2D::get_global_position);
- ClassDB::bind_method(_MD("set_global_rotation","radians"),&Node2D::set_global_rotation);
- ClassDB::bind_method(_MD("get_global_rotation"),&Node2D::get_global_rotation);
- ClassDB::bind_method(_MD("set_global_rotation_in_degrees","degrees"),&Node2D::set_global_rotation_in_degrees);
- ClassDB::bind_method(_MD("get_global_rotation_in_degrees"),&Node2D::get_global_rotation_in_degrees);
- ClassDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale);
- ClassDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale);
+ ClassDB::bind_method(D_METHOD("set_global_position","pos"),&Node2D::set_global_position);
+ ClassDB::bind_method(D_METHOD("get_global_position"),&Node2D::get_global_position);
+ ClassDB::bind_method(D_METHOD("set_global_rotation","radians"),&Node2D::set_global_rotation);
+ ClassDB::bind_method(D_METHOD("get_global_rotation"),&Node2D::get_global_rotation);
+ ClassDB::bind_method(D_METHOD("set_global_rotation_in_degrees","degrees"),&Node2D::set_global_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("get_global_rotation_in_degrees"),&Node2D::get_global_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("set_global_scale","scale"),&Node2D::set_global_scale);
+ ClassDB::bind_method(D_METHOD("get_global_scale"),&Node2D::get_global_scale);
- ClassDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform);
- ClassDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","xform"),&Node2D::set_transform);
+ ClassDB::bind_method(D_METHOD("set_global_transform","xform"),&Node2D::set_global_transform);
- ClassDB::bind_method(_MD("look_at","point"),&Node2D::look_at);
- ClassDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to);
+ 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(_MD("set_z","z"),&Node2D::set_z);
- ClassDB::bind_method(_MD("get_z"),&Node2D::get_z);
+ ClassDB::bind_method(D_METHOD("set_z","z"),&Node2D::set_z);
+ ClassDB::bind_method(D_METHOD("get_z"),&Node2D::get_z);
- ClassDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
- ClassDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
+ ClassDB::bind_method(D_METHOD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
+ ClassDB::bind_method(D_METHOD("is_z_relative"),&Node2D::is_z_relative);
- ClassDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
+ ClassDB::bind_method(D_METHOD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
- ClassDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent);
+ ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent);
ADD_GROUP("Transform","");
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"position"),_SCS("set_position"),_SCS("get_position"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_rotation"),_SCS("get_rotation"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation_deg",PROPERTY_HINT_RANGE,"-1440,1440,0.1",PROPERTY_USAGE_EDITOR),_SCS("set_rotation_in_degrees"),_SCS("get_rotation_in_degrees"));
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale"));
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"transform",PROPERTY_HINT_NONE,"",0),_SCS("set_transform"),_SCS("get_transform"));
-
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_position",PROPERTY_HINT_NONE,"",0),_SCS("set_global_position"),_SCS("get_global_position"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation"),_SCS("get_global_rotation"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation_deg",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation_in_degrees"),_SCS("get_global_rotation_in_degrees"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_scale",PROPERTY_HINT_NONE,"",0),_SCS("set_global_scale"),_SCS("get_global_scale"));
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"global_transform",PROPERTY_HINT_NONE,"",0),_SCS("set_global_transform"),_SCS("get_global_transform"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"position"),"set_position","get_position");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_rotation","get_rotation");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation_deg",PROPERTY_HINT_RANGE,"-1440,1440,0.1",PROPERTY_USAGE_EDITOR),"set_rotation_in_degrees","get_rotation_in_degrees");
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"scale"),"set_scale","get_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"transform",PROPERTY_HINT_NONE,"",0),"set_transform","get_transform");
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_position",PROPERTY_HINT_NONE,"",0),"set_global_position","get_global_position");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation",PROPERTY_HINT_NONE,"",0),"set_global_rotation","get_global_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation_deg",PROPERTY_HINT_NONE,"",0),"set_global_rotation_in_degrees","get_global_rotation_in_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_scale",PROPERTY_HINT_NONE,"",0),"set_global_scale","get_global_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"global_transform",PROPERTY_HINT_NONE,"",0),"set_global_transform","get_global_transform");
ADD_GROUP("Z","");
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z"));
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z_as_relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),"set_z","get_z");
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z_as_relative"),"set_z_as_relative","is_z_relative");
}
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 1e6a449fce..9336dc51af 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -189,28 +189,28 @@ Vector2 ParallaxBackground::get_final_offset() const {
void ParallaxBackground::_bind_methods() {
- ClassDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
- ClassDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
- ClassDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
- ClassDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
- ClassDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
- ClassDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
- ClassDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
- ClassDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
- ClassDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
- ClassDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
- ClassDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
- ClassDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
- ClassDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
+ ClassDB::bind_method(D_METHOD("_camera_moved"),&ParallaxBackground::_camera_moved);
+ ClassDB::bind_method(D_METHOD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
+ ClassDB::bind_method(D_METHOD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
+ ClassDB::bind_method(D_METHOD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
+ ClassDB::bind_method(D_METHOD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
+ ClassDB::bind_method(D_METHOD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
+ ClassDB::bind_method(D_METHOD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
+ ClassDB::bind_method(D_METHOD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
+ ClassDB::bind_method(D_METHOD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
+ ClassDB::bind_method(D_METHOD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
+ ClassDB::bind_method(D_METHOD("get_limit_end"),&ParallaxBackground::get_limit_end);
+ ClassDB::bind_method(D_METHOD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
+ ClassDB::bind_method(D_METHOD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
ADD_GROUP("Scroll","scroll_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll_ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_offset"),"set_scroll_offset","get_scroll_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_offset"),"set_scroll_base_offset","get_scroll_base_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_scale"),"set_scroll_base_scale","get_scroll_base_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_begin"),"set_limit_begin","get_limit_begin");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_end"),"set_limit_end","get_limit_end");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll_ignore_camera_zoom"), "set_ignore_camera_zoom", "is_ignore_camera_zoom");
}
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 9aa6640727..37d8fb52f1 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -150,17 +150,17 @@ String ParallaxLayer::get_configuration_warning() const {
void ParallaxLayer::_bind_methods() {
- ClassDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
- ClassDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
- ClassDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
- ClassDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
- ClassDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
- ClassDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
+ ClassDB::bind_method(D_METHOD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
+ ClassDB::bind_method(D_METHOD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
+ ClassDB::bind_method(D_METHOD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
+ ClassDB::bind_method(D_METHOD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
+ ClassDB::bind_method(D_METHOD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
+ ClassDB::bind_method(D_METHOD("get_mirroring"),&ParallaxLayer::get_mirroring);
ADD_GROUP("Motion","motion_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_scale"),"set_motion_scale","get_motion_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_offset"),"set_motion_offset","get_motion_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_mirroring"),"set_mirroring","get_mirroring");
}
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index cd99f30f6d..77ace0348a 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "particles_2d.h"
+#include "scene/scene_string_names.h"
@@ -113,30 +114,30 @@ void ParticleAttractor2D::_set_owner(Particles2D* p_owner) {
void ParticleAttractor2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&ParticleAttractor2D::is_enabled);
- ClassDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius","radius"),&ParticleAttractor2D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&ParticleAttractor2D::get_radius);
- ClassDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius);
- ClassDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius);
+ ClassDB::bind_method(D_METHOD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius);
+ ClassDB::bind_method(D_METHOD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius);
- ClassDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity);
- ClassDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity);
+ ClassDB::bind_method(D_METHOD("get_gravity"),&ParticleAttractor2D::get_gravity);
- ClassDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption);
- ClassDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption);
+ ClassDB::bind_method(D_METHOD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption);
+ ClassDB::bind_method(D_METHOD("get_absorption"),&ParticleAttractor2D::get_absorption);
- ClassDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path);
- ClassDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path);
+ ClassDB::bind_method(D_METHOD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path);
+ ClassDB::bind_method(D_METHOD("get_particles_path"),&ParticleAttractor2D::get_particles_path);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_radius"),_SCS("get_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"disable_radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_disable_radius"),_SCS("get_disable_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-512,512,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"absorption",PROPERTY_HINT_RANGE,"0,512,0.01"),_SCS("set_absorption"),_SCS("get_absorption"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"particles_path",PROPERTY_HINT_RESOURCE_TYPE,"Particles2D"),_SCS("set_particles_path"),_SCS("get_particles_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),"set_radius","get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"disable_radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),"set_disable_radius","get_disable_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-512,512,0.01"),"set_gravity","get_gravity");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"absorption",PROPERTY_HINT_RANGE,"0,512,0.01"),"set_absorption","get_absorption");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"particles_path",PROPERTY_HINT_RESOURCE_TYPE,"Particles2D"),"set_particles_path","get_particles_path");
@@ -227,21 +228,10 @@ ParticleAttractor2D::ParticleAttractor2D() {
/****************************************/
-_FORCE_INLINE_ static float _rand_from_seed(uint32_t *seed) {
+_FORCE_INLINE_ static float _rand_from_seed(uint64_t *seed) {
- uint32_t k;
- uint32_t s = (*seed);
- if (s == 0)
- s = 0x12345987;
- k = s / 127773;
- s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
- s += 2147483647;
- (*seed) = s;
-
- float v=((float)((*seed) & 0xFFFFF))/(float)0xFFFFF;
- v=v*2.0-1.0;
- return v;
+ uint32_t r = Math::rand_from_seed(seed);
+ return 2.0f * (float)r / (float)Math::RANDOM_MAX - 1.0f;
}
void Particles2D::_process_particles(float p_delta) {
@@ -348,7 +338,7 @@ void Particles2D::_process_particles(float p_delta) {
}
}
p.seed=Math::rand() % 12345678;
- uint32_t rand_seed=p.seed*(i+1);
+ uint64_t rand_seed=p.seed*(i+1);
float angle = Math::deg2rad(param[PARAM_DIRECTION]+_rand_from_seed(&rand_seed)*param[PARAM_SPREAD]);
@@ -364,7 +354,7 @@ void Particles2D::_process_particles(float p_delta) {
p.rot=Math::deg2rad(param[PARAM_INITIAL_ANGLE]+param[PARAM_INITIAL_ANGLE]*randomness[PARAM_INITIAL_ANGLE]*_rand_from_seed(&rand_seed));
active_count++;
- p.frame=Math::fmod(param[PARAM_ANIM_INITIAL_POS]+randomness[PARAM_ANIM_INITIAL_POS]*_rand_from_seed(&rand_seed),1.0);
+ p.frame=Math::fmod(param[PARAM_ANIM_INITIAL_POS]+randomness[PARAM_ANIM_INITIAL_POS]*_rand_from_seed(&rand_seed),1.0f);
} else {
@@ -377,7 +367,7 @@ void Particles2D::_process_particles(float p_delta) {
if (!p.active)
continue;
- uint32_t rand_seed=p.seed*(i+1);
+ uint64_t rand_seed=p.seed*(i+1);
Vector2 force;
@@ -438,7 +428,7 @@ void Particles2D::_process_particles(float p_delta) {
p.pos+=p.velocity*frame_time;
p.rot+=Math::lerp(param[PARAM_SPIN_VELOCITY],param[PARAM_SPIN_VELOCITY]*randomness[PARAM_SPIN_VELOCITY]*_rand_from_seed(&rand_seed),randomness[PARAM_SPIN_VELOCITY])*frame_time;
float anim_spd=param[PARAM_ANIM_SPEED_SCALE]+param[PARAM_ANIM_SPEED_SCALE]*randomness[PARAM_ANIM_SPEED_SCALE]*_rand_from_seed(&rand_seed);
- p.frame=Math::fposmod(p.frame+(frame_time/lifetime)*anim_spd,1.0);
+ p.frame=Math::fposmod(p.frame+(frame_time/lifetime)*anim_spd,1.0f);
active_count++;
@@ -451,8 +441,9 @@ void Particles2D::_process_particles(float p_delta) {
time=Math::fmod( time+frame_time, lifetime );
if (!emitting && active_count==0) {
+ emit_signal(SceneStringNames::get_singleton()->emission_finished);
set_process(false);
-
+ set_fixed_process(false);
}
update();
@@ -470,6 +461,11 @@ void Particles2D::_notification(int p_what) {
_process_particles( get_process_delta_time() );
} break;
+ case NOTIFICATION_FIXED_PROCESS: {
+
+ _process_particles( get_fixed_process_delta_time() );
+ } break;
+
case NOTIFICATION_ENTER_TREE: {
float ppt=preprocess;
@@ -530,7 +526,7 @@ void Particles2D::_notification(int p_what) {
else
ptime=(1.0-ptime)+time_pos;
- uint32_t rand_seed=p.seed*(i+1);
+ uint64_t rand_seed=p.seed*(i+1);
Color color;
@@ -555,7 +551,7 @@ void Particles2D::_notification(int p_what) {
float a=color.a;
//float preh=h;
h+=huerot;
- h=Math::abs(Math::fposmod(h,1.0));
+ h=Math::abs(Math::fposmod(h,1.0f));
//print_line("rand: "+rtos(randomness[PARAM_HUE_VARIATION])+" rand: "+rtos(huerand));
//print_line(itos(i)+":hue: "+rtos(preh)+" + "+rtos(huerot)+" = "+rtos(h));
color.set_hsv(h,s,v);
@@ -607,6 +603,10 @@ void Particles2D::_notification(int p_what) {
src_rect.pos.y = size.y * (frame/h_frames);
}
+ if (flip_h)
+ src_rect.size.x=-src_rect.size.x;
+ if (flip_v)
+ src_rect.size.y=-src_rect.size.y;
texture->draw_rect_region(ci,Rect2(Point2(),size),src_rect,color);
//VisualServer::get_singleton()->canvas_item_add_texture_rect(ci,r,texrid,false,color);
@@ -691,7 +691,8 @@ void Particles2D::set_emitting(bool p_emitting) {
if (active_count==0)
time=0;
- set_process(true);
+ set_process(process_mode==PROCESS_IDLE);
+ set_fixed_process(process_mode==PROCESS_FIXED);
time_to_live = emit_timeout;
};
emitting=p_emitting;
@@ -703,6 +704,19 @@ bool Particles2D::is_emitting() const {
return emitting;
}
+void Particles2D::set_process_mode(ProcessMode p_mode) {
+
+ process_mode=p_mode;
+ const bool should_process=emitting || active_count!=0;
+ set_process(should_process && process_mode==PROCESS_IDLE);
+ set_fixed_process(should_process && process_mode==PROCESS_FIXED);
+}
+
+Particles2D::ProcessMode Particles2D::get_process_mode() const {
+
+ return process_mode;
+}
+
void Particles2D::set_amount(int p_amount) {
ERR_FAIL_INDEX(p_amount,1024+1);
@@ -914,15 +928,6 @@ Vector2 Particles2D::get_emission_half_extents() const {
return extents;
}
-void Particles2D::testee(int a, int b, int c, int d, int e) {
-
- print_line(itos(a));
- print_line(itos(b));
- print_line(itos(c));
- print_line(itos(d));
- print_line(itos(e));
-}
-
void Particles2D::set_initial_velocity(const Vector2& p_velocity) {
@@ -1013,119 +1018,125 @@ void Particles2D::reset() {
void Particles2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting);
- ClassDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting);
+ ClassDB::bind_method(D_METHOD("set_emitting","active"),&Particles2D::set_emitting);
+ ClassDB::bind_method(D_METHOD("is_emitting"),&Particles2D::is_emitting);
+
+ ClassDB::bind_method(D_METHOD("set_process_mode","mode"),&Particles2D::set_process_mode);
+ ClassDB::bind_method(D_METHOD("get_process_mode"),&Particles2D::get_process_mode);
+
+ ClassDB::bind_method(D_METHOD("set_amount","amount"),&Particles2D::set_amount);
+ ClassDB::bind_method(D_METHOD("get_amount"),&Particles2D::get_amount);
- ClassDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount);
- ClassDB::bind_method(_MD("get_amount"),&Particles2D::get_amount);
+ ClassDB::bind_method(D_METHOD("set_lifetime","lifetime"),&Particles2D::set_lifetime);
+ ClassDB::bind_method(D_METHOD("get_lifetime"),&Particles2D::get_lifetime);
- ClassDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime);
- ClassDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime);
+ ClassDB::bind_method(D_METHOD("set_time_scale","time_scale"),&Particles2D::set_time_scale);
+ ClassDB::bind_method(D_METHOD("get_time_scale"),&Particles2D::get_time_scale);
- ClassDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale);
- ClassDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale);
+ ClassDB::bind_method(D_METHOD("set_pre_process_time","time"),&Particles2D::set_pre_process_time);
+ ClassDB::bind_method(D_METHOD("get_pre_process_time"),&Particles2D::get_pre_process_time);
- ClassDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time);
- ClassDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time);
+ ClassDB::bind_method(D_METHOD("set_emit_timeout","value"),&Particles2D::set_emit_timeout);
+ ClassDB::bind_method(D_METHOD("get_emit_timeout"),&Particles2D::get_emit_timeout);
- ClassDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout);
- ClassDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&Particles2D::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&Particles2D::get_param);
- ClassDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&Particles2D::get_param);
+ ClassDB::bind_method(D_METHOD("set_randomness","param","value"),&Particles2D::set_randomness);
+ ClassDB::bind_method(D_METHOD("get_randomness","param"),&Particles2D::get_randomness);
- ClassDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness);
- ClassDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness);
+ ClassDB::bind_method(D_METHOD("set_texture:Texture","texture"),&Particles2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"),&Particles2D::get_texture);
- ClassDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture);
- ClassDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_color","color"),&Particles2D::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"),&Particles2D::get_color);
- ClassDB::bind_method(_MD("set_color","color"),&Particles2D::set_color);
- ClassDB::bind_method(_MD("get_color"),&Particles2D::get_color);
+ ClassDB::bind_method(D_METHOD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp);
+ ClassDB::bind_method(D_METHOD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp);
- ClassDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp);
- ClassDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp);
+ ClassDB::bind_method(D_METHOD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset);
+ ClassDB::bind_method(D_METHOD("get_emissor_offset"),&Particles2D::get_emissor_offset);
- ClassDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset);
- ClassDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset);
+ ClassDB::bind_method(D_METHOD("set_flip_h","enable"),&Particles2D::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"),&Particles2D::is_flipped_h);
- ClassDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h);
- ClassDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_v","enable"),&Particles2D::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"),&Particles2D::is_flipped_v);
- ClassDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v);
- ClassDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_h_frames","enable"),&Particles2D::set_h_frames);
+ ClassDB::bind_method(D_METHOD("get_h_frames"),&Particles2D::get_h_frames);
- ClassDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames);
- ClassDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames);
+ ClassDB::bind_method(D_METHOD("set_v_frames","enable"),&Particles2D::set_v_frames);
+ ClassDB::bind_method(D_METHOD("get_v_frames"),&Particles2D::get_v_frames);
- ClassDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames);
- ClassDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames);
+ ClassDB::bind_method(D_METHOD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents);
+ ClassDB::bind_method(D_METHOD("get_emission_half_extents"),&Particles2D::get_emission_half_extents);
- ClassDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents);
- ClassDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents);
+ ClassDB::bind_method(D_METHOD("set_color_phases","phases"),&Particles2D::set_color_phases);
+ ClassDB::bind_method(D_METHOD("get_color_phases"),&Particles2D::get_color_phases);
- ClassDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases);
- ClassDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases);
+ ClassDB::bind_method(D_METHOD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color);
+ ClassDB::bind_method(D_METHOD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color);
- ClassDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color);
- ClassDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color);
+ ClassDB::bind_method(D_METHOD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos);
+ ClassDB::bind_method(D_METHOD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
- ClassDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos);
- ClassDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
+ ClassDB::bind_method(D_METHOD("pre_process","time"),&Particles2D::pre_process);
+ ClassDB::bind_method(D_METHOD("reset"),&Particles2D::reset);
- ClassDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process);
- ClassDB::bind_method(_MD("reset"),&Particles2D::reset);
+ ClassDB::bind_method(D_METHOD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
+ ClassDB::bind_method(D_METHOD("is_using_local_space"),&Particles2D::is_using_local_space);
- ClassDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
- ClassDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space);
+ ClassDB::bind_method(D_METHOD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity);
+ ClassDB::bind_method(D_METHOD("get_initial_velocity"),&Particles2D::get_initial_velocity);
- ClassDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity);
- ClassDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity);
+ ClassDB::bind_method(D_METHOD("set_explosiveness","amount"),&Particles2D::set_explosiveness);
+ ClassDB::bind_method(D_METHOD("get_explosiveness"),&Particles2D::get_explosiveness);
- ClassDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness);
- ClassDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness);
+ ClassDB::bind_method(D_METHOD("set_emission_points","points"),&Particles2D::set_emission_points);
+ ClassDB::bind_method(D_METHOD("get_emission_points"),&Particles2D::get_emission_points);
- ClassDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points);
- ClassDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points);
+ ADD_SIGNAL(MethodInfo("emission_finished"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),_SCS("set_amount"),_SCS("get_amount") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_lifetime"),_SCS("get_lifetime") );
- ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/time_scale",PROPERTY_HINT_EXP_RANGE,"0.01,128,0.01"),_SCS("set_time_scale"),_SCS("get_time_scale") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/preprocess",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_pre_process_time"),_SCS("get_pre_process_time") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/emit_timeout",PROPERTY_HINT_RANGE,"0,3600,0.1"),_SCS("set_emit_timeout"),_SCS("get_emit_timeout") );
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/emitting"),_SCS("set_emitting"),_SCS("is_emitting") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/offset"),_SCS("set_emissor_offset"),_SCS("get_emissor_offset"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/half_extents"),_SCS("set_emission_half_extents"),_SCS("get_emission_half_extents"));
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/local_space"),_SCS("set_use_local_space"),_SCS("is_using_local_space"));
- ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_explosiveness"),_SCS("get_explosiveness"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_h"),_SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_v"),_SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/h_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_h_frames"),_SCS("get_h_frames"));
- ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/v_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_v_frames"),_SCS("get_v_frames"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),"set_amount","get_amount") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),"set_lifetime","get_lifetime") ;
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/time_scale",PROPERTY_HINT_EXP_RANGE,"0.01,128,0.01"),"set_time_scale","get_time_scale") ;
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/preprocess",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),"set_pre_process_time","get_pre_process_time") ;
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/emit_timeout",PROPERTY_HINT_RANGE,"0,3600,0.1"),"set_emit_timeout","get_emit_timeout") ;
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/emitting"),"set_emitting","is_emitting") ;
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"config/process_mode",PROPERTY_HINT_ENUM, "Fixed,Idle"),"set_process_mode","get_process_mode");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/offset"),"set_emissor_offset","get_emissor_offset");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/half_extents"),"set_emission_half_extents","get_emission_half_extents");
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/local_space"),"set_use_local_space","is_using_local_space");
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_explosiveness","get_explosiveness");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_h"),"set_flip_h","is_flipped_h");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_v"),"set_flip_v","is_flipped_v");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/h_frames",PROPERTY_HINT_RANGE,"1,512,1"),"set_h_frames","get_h_frames");
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/v_frames",PROPERTY_HINT_RANGE,"1,512,1"),"set_v_frames","get_v_frames");
for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,_particlesframe_property_names[i],PROPERTY_HINT_RANGE,_particlesframe_property_ranges[i]),_SCS("set_param"),_SCS("get_param"),i);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,_particlesframe_property_names[i],PROPERTY_HINT_RANGE,_particlesframe_property_ranges[i]),"set_param","get_param",i);
}
for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYINZ(PropertyInfo(Variant::REAL,_particlesframe_property_rnames[i],PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_randomness"),_SCS("get_randomness"),i);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::REAL,_particlesframe_property_rnames[i],PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_randomness","get_randomness",i);
}
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1", 0), _SCS("set_color_phases"), _SCS("get_color_phases"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1", 0), "set_color_phases", "get_color_phases");
//Backward compatibility. They will be converted to color ramp
for(int i=0;i<MAX_COLOR_PHASES;i++) {
String phase="phase_"+itos(i)+"/";
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01", 0),_SCS("set_color_phase_pos"),_SCS("get_color_phase_pos"),i );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color", PROPERTY_HINT_NONE, "", 0),_SCS("set_color_phase_color"),_SCS("get_color_phase_color"),i );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01", 0),"set_color_phase_pos","get_color_phase_pos",i );
+ ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color", PROPERTY_HINT_NONE, "", 0),"set_color_phase_color","get_color_phase_color",i );
}
- ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),_SCS("set_color_ramp"),_SCS("get_color_ramp"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),"set_color","get_color");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),"set_color_ramp","get_color_ramp");
- ADD_PROPERTYNZ(PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_emission_points","get_emission_points");
BIND_CONSTANT( PARAM_DIRECTION );
BIND_CONSTANT( PARAM_SPREAD );
@@ -1176,6 +1187,7 @@ Particles2D::Particles2D() {
particles.resize(32);
active_count=-1;
set_emitting(true);
+ process_mode=PROCESS_IDLE;
local_space=true;
preprocess=0;
time_scale=1.0;
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 91f42c5222..c6ababe3be 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -111,6 +111,11 @@ public:
MAX_COLOR_PHASES=4
};
+ enum ProcessMode {
+ PROCESS_FIXED,
+ PROCESS_IDLE,
+ };
+
private:
float param[PARAM_MAX];
@@ -122,7 +127,7 @@ private:
Vector2 velocity;
float rot;
float frame;
- uint32_t seed;
+ uint64_t seed;
Particle() { active=false; seed=123465789; rot=0; frame=0;}
};
@@ -153,6 +158,8 @@ private:
Vector2 extents;
PoolVector<Vector2> emission_points;
+ ProcessMode process_mode;
+
float time;
int active_count;
@@ -162,7 +169,6 @@ private:
Color default_color;
Ref<ColorRamp> color_ramp;
- void testee(int a, int b, int c, int d, int e);
void _process_particles(float p_delta);
friend class ParticleAttractor2D;
@@ -178,6 +184,9 @@ public:
void set_emitting(bool p_emitting);
bool is_emitting() const;
+ void set_process_mode(ProcessMode p_mode);
+ ProcessMode get_process_mode() const;
+
void set_amount(int p_amount);
int get_amount() const;
@@ -254,6 +263,7 @@ public:
Particles2D();
};
+VARIANT_ENUM_CAST( Particles2D::ProcessMode );
VARIANT_ENUM_CAST( Particles2D::Parameter );
#endif // PARTICLES_FRAME_H
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 0508a715eb..63531ae599 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -85,11 +85,11 @@ Ref<Curve2D> Path2D::get_curve() const{
void Path2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve);
- ClassDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve);
- ClassDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed);
+ ClassDB::bind_method(D_METHOD("set_curve","curve:Curve2D"),&Path2D::set_curve);
+ ClassDB::bind_method(D_METHOD("get_curve:Curve2D","curve"),&Path2D::get_curve);
+ ClassDB::bind_method(D_METHOD("_curve_changed"),&Path2D::_curve_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), _SCS("set_curve"),_SCS("get_curve"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), "set_curve","get_curve");
}
Path2D::Path2D() {
@@ -239,7 +239,7 @@ void PathFollow2D::_get_property_list( List<PropertyInfo> *p_list) const{
String PathFollow2D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!get_parent() || !get_parent()->cast_to<Path2D>()) {
@@ -252,26 +252,26 @@ String PathFollow2D::get_configuration_warning() const {
void PathFollow2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&PathFollow2D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&PathFollow2D::get_offset);
- ClassDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset);
- ClassDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset);
+ ClassDB::bind_method(D_METHOD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset);
+ ClassDB::bind_method(D_METHOD("get_h_offset"),&PathFollow2D::get_h_offset);
- ClassDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset);
- ClassDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset);
+ ClassDB::bind_method(D_METHOD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset);
+ ClassDB::bind_method(D_METHOD("get_v_offset"),&PathFollow2D::get_v_offset);
- ClassDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset);
- ClassDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset);
+ ClassDB::bind_method(D_METHOD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset);
+ ClassDB::bind_method(D_METHOD("get_unit_offset"),&PathFollow2D::get_unit_offset);
- ClassDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate);
- ClassDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating);
+ ClassDB::bind_method(D_METHOD("set_rotate","enable"),&PathFollow2D::set_rotate);
+ ClassDB::bind_method(D_METHOD("is_rotating"),&PathFollow2D::is_rotating);
- ClassDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation);
- ClassDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation);
- ClassDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop);
+ ClassDB::bind_method(D_METHOD("set_loop","loop"),&PathFollow2D::set_loop);
+ ClassDB::bind_method(D_METHOD("has_loop"),&PathFollow2D::has_loop);
}
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 1498ad13a6..0ffaf81e3d 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -70,53 +70,54 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{
void PhysicsBody2D::_set_layers(uint32_t p_mask) {
- set_layer_mask(p_mask);
+ set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
uint32_t PhysicsBody2D::_get_layers() const{
- return get_layer_mask();
+ return get_collision_layer();
}
void PhysicsBody2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
- ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
- ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_layer","mask"),&PhysicsBody2D::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"),&PhysicsBody2D::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
- ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit);
- ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit);
- ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit);
- ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit","bit","value"),&PhysicsBody2D::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit","bit"),&PhysicsBody2D::get_collision_layer_bit);
+
+ ClassDB::bind_method(D_METHOD("_set_layers","mask"),&PhysicsBody2D::_set_layers);
+ ClassDB::bind_method(D_METHOD("_get_layers"),&PhysicsBody2D::_get_layers);
+ ClassDB::bind_method(D_METHOD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
+ ClassDB::bind_method(D_METHOD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
+ ClassDB::bind_method(D_METHOD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
+ ClassDB::bind_method(D_METHOD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
+ ClassDB::bind_method(D_METHOD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_LAYERS_2D_PHYSICS,"",0),"_set_layers","_get_layers"); //for backwards compat
- ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers);
- ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers);
- ClassDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
- ClassDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
- ClassDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
- ClassDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
- ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
- ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_LAYERS_2D_PHYSICS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
ADD_GROUP("Collision","collision_");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_collision_layer","get_collision_layer");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_collision_mask","get_collision_mask");
ADD_GROUP("","");
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),"set_one_way_collision_direction","get_one_way_collision_direction");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),"set_one_way_collision_max_depth","get_one_way_collision_max_depth");
}
-void PhysicsBody2D::set_layer_mask(uint32_t p_mask) {
+void PhysicsBody2D::set_collision_layer(uint32_t p_mask) {
mask=p_mask;
Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
}
-uint32_t PhysicsBody2D::get_layer_mask() const {
+uint32_t PhysicsBody2D::get_collision_layer() const {
return mask;
}
@@ -148,20 +149,20 @@ bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{
}
-void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) {
+void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) {
- uint32_t mask = get_layer_mask();
+ uint32_t mask = get_collision_layer();
if (p_value)
mask|=1<<p_bit;
else
mask&=~(1<<p_bit);
- set_layer_mask(mask);
+ set_collision_layer(mask);
}
-bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const{
- return get_layer_mask()&(1<<p_bit);
+ return get_collision_layer()&(1<<p_bit);
}
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) {
@@ -270,20 +271,20 @@ real_t StaticBody2D::get_bounce() const{
void StaticBody2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity);
- ClassDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity);
- ClassDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity);
- ClassDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity);
- ClassDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction);
- ClassDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction);
+ ClassDB::bind_method(D_METHOD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_friction","friction"),&StaticBody2D::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"),&StaticBody2D::get_friction);
- ClassDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce);
- ClassDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce);
+ ClassDB::bind_method(D_METHOD("set_bounce","bounce"),&StaticBody2D::set_bounce);
+ ClassDB::bind_method(D_METHOD("get_bounce"),&StaticBody2D::get_bounce);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"constant_linear_velocity"),"set_constant_linear_velocity","get_constant_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"constant_angular_velocity"),"set_constant_angular_velocity","get_constant_angular_velocity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_friction","get_friction");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_bounce","get_bounce");
}
StaticBody2D::StaticBody2D() : PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) {
@@ -374,7 +375,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (!E) {
E = contact_monitor->body_map.insert(objid,BodyState());
-// E->get().rc=0;
+ //E->get().rc=0;
E->get().in_scene=node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
@@ -493,7 +494,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ //bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
@@ -881,96 +882,96 @@ bool RigidBody2D::is_contact_monitor_enabled() const {
void RigidBody2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&RigidBody2D::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&RigidBody2D::get_mode);
- ClassDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass);
- ClassDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass","mass"),&RigidBody2D::set_mass);
+ ClassDB::bind_method(D_METHOD("get_mass"),&RigidBody2D::get_mass);
- ClassDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia);
- ClassDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia);
+ ClassDB::bind_method(D_METHOD("get_inertia"),&RigidBody2D::get_inertia);
+ ClassDB::bind_method(D_METHOD("set_inertia","inertia"),&RigidBody2D::set_inertia);
- ClassDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight);
- ClassDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight);
+ ClassDB::bind_method(D_METHOD("set_weight","weight"),&RigidBody2D::set_weight);
+ ClassDB::bind_method(D_METHOD("get_weight"),&RigidBody2D::get_weight);
- ClassDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction);
- ClassDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction);
+ ClassDB::bind_method(D_METHOD("set_friction","friction"),&RigidBody2D::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"),&RigidBody2D::get_friction);
- ClassDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce);
- ClassDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce);
+ ClassDB::bind_method(D_METHOD("set_bounce","bounce"),&RigidBody2D::set_bounce);
+ ClassDB::bind_method(D_METHOD("get_bounce"),&RigidBody2D::get_bounce);
- ClassDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale);
- ClassDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_scale"),&RigidBody2D::get_gravity_scale);
- ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp);
- ClassDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"),&RigidBody2D::get_linear_damp);
- ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp);
- ClassDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"),&RigidBody2D::get_angular_damp);
- ClassDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity);
- ClassDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"),&RigidBody2D::get_linear_velocity);
- ClassDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity);
- ClassDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"),&RigidBody2D::get_angular_velocity);
- ClassDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported);
- ClassDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported);
- ClassDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator);
- ClassDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator);
+ ClassDB::bind_method(D_METHOD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator);
+ ClassDB::bind_method(D_METHOD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator);
- ClassDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor);
- ClassDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled);
+ ClassDB::bind_method(D_METHOD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor);
+ ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled);
- ClassDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode);
- ClassDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
- ClassDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
- ClassDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
+ ClassDB::bind_method(D_METHOD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
- ClassDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
- ClassDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
+ ClassDB::bind_method(D_METHOD("set_applied_force","force"),&RigidBody2D::set_applied_force);
+ ClassDB::bind_method(D_METHOD("get_applied_force"),&RigidBody2D::get_applied_force);
- ClassDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
- ClassDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque);
+ ClassDB::bind_method(D_METHOD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
+ ClassDB::bind_method(D_METHOD("get_applied_torque"),&RigidBody2D::get_applied_torque);
- ClassDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force);
+ ClassDB::bind_method(D_METHOD("add_force","offset","force"),&RigidBody2D::add_force);
- ClassDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
- ClassDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
+ ClassDB::bind_method(D_METHOD("is_sleeping"),&RigidBody2D::is_sleeping);
- ClassDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
- ClassDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
+ ClassDB::bind_method(D_METHOD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
+ ClassDB::bind_method(D_METHOD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
- ClassDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed);
- ClassDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree);
- ClassDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"),&RigidBody2D::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_body_enter_tree"),&RigidBody2D::_body_enter_tree);
+ ClassDB::bind_method(D_METHOD("_body_exit_tree"),&RigidBody2D::_body_exit_tree);
- ClassDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies);
+ ClassDB::bind_method(D_METHOD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies);
BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:Physics2DDirectBodyState")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),_SCS("set_weight"),_SCS("get_weight"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),_SCS("set_gravity_scale"),_SCS("get_gravity_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),_SCS("set_use_custom_integrator"),_SCS("is_using_custom_integrator"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"continuous_cd",PROPERTY_HINT_ENUM,"Disabled,Cast Ray,Cast Shape"),_SCS("set_continuous_collision_detection_mode"),_SCS("get_continuous_collision_detection_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),"set_mode","get_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),"set_mass","get_mass");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),"set_weight","get_weight");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_friction","get_friction");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_bounce","get_bounce");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),"set_gravity_scale","get_gravity_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),"set_use_custom_integrator","is_using_custom_integrator");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"continuous_cd",PROPERTY_HINT_ENUM,"Disabled,Cast Ray,Cast Shape"),"set_continuous_collision_detection_mode","get_continuous_collision_detection_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),"set_max_contacts_reported","get_max_contacts_reported");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),"set_contact_monitor","is_contact_monitor_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),"set_sleeping","is_sleeping");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),"set_can_sleep","is_able_to_sleep");
ADD_GROUP("Linear","linear_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"linear_velocity"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"linear_velocity"),"set_linear_velocity","get_linear_velocity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),"set_linear_damp","get_linear_damp");
ADD_GROUP("Angular","angular_");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_velocity"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_velocity"),"set_angular_velocity","get_angular_velocity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),"set_angular_damp","get_angular_damp");
ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
@@ -1140,8 +1141,10 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
float d = a.distance_to(b);
- //if (d<margin)
- /// continue;
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.4;
}
@@ -1259,7 +1262,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2& p_linear_velocity,const V
//all is a wall
move_and_slide_on_wall=true;
} else {
- if ( get_collision_normal().dot(p_floor_direction) > Math::cos(Math::deg2rad(45))) { //floor
+ if ( get_collision_normal().dot(p_floor_direction) > Math::cos(Math::deg2rad((float)45))) { //floor
move_and_slide_on_floor=true;
@@ -1269,7 +1272,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2& p_linear_velocity,const V
revert_motion();
return Vector2();
}
- } else if ( get_collision_normal().dot(p_floor_direction) < Math::cos(Math::deg2rad(45))) { //ceiling
+ } else if ( get_collision_normal().dot(p_floor_direction) < Math::cos(Math::deg2rad((float)45))) { //ceiling
move_and_slide_on_ceiling=true;
} else {
move_and_slide_on_wall=true;
@@ -1385,31 +1388,31 @@ float KinematicBody2D::get_collision_margin() const{
void KinematicBody2D::_bind_methods() {
- ClassDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move);
- ClassDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to);
- ClassDB::bind_method(_MD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4));
+ ClassDB::bind_method(D_METHOD("move","rel_vec"),&KinematicBody2D::move);
+ ClassDB::bind_method(D_METHOD("move_to","position"),&KinematicBody2D::move_to);
+ ClassDB::bind_method(D_METHOD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4));
- ClassDB::bind_method(_MD("test_move","from","rel_vec"),&KinematicBody2D::test_move);
- ClassDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel);
- ClassDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion);
+ ClassDB::bind_method(D_METHOD("test_move","from","rel_vec"),&KinematicBody2D::test_move);
+ ClassDB::bind_method(D_METHOD("get_travel"),&KinematicBody2D::get_travel);
+ ClassDB::bind_method(D_METHOD("revert_motion"),&KinematicBody2D::revert_motion);
- ClassDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding);
+ ClassDB::bind_method(D_METHOD("is_colliding"),&KinematicBody2D::is_colliding);
- ClassDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos);
- ClassDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal);
- ClassDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
- ClassDB::bind_method(_MD("get_collider:Variant"),&KinematicBody2D::_get_collider);
- ClassDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
- ClassDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
- ClassDB::bind_method(_MD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders);
- ClassDB::bind_method(_MD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor);
- ClassDB::bind_method(_MD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling);
- ClassDB::bind_method(_MD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall);
+ ClassDB::bind_method(D_METHOD("get_collision_pos"),&KinematicBody2D::get_collision_pos);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"),&KinematicBody2D::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider:Variant"),&KinematicBody2D::_get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
+ ClassDB::bind_method(D_METHOD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders);
+ ClassDB::bind_method(D_METHOD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor);
+ ClassDB::bind_method(D_METHOD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling);
+ ClassDB::bind_method(D_METHOD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall);
- ClassDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
- ClassDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
+ ClassDB::bind_method(D_METHOD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
+ ClassDB::bind_method(D_METHOD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),"set_collision_margin","get_collision_margin");
}
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 2637238c04..5b7db35fe8 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -55,8 +55,8 @@ protected:
static void _bind_methods();
public:
- void set_layer_mask(uint32_t p_mask);
- uint32_t get_layer_mask() const;
+ void set_collision_layer(uint32_t p_mask);
+ uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
@@ -65,8 +65,8 @@ public:
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
- void set_layer_mask_bit(int p_bit, bool p_value);
- bool get_layer_mask_bit(int p_bit) const;
+ void set_collision_layer_bit(int p_bit, bool p_value);
+ bool get_collision_layer_bit(int p_bit) const;
void add_collision_exception_with(Node* p_node); //must be physicsbody
void remove_collision_exception_with(Node* p_node);
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 30e22a8437..ec6729844b 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -333,60 +333,60 @@ Vector2 Polygon2D::get_offset() const {
void Polygon2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon);
- ClassDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon);
+ ClassDB::bind_method(D_METHOD("set_polygon","polygon"),&Polygon2D::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"),&Polygon2D::get_polygon);
- ClassDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv);
- ClassDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv);
+ ClassDB::bind_method(D_METHOD("set_uv","uv"),&Polygon2D::set_uv);
+ ClassDB::bind_method(D_METHOD("get_uv"),&Polygon2D::get_uv);
- ClassDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color);
- ClassDB::bind_method(_MD("get_color"),&Polygon2D::get_color);
+ ClassDB::bind_method(D_METHOD("set_color","color"),&Polygon2D::set_color);
+ ClassDB::bind_method(D_METHOD("get_color"),&Polygon2D::get_color);
- ClassDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors);
- ClassDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors);
+ 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(_MD("set_texture","texture"),&Polygon2D::set_texture);
- ClassDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","texture"),&Polygon2D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture"),&Polygon2D::get_texture);
- ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset);
- ClassDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset);
+ 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);
- ClassDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation);
- ClassDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation);
+ ClassDB::bind_method(D_METHOD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation);
+ ClassDB::bind_method(D_METHOD("get_texture_rotation"),&Polygon2D::get_texture_rotation);
- ClassDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd);
- ClassDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd);
+ ClassDB::bind_method(D_METHOD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd);
+ ClassDB::bind_method(D_METHOD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd);
- ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
- ClassDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale);
+ ClassDB::bind_method(D_METHOD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
+ ClassDB::bind_method(D_METHOD("get_texture_scale"),&Polygon2D::get_texture_scale);
- ClassDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert);
- ClassDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert);
+ ClassDB::bind_method(D_METHOD("set_invert","invert"),&Polygon2D::set_invert);
+ ClassDB::bind_method(D_METHOD("get_invert"),&Polygon2D::get_invert);
- ClassDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border);
- ClassDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border);
+ ClassDB::bind_method(D_METHOD("set_invert_border","invert_border"),&Polygon2D::set_invert_border);
+ ClassDB::bind_method(D_METHOD("get_invert_border"),&Polygon2D::get_invert_border);
- ClassDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&Polygon2D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&Polygon2D::get_offset);
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::POOL_COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),"set_polygon","get_polygon");
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"uv"),"set_uv","get_uv");
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),"set_color","get_color");
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_COLOR_ARRAY,"vertex_colors"),"set_vertex_colors","get_vertex_colors");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),"set_offset","get_offset");
ADD_GROUP("Texture","");
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture");
ADD_GROUP("Texture","texture_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture_rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_offset"),"set_texture_offset","get_texture_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_scale"),"set_texture_scale","get_texture_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture_rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),"_set_texture_rotationd","_get_texture_rotationd");
ADD_GROUP("Invert","invert_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert_enable"),_SCS("set_invert"),_SCS("get_invert"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert_border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert_enable"),"set_invert","get_invert");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert_border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),"set_invert_border","get_invert_border");
}
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 14dfc10d9f..72247811dc 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -263,42 +263,42 @@ void RayCast2D::clear_exceptions(){
void RayCast2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&RayCast2D::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&RayCast2D::is_enabled);
- ClassDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to);
- ClassDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
+ ClassDB::bind_method(D_METHOD("set_cast_to","local_point"),&RayCast2D::set_cast_to);
+ ClassDB::bind_method(D_METHOD("get_cast_to"),&RayCast2D::get_cast_to);
- ClassDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
- ClassDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update);
+ ClassDB::bind_method(D_METHOD("is_colliding"),&RayCast2D::is_colliding);
+ ClassDB::bind_method(D_METHOD("force_raycast_update"),&RayCast2D::force_raycast_update);
- ClassDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
- ClassDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
- ClassDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point);
- ClassDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider"),&RayCast2D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"),&RayCast2D::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_point"),&RayCast2D::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"),&RayCast2D::get_collision_normal);
- ClassDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid);
- ClassDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception);
+ ClassDB::bind_method(D_METHOD("add_exception_rid","rid"),&RayCast2D::add_exception_rid);
+ ClassDB::bind_method(D_METHOD("add_exception","node"),&RayCast2D::add_exception);
- ClassDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid);
- ClassDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception);
+ ClassDB::bind_method(D_METHOD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid);
+ ClassDB::bind_method(D_METHOD("remove_exception","node"),&RayCast2D::remove_exception);
- ClassDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions);
+ ClassDB::bind_method(D_METHOD("clear_exceptions"),&RayCast2D::clear_exceptions);
- ClassDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&RayCast2D::get_layer_mask);
- ClassDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask);
- ClassDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask);
+ ClassDB::bind_method(D_METHOD("set_type_mask","mask"),&RayCast2D::set_type_mask);
+ ClassDB::bind_method(D_METHOD("get_type_mask"),&RayCast2D::get_type_mask);
- ClassDB::bind_method(_MD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body);
- ClassDB::bind_method(_MD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body);
+ ClassDB::bind_method(D_METHOD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body);
+ ClassDB::bind_method(D_METHOD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"exclude_parent"),_SCS("set_exclude_parent_body"),_SCS("get_exclude_parent_body"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"exclude_parent"),"set_exclude_parent_body","get_exclude_parent_body");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),"set_cast_to","get_cast_to");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_layer_mask","get_layer_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),"set_type_mask","get_type_mask");
}
RayCast2D::RayCast2D() {
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index c7ec84a8d7..e1f360c0c1 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -118,16 +118,16 @@ String RemoteTransform2D::get_configuration_warning() const {
void RemoteTransform2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node);
- ClassDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node);
+ 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);
- ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
+ ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),"set_remote_node","get_remote_node");
}
RemoteTransform2D::RemoteTransform2D() {
cache=0;
-
+ set_notify_transform(true);
}
diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp
deleted file mode 100644
index 62eabea98e..0000000000
--- a/scene/2d/sample_player_2d.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*************************************************************************/
-/* sample_player_2d.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "sample_player_2d.h"
-
-#include "servers/audio_server.h"
-#include "servers/audio_server.h"
-#include "servers/spatial_sound_server.h"
-
-
-bool SamplePlayer2D::_set(const StringName& p_name, const Variant& p_value) {
-
- String name=p_name;
-
- if (name=="play/play") {
- if (library.is_valid()) {
-
- String what=p_value;
- if (what=="")
- stop_all();
- else
- play(what);
-
- played_back=what;
- }
- } else
- return false;
-
- return true;
-}
-
-bool SamplePlayer2D::_get(const StringName& p_name,Variant &r_ret) const {
-
-
- String name=p_name;
-
- if (name=="play/play") {
- r_ret=played_back;
- } else
- return false;
-
- return true;
-}
-
-void SamplePlayer2D::_get_property_list(List<PropertyInfo> *p_list) const {
-
- String en="";
- if (library.is_valid()) {
- List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
- ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
-
- en+=",";
- en+=E->get();
- }
- }
-
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
-}
-
-void SamplePlayer2D::_notification(int p_what) {
-
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
-
- } break;
- }
-
-}
-
-void SamplePlayer2D::set_sample_library(const Ref<SampleLibrary>& p_library) {
-
- library=p_library;
- _change_notify();
- update_configuration_warning();
-}
-
-Ref<SampleLibrary> SamplePlayer2D::get_sample_library() const {
-
- return library;
-}
-
-void SamplePlayer2D::set_polyphony(int p_voice_count) {
-
- ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64);
- polyphony=p_voice_count;
- if (get_source_rid().is_valid())
- SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
-}
-
-int SamplePlayer2D::get_polyphony() const {
-
- return polyphony;
-}
-
-SamplePlayer2D::VoiceID SamplePlayer2D::play(const String& p_sample,int p_voice) {
-
- if (!get_source_rid().is_valid())
- return INVALID_VOICE;
- if (library.is_null())
- return INVALID_VOICE;
- if (!library->has_sample(p_sample))
- return INVALID_VOICE;
- Ref<Sample> sample = library->get_sample(p_sample);
- float vol_change = library->sample_get_volume_db(p_sample);
- float pitch_change = library->sample_get_pitch_scale(p_sample);
-
- VoiceID vid = SpatialSound2DServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice);
- if (vol_change)
- SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change);
-
-
- if (random_pitch_scale) {
- float ps = Math::random(-random_pitch_scale,random_pitch_scale);
- if (ps>0)
- ps=1.0+ps;
- else
- ps=1.0/(1.0-ps);
- SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),vid,ps*pitch_change);
-
- }
-
- return vid;
-}
-//voices
-void SamplePlayer2D::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) {
-
- if (!get_source_rid().is_valid())
- return;
-
- SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale);
-
-}
-
-void SamplePlayer2D::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) {
-
- if (!get_source_rid().is_valid())
- return;
- SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db);
-
-}
-
-bool SamplePlayer2D::is_voice_active(VoiceID p_voice) const {
-
- if (!get_source_rid().is_valid())
- return false;
- return SpatialSound2DServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice);
-
-}
-
-void SamplePlayer2D::stop_voice(VoiceID p_voice) {
-
- if (!get_source_rid().is_valid())
- return;
- SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice);
-
-}
-
-void SamplePlayer2D::stop_all() {
-
- if (!get_source_rid().is_valid())
- return;
-
- for(int i=0;i<polyphony;i++) {
-
- SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),i);
- }
-}
-
-void SamplePlayer2D::set_random_pitch_scale(float p_scale) {
- random_pitch_scale=p_scale;
-}
-
-float SamplePlayer2D::get_random_pitch_scale() const {
-
- return random_pitch_scale;
-}
-
-String SamplePlayer2D::get_configuration_warning() const {
-
- if (library.is_null()) {
- return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SamplePlayer to play sound.");
- }
-
- return String();
-}
-
-void SamplePlayer2D::_bind_methods() {
-
-
- ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library);
- ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library);
-
- ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony);
- ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony);
-
- ClassDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE));
- //voices,DEV
- ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale);
- ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db);
-
- ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active);
- ClassDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice);
- ClassDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all);
-
- ClassDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale);
- ClassDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale);
-
- BIND_CONSTANT( INVALID_VOICE );
- BIND_CONSTANT( NEXT_VOICE );
-
- ADD_GROUP("Config","");
- ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale"));
-
-
-}
-
-
-SamplePlayer2D::SamplePlayer2D() {
-
- polyphony=1;
- random_pitch_scale=0;
-
-}
-
-SamplePlayer2D::~SamplePlayer2D() {
-
-
-}
diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h
deleted file mode 100644
index 5cf598327b..0000000000
--- a/scene/2d/sample_player_2d.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*************************************************************************/
-/* sample_player_2d.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SAMPLE_PLAYER_2D_H
-#define SAMPLE_PLAYER_2D_H
-
-#include "scene/2d/sound_player_2d.h"
-#include "scene/resources/sample_library.h"
-
-class SamplePlayer2D : public SoundPlayer2D {
-
- GDCLASS(SamplePlayer2D,SoundPlayer2D);
-public:
-
- enum {
-
- INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE,
- NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE
- };
-
- typedef int VoiceID;
-
-
-private:
-
- Ref<SampleLibrary> library;
- int polyphony;
- String played_back;
- float random_pitch_scale;
-
-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;
-
- void _notification(int p_what);
-
- static void _bind_methods();
-
-public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
- Ref<SampleLibrary> get_sample_library() const;
-
- void set_polyphony(int p_voice_count);
- int get_polyphony() const;
-
- VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE);
- //voices
- void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
- void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db);
-
- bool is_voice_active(VoiceID p_voice) const;
- void stop_voice(VoiceID p_voice);
- void stop_all();
-
- void set_random_pitch_scale(float p_scale);
- float get_random_pitch_scale() const;
-
- String get_configuration_warning() const;
-
- SamplePlayer2D();
- ~SamplePlayer2D();
-
-
-};
-
-#endif // SAMPLE_PLAYER_2D_H
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 3aacd7091a..4b607e9261 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -63,6 +63,38 @@ Ref<BitMap> TouchScreenButton::get_bitmask() const{
return bitmask;
}
+void TouchScreenButton::set_shape(const Ref<Shape2D>& p_shape){
+
+ shape=p_shape;
+
+ if (!is_inside_tree())
+ return;
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ return;
+ update();
+}
+
+Ref<Shape2D> TouchScreenButton::get_shape() const{
+
+ return shape;
+}
+
+void TouchScreenButton::set_shape_centered(bool p_shape_centered) {
+
+ shape_centered=p_shape_centered;
+
+ if (!is_inside_tree())
+ return;
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ return;
+ update();
+}
+
+bool TouchScreenButton::is_shape_centered() const {
+
+ return shape_centered;
+}
+
void TouchScreenButton::_notification(int p_what) {
switch(p_what) {
@@ -86,6 +118,15 @@ void TouchScreenButton::_notification(int p_what) {
draw_texture(texture,Point2());
}
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ return;
+ if (shape.is_valid()) {
+ Color draw_col=get_tree()->get_debug_collisions_color();
+ Vector2 pos=shape_centered ? get_item_rect().size*0.5f : Vector2();
+ draw_set_transform_matrix(get_canvas_transform().translated(pos));
+ shape->draw(get_canvas_item(),draw_col);
+ }
+
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -104,8 +145,12 @@ void TouchScreenButton::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
if (is_pressed())
- Input::get_singleton()->action_release(action);
+ _release(true);
} break;
+ case NOTIFICATION_PAUSED: {
+ // So the button can be pressed again even though the release gets unhandled because of coming during pause
+ allow_repress=true;
+ }
}
}
@@ -143,22 +188,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::SCREEN_TOUCH && !p_event.screen_touch.pressed && finger_pressed==p_event.screen_touch.index) {
- emit_signal("released");
-
- if (action_id!=-1) {
-
- Input::get_singleton()->action_release(action);
- InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=false;
- get_tree()->input_event(ie);
- }
- finger_pressed=-1;
-
- update();
-
+ _release();
}
if ((p_event.type==InputEvent::SCREEN_TOUCH && p_event.screen_touch.pressed)|| p_event.type==InputEvent::SCREEN_DRAG) {
@@ -184,44 +214,12 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (touched) {
-
if (finger_pressed==-1) {
- finger_pressed=p_event.screen_touch.index;
- //emit change stuff
- emit_signal("pressed");
- if (action_id!=-1) {
-
- Input::get_singleton()->action_press(action);
- InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=true;
- get_tree()->input_event(ie);
- }
-
- update();
+ _press(p_event.screen_touch.index);
}
-
} else {
-
if (finger_pressed!=-1) {
-
- emit_signal("released");
-
- if (action_id!=-1) {
-
- Input::get_singleton()->action_release(action);
- InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=false;
- get_tree()->input_event(ie);
- }
- finger_pressed=-1;
-
- update();
+ _release();
}
}
@@ -236,79 +234,104 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (p_event.screen_touch.pressed) {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
- if (finger_pressed!=-1)
+ const bool can_press=finger_pressed==-1 || allow_repress;
+ if (!can_press)
return; //already fingering
Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
+ Rect2 item_rect = get_item_rect();
bool touched=false;
+ bool check_rect=true;
+ if (shape.is_valid()) {
+
+ check_rect=false;
+ Transform2D xform=shape_centered ? Transform2D().translated(get_item_rect().size*0.5f) : Transform2D();
+ touched=shape->collide(xform, unit_rect, Transform2D(0, coord + Vector2(0.5,0.5)));
+ }
+
if (bitmask.is_valid()) {
- if (Rect2(Point2(),bitmask->get_size()).has_point(coord)) {
+ check_rect=false;
+ if (!touched && Rect2(Point2(),bitmask->get_size()).has_point(coord)) {
if (bitmask->get_bit(coord))
touched=true;
}
- } else {
- if (!texture.is_null())
- touched=Rect2(Point2(),texture->get_size()).has_point(coord);
}
+ if (!touched && check_rect) {
+ if (!texture.is_null())
+ touched=item_rect.has_point(coord);
+ }
if (touched) {
-
- finger_pressed=p_event.screen_touch.index;
- //emit change stuff
- emit_signal("pressed");
- if (action_id!=-1) {
-
- Input::get_singleton()->action_press(action);
- InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=true;
- get_tree()->input_event(ie);
- }
- update();
-
+ _press(p_event.screen_touch.index);
}
} else {
+ if (p_event.screen_touch.index==finger_pressed) {
+ _release();
+ }
+ }
+ }
+ }
+}
+void TouchScreenButton::_press(int p_finger_pressed) {
- if (p_event.screen_touch.index==finger_pressed) {
- //untouch
+ finger_pressed=p_finger_pressed;
+ allow_repress=false;
- emit_signal("released");
+ if (action_id!=-1) {
- if (action_id!=-1) {
+ Input::get_singleton()->action_press(action);
+ InputEvent ie;
+ ie.type=InputEvent::ACTION;
+ ie.ID=0;
+ ie.action.action=action_id;
+ ie.action.pressed=true;
+ get_tree()->input_event(ie);
+ }
- Input::get_singleton()->action_release(action);
- InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=false;
- get_tree()->input_event(ie);
- }
- finger_pressed=-1;
- update();
- }
- }
+ emit_signal("pressed");
+ update();
+}
+
+void TouchScreenButton::_release(bool p_exiting_tree) {
+
+ finger_pressed=-1;
+
+ if (action_id!=-1) {
+
+ Input::get_singleton()->action_release(action);
+ if (!p_exiting_tree) {
+ InputEvent ie;
+ ie.type=InputEvent::ACTION;
+ ie.ID=0;
+ ie.action.action=action_id;
+ ie.action.pressed=false;
+ get_tree()->input_event(ie);
}
}
+
+ if (!p_exiting_tree) {
+ emit_signal("released");
+ update();
+ }
}
Rect2 TouchScreenButton::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
return Rect2(Size2(),texture->get_size());
}
@@ -338,34 +361,42 @@ bool TouchScreenButton::is_passby_press_enabled() const{
void TouchScreenButton::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture);
- ClassDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture);
+ 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_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_bitmask","bitmask"),&TouchScreenButton::set_bitmask);
+ ClassDB::bind_method(D_METHOD("get_bitmask"),&TouchScreenButton::get_bitmask);
- ClassDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed);
- ClassDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed);
+ ClassDB::bind_method(D_METHOD("set_shape","shape"),&TouchScreenButton::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"),&TouchScreenButton::get_shape);
- ClassDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask);
- ClassDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask);
+ 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);
- ClassDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action);
- ClassDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action);
+ ClassDB::bind_method(D_METHOD("set_action","action"),&TouchScreenButton::set_action);
+ ClassDB::bind_method(D_METHOD("get_action"),&TouchScreenButton::get_action);
- ClassDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode);
- ClassDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode);
+ ClassDB::bind_method(D_METHOD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode);
+ ClassDB::bind_method(D_METHOD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode);
- ClassDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press);
- ClassDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled);
+ ClassDB::bind_method(D_METHOD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press);
+ ClassDB::bind_method(D_METHOD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled);
- ClassDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed);
+ ClassDB::bind_method(D_METHOD("is_pressed"),&TouchScreenButton::is_pressed);
- ClassDB::bind_method(_MD("_input"),&TouchScreenButton::_input);
+ ClassDB::bind_method(D_METHOD("_input"),&TouchScreenButton::_input);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture_pressed"),_SCS("get_texture_pressed"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"bitmask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"),_SCS("set_bitmask"),_SCS("get_bitmask"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"passby_press"),_SCS("set_passby_press"),_SCS("is_passby_press_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),_SCS("set_action"),_SCS("get_action"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"visibility_mode",PROPERTY_HINT_ENUM,"Always,TouchScreen Only"),_SCS("set_visibility_mode"),_SCS("get_visibility_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture_pressed","get_texture_pressed");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"bitmask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"),"set_bitmask","get_bitmask");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),"set_shape","get_shape");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shape_centered"),"set_shape_centered","is_shape_centered");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"passby_press"),"set_passby_press","is_passby_press_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),"set_action","get_action");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"visibility_mode",PROPERTY_HINT_ENUM,"Always,TouchScreen Only"),"set_visibility_mode","get_visibility_mode");
ADD_SIGNAL( MethodInfo("pressed" ) );
ADD_SIGNAL( MethodInfo("released" ) );
@@ -377,7 +408,11 @@ void TouchScreenButton::_bind_methods() {
TouchScreenButton::TouchScreenButton() {
finger_pressed=-1;
+ allow_repress=false;
action_id=-1;
passby_press=false;
visibility=VISIBILITY_ALWAYS;
+ shape_centered=true;
+ unit_rect=Ref<RectangleShape2D>(memnew(RectangleShape2D));
+ unit_rect->set_extents(Vector2(0.5,0.5));
}
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index 34e02d644b..8ce378c660 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -32,6 +32,7 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
#include "scene/resources/bit_mask.h"
+#include "scene/resources/rectangle_shape_2d.h"
class TouchScreenButton : public Node2D {
@@ -47,16 +48,24 @@ private:
Ref<Texture> texture;
Ref<Texture> texture_pressed;
Ref<BitMap> bitmask;
+ Ref<Shape2D> shape;
+ bool shape_centered;
+
+ Ref<RectangleShape2D> unit_rect;
StringName action;
bool passby_press;
int finger_pressed;
+ bool allow_repress;
int action_id;
VisibilityMode visibility;
void _input(const InputEvent& p_Event);
+ void _press(int p_finger_pressed);
+ void _release(bool p_exiting_tree=false);
+
protected:
void _notification(int p_what);
@@ -73,6 +82,12 @@ public:
void set_bitmask(const Ref<BitMap>& p_bitmask);
Ref<BitMap> get_bitmask() const;
+ void set_shape(const Ref<Shape2D>& p_shape);
+ Ref<Shape2D> get_shape() const;
+
+ void set_shape_centered(bool p_shape_centered);
+ bool is_shape_centered() const;
+
void set_action(const String& p_action);
String get_action() const;
diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp
deleted file mode 100644
index 96382caa25..0000000000
--- a/scene/2d/sound_player_2d.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*************************************************************************/
-/* sound_player_2d.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "sound_player_2d.h"
-
-#include "servers/audio_server.h"
-
-#include "servers/spatial_sound_2d_server.h"
-#include "scene/resources/surface_tool.h"
-
-
-void SoundPlayer2D::_notification(int p_what) {
-
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
- //find the sound space
-
- source_rid = SpatialSound2DServer::get_singleton()->source_create(get_world_2d()->get_sound_space());
-
- for(int i=0;i<PARAM_MAX;i++)
- set_param(Param(i),params[i]);
-
- SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
-
-
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
-
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- if (source_rid.is_valid())
- SpatialSound2DServer::get_singleton()->free(source_rid);
-
- } break;
- }
-
-}
-
-
-void SoundPlayer2D::set_param( Param p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
- if (source_rid.is_valid())
- SpatialSound2DServer::get_singleton()->source_set_param(source_rid,(SpatialSound2DServer::SourceParam)p_param,p_value);
-
-}
-
-float SoundPlayer2D::get_param( Param p_param) const {
-
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
- return params[p_param];
-
-}
-
-
-void SoundPlayer2D::_bind_methods() {
-
-
- ClassDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param);
-
- BIND_CONSTANT( PARAM_VOLUME_DB );
- BIND_CONSTANT( PARAM_PITCH_SCALE );
- BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP );
- BIND_CONSTANT( PARAM_MAX );
-
- ADD_GROUP("Parameters","");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_GROUP("Attenuation","attenuation_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
-
-}
-
-
-SoundPlayer2D::SoundPlayer2D() {
-
- params[PARAM_VOLUME_DB]=0.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[PARAM_ATTENUATION_MAX_DISTANCE]=2048;
- params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
-
-
-}
-
-SoundPlayer2D::~SoundPlayer2D() {
-
-
-}
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 8bad8fcb38..26c2756acd 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -86,7 +86,7 @@ void Sprite::_notification(int p_what) {
Point2 ofs=offset;
if (centered)
ofs-=s/2;
- if (OS::get_singleton()->get_use_pixel_snap()) {
+ if (Engine::get_singleton()->get_use_pixel_snap()) {
ofs=ofs.floor();
}
@@ -255,8 +255,10 @@ Rect2 Sprite::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -292,49 +294,49 @@ void Sprite::_validate_property(PropertyInfo& property) const {
void Sprite::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture);
- ClassDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","texture:Texture"),&Sprite::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"),&Sprite::get_texture);
- ClassDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered);
- ClassDB::bind_method(_MD("is_centered"),&Sprite::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered","centered"),&Sprite::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"),&Sprite::is_centered);
- ClassDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&Sprite::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&Sprite::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&Sprite::get_offset);
- ClassDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h);
- ClassDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_h","flip_h"),&Sprite::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"),&Sprite::is_flipped_h);
- ClassDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v);
- ClassDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_flip_v","flip_v"),&Sprite::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"),&Sprite::is_flipped_v);
- ClassDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region);
- ClassDB::bind_method(_MD("is_region"),&Sprite::is_region);
+ ClassDB::bind_method(D_METHOD("set_region","enabled"),&Sprite::set_region);
+ ClassDB::bind_method(D_METHOD("is_region"),&Sprite::is_region);
- ClassDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect);
- ClassDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect);
+ ClassDB::bind_method(D_METHOD("set_region_rect","rect"),&Sprite::set_region_rect);
+ ClassDB::bind_method(D_METHOD("get_region_rect"),&Sprite::get_region_rect);
- ClassDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame);
- ClassDB::bind_method(_MD("get_frame"),&Sprite::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame","frame"),&Sprite::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"),&Sprite::get_frame);
- ClassDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes);
- ClassDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes);
+ ClassDB::bind_method(D_METHOD("set_vframes","vframes"),&Sprite::set_vframes);
+ ClassDB::bind_method(D_METHOD("get_vframes"),&Sprite::get_vframes);
- ClassDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes);
- ClassDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes);
+ ClassDB::bind_method(D_METHOD("set_hframes","hframes"),&Sprite::set_hframes);
+ ClassDB::bind_method(D_METHOD("get_hframes"),&Sprite::get_hframes);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_texture","get_texture");
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), "set_centered","is_centered");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), "set_offset","get_offset");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), "set_flip_h","is_flipped_h");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), "set_flip_v","is_flipped_v");
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), "set_vframes","get_vframes");
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), "set_hframes","get_hframes");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), "set_region","is_region");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), "set_region_rect","get_region_rect");
}
@@ -510,8 +512,10 @@ Rect2 ViewportSprite::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -548,22 +552,22 @@ String ViewportSprite::get_configuration_warning() const {
void ViewportSprite::_bind_methods() {
- ClassDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path);
- ClassDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path);
+ ClassDB::bind_method(D_METHOD("set_viewport_path","path"),&ViewportSprite::set_viewport_path);
+ ClassDB::bind_method(D_METHOD("get_viewport_path"),&ViewportSprite::get_viewport_path);
- ClassDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered);
- ClassDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered","centered"),&ViewportSprite::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"),&ViewportSprite::is_centered);
- ClassDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&ViewportSprite::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&ViewportSprite::get_offset);
- ClassDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate);
- ClassDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_modulate","modulate"),&ViewportSprite::set_modulate);
+ ClassDB::bind_method(D_METHOD("get_modulate"),&ViewportSprite::get_modulate);
- ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), "set_viewport_path","get_viewport_path");
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), "set_centered","is_centered");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), "set_offset","get_offset");
+ ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), "set_modulate","get_modulate");
}
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index 05c0bd9eec..ab4487ef7b 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -58,7 +58,7 @@ protected:
void _notification(int p_what);
- static void _bind_methods();;
+ static void _bind_methods();
virtual void _validate_property(PropertyInfo& property) const;
@@ -119,7 +119,7 @@ protected:
void _notification(int p_what);
- static void _bind_methods();;
+ static void _bind_methods();
public:
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 7bd3a5d932..15fbec4441 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -457,10 +457,11 @@ void TileMap::_update_dirty_quadrants() {
}
+ Color modulate = tile_set->tile_get_modulate(c.id);
if (r==Rect2()) {
- tex->draw_rect(canvas_item,rect,false,Color(1,1,1),c.transpose);
+ tex->draw_rect(canvas_item,rect,false,modulate,c.transpose);
} else {
- tex->draw_rect_region(canvas_item,rect,r,Color(1,1,1),c.transpose);
+ tex->draw_rect_region(canvas_item,rect,r,modulate,c.transpose);
}
Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
@@ -610,7 +611,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
xform.set_origin( q.pos );
-// q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ //q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
@@ -729,6 +730,7 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo
c.transpose=p_transpose;
_make_quadrant_dirty(Q);
+ used_size_cache_dirty=true;
}
@@ -817,6 +819,7 @@ void TileMap::clear() {
_clear_quadrants();
tile_map.clear();
+ used_size_cache_dirty=true;
}
void TileMap::_set_tile_data(const PoolVector<int>& p_data) {
@@ -849,8 +852,10 @@ void TileMap::_set_tile_data(const PoolVector<int>& p_data) {
bool transpose = v&(1<<31);
v&=(1<<29)-1;
-// if (x<-20 || y <-20 || x>4000 || y>4000)
-// continue;
+ /*
+ if (x<-20 || y <-20 || x>4000 || y>4000)
+ continue;
+ */
set_cell(x,y,v,flip_h,flip_v,transpose);
}
@@ -1156,6 +1161,28 @@ Array TileMap::get_used_cells() const {
return a;
}
+Rect2 TileMap::get_used_rect() { // Not const because of cache
+
+ if (used_size_cache_dirty) {
+ if(tile_map.size() > 0) {
+ used_size_cache = Rect2(tile_map.front()->key().x, tile_map.front()->key().y, 0, 0);
+
+ for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
+ used_size_cache.expand_to(Vector2(E->key().x, E->key().y));
+ }
+
+ used_size_cache.size += Vector2(1,1);
+ } else {
+ used_size_cache = Rect2();
+ }
+
+ used_size_cache_dirty = false;
+ }
+
+ return used_size_cache;
+}
+
+
void TileMap::set_occluder_light_mask(int p_mask) {
occluder_light_mask=p_mask;
@@ -1186,101 +1213,102 @@ void TileMap::set_light_mask(int p_light_mask) {
void TileMap::_bind_methods() {
- ClassDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset);
- ClassDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset);
+ ClassDB::bind_method(D_METHOD("set_tileset","tileset:TileSet"),&TileMap::set_tileset);
+ ClassDB::bind_method(D_METHOD("get_tileset:TileSet"),&TileMap::get_tileset);
- ClassDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&TileMap::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&TileMap::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&TileMap::get_mode);
- ClassDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset);
- ClassDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset);
+ ClassDB::bind_method(D_METHOD("set_half_offset","half_offset"),&TileMap::set_half_offset);
+ ClassDB::bind_method(D_METHOD("get_half_offset"),&TileMap::get_half_offset);
- ClassDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform);
- ClassDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform);
+ ClassDB::bind_method(D_METHOD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform);
+ ClassDB::bind_method(D_METHOD("get_custom_transform"),&TileMap::get_custom_transform);
- ClassDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size);
- ClassDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size);
+ ClassDB::bind_method(D_METHOD("set_cell_size","size"),&TileMap::set_cell_size);
+ ClassDB::bind_method(D_METHOD("get_cell_size"),&TileMap::get_cell_size);
- ClassDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size);
- ClassDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size);
+ ClassDB::bind_method(D_METHOD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size);
+ ClassDB::bind_method(D_METHOD("_get_old_cell_size"),&TileMap::_get_old_cell_size);
- ClassDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
- ClassDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size);
+ ClassDB::bind_method(D_METHOD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
+ ClassDB::bind_method(D_METHOD("get_quadrant_size"),&TileMap::get_quadrant_size);
- ClassDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin);
- ClassDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin);
+ ClassDB::bind_method(D_METHOD("set_tile_origin","origin"),&TileMap::set_tile_origin);
+ ClassDB::bind_method(D_METHOD("get_tile_origin"),&TileMap::get_tile_origin);
- ClassDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x);
- ClassDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x);
+ ClassDB::bind_method(D_METHOD("set_center_x","enable"),&TileMap::set_center_x);
+ ClassDB::bind_method(D_METHOD("get_center_x"),&TileMap::get_center_x);
- ClassDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
- ClassDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
+ ClassDB::bind_method(D_METHOD("set_center_y","enable"),&TileMap::set_center_y);
+ ClassDB::bind_method(D_METHOD("get_center_y"),&TileMap::get_center_y);
- ClassDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
- ClassDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
+ ClassDB::bind_method(D_METHOD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
+ ClassDB::bind_method(D_METHOD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
- ClassDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
- ClassDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
+ ClassDB::bind_method(D_METHOD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
+ ClassDB::bind_method(D_METHOD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
- ClassDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer);
- ClassDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer","mask"),&TileMap::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"),&TileMap::get_collision_layer);
- ClassDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask);
- ClassDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask","mask"),&TileMap::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"),&TileMap::get_collision_mask);
- ClassDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
- ClassDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
+ ClassDB::bind_method(D_METHOD("set_collision_friction","value"),&TileMap::set_collision_friction);
+ ClassDB::bind_method(D_METHOD("get_collision_friction"),&TileMap::get_collision_friction);
- ClassDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
- ClassDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
+ ClassDB::bind_method(D_METHOD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
+ ClassDB::bind_method(D_METHOD("get_collision_bounce"),&TileMap::get_collision_bounce);
- ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
- ClassDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
+ ClassDB::bind_method(D_METHOD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
+ ClassDB::bind_method(D_METHOD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
- ClassDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ClassDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ClassDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
- ClassDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv);
- ClassDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
- ClassDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
- ClassDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed);
+ ClassDB::bind_method(D_METHOD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_cell","x","y"),&TileMap::get_cell);
+ ClassDB::bind_method(D_METHOD("get_cellv","pos"),&TileMap::get_cellv);
+ ClassDB::bind_method(D_METHOD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
+ ClassDB::bind_method(D_METHOD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
+ ClassDB::bind_method(D_METHOD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed);
- ClassDB::bind_method(_MD("clear"),&TileMap::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&TileMap::clear);
- ClassDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells);
+ ClassDB::bind_method(D_METHOD("get_used_cells"),&TileMap::get_used_cells);
+ ClassDB::bind_method(D_METHOD("get_used_rect"),&TileMap::get_used_rect);
- ClassDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false));
- ClassDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map);
+ ClassDB::bind_method(D_METHOD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("world_to_map","worldpos"),&TileMap::world_to_map);
- ClassDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants);
- ClassDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants);
- ClassDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants);
+ ClassDB::bind_method(D_METHOD("_clear_quadrants"),&TileMap::_clear_quadrants);
+ ClassDB::bind_method(D_METHOD("_recreate_quadrants"),&TileMap::_recreate_quadrants);
+ ClassDB::bind_method(D_METHOD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants);
- ClassDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data);
- ClassDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data);
+ ClassDB::bind_method(D_METHOD("_set_tile_data"),&TileMap::_set_tile_data);
+ ClassDB::bind_method(D_METHOD("_get_tile_data"),&TileMap::_get_tile_data);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Square,Isometric,Custom"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_set",PROPERTY_HINT_RESOURCE_TYPE,"TileSet"),_SCS("set_tileset"),_SCS("get_tileset"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Square,Isometric,Custom"),"set_mode","get_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_set",PROPERTY_HINT_RESOURCE_TYPE,"TileSet"),"set_tileset","get_tileset");
ADD_GROUP("Cell","cell_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
- ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM2D,"cell_custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),_SCS("set_tile_origin"),_SCS("get_tile_origin"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell_y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1"),"set_cell_size","get_cell_size");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),"set_quadrant_size","get_quadrant_size");
+ ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM2D,"cell_custom_transform"),"set_custom_transform","get_custom_transform");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),"set_half_offset","get_half_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),"set_tile_origin","get_tile_origin");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell_y_sort"),"set_y_sort_mode","is_y_sort_mode_enabled");
ADD_GROUP("Collision","collision_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision_use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision_use_kinematic",PROPERTY_HINT_NONE,""),"set_collision_use_kinematic","get_collision_use_kinematic");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_friction",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_collision_friction","get_collision_friction");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision_bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_collision_bounce","get_collision_bounce");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_collision_layer","get_collision_layer");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),"set_collision_mask","get_collision_mask");
ADD_GROUP("Occluder","occluder_");
- ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder_light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder_light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),"set_occluder_light_mask","get_occluder_light_mask");
ADD_GROUP("","");
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_tile_data","_get_tile_data");
ADD_SIGNAL(MethodInfo("settings_changed"));
@@ -1302,6 +1330,7 @@ TileMap::TileMap() {
rect_cache_dirty=true;
+ used_size_cache_dirty=true;
pending_update=false;
quadrant_order_dirty=false;
quadrant_size=16;
@@ -1321,6 +1350,7 @@ TileMap::TileMap() {
fp_adjust=0.00001;
tile_origin=TILE_ORIGIN_TOP_LEFT;
+ set_notify_transform(true);
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index ba6de62f8e..c581aa8056 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -141,6 +141,8 @@ private:
Rect2 rect_cache;
bool rect_cache_dirty;
+ Rect2 used_size_cache;
+ bool used_size_cache_dirty;
bool quadrant_order_dirty;
bool y_sort_mode;
float fp_adjust;
@@ -176,8 +178,6 @@ private:
_FORCE_INLINE_ Vector2 _map_to_world(int p_x,int p_y,bool p_ignore_ofs=false) const;
- Array get_used_cells() const;
-
protected:
@@ -252,6 +252,9 @@ public:
void set_y_sort_mode(bool p_enable);
bool is_y_sort_mode_enabled() const;
+ Array get_used_cells() const;
+ Rect2 get_used_rect(); // Not const because of cache
+
void set_occluder_light_mask(int p_mask);
int get_occluder_light_mask() const;
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 61d57b0e8c..64ab333e48 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -129,11 +129,11 @@ bool VisibilityNotifier2D::is_on_screen() const {
void VisibilityNotifier2D::_bind_methods(){
- ClassDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect);
- ClassDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect);
- ClassDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen);
+ ClassDB::bind_method(D_METHOD("set_rect","rect"),&VisibilityNotifier2D::set_rect);
+ ClassDB::bind_method(D_METHOD("get_rect"),&VisibilityNotifier2D::get_rect);
+ ClassDB::bind_method(D_METHOD("is_on_screen"),&VisibilityNotifier2D::is_on_screen);
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
+ ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),"set_rect","get_rect");
ADD_SIGNAL( MethodInfo("viewport_entered",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
ADD_SIGNAL( MethodInfo("viewport_exited",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
@@ -145,6 +145,7 @@ void VisibilityNotifier2D::_bind_methods(){
VisibilityNotifier2D::VisibilityNotifier2D() {
rect=Rect2(-10,-10,20,20);
+ set_notify_transform(true);
}
@@ -354,16 +355,16 @@ String VisibilityEnabler2D::get_configuration_warning() const {
void VisibilityEnabler2D::_bind_methods(){
- ClassDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler);
- ClassDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled);
- ClassDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed);
+ ClassDB::bind_method(D_METHOD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler);
+ ClassDB::bind_method(D_METHOD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&VisibilityEnabler2D::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),"set_enabler","is_enabler_enabled", ENABLER_PAUSE_ANIMATIONS );
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),"set_enabler","is_enabler_enabled", ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_particles"),"set_enabler","is_enabler_enabled", ENABLER_PAUSE_PARTICLES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animated_sprites"),"set_enabler","is_enabler_enabled", ENABLER_PAUSE_ANIMATED_SPRITES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"process_parent"),"set_enabler","is_enabler_enabled", ENABLER_PARENT_PROCESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fixed_process_parent"),"set_enabler","is_enabler_enabled", ENABLER_PARENT_FIXED_PROCESS);
BIND_CONSTANT( ENABLER_FREEZE_BODIES );
BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index 588f343048..cb9a494e87 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -43,11 +43,11 @@ bool YSort::is_sort_enabled() const {
void YSort::_bind_methods() {
- ClassDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled);
- ClassDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled);
+ ClassDB::bind_method(D_METHOD("set_sort_enabled","enabled"),&YSort::set_sort_enabled);
+ ClassDB::bind_method(D_METHOD("is_sort_enabled"),&YSort::is_sort_enabled);
ADD_GROUP("Sort","sort_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort_enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort_enabled"),"set_sort_enabled","is_sort_enabled");
}
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index c4afed4b31..92ac091fc5 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -295,7 +295,7 @@ void Area::_notification(int p_what) {
}
}
-void Area::set_enable_monitoring(bool p_enable) {
+void Area::set_monitoring(bool p_enable) {
if (locked) {
ERR_EXPLAIN("This function can't be used during the in/out signal.");
@@ -433,7 +433,7 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
}
-bool Area::is_monitoring_enabled() const {
+bool Area::is_monitoring() const {
return monitoring;
}
@@ -576,63 +576,63 @@ bool Area::get_layer_mask_bit(int p_bit) const{
void Area::_bind_methods() {
- ClassDB::bind_method(_MD("_body_enter_tree","id"),&Area::_body_enter_tree);
- ClassDB::bind_method(_MD("_body_exit_tree","id"),&Area::_body_exit_tree);
+ ClassDB::bind_method(D_METHOD("_body_enter_tree","id"),&Area::_body_enter_tree);
+ ClassDB::bind_method(D_METHOD("_body_exit_tree","id"),&Area::_body_exit_tree);
- ClassDB::bind_method(_MD("_area_enter_tree","id"),&Area::_area_enter_tree);
- ClassDB::bind_method(_MD("_area_exit_tree","id"),&Area::_area_exit_tree);
+ ClassDB::bind_method(D_METHOD("_area_enter_tree","id"),&Area::_area_enter_tree);
+ ClassDB::bind_method(D_METHOD("_area_exit_tree","id"),&Area::_area_exit_tree);
- ClassDB::bind_method(_MD("set_space_override_mode","enable"),&Area::set_space_override_mode);
- ClassDB::bind_method(_MD("get_space_override_mode"),&Area::get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("set_space_override_mode","enable"),&Area::set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("get_space_override_mode"),&Area::get_space_override_mode);
- ClassDB::bind_method(_MD("set_gravity_is_point","enable"),&Area::set_gravity_is_point);
- ClassDB::bind_method(_MD("is_gravity_a_point"),&Area::is_gravity_a_point);
+ ClassDB::bind_method(D_METHOD("set_gravity_is_point","enable"),&Area::set_gravity_is_point);
+ ClassDB::bind_method(D_METHOD("is_gravity_a_point"),&Area::is_gravity_a_point);
- ClassDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area::set_gravity_distance_scale);
- ClassDB::bind_method(_MD("get_gravity_distance_scale"),&Area::get_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_distance_scale","distance_scale"),&Area::set_gravity_distance_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_distance_scale"),&Area::get_gravity_distance_scale);
- ClassDB::bind_method(_MD("set_gravity_vector","vector"),&Area::set_gravity_vector);
- ClassDB::bind_method(_MD("get_gravity_vector"),&Area::get_gravity_vector);
+ ClassDB::bind_method(D_METHOD("set_gravity_vector","vector"),&Area::set_gravity_vector);
+ ClassDB::bind_method(D_METHOD("get_gravity_vector"),&Area::get_gravity_vector);
- ClassDB::bind_method(_MD("set_gravity","gravity"),&Area::set_gravity);
- ClassDB::bind_method(_MD("get_gravity"),&Area::get_gravity);
+ ClassDB::bind_method(D_METHOD("set_gravity","gravity"),&Area::set_gravity);
+ ClassDB::bind_method(D_METHOD("get_gravity"),&Area::get_gravity);
- ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area::set_angular_damp);
- ClassDB::bind_method(_MD("get_angular_damp"),&Area::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp","angular_damp"),&Area::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"),&Area::get_angular_damp);
- ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area::set_linear_damp);
- ClassDB::bind_method(_MD("get_linear_damp"),&Area::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp","linear_damp"),&Area::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"),&Area::get_linear_damp);
- ClassDB::bind_method(_MD("set_priority","priority"),&Area::set_priority);
- ClassDB::bind_method(_MD("get_priority"),&Area::get_priority);
+ ClassDB::bind_method(D_METHOD("set_priority","priority"),&Area::set_priority);
+ ClassDB::bind_method(D_METHOD("get_priority"),&Area::get_priority);
- ClassDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area::set_collision_mask);
- ClassDB::bind_method(_MD("get_collision_mask"),&Area::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask","collision_mask"),&Area::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"),&Area::get_collision_mask);
- ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&Area::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","layer_mask"),&Area::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&Area::get_layer_mask);
- ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area::set_collision_mask_bit);
- ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit","bit","value"),&Area::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit","bit"),&Area::get_collision_mask_bit);
- ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area::set_layer_mask_bit);
- ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area::get_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_layer_mask_bit","bit","value"),&Area::set_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_layer_mask_bit","bit"),&Area::get_layer_mask_bit);
- ClassDB::bind_method(_MD("set_monitorable","enable"),&Area::set_monitorable);
- ClassDB::bind_method(_MD("is_monitorable"),&Area::is_monitorable);
+ ClassDB::bind_method(D_METHOD("set_monitorable","enable"),&Area::set_monitorable);
+ ClassDB::bind_method(D_METHOD("is_monitorable"),&Area::is_monitorable);
- ClassDB::bind_method(_MD("set_enable_monitoring","enable"),&Area::set_enable_monitoring);
- ClassDB::bind_method(_MD("is_monitoring_enabled"),&Area::is_monitoring_enabled);
+ ClassDB::bind_method(D_METHOD("set_monitoring","enable"),&Area::set_monitoring);
+ ClassDB::bind_method(D_METHOD("is_monitoring"),&Area::is_monitoring);
- ClassDB::bind_method(_MD("get_overlapping_bodies"),&Area::get_overlapping_bodies);
- ClassDB::bind_method(_MD("get_overlapping_areas"),&Area::get_overlapping_areas);
+ ClassDB::bind_method(D_METHOD("get_overlapping_bodies"),&Area::get_overlapping_bodies);
+ ClassDB::bind_method(D_METHOD("get_overlapping_areas"),&Area::get_overlapping_areas);
- ClassDB::bind_method(_MD("overlaps_body","body"),&Area::overlaps_body);
- ClassDB::bind_method(_MD("overlaps_area","area"),&Area::overlaps_area);
+ ClassDB::bind_method(D_METHOD("overlaps_body","body"),&Area::overlaps_body);
+ ClassDB::bind_method(D_METHOD("overlaps_area","area"),&Area::overlaps_area);
- ClassDB::bind_method(_MD("_body_inout"),&Area::_body_inout);
- ClassDB::bind_method(_MD("_area_inout"),&Area::_area_inout);
+ ClassDB::bind_method(D_METHOD("_body_inout"),&Area::_body_inout);
+ ClassDB::bind_method(D_METHOD("_area_inout"),&Area::_area_inout);
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")));
@@ -645,26 +645,26 @@ void Area::_bind_methods() {
ADD_SIGNAL( MethodInfo("area_entered",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
ADD_SIGNAL( MethodInfo("area_exited",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),"set_space_override_mode","get_space_override_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),"set_gravity_is_point","is_gravity_a_point");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),"set_gravity_distance_scale","get_gravity_distance_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"gravity_vec"),"set_gravity_vector","get_gravity_vector");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),"set_gravity","get_gravity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),"set_linear_damp","get_linear_damp");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),"set_angular_damp","get_angular_damp");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),"set_priority","get_priority");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),"set_monitoring","is_monitoring");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),"set_monitorable","is_monitorable");
ADD_GROUP("Collision","collision_");
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_3D_PHYSICS),"set_layer_mask","get_layer_mask");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),"set_collision_mask","get_collision_mask");
}
Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),true) {
space_override=SPACE_OVERRIDE_DISABLED;
- set_gravity(9.8);;
+ set_gravity(9.8);
locked=false;
set_gravity_vector(Vector3(0,-1,0));
gravity_is_point=false;
@@ -676,7 +676,7 @@ Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),tru
collision_mask=1;
layer_mask=1;
set_ray_pickable(false);
- set_enable_monitoring(true);
+ set_monitoring(true);
set_monitorable(true);
}
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 3260bad0a4..7956846505 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -153,8 +153,8 @@ public:
void set_priority(real_t p_priority);
real_t get_priority() const;
- void set_enable_monitoring(bool p_enable);
- bool is_monitoring_enabled() const;
+ void set_monitoring(bool p_enable);
+ bool is_monitoring() const;
void set_monitorable(bool p_enable);
bool is_monitorable() const;
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index 59d8d7ecac..e20d8faafd 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -389,8 +389,8 @@ void BakedLight::_plot_face(int p_idx, int p_level, const Vector3 *p_vtx, const
Vector2 uv = get_uv(intersection,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
albedo_accum.r+=p_material.albedo[ofs].r;
@@ -415,8 +415,8 @@ void BakedLight::_plot_face(int p_idx, int p_level, const Vector3 *p_vtx, const
Vector2 uv = get_uv(inters,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
@@ -943,7 +943,7 @@ void BakedLight::_bake_light(Light* p_light) {
Vector3 light_dir = -rel_xf.basis.get_axis(2);
Color color = dl->get_color();
- float nrg = dl->get_param(Light::PARAM_ENERGY);;
+ float nrg = dl->get_param(Light::PARAM_ENERGY);
color.r*=nrg;
color.g*=nrg;
color.b*=nrg;
@@ -1524,7 +1524,7 @@ void BakedLight::set_cell_subdiv(int p_subdiv) {
cell_subdiv=p_subdiv;
-// VS::get_singleton()->baked_light_set_subdivision(baked_light,p_subdiv);
+ //VS::get_singleton()->baked_light_set_subdivision(baked_light,p_subdiv);
}
int BakedLight::get_cell_subdiv() const {
@@ -1705,7 +1705,6 @@ void BakedLight::create_debug_mesh(DebugMode p_mode) {
#else
mmi->set_owner(get_owner());
#endif
-
}
void BakedLight::_debug_mesh_albedo() {
@@ -1719,33 +1718,33 @@ void BakedLight::_debug_mesh_light() {
void BakedLight::_bind_methods() {
- ClassDB::bind_method(_MD("set_cell_subdiv","steps"),&BakedLight::set_cell_subdiv);
- ClassDB::bind_method(_MD("get_cell_subdiv"),&BakedLight::get_cell_subdiv);
+ ClassDB::bind_method(D_METHOD("set_cell_subdiv","steps"),&BakedLight::set_cell_subdiv);
+ ClassDB::bind_method(D_METHOD("get_cell_subdiv"),&BakedLight::get_cell_subdiv);
- ClassDB::bind_method(_MD("bake"),&BakedLight::bake);
- ClassDB::set_method_flags(get_class_static(),_SCS("bake"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("bake"),&BakedLight::bake);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("bake"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("bake_lights"),&BakedLight::bake_lights);
- ClassDB::set_method_flags(get_class_static(),_SCS("bake_lights"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("bake_lights"),&BakedLight::bake_lights);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("bake_lights"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("bake_radiance"),&BakedLight::bake_radiance);
- ClassDB::set_method_flags(get_class_static(),_SCS("bake_radiance"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("bake_radiance"),&BakedLight::bake_radiance);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("bake_radiance"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("debug_mesh_albedo"),&BakedLight::_debug_mesh_albedo);
- ClassDB::set_method_flags(get_class_static(),_SCS("debug_mesh_albedo"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("debug_mesh_albedo"),&BakedLight::_debug_mesh_albedo);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("debug_mesh_albedo"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("debug_mesh_light"),&BakedLight::_debug_mesh_light);
- ClassDB::set_method_flags(get_class_static(),_SCS("debug_mesh_light"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("debug_mesh_light"),&BakedLight::_debug_mesh_light);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("debug_mesh_light"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"cell_subdiv"),_SCS("set_cell_subdiv"),_SCS("get_cell_subdiv"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"cell_subdiv"),"set_cell_subdiv","get_cell_subdiv");
ADD_SIGNAL( MethodInfo("baked_light_changed"));
}
BakedLight::BakedLight() {
-// baked_light=VisualServer::get_singleton()->baked_light_create();
+ //baked_light=VisualServer::get_singleton()->baked_light_create();
VS::get_singleton()->instance_set_base(get_instance(),baked_light);
cell_subdiv=8;
@@ -1798,11 +1797,11 @@ DVector<Face3> BakedLightSampler::get_faces(uint32_t p_usage_flags) const {
void BakedLightSampler::_bind_methods() {
- ClassDB::bind_method(_MD("set_param","param","value"),&BakedLightSampler::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&BakedLightSampler::get_param);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&BakedLightSampler::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&BakedLightSampler::get_param);
- ClassDB::bind_method(_MD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
- ClassDB::bind_method(_MD("get_resolution"),&BakedLightSampler::get_resolution);
+ ClassDB::bind_method(D_METHOD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
+ ClassDB::bind_method(D_METHOD("get_resolution"),&BakedLightSampler::get_resolution);
BIND_CONSTANT( PARAM_RADIUS );
@@ -1811,12 +1810,12 @@ void BakedLightSampler::_bind_methods() {
BIND_CONSTANT( PARAM_DETAIL_RATIO );
BIND_CONSTANT( PARAM_MAX );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/radius",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_RADIUS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/strength",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
-// ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/resolution",PROPERTY_HINT_RANGE,"4,32,1"),_SCS("set_resolution"),_SCS("get_resolution"));
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/radius",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),"set_param","get_param",PARAM_RADIUS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/strength",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param","get_param",PARAM_STRENGTH);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/attenuation",PROPERTY_HINT_EXP_EASING),"set_param","get_param",PARAM_ATTENUATION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),"set_param","get_param",PARAM_DETAIL_RATIO);
+ //ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),"set_param","get_param",PARAM_DETAIL_RATIO);
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/resolution",PROPERTY_HINT_RANGE,"4,32,1"),"set_resolution","get_resolution");
}
diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp
index ff8b0f15bf..af3fe3c0a4 100644
--- a/scene/3d/body_shape.cpp
+++ b/scene/3d/body_shape.cpp
@@ -96,7 +96,7 @@ void CollisionShape::_update_indicator() {
pt = VS::PRIMITIVE_LINES;
} else if (shape->cast_to<SphereShape>()) {
-// VisualServer *vs=VisualServer::get_singleton();
+ //VisualServer *vs=VisualServer::get_singleton();
SphereShape *shapeptr=shape->cast_to<SphereShape>();
@@ -337,7 +337,7 @@ void CollisionShape::_notification(int p_what) {
//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());
+ //VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
if (can_update_body && updating_body) {
_update_body();
}
@@ -414,22 +414,22 @@ String CollisionShape::get_configuration_warning() const {
void CollisionShape::_bind_methods() {
//not sure if this should do anything
- ClassDB::bind_method(_MD("resource_changed","resource"),&CollisionShape::resource_changed);
- ClassDB::bind_method(_MD("set_shape","shape"),&CollisionShape::set_shape);
- ClassDB::bind_method(_MD("get_shape"),&CollisionShape::get_shape);
- ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape::_add_to_collision_object);
- ClassDB::bind_method(_MD("set_trigger","enable"),&CollisionShape::set_trigger);
- ClassDB::bind_method(_MD("is_trigger"),&CollisionShape::is_trigger);
- ClassDB::bind_method(_MD("make_convex_from_brothers"),&CollisionShape::make_convex_from_brothers);
+ 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(_MD("_set_update_shape_index","index"),&CollisionShape::_set_update_shape_index);
- ClassDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape::_get_update_shape_index);
+ 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(_MD("get_collision_object_shape_index"),&CollisionShape::get_collision_object_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"), _SCS("set_shape"), _SCS("get_shape"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_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");
}
@@ -506,7 +506,7 @@ void CollisionShape::_create_debug_shape() {
if (debug_shape) {
- debug_shape->queue_delete();;
+ debug_shape->queue_delete();
debug_shape=NULL;
}
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index c3ab2df939..1a2680e3b8 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -79,7 +79,7 @@ void BoneAttachment::_check_bind() {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
if (idx!=-1) {
- sk->bind_child_node_to_bone(idx,this);;
+ sk->bind_child_node_to_bone(idx,this);
set_transform(sk->get_bone_global_pose(idx));
bound=true;
}
@@ -94,7 +94,7 @@ void BoneAttachment::_check_unbind() {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
if (idx!=-1) {
- sk->unbind_child_node_from_bone(idx,this);;
+ sk->unbind_child_node_from_bone(idx,this);
}
}
bound=false;
@@ -139,6 +139,6 @@ BoneAttachment::BoneAttachment()
}
void BoneAttachment::_bind_methods(){
- ClassDB::bind_method(_MD("set_bone_name","bone_name"),&BoneAttachment::set_bone_name);
- ClassDB::bind_method(_MD("get_bone_name"),&BoneAttachment::get_bone_name);
+ ClassDB::bind_method(D_METHOD("set_bone_name","bone_name"),&BoneAttachment::set_bone_name);
+ ClassDB::bind_method(D_METHOD("get_bone_name"),&BoneAttachment::get_bone_name);
}
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 6298e629a4..2e04f2d8bc 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -190,9 +190,11 @@ void Camera::_update_camera() {
tr.origin+=tr.basis.get_axis(0)*h_offset;
VisualServer::get_singleton()->camera_set_transform( camera, tr );
-// here goes listener stuff
-// if (viewport_ptr && is_inside_scene() && is_current())
-// get_viewport()->_camera_transform_changed_notify();
+ // here goes listener stuff
+ /*
+ if (viewport_ptr && is_inside_scene() && is_current())
+ get_viewport()->_camera_transform_changed_notify();
+ */
if (is_inside_tree() && is_current()) {
get_viewport()->_camera_transform_changed_notify();
@@ -373,7 +375,7 @@ Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const {
ray=Vector3(0,0,-1);
} else {
CameraMatrix cm;
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
float screen_w,screen_h;
cm.get_viewport_size(screen_w,screen_h);
ray=Vector3( ((cpos.x/viewport_size.width)*2.0-1.0)*screen_w, ((1.0-(cpos.y/viewport_size.height))*2.0-1.0)*screen_h,-near).normalized();
@@ -400,7 +402,7 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
#endif
ERR_FAIL_COND_V( viewport_size.y == 0, Vector3() );
-// float aspect = viewport_size.x / viewport_size.y;
+ //float aspect = viewport_size.x / viewport_size.y;
if (mode == PROJECTION_PERSPECTIVE) {
@@ -410,10 +412,10 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
Vector2 pos = cpos / viewport_size;
float vsize,hsize;
if (keep_aspect==KEEP_WIDTH) {
- vsize = size/viewport_size.get_aspect();
+ vsize = size/viewport_size.aspect();
hsize = size;
} else {
- hsize = size*viewport_size.get_aspect();
+ hsize = size*viewport_size.aspect();
vsize = size;
}
@@ -449,9 +451,9 @@ Point2 Camera::unproject_position(const Vector3& p_pos) const {
if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
Plane p(get_camera_transform().xform_inv(p_pos),1.0);
@@ -479,9 +481,9 @@ Vector3 Camera::project_position(const Point2& p_point) const {
CameraMatrix cm;
if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
Size2 vp_size;
cm.get_viewport_size(vp_size.x,vp_size.y);
@@ -546,34 +548,34 @@ Camera::KeepAspect Camera::get_keep_aspect_mode() const{
void Camera::_bind_methods() {
- ClassDB::bind_method( _MD("project_ray_normal","screen_point"), &Camera::project_ray_normal);
- ClassDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
- ClassDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
- ClassDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
- ClassDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
- ClassDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
- ClassDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
- ClassDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
- ClassDB::bind_method( _MD("make_current"),&Camera::make_current );
- ClassDB::bind_method( _MD("clear_current"),&Camera::clear_current );
- ClassDB::bind_method( _MD("is_current"),&Camera::is_current );
- ClassDB::bind_method( _MD("get_camera_transform"),&Camera::get_camera_transform );
- ClassDB::bind_method( _MD("get_fov"),&Camera::get_fov );
- ClassDB::bind_method( _MD("get_size"),&Camera::get_size );
- ClassDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
- ClassDB::bind_method( _MD("get_znear"),&Camera::get_znear );
- ClassDB::bind_method( _MD("get_projection"),&Camera::get_projection );
- ClassDB::bind_method( _MD("set_h_offset","ofs"),&Camera::set_h_offset );
- ClassDB::bind_method( _MD("get_h_offset"),&Camera::get_h_offset );
- ClassDB::bind_method( _MD("set_v_offset","ofs"),&Camera::set_v_offset );
- ClassDB::bind_method( _MD("get_v_offset"),&Camera::get_v_offset );
- ClassDB::bind_method( _MD("set_cull_mask","mask"),&Camera::set_cull_mask );
- ClassDB::bind_method( _MD("get_cull_mask"),&Camera::get_cull_mask );
- ClassDB::bind_method( _MD("set_environment","env:Environment"),&Camera::set_environment );
- ClassDB::bind_method( _MD("get_environment:Environment"),&Camera::get_environment );
- ClassDB::bind_method( _MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode );
- ClassDB::bind_method( _MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode );
- //ClassDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
+ ClassDB::bind_method(D_METHOD("project_ray_normal","screen_point"), &Camera::project_ray_normal);
+ ClassDB::bind_method(D_METHOD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
+ ClassDB::bind_method(D_METHOD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
+ ClassDB::bind_method(D_METHOD("unproject_position","world_point"), &Camera::unproject_position);
+ ClassDB::bind_method(D_METHOD("is_position_behind","world_point"), &Camera::is_position_behind);
+ ClassDB::bind_method(D_METHOD("project_position","screen_point"), &Camera::project_position);
+ ClassDB::bind_method(D_METHOD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
+ ClassDB::bind_method(D_METHOD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
+ ClassDB::bind_method(D_METHOD("make_current"),&Camera::make_current );
+ ClassDB::bind_method(D_METHOD("clear_current"),&Camera::clear_current );
+ ClassDB::bind_method(D_METHOD("is_current"),&Camera::is_current );
+ ClassDB::bind_method(D_METHOD("get_camera_transform"),&Camera::get_camera_transform );
+ ClassDB::bind_method(D_METHOD("get_fov"),&Camera::get_fov );
+ ClassDB::bind_method(D_METHOD("get_size"),&Camera::get_size );
+ ClassDB::bind_method(D_METHOD("get_zfar"),&Camera::get_zfar );
+ ClassDB::bind_method(D_METHOD("get_znear"),&Camera::get_znear );
+ ClassDB::bind_method(D_METHOD("get_projection"),&Camera::get_projection );
+ ClassDB::bind_method(D_METHOD("set_h_offset","ofs"),&Camera::set_h_offset );
+ ClassDB::bind_method(D_METHOD("get_h_offset"),&Camera::get_h_offset );
+ ClassDB::bind_method(D_METHOD("set_v_offset","ofs"),&Camera::set_v_offset );
+ ClassDB::bind_method(D_METHOD("get_v_offset"),&Camera::get_v_offset );
+ ClassDB::bind_method(D_METHOD("set_cull_mask","mask"),&Camera::set_cull_mask );
+ ClassDB::bind_method(D_METHOD("get_cull_mask"),&Camera::get_cull_mask );
+ ClassDB::bind_method(D_METHOD("set_environment","env:Environment"),&Camera::set_environment );
+ 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("_camera_make_current"),&Camera::_camera_make_current );
BIND_CONSTANT( PROJECTION_PERSPECTIVE );
BIND_CONSTANT( PROJECTION_ORTHOGONAL );
@@ -628,9 +630,9 @@ Vector<Plane> Camera::get_frustum() const {
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
if (mode==PROJECTION_PERSPECTIVE)
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
else
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size,viewport_size.aspect(),near,far,keep_aspect==KEEP_WIDTH);
return cm.get_projection_planes(get_camera_transform());
@@ -642,7 +644,7 @@ Vector<Plane> Camera::get_frustum() const {
void Camera::set_v_offset(float p_offset) {
v_offset=p_offset;
- _update_camera();;
+ _update_camera();
}
float Camera::get_v_offset() const {
@@ -678,6 +680,7 @@ Camera::Camera() {
h_offset=0;
VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
//active=false;
+ set_notify_transform(true);
}
diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp
index b4cd46bd35..424a7fc79c 100644
--- a/scene/3d/character_camera.cpp
+++ b/scene/3d/character_camera.cpp
@@ -97,7 +97,7 @@ void CharacterCamera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::INT, "type", PROPERTY_HINT_ENUM, "Fixed,Follow") );
p_list->push_back( PropertyInfo( Variant::VECTOR2, "orbit" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,0.01" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); ;
+ p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "max_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "min_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "min_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) );
@@ -168,7 +168,7 @@ void CharacterCamera::_compute_camera() {
Vector3 vec1 = accepted.origin;
Vector3 vec2 = proposed.origin;
- final.origin = vec2.linear_interpolate(vec1, pos_ratio * time);;
+ final.origin = vec2.linear_interpolate(vec1, pos_ratio * time);
Quat q1 = accepted.basis;
Quat q2 = proposed.basis;
@@ -634,30 +634,30 @@ float CharacterCamera::get_autoturn_speed() const {
void CharacterCamera::_bind_methods() {
- ClassDB::bind_method(_MD("set_camera_type","type"),&CharacterCamera::set_camera_type);
- ClassDB::bind_method(_MD("get_camera_type"),&CharacterCamera::get_camera_type);
- ClassDB::bind_method(_MD("set_orbit","orbit"),&CharacterCamera::set_orbit);
- ClassDB::bind_method(_MD("get_orbit"),&CharacterCamera::get_orbit);
- ClassDB::bind_method(_MD("set_orbit_x","x"),&CharacterCamera::set_orbit_x);
- ClassDB::bind_method(_MD("set_orbit_y","y"),&CharacterCamera::set_orbit_y);
- ClassDB::bind_method(_MD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x);
- ClassDB::bind_method(_MD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x);
- ClassDB::bind_method(_MD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x);
- ClassDB::bind_method(_MD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x);
- ClassDB::bind_method(_MD("rotate_orbit"),&CharacterCamera::rotate_orbit);
- ClassDB::bind_method(_MD("set_distance","distance"),&CharacterCamera::set_distance);
- ClassDB::bind_method(_MD("get_distance"),&CharacterCamera::get_distance);
- ClassDB::bind_method(_MD("set_clip","enable"),&CharacterCamera::set_clip);
- ClassDB::bind_method(_MD("has_clip"),&CharacterCamera::has_clip);
- ClassDB::bind_method(_MD("set_autoturn","enable"),&CharacterCamera::set_autoturn);
- ClassDB::bind_method(_MD("has_autoturn"),&CharacterCamera::has_autoturn);
- ClassDB::bind_method(_MD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance);
- ClassDB::bind_method(_MD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance);
- ClassDB::bind_method(_MD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed);
- ClassDB::bind_method(_MD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed);
- ClassDB::bind_method(_MD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3()));
-
- ClassDB::bind_method(_MD("_ray_collision"),&CharacterCamera::_ray_collision);
+ ClassDB::bind_method(D_METHOD("set_camera_type","type"),&CharacterCamera::set_camera_type);
+ ClassDB::bind_method(D_METHOD("get_camera_type"),&CharacterCamera::get_camera_type);
+ ClassDB::bind_method(D_METHOD("set_orbit","orbit"),&CharacterCamera::set_orbit);
+ ClassDB::bind_method(D_METHOD("get_orbit"),&CharacterCamera::get_orbit);
+ ClassDB::bind_method(D_METHOD("set_orbit_x","x"),&CharacterCamera::set_orbit_x);
+ ClassDB::bind_method(D_METHOD("set_orbit_y","y"),&CharacterCamera::set_orbit_y);
+ ClassDB::bind_method(D_METHOD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x);
+ ClassDB::bind_method(D_METHOD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x);
+ ClassDB::bind_method(D_METHOD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x);
+ ClassDB::bind_method(D_METHOD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x);
+ ClassDB::bind_method(D_METHOD("rotate_orbit"),&CharacterCamera::rotate_orbit);
+ ClassDB::bind_method(D_METHOD("set_distance","distance"),&CharacterCamera::set_distance);
+ ClassDB::bind_method(D_METHOD("get_distance"),&CharacterCamera::get_distance);
+ ClassDB::bind_method(D_METHOD("set_clip","enable"),&CharacterCamera::set_clip);
+ ClassDB::bind_method(D_METHOD("has_clip"),&CharacterCamera::has_clip);
+ ClassDB::bind_method(D_METHOD("set_autoturn","enable"),&CharacterCamera::set_autoturn);
+ ClassDB::bind_method(D_METHOD("has_autoturn"),&CharacterCamera::has_autoturn);
+ ClassDB::bind_method(D_METHOD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance);
+ ClassDB::bind_method(D_METHOD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance);
+ ClassDB::bind_method(D_METHOD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed);
+ ClassDB::bind_method(D_METHOD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed);
+ ClassDB::bind_method(D_METHOD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3()));
+
+ ClassDB::bind_method(D_METHOD("_ray_collision"),&CharacterCamera::_ray_collision);
BIND_CONSTANT( CAMERA_FIXED );
BIND_CONSTANT( CAMERA_FOLLOW );
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 0660d0bdad..32e60f0d57 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -206,7 +206,7 @@ void CollisionObject::_mouse_exit() {
void CollisionObject::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = ray_pickable && is_inside_tree() && is_visible();
+ bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree();
if (area)
PhysicsServer::get_singleton()->area_set_ray_pickable(rid,pickable);
else
@@ -228,30 +228,30 @@ bool CollisionObject::is_ray_pickable() const {
void CollisionObject::_bind_methods() {
- ClassDB::bind_method(_MD("add_shape","shape:Shape","transform"),&CollisionObject::add_shape,DEFVAL(Transform()));
- ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject::get_shape_count);
- ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject::set_shape);
- ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
-// ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
- ClassDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject::set_shape_as_trigger);
- ClassDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject::is_shape_set_as_trigger);
- ClassDB::bind_method(_MD("get_shape:Shape","shape_idx"),&CollisionObject::get_shape);
- ClassDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject::get_shape_transform);
- ClassDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject::remove_shape);
- ClassDB::bind_method(_MD("clear_shapes"),&CollisionObject::clear_shapes);
- ClassDB::bind_method(_MD("set_ray_pickable","ray_pickable"),&CollisionObject::set_ray_pickable);
- ClassDB::bind_method(_MD("is_ray_pickable"),&CollisionObject::is_ray_pickable);
- ClassDB::bind_method(_MD("set_capture_input_on_drag","enable"),&CollisionObject::set_capture_input_on_drag);
- ClassDB::bind_method(_MD("get_capture_input_on_drag"),&CollisionObject::get_capture_input_on_drag);
- ClassDB::bind_method(_MD("get_rid"),&CollisionObject::get_rid);
+ 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);
BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"camera"),PropertyInfo(Variant::INPUT_EVENT,"event"),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::INPUT_EVENT,"event"),PropertyInfo(Variant::VECTOR3,"click_pos"),PropertyInfo(Variant::VECTOR3,"click_normal"),PropertyInfo(Variant::INT,"shape_idx")));
ADD_SIGNAL( MethodInfo("mouse_entered"));
ADD_SIGNAL( MethodInfo("mouse_exited"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_ray_pickable"),_SCS("set_ray_pickable"),_SCS("is_ray_pickable"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"input_capture_on_drag"),_SCS("set_capture_input_on_drag"),_SCS("get_capture_input_on_drag"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_ray_pickable"),"set_ray_pickable","is_ray_pickable");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"input_capture_on_drag"),"set_capture_input_on_drag","get_capture_input_on_drag");
}
@@ -334,12 +334,13 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
area=p_area;
capture_input_on_drag=false;
ray_pickable=true;
+ set_notify_transform(true);
if (p_area) {
PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
} else {
PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid,get_instance_ID());
}
-// set_transform_notify(true);
+ //set_transform_notify(true);
}
@@ -360,7 +361,7 @@ CollisionObject::CollisionObject() {
capture_input_on_drag=false;
ray_pickable=true;
-
+ set_notify_transform(true);
//owner=
//set_transform_notify(true);
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index d0612986df..82637c2488 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -275,27 +275,27 @@ String CollisionPolygon::get_configuration_warning() const {
void CollisionPolygon::_bind_methods() {
- ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object);
+ ClassDB::bind_method(D_METHOD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object);
- ClassDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon::set_build_mode);
- ClassDB::bind_method(_MD("get_build_mode"),&CollisionPolygon::get_build_mode);
+ 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(_MD("set_depth","depth"),&CollisionPolygon::set_depth);
- ClassDB::bind_method(_MD("get_depth"),&CollisionPolygon::get_depth);
+ ClassDB::bind_method(D_METHOD("set_depth","depth"),&CollisionPolygon::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"),&CollisionPolygon::get_depth);
- ClassDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon::set_polygon);
- ClassDB::bind_method(_MD("get_polygon"),&CollisionPolygon::get_polygon);
+ ClassDB::bind_method(D_METHOD("set_polygon","polygon"),&CollisionPolygon::set_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon"),&CollisionPolygon::get_polygon);
- ClassDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon::_set_shape_range);
- ClassDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon::_get_shape_range);
+ 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(_MD("get_collision_object_first_shape"),&CollisionPolygon::get_collision_object_first_shape);
- ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon::get_collision_object_last_shape);
+ 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);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Triangles"),_SCS("set_build_mode"),_SCS("get_build_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"depth"),_SCS("set_depth"),_SCS("get_depth"));
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
+ 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::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() {
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 13e7c175ed..e3c8ba09fc 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -64,6 +64,31 @@ float GIProbeData::get_energy() const{
}
+
+void GIProbeData::set_bias(float p_range) {
+
+ VS::get_singleton()->gi_probe_set_bias(probe,p_range);
+}
+
+float GIProbeData::get_bias() const{
+
+ return VS::get_singleton()->gi_probe_get_bias(probe);
+
+}
+
+
+void GIProbeData::set_propagation(float p_range) {
+
+ VS::get_singleton()->gi_probe_set_propagation(probe,p_range);
+}
+
+float GIProbeData::get_propagation() const{
+
+ return VS::get_singleton()->gi_probe_get_propagation(probe);
+
+}
+
+
void GIProbeData::set_interior(bool p_enable) {
VS::get_singleton()->gi_probe_set_interior(probe,p_enable);
@@ -103,39 +128,47 @@ RID GIProbeData::get_rid() const {
void GIProbeData::_bind_methods() {
- ClassDB::bind_method(_MD("set_bounds","bounds"),&GIProbeData::set_bounds);
- ClassDB::bind_method(_MD("get_bounds"),&GIProbeData::get_bounds);
+ ClassDB::bind_method(D_METHOD("set_bounds","bounds"),&GIProbeData::set_bounds);
+ ClassDB::bind_method(D_METHOD("get_bounds"),&GIProbeData::get_bounds);
+
+ ClassDB::bind_method(D_METHOD("set_cell_size","cell_size"),&GIProbeData::set_cell_size);
+ ClassDB::bind_method(D_METHOD("get_cell_size"),&GIProbeData::get_cell_size);
+
+ ClassDB::bind_method(D_METHOD("set_to_cell_xform","to_cell_xform"),&GIProbeData::set_to_cell_xform);
+ ClassDB::bind_method(D_METHOD("get_to_cell_xform"),&GIProbeData::get_to_cell_xform);
- ClassDB::bind_method(_MD("set_cell_size","cell_size"),&GIProbeData::set_cell_size);
- ClassDB::bind_method(_MD("get_cell_size"),&GIProbeData::get_cell_size);
+ ClassDB::bind_method(D_METHOD("set_dynamic_data","dynamic_data"),&GIProbeData::set_dynamic_data);
+ ClassDB::bind_method(D_METHOD("get_dynamic_data"),&GIProbeData::get_dynamic_data);
- ClassDB::bind_method(_MD("set_to_cell_xform","to_cell_xform"),&GIProbeData::set_to_cell_xform);
- ClassDB::bind_method(_MD("get_to_cell_xform"),&GIProbeData::get_to_cell_xform);
+ ClassDB::bind_method(D_METHOD("set_dynamic_range","dynamic_range"),&GIProbeData::set_dynamic_range);
+ ClassDB::bind_method(D_METHOD("get_dynamic_range"),&GIProbeData::get_dynamic_range);
- ClassDB::bind_method(_MD("set_dynamic_data","dynamic_data"),&GIProbeData::set_dynamic_data);
- ClassDB::bind_method(_MD("get_dynamic_data"),&GIProbeData::get_dynamic_data);
+ ClassDB::bind_method(D_METHOD("set_energy","energy"),&GIProbeData::set_energy);
+ ClassDB::bind_method(D_METHOD("get_energy"),&GIProbeData::get_energy);
- ClassDB::bind_method(_MD("set_dynamic_range","dynamic_range"),&GIProbeData::set_dynamic_range);
- ClassDB::bind_method(_MD("get_dynamic_range"),&GIProbeData::get_dynamic_range);
+ ClassDB::bind_method(D_METHOD("set_bias","bias"),&GIProbeData::set_bias);
+ ClassDB::bind_method(D_METHOD("get_bias"),&GIProbeData::get_bias);
- ClassDB::bind_method(_MD("set_energy","energy"),&GIProbeData::set_energy);
- ClassDB::bind_method(_MD("get_energy"),&GIProbeData::get_energy);
+ ClassDB::bind_method(D_METHOD("set_propagation","propagation"),&GIProbeData::set_propagation);
+ ClassDB::bind_method(D_METHOD("get_propagation"),&GIProbeData::get_propagation);
- ClassDB::bind_method(_MD("set_interior","interior"),&GIProbeData::set_interior);
- ClassDB::bind_method(_MD("is_interior"),&GIProbeData::is_interior);
+ ClassDB::bind_method(D_METHOD("set_interior","interior"),&GIProbeData::set_interior);
+ ClassDB::bind_method(D_METHOD("is_interior"),&GIProbeData::is_interior);
- ClassDB::bind_method(_MD("set_compress","compress"),&GIProbeData::set_compress);
- ClassDB::bind_method(_MD("is_compressed"),&GIProbeData::is_compressed);
+ ClassDB::bind_method(D_METHOD("set_compress","compress"),&GIProbeData::set_compress);
+ ClassDB::bind_method(D_METHOD("is_compressed"),&GIProbeData::is_compressed);
- ADD_PROPERTY(PropertyInfo(Variant::RECT3,"bounds",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_bounds"),_SCS("get_bounds"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"cell_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_cell_size"),_SCS("get_cell_size"));
- ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM,"to_cell_xform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_to_cell_xform"),_SCS("get_to_cell_xform"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT3,"bounds",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_bounds","get_bounds");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"cell_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_cell_size","get_cell_size");
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM,"to_cell_xform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_to_cell_xform","get_to_cell_xform");
- ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_data"),_SCS("get_dynamic_data"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_energy"),_SCS("get_energy"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"interior",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_interior"),_SCS("is_interior"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"compress",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_compress"),_SCS("is_compressed"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY,"dynamic_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_dynamic_data","get_dynamic_data");
+ 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,"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");
}
@@ -214,6 +247,30 @@ float GIProbe::get_energy() const {
return energy;
}
+void GIProbe::set_bias(float p_bias) {
+
+ bias=p_bias;
+ if (probe_data.is_valid()) {
+ probe_data->set_bias(bias);
+ }
+}
+float GIProbe::get_bias() const {
+
+ return bias;
+}
+
+void GIProbe::set_propagation(float p_propagation) {
+
+ propagation=p_propagation;
+ if (probe_data.is_valid()) {
+ probe_data->set_propagation(propagation);
+ }
+}
+float GIProbe::get_propagation() const {
+
+ return propagation;
+}
+
void GIProbe::set_interior(bool p_enable) {
interior=p_enable;
@@ -438,7 +495,8 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
int closest_axis;
float closest_dot;
- Vector3 normal = Plane(p_vtx[0],p_vtx[1],p_vtx[2]).normal;
+ Plane plane = Plane(p_vtx[0],p_vtx[1],p_vtx[2]);
+ Vector3 normal = plane.normal;
for(int i=0;i<3;i++) {
@@ -451,6 +509,7 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
}
}
+
Vector3 axis;
axis[closest_axis]=1.0;
Vector3 t1;
@@ -489,29 +548,28 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
Vector3 ray_from = from + (t1+t2)*0.5 - axis * p_aabb.size[closest_axis];
Vector3 ray_to = ray_from + axis * p_aabb.size[closest_axis]*2;
+ if (normal.dot(ray_from-ray_to)<0) {
+ SWAP(ray_from,ray_to);
+ }
+
Vector3 intersection;
- if (!Geometry::ray_intersects_triangle(ray_from,ray_to,p_vtx[0],p_vtx[1],p_vtx[2],&intersection)) {
- //no intersect? look in edges
-
- float closest_dist=1e20;
- for(int j=0;j<3;j++) {
- Vector3 c;
- Vector3 inters;
- Geometry::get_closest_points_between_segments(p_vtx[j],p_vtx[(j+1)%3],ray_from,ray_to,inters,c);
- float d=c.distance_to(intersection);
- if (j==0 || d<closest_dist) {
- closest_dist=d;
- intersection=inters;
- }
+ if (!plane.intersects_segment(ray_from,ray_to,&intersection)) {
+ if (ABS(plane.distance_to(ray_from)) < ABS(plane.distance_to(ray_to))) {
+ intersection = plane.project(ray_from);
+ } else {
+
+ intersection = plane.project(ray_to);
}
}
+ intersection=Face3(p_vtx[0],p_vtx[1],p_vtx[2]).get_closest_point_to(intersection);
+
Vector2 uv = get_uv(intersection,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
albedo_accum.r+=p_material.albedo[ofs].r;
@@ -539,8 +597,8 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
Vector2 uv = get_uv(inters,p_vtx,p_uv);
- int uv_x = CLAMP(Math::fposmod(uv.x,1.0)*bake_texture_size,0,bake_texture_size-1);
- int uv_y = CLAMP(Math::fposmod(uv.y,1.0)*bake_texture_size,0,bake_texture_size-1);
+ int uv_x = CLAMP(Math::fposmod(uv.x,1.0f)*bake_texture_size,0,bake_texture_size-1);
+ int uv_y = CLAMP(Math::fposmod(uv.y,1.0f)*bake_texture_size,0,bake_texture_size-1);
int ofs = uv_y*bake_texture_size+uv_x;
@@ -828,6 +886,10 @@ Vector<Color> GIProbe::_get_bake_texture(Image &p_image,const Color& p_color) {
return ret;
}
+ if (p_image.is_compressed()) {
+ print_line("DECOMPRESSING!!!!");
+ p_image.decompress();
+ }
p_image.convert(Image::FORMAT_RGBA8);
p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC);
@@ -864,13 +926,14 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
if (mat.is_valid()) {
-
- Ref<ImageTexture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
+ Ref<Texture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
Image img_albedo;
if (albedo_tex.is_valid()) {
img_albedo = albedo_tex->get_data();
+ } else {
+
}
mc.albedo=_get_bake_texture(img_albedo,mat->get_albedo());
@@ -906,7 +969,7 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
}
-void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_baker) {
+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++) {
@@ -914,7 +977,17 @@ void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_b
if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
continue; //only triangles
- Baker::MaterialCache material = _get_material_cache(p_mesh->surface_get_material(i),p_baker);
+ Ref<Material> src_material;
+
+ if (p_override_material.is_valid()) {
+ src_material=p_override_material;
+ } else if (i<p_materials.size() && p_materials[i].is_valid()) {
+ src_material=p_materials[i];
+ } else {
+ src_material=p_mesh->surface_get_material(i);
+
+ }
+ Baker::MaterialCache material = _get_material_cache(src_material,p_baker);
Array a = p_mesh->surface_get_arrays(i);
@@ -1009,6 +1082,35 @@ void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){
Baker::PlotMesh pm;
pm.local_xform=xf;
pm.mesh=mesh;
+ for(int i=0;i<mesh->get_surface_count();i++) {
+ pm.instance_materials.push_back(mi->get_surface_material(i));
+ }
+ pm.override_material=mi->get_material_override();
+ p_baker->mesh_list.push_back(pm);
+
+ }
+ }
+ }
+
+ if (p_at_node->cast_to<Spatial>()) {
+
+ Spatial *s = p_at_node->cast_to<Spatial>();
+ Array meshes = p_at_node->call("get_meshes");
+ for(int i=0;i<meshes.size();i+=2) {
+
+ Transform mxf = meshes[i];
+ Ref<Mesh> mesh = meshes[i+1];
+ if (!mesh.is_valid())
+ continue;
+
+ Rect3 aabb = mesh->get_aabb();
+
+ Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+
+ if (Rect3(-extents,extents*2).intersects(xf.xform(aabb))) {
+ Baker::PlotMesh pm;
+ pm.local_xform=xf;
+ pm.mesh=mesh;
p_baker->mesh_list.push_back(pm);
}
@@ -1083,7 +1185,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug){
print_line("plotting mesh "+itos(pmc++)+"/"+itos(baker.mesh_list.size()));
- _plot_mesh(E->get().local_xform,E->get().mesh,&baker);
+ _plot_mesh(E->get().local_xform,E->get().mesh,&baker,E->get().instance_materials,E->get().override_material);
}
_fixup_plot(0,0,0,0,0,&baker);
@@ -1167,26 +1269,30 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug){
}
- Ref<GIProbeData> probe_data;
- probe_data.instance();
- probe_data->set_bounds(Rect3(-extents,extents*2.0));
- probe_data->set_cell_size(baker.po2_bounds.size[longest_axis]/baker.axis_cell_size[longest_axis]);
- probe_data->set_dynamic_data(data);
- probe_data->set_dynamic_range(dynamic_range);
- probe_data->set_energy(energy);
- probe_data->set_interior(interior);
- probe_data->set_compress(compress);
- probe_data->set_to_cell_xform(baker.to_cell_space);
-
- set_probe_data(probe_data);
+ if (p_create_visual_debug) {
+ _create_debug_mesh(&baker);
+ } else {
+ Ref<GIProbeData> probe_data;
+ probe_data.instance();
+ probe_data->set_bounds(Rect3(-extents,extents*2.0));
+ probe_data->set_cell_size(baker.po2_bounds.size[longest_axis]/baker.axis_cell_size[longest_axis]);
+ probe_data->set_dynamic_data(data);
+ probe_data->set_dynamic_range(dynamic_range);
+ probe_data->set_energy(energy);
+ probe_data->set_bias(bias);
+ probe_data->set_propagation(propagation);
+ probe_data->set_interior(interior);
+ probe_data->set_compress(compress);
+ probe_data->set_to_cell_xform(baker.to_cell_space);
- if (p_create_visual_debug) {
- // _create_debug_mesh(&baker);
+ set_probe_data(probe_data);
}
+
+
}
@@ -1324,7 +1430,6 @@ void GIProbe::_create_debug_mesh(Baker *p_baker) {
#else
mmi->set_owner(get_owner());
#endif
-
}
void GIProbe::_debug_bake() {
@@ -1344,38 +1449,46 @@ PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
void GIProbe::_bind_methods() {
- ClassDB::bind_method(_MD("set_probe_data","data"),&GIProbe::set_probe_data);
- ClassDB::bind_method(_MD("get_probe_data"),&GIProbe::get_probe_data);
+ 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_subdiv","subdiv"),&GIProbe::set_subdiv);
+ ClassDB::bind_method(D_METHOD("get_subdiv"),&GIProbe::get_subdiv);
+
+ ClassDB::bind_method(D_METHOD("set_extents","extents"),&GIProbe::set_extents);
+ ClassDB::bind_method(D_METHOD("get_extents"),&GIProbe::get_extents);
- ClassDB::bind_method(_MD("set_subdiv","subdiv"),&GIProbe::set_subdiv);
- ClassDB::bind_method(_MD("get_subdiv"),&GIProbe::get_subdiv);
+ ClassDB::bind_method(D_METHOD("set_dynamic_range","max"),&GIProbe::set_dynamic_range);
+ ClassDB::bind_method(D_METHOD("get_dynamic_range"),&GIProbe::get_dynamic_range);
- ClassDB::bind_method(_MD("set_extents","extents"),&GIProbe::set_extents);
- ClassDB::bind_method(_MD("get_extents"),&GIProbe::get_extents);
+ ClassDB::bind_method(D_METHOD("set_energy","max"),&GIProbe::set_energy);
+ ClassDB::bind_method(D_METHOD("get_energy"),&GIProbe::get_energy);
- ClassDB::bind_method(_MD("set_dynamic_range","max"),&GIProbe::set_dynamic_range);
- ClassDB::bind_method(_MD("get_dynamic_range"),&GIProbe::get_dynamic_range);
+ ClassDB::bind_method(D_METHOD("set_bias","max"),&GIProbe::set_bias);
+ ClassDB::bind_method(D_METHOD("get_bias"),&GIProbe::get_bias);
- ClassDB::bind_method(_MD("set_energy","max"),&GIProbe::set_energy);
- ClassDB::bind_method(_MD("get_energy"),&GIProbe::get_energy);
+ ClassDB::bind_method(D_METHOD("set_propagation","max"),&GIProbe::set_propagation);
+ ClassDB::bind_method(D_METHOD("get_propagation"),&GIProbe::get_propagation);
- ClassDB::bind_method(_MD("set_interior","enable"),&GIProbe::set_interior);
- ClassDB::bind_method(_MD("is_interior"),&GIProbe::is_interior);
+ ClassDB::bind_method(D_METHOD("set_interior","enable"),&GIProbe::set_interior);
+ ClassDB::bind_method(D_METHOD("is_interior"),&GIProbe::is_interior);
- ClassDB::bind_method(_MD("set_compress","enable"),&GIProbe::set_compress);
- ClassDB::bind_method(_MD("is_compressed"),&GIProbe::is_compressed);
+ ClassDB::bind_method(D_METHOD("set_compress","enable"),&GIProbe::set_compress);
+ ClassDB::bind_method(D_METHOD("is_compressed"),&GIProbe::is_compressed);
- ClassDB::bind_method(_MD("bake","from_node","create_visual_debug"),&GIProbe::bake,DEFVAL(Variant()),DEFVAL(false));
- ClassDB::bind_method(_MD("debug_bake"),&GIProbe::_debug_bake);
- ClassDB::set_method_flags(get_class_static(),_SCS("debug_bake"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("bake","from_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);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"subdiv",PROPERTY_HINT_ENUM,"64,128,256,512"),_SCS("set_subdiv"),_SCS("get_subdiv"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"),_SCS("set_extents"),_SCS("get_extents"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_RANGE,"1,16,1"),_SCS("set_dynamic_range"),_SCS("get_dynamic_range"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_energy"),_SCS("get_energy"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior"),_SCS("set_interior"),_SCS("is_interior"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"compress"),_SCS("set_compress"),_SCS("is_compressed"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"data",PROPERTY_HINT_RESOURCE_TYPE,"GIProbeData"),_SCS("set_probe_data"),_SCS("get_probe_data"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"subdiv",PROPERTY_HINT_ENUM,"64,128,256,512"),"set_subdiv","get_subdiv");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"),"set_extents","get_extents");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"dynamic_range",PROPERTY_HINT_RANGE,"1,16,1"),"set_dynamic_range","get_dynamic_range");
+ 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::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");
BIND_CONSTANT( SUBDIV_64 );
@@ -1390,6 +1503,8 @@ GIProbe::GIProbe() {
subdiv=SUBDIV_128;
dynamic_range=4;
energy=1.0;
+ bias=0.4;
+ propagation=1.0;
extents=Vector3(10,10,10);
color_scan_cell_width=4;
bake_texture_size=128;
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index e416b28791..0f003d7cb1 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -32,9 +32,15 @@ public:
void set_dynamic_range(int p_range);
int get_dynamic_range() const;
+ void set_propagation(float p_range);
+ float get_propagation() const;
+
void set_energy(float p_range);
float get_energy() const;
+ void set_bias(float p_range);
+ float get_bias() const;
+
void set_interior(bool p_enable);
bool is_interior() const;
@@ -114,6 +120,8 @@ private:
int axis_cell_size[3];
struct PlotMesh {
+ Ref<Material> override_material;
+ Vector<Ref<Material> > instance_materials;
Ref<Mesh> mesh;
Transform local_xform;
};
@@ -132,6 +140,8 @@ private:
Vector3 extents;
int dynamic_range;
float energy;
+ float bias;
+ float propagation;
bool interior;
bool compress;
@@ -141,7 +151,7 @@ private:
Vector<Color> _get_bake_texture(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<Mesh>& p_mesh, Baker *p_baker);
+ 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);
@@ -170,6 +180,12 @@ public:
void set_energy(float p_energy);
float get_energy() const;
+ void set_bias(float p_bias);
+ float get_bias() const;
+
+ void set_propagation(float p_propagation);
+ float get_propagation() const;
+
void set_interior(bool p_enable);
bool is_interior() const;
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 08fc1f59e8..6adbbe9ccf 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -154,16 +154,16 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool
void ImmediateGeometry::_bind_methods() {
- ClassDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
- ClassDB::bind_method(_MD("set_normal","normal"),&ImmediateGeometry::set_normal);
- ClassDB::bind_method(_MD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
- ClassDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
- ClassDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
- ClassDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
- ClassDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
- ClassDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
- ClassDB::bind_method(_MD("end"),&ImmediateGeometry::end);
- ClassDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
+ ClassDB::bind_method(D_METHOD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(D_METHOD("set_normal","normal"),&ImmediateGeometry::set_normal);
+ ClassDB::bind_method(D_METHOD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
+ ClassDB::bind_method(D_METHOD("set_color","color"),&ImmediateGeometry::set_color);
+ ClassDB::bind_method(D_METHOD("set_uv","uv"),&ImmediateGeometry::set_uv);
+ ClassDB::bind_method(D_METHOD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
+ ClassDB::bind_method(D_METHOD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
+ ClassDB::bind_method(D_METHOD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("end"),&ImmediateGeometry::end);
+ ClassDB::bind_method(D_METHOD("clear"),&ImmediateGeometry::clear);
}
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index c7464d3c5d..15ee971b7e 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -134,19 +134,19 @@ real_t InterpolatedCamera::get_speed() const {
void InterpolatedCamera::_bind_methods() {
- ClassDB::bind_method(_MD("set_target_path","target_path"),&InterpolatedCamera::set_target_path);
- ClassDB::bind_method(_MD("get_target_path"),&InterpolatedCamera::get_target_path);
- ClassDB::bind_method(_MD("set_target","target:Camera"),&InterpolatedCamera::_set_target);
+ ClassDB::bind_method(D_METHOD("set_target_path","target_path"),&InterpolatedCamera::set_target_path);
+ ClassDB::bind_method(D_METHOD("get_target_path"),&InterpolatedCamera::get_target_path);
+ ClassDB::bind_method(D_METHOD("set_target","target:Camera"),&InterpolatedCamera::_set_target);
- ClassDB::bind_method(_MD("set_speed","speed"),&InterpolatedCamera::set_speed);
- ClassDB::bind_method(_MD("get_speed"),&InterpolatedCamera::get_speed);
+ ClassDB::bind_method(D_METHOD("set_speed","speed"),&InterpolatedCamera::set_speed);
+ ClassDB::bind_method(D_METHOD("get_speed"),&InterpolatedCamera::get_speed);
- ClassDB::bind_method(_MD("set_interpolation_enabled","target_path"),&InterpolatedCamera::set_interpolation_enabled);
- ClassDB::bind_method(_MD("is_interpolation_enabled"),&InterpolatedCamera::is_interpolation_enabled);
+ ClassDB::bind_method(D_METHOD("set_interpolation_enabled","target_path"),&InterpolatedCamera::set_interpolation_enabled);
+ ClassDB::bind_method(D_METHOD("is_interpolation_enabled"),&InterpolatedCamera::is_interpolation_enabled);
- ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"target"), _SCS("set_target_path"), _SCS("get_target_path") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"speed"), _SCS("set_speed"), _SCS("get_speed") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"), _SCS("set_interpolation_enabled"), _SCS("is_interpolation_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"target"), "set_target_path", "get_target_path") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"speed"), "set_speed", "get_speed") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"), "set_interpolation_enabled", "is_interpolation_enabled") ;
}
InterpolatedCamera::InterpolatedCamera() {
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 50ee3482c3..473bca8d3b 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "light.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/resources/surface_tool.h"
#include "baked_light_instance.h"
@@ -47,7 +47,7 @@ void Light::set_param(Param p_param, float p_value) {
VS::get_singleton()->light_set_param(light,VS::LightParam(p_param),p_value);
if (p_param==PARAM_SPOT_ANGLE || p_param==PARAM_RANGE) {
- update_gizmo();;
+ update_gizmo();
}
@@ -164,7 +164,7 @@ void Light::_update_visibility() {
}
#endif
- //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && editor_ok);
+ //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible_in_tree() && editor_ok);
_change_notify("geometry/visible");
}
@@ -221,41 +221,42 @@ bool Light::is_editor_only() const{
void Light::_bind_methods() {
- ClassDB::bind_method(_MD("set_editor_only","editor_only"), &Light::set_editor_only );
- ClassDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only );
+ ClassDB::bind_method(D_METHOD("set_editor_only","editor_only"), &Light::set_editor_only );
+ ClassDB::bind_method(D_METHOD("is_editor_only"), &Light::is_editor_only );
- ClassDB::bind_method(_MD("set_param","param","value"), &Light::set_param );
- ClassDB::bind_method(_MD("get_param","param"), &Light::get_param );
+ ClassDB::bind_method(D_METHOD("set_param","param","value"), &Light::set_param );
+ ClassDB::bind_method(D_METHOD("get_param","param"), &Light::get_param );
- ClassDB::bind_method(_MD("set_shadow","enabled"), &Light::set_shadow );
- ClassDB::bind_method(_MD("has_shadow"), &Light::has_shadow );
+ ClassDB::bind_method(D_METHOD("set_shadow","enabled"), &Light::set_shadow );
+ ClassDB::bind_method(D_METHOD("has_shadow"), &Light::has_shadow );
- ClassDB::bind_method(_MD("set_negative","enabled"), &Light::set_negative );
- ClassDB::bind_method(_MD("is_negative"), &Light::is_negative );
+ ClassDB::bind_method(D_METHOD("set_negative","enabled"), &Light::set_negative );
+ ClassDB::bind_method(D_METHOD("is_negative"), &Light::is_negative );
- ClassDB::bind_method(_MD("set_cull_mask","cull_mask"), &Light::set_cull_mask );
- ClassDB::bind_method(_MD("get_cull_mask"), &Light::get_cull_mask );
+ ClassDB::bind_method(D_METHOD("set_cull_mask","cull_mask"), &Light::set_cull_mask );
+ ClassDB::bind_method(D_METHOD("get_cull_mask"), &Light::get_cull_mask );
- ClassDB::bind_method(_MD("set_color","color"), &Light::set_color );
- ClassDB::bind_method(_MD("get_color"), &Light::get_color );
+ ClassDB::bind_method(D_METHOD("set_color","color"), &Light::set_color );
+ ClassDB::bind_method(D_METHOD("get_color"), &Light::get_color );
- ClassDB::bind_method(_MD("set_shadow_color","shadow_color"), &Light::set_shadow_color );
- ClassDB::bind_method(_MD("get_shadow_color"), &Light::get_shadow_color );
+ ClassDB::bind_method(D_METHOD("set_shadow_color","shadow_color"), &Light::set_shadow_color );
+ ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light::get_shadow_color );
ADD_GROUP("Light","light_");
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color",PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_color"), _SCS("get_color"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ENERGY);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "light_negative"), _SCS("set_negative"), _SCS("is_negative"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_specular",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPECULAR);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "light_cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER), _SCS("set_cull_mask"), _SCS("get_cull_mask"));
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color",PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"), "set_param", "get_param", PARAM_ENERGY);
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "light_negative"), "set_negative", "is_negative");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "light_specular",PROPERTY_HINT_RANGE,"0,1,0.01"), "set_param", "get_param", PARAM_SPECULAR);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "light_cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
ADD_GROUP("Shadow","shadow_");
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow_enabled"), _SCS("set_shadow"), _SCS("has_shadow"));
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "shadow_color",PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_shadow_color"), _SCS("get_shadow_color"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_bias",PROPERTY_HINT_RANGE,"-16,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_BIAS);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_max_distance",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_MAX_DISTANCE);
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow_enabled"), "set_shadow", "has_shadow");
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "shadow_color",PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_bias",PROPERTY_HINT_RANGE,"-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_contact",PROPERTY_HINT_RANGE,"0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow_max_distance",PROPERTY_HINT_RANGE,"0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
ADD_GROUP("Editor","");
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
ADD_GROUP("","");
BIND_CONSTANT( PARAM_ENERGY );
@@ -264,6 +265,7 @@ void Light::_bind_methods() {
BIND_CONSTANT( PARAM_ATTENUATION );
BIND_CONSTANT( PARAM_SPOT_ANGLE );
BIND_CONSTANT( PARAM_SPOT_ATTENUATION );
+ BIND_CONSTANT( PARAM_CONTACT_SHADOW_SIZE );
BIND_CONSTANT( PARAM_SHADOW_MAX_DISTANCE );
BIND_CONSTANT( PARAM_SHADOW_SPLIT_1_OFFSET );
BIND_CONSTANT( PARAM_SHADOW_SPLIT_2_OFFSET );
@@ -297,6 +299,7 @@ Light::Light(VisualServer::LightType p_type) {
set_param(PARAM_ATTENUATION,1);
set_param(PARAM_SPOT_ANGLE,45);
set_param(PARAM_SPOT_ATTENUATION,1);
+ set_param(PARAM_CONTACT_SHADOW_SIZE,0);
set_param(PARAM_SHADOW_MAX_DISTANCE,0);
set_param(PARAM_SHADOW_SPLIT_1_OFFSET,0.1);
set_param(PARAM_SHADOW_SPLIT_2_OFFSET,0.2);
@@ -349,20 +352,20 @@ bool DirectionalLight::is_blend_splits_enabled() const {
void DirectionalLight::_bind_methods() {
- ClassDB::bind_method( _MD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
- ClassDB::bind_method( _MD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
+ ClassDB::bind_method( D_METHOD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
+ ClassDB::bind_method( D_METHOD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
- ClassDB::bind_method( _MD("set_blend_splits","enabled"),&DirectionalLight::set_blend_splits);
- ClassDB::bind_method( _MD("is_blend_splits_enabled"),&DirectionalLight::is_blend_splits_enabled);
+ ClassDB::bind_method( D_METHOD("set_blend_splits","enabled"),&DirectionalLight::set_blend_splits);
+ ClassDB::bind_method( D_METHOD("is_blend_splits_enabled"),&DirectionalLight::is_blend_splits_enabled);
ADD_GROUP("Directional Shadow","directional_shadow_");
- ADD_PROPERTY( PropertyInfo( Variant::INT, "directional_shadow_mode",PROPERTY_HINT_ENUM,"Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), _SCS("set_shadow_mode"), _SCS("get_shadow_mode"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_1",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_1_OFFSET);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_2",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_2_OFFSET);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_3",PROPERTY_HINT_RANGE,"0,1,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_SPLIT_3_OFFSET);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "directional_shadow_blend_splits"), _SCS("set_blend_splits"), _SCS("is_blend_splits_enabled"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_normal_bias",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_NORMAL_BIAS);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_bias_split_scale",PROPERTY_HINT_RANGE,"0,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SHADOW_BIAS_SPLIT_SCALE);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "directional_shadow_mode",PROPERTY_HINT_ENUM,"Orthogonal,PSSM 2 Splits,PSSM 4 Splits"), "set_shadow_mode", "get_shadow_mode");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_1",PROPERTY_HINT_RANGE,"0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_1_OFFSET);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_2",PROPERTY_HINT_RANGE,"0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_2_OFFSET);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_split_3",PROPERTY_HINT_RANGE,"0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET);
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled");
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_normal_bias",PROPERTY_HINT_RANGE,"0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "directional_shadow_bias_split_scale",PROPERTY_HINT_RANGE,"0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE);
BIND_CONSTANT( SHADOW_ORTHOGONAL );
BIND_CONSTANT( SHADOW_PARALLEL_2_SPLITS );
@@ -403,17 +406,17 @@ OmniLight::ShadowDetail OmniLight::get_shadow_detail() const{
void OmniLight::_bind_methods() {
- ClassDB::bind_method( _MD("set_shadow_mode","mode"),&OmniLight::set_shadow_mode);
- ClassDB::bind_method( _MD("get_shadow_mode"),&OmniLight::get_shadow_mode);
+ ClassDB::bind_method( D_METHOD("set_shadow_mode","mode"),&OmniLight::set_shadow_mode);
+ ClassDB::bind_method( D_METHOD("get_shadow_mode"),&OmniLight::get_shadow_mode);
- ClassDB::bind_method( _MD("set_shadow_detail","detail"),&OmniLight::set_shadow_detail);
- ClassDB::bind_method( _MD("get_shadow_detail"),&OmniLight::get_shadow_detail);
+ ClassDB::bind_method( D_METHOD("set_shadow_detail","detail"),&OmniLight::set_shadow_detail);
+ ClassDB::bind_method( D_METHOD("get_shadow_detail"),&OmniLight::get_shadow_detail);
ADD_GROUP("Omni","omni_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_RANGE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_mode",PROPERTY_HINT_ENUM,"Dual Paraboloid,Cube"), _SCS("set_shadow_mode"), _SCS("get_shadow_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_detail",PROPERTY_HINT_ENUM,"Vertical,Horizontal"), _SCS("set_shadow_detail"), _SCS("get_shadow_detail"));
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), "set_param", "get_param", PARAM_RANGE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "omni_attenuation",PROPERTY_HINT_EXP_EASING), "set_param", "get_param", PARAM_ATTENUATION);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_mode",PROPERTY_HINT_ENUM,"Dual Paraboloid,Cube"), "set_shadow_mode", "get_shadow_mode");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "omni_shadow_detail",PROPERTY_HINT_ENUM,"Vertical,Horizontal"), "set_shadow_detail", "get_shadow_detail");
}
@@ -427,9 +430,9 @@ OmniLight::OmniLight() : Light( VisualServer::LIGHT_OMNI ) {
void SpotLight::_bind_methods() {
ADD_GROUP("Spot","spot_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_RANGE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle",PROPERTY_HINT_RANGE,"0,180,0.1"), _SCS("set_param"), _SCS("get_param"), PARAM_SPOT_ANGLE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle_attenuation",PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_SPOT_ATTENUATION);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_range",PROPERTY_HINT_RANGE,"0,65536,0.1"), "set_param", "get_param", PARAM_RANGE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_attenuation",PROPERTY_HINT_EXP_EASING), "set_param", "get_param", PARAM_ATTENUATION);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle",PROPERTY_HINT_RANGE,"0,180,0.1"), "set_param", "get_param", PARAM_SPOT_ANGLE);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "spot_angle_attenuation",PROPERTY_HINT_EXP_EASING), "set_param", "get_param", PARAM_SPOT_ATTENUATION);
}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index d27b9fed12..4cf0156d5c 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -55,6 +55,7 @@ public:
PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION,
PARAM_SPOT_ANGLE = VS::LIGHT_PARAM_SPOT_ANGLE,
PARAM_SPOT_ATTENUATION = VS::LIGHT_PARAM_SPOT_ATTENUATION,
+ PARAM_CONTACT_SHADOW_SIZE= VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE,
PARAM_SHADOW_MAX_DISTANCE = VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE,
PARAM_SHADOW_SPLIT_1_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
PARAM_SHADOW_SPLIT_2_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
diff --git a/scene/3d/listener.cpp b/scene/3d/listener.cpp
index a227f5cd70..c774d59d77 100644
--- a/scene/3d/listener.cpp
+++ b/scene/3d/listener.cpp
@@ -146,16 +146,17 @@ RES Listener::_get_gizmo_geometry() const {
void Listener::_bind_methods() {
- ClassDB::bind_method( _MD("make_current"),&Listener::make_current );
- ClassDB::bind_method( _MD("clear_current"),&Listener::clear_current );
- ClassDB::bind_method( _MD("is_current"),&Listener::is_current );
- ClassDB::bind_method( _MD("get_listener_transform"),&Listener::get_listener_transform );
+ ClassDB::bind_method( D_METHOD("make_current"),&Listener::make_current );
+ ClassDB::bind_method( D_METHOD("clear_current"),&Listener::clear_current );
+ ClassDB::bind_method( D_METHOD("is_current"),&Listener::is_current );
+ ClassDB::bind_method( D_METHOD("get_listener_transform"),&Listener::get_listener_transform );
}
Listener::Listener() {
current=false;
force_change=false;
+ set_notify_transform(true);
//active=false;
}
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index 66bad45c45..e6bd69aed2 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -91,7 +91,7 @@ void MeshInstance::_get_property_list( List<PropertyInfo> *p_list) const {
ls.push_back(E->key());
}
- ls.sort();;
+ ls.sort();
for(List<String>::Element *E=ls.front();E;E=E->next()) {
p_list->push_back( PropertyInfo(Variant::REAL,E->get(),PROPERTY_HINT_RANGE,"0,1,0.01"));
@@ -294,19 +294,19 @@ void MeshInstance::_mesh_changed() {
void MeshInstance::_bind_methods() {
- ClassDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
- ClassDB::bind_method(_MD("get_mesh:Mesh"),&MeshInstance::get_mesh);
- ClassDB::bind_method(_MD("set_skeleton_path","skeleton_path:NodePath"),&MeshInstance::set_skeleton_path);
- ClassDB::bind_method(_MD("get_skeleton_path:NodePath"),&MeshInstance::get_skeleton_path);
- ClassDB::bind_method(_MD("get_aabb"),&MeshInstance::get_aabb);
- ClassDB::bind_method(_MD("create_trimesh_collision"),&MeshInstance::create_trimesh_collision);
+ ClassDB::bind_method(D_METHOD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh:Mesh"),&MeshInstance::get_mesh);
+ 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("create_trimesh_collision"),&MeshInstance::create_trimesh_collision);
ClassDB::set_method_flags("MeshInstance","create_trimesh_collision",METHOD_FLAGS_DEFAULT);
- ClassDB::bind_method(_MD("create_convex_collision"),&MeshInstance::create_convex_collision);
+ 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(_MD("_mesh_changed"),&MeshInstance::_mesh_changed);
+ ClassDB::bind_method(D_METHOD("_mesh_changed"),&MeshInstance::_mesh_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh" ), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY( PropertyInfo (Variant::NODE_PATH, "skeleton"), _SCS("set_skeleton_path"), _SCS("get_skeleton_path"));
+ 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");
}
MeshInstance::MeshInstance()
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index 31843fadaa..e1acdfca53 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -34,9 +34,9 @@
void MultiMeshInstance::_bind_methods() {
- ClassDB::bind_method(_MD("set_multimesh","multimesh"),&MultiMeshInstance::set_multimesh);
- ClassDB::bind_method(_MD("get_multimesh"),&MultiMeshInstance::get_multimesh);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"multimesh",PROPERTY_HINT_RESOURCE_TYPE,"MultiMesh"), _SCS("set_multimesh"), _SCS("get_multimesh"));
+ ClassDB::bind_method(D_METHOD("set_multimesh","multimesh"),&MultiMeshInstance::set_multimesh);
+ ClassDB::bind_method(D_METHOD("get_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.cpp b/scene/3d/navigation.cpp
index 40666a60dc..5c8fe6bb67 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -129,7 +129,7 @@ void Navigation::_navmesh_link(int p_id) {
C->get().B=&p;
C->get().B_edge=j;
C->get().A->edges[C->get().A_edge].C=&p;
- C->get().A->edges[C->get().A_edge].C_edge=j;;
+ C->get().A->edges[C->get().A_edge].C_edge=j;
p.edges[j].C=C->get().A;
p.edges[j].C_edge=C->get().A_edge;
//connection successful.
@@ -368,7 +368,7 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector
while(!found_route) {
if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ //print_line("NOU OPEN LIST");
break;
}
//check open list
@@ -550,7 +550,7 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector
path.push_back(begin_point);
- path.invert();;
+ path.invert();
}
return path;
@@ -730,20 +730,20 @@ Vector3 Navigation::get_up_vector() const{
void Navigation::_bind_methods() {
- ClassDB::bind_method(_MD("navmesh_create","mesh:NavigationMesh","xform","owner"),&Navigation::navmesh_create,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("navmesh_set_transform","id","xform"),&Navigation::navmesh_set_transform);
- ClassDB::bind_method(_MD("navmesh_remove","id"),&Navigation::navmesh_remove);
+ ClassDB::bind_method(D_METHOD("navmesh_create","mesh:NavigationMesh","xform","owner"),&Navigation::navmesh_create,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("navmesh_set_transform","id","xform"),&Navigation::navmesh_set_transform);
+ ClassDB::bind_method(D_METHOD("navmesh_remove","id"),&Navigation::navmesh_remove);
- ClassDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation::get_simple_path,DEFVAL(true));
- ClassDB::bind_method(_MD("get_closest_point_to_segment","start","end","use_collision"),&Navigation::get_closest_point_to_segment,DEFVAL(false));
- ClassDB::bind_method(_MD("get_closest_point","to_point"),&Navigation::get_closest_point);
- ClassDB::bind_method(_MD("get_closest_point_normal","to_point"),&Navigation::get_closest_point_normal);
- ClassDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation::get_closest_point_owner);
+ ClassDB::bind_method(D_METHOD("get_simple_path","start","end","optimize"),&Navigation::get_simple_path,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment","start","end","use_collision"),&Navigation::get_closest_point_to_segment,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_closest_point","to_point"),&Navigation::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_point_normal","to_point"),&Navigation::get_closest_point_normal);
+ ClassDB::bind_method(D_METHOD("get_closest_point_owner","to_point"),&Navigation::get_closest_point_owner);
- ClassDB::bind_method(_MD("set_up_vector","up"),&Navigation::set_up_vector);
- ClassDB::bind_method(_MD("get_up_vector"),&Navigation::get_up_vector);
+ ClassDB::bind_method(D_METHOD("set_up_vector","up"),&Navigation::set_up_vector);
+ ClassDB::bind_method(D_METHOD("get_up_vector"),&Navigation::get_up_vector);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"up_vector"),_SCS("set_up_vector"),_SCS("get_up_vector"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"up_vector"),"set_up_vector","get_up_vector");
}
Navigation::Navigation() {
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 434b400e01..8efb9bb333 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -208,19 +208,19 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
void NavigationMesh::_bind_methods() {
- ClassDB::bind_method(_MD("set_vertices","vertices"),&NavigationMesh::set_vertices);
- ClassDB::bind_method(_MD("get_vertices"),&NavigationMesh::get_vertices);
+ ClassDB::bind_method(D_METHOD("set_vertices","vertices"),&NavigationMesh::set_vertices);
+ ClassDB::bind_method(D_METHOD("get_vertices"),&NavigationMesh::get_vertices);
- ClassDB::bind_method(_MD("add_polygon","polygon"),&NavigationMesh::add_polygon);
- ClassDB::bind_method(_MD("get_polygon_count"),&NavigationMesh::get_polygon_count);
- ClassDB::bind_method(_MD("get_polygon","idx"),&NavigationMesh::get_polygon);
- ClassDB::bind_method(_MD("clear_polygons"),&NavigationMesh::clear_polygons);
+ ClassDB::bind_method(D_METHOD("add_polygon","polygon"),&NavigationMesh::add_polygon);
+ ClassDB::bind_method(D_METHOD("get_polygon_count"),&NavigationMesh::get_polygon_count);
+ ClassDB::bind_method(D_METHOD("get_polygon","idx"),&NavigationMesh::get_polygon);
+ ClassDB::bind_method(D_METHOD("clear_polygons"),&NavigationMesh::clear_polygons);
- ClassDB::bind_method(_MD("_set_polygons","polygons"),&NavigationMesh::_set_polygons);
- ClassDB::bind_method(_MD("_get_polygons"),&NavigationMesh::_get_polygons);
+ ClassDB::bind_method(D_METHOD("_set_polygons","polygons"),&NavigationMesh::_set_polygons);
+ ClassDB::bind_method(D_METHOD("_get_polygons"),&NavigationMesh::_get_polygons);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_vertices","get_vertices");
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_polygons","_get_polygons");
}
NavigationMesh::NavigationMesh() {
@@ -373,7 +373,7 @@ Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const{
String NavigationMeshInstance::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree())
return String();
if (!navmesh.is_valid()) {
@@ -394,14 +394,14 @@ String NavigationMeshInstance::get_configuration_warning() const {
void NavigationMeshInstance::_bind_methods() {
- ClassDB::bind_method(_MD("set_navigation_mesh","navmesh"),&NavigationMeshInstance::set_navigation_mesh);
- ClassDB::bind_method(_MD("get_navigation_mesh"),&NavigationMeshInstance::get_navigation_mesh);
+ 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(_MD("set_enabled","enabled"),&NavigationMeshInstance::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&NavigationMeshInstance::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&NavigationMeshInstance::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&NavigationMeshInstance::is_enabled);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navmesh",PROPERTY_HINT_RESOURCE_TYPE,"NavigationMesh"),_SCS("set_navigation_mesh"),_SCS("get_navigation_mesh"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navmesh",PROPERTY_HINT_RESOURCE_TYPE,"NavigationMesh"),"set_navigation_mesh","get_navigation_mesh");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
}
NavigationMeshInstance::NavigationMeshInstance() {
@@ -410,5 +410,6 @@ NavigationMeshInstance::NavigationMeshInstance() {
navigation=NULL;
nav_id=-1;
enabled=true;
+ set_notify_transform(true);
}
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 9e37658cd9..0e0c1e9dc6 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -325,7 +325,7 @@ RES Particles::_get_gizmo_geometry() const {
mat->set_parameter( FixedSpatialMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
mat->set_blend_mode( Material::BLEND_MODE_ADD );
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ //mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
@@ -334,7 +334,7 @@ RES Particles::_get_gizmo_geometry() const {
int sides=16;
int sections=24;
-// float len=1;
+ //float len=1;
float deg=Math::deg2rad(var[VAR_SPREAD]*180);
if (deg==180)
deg=179.5;
@@ -406,79 +406,79 @@ RES Particles::_get_gizmo_geometry() const {
void Particles::_bind_methods() {
- ClassDB::bind_method(_MD("set_amount","amount"),&Particles::set_amount);
- ClassDB::bind_method(_MD("get_amount"),&Particles::get_amount);
- ClassDB::bind_method(_MD("set_emitting","enabled"),&Particles::set_emitting);
- ClassDB::bind_method(_MD("is_emitting"),&Particles::is_emitting);
- ClassDB::bind_method(_MD("set_visibility_aabb","aabb"),&Particles::set_visibility_aabb);
- ClassDB::bind_method(_MD("get_visibility_aabb"),&Particles::get_visibility_aabb);
- ClassDB::bind_method(_MD("set_emission_half_extents","half_extents"),&Particles::set_emission_half_extents);
- ClassDB::bind_method(_MD("get_emission_half_extents"),&Particles::get_emission_half_extents);
- ClassDB::bind_method(_MD("set_emission_base_velocity","base_velocity"),&Particles::set_emission_base_velocity);
- ClassDB::bind_method(_MD("get_emission_base_velocity"),&Particles::get_emission_base_velocity);
- ClassDB::bind_method(_MD("set_emission_points","points"),&Particles::set_emission_points);
- ClassDB::bind_method(_MD("get_emission_points"),&Particles::get_emission_points);
- ClassDB::bind_method(_MD("set_gravity_normal","normal"),&Particles::set_gravity_normal);
- ClassDB::bind_method(_MD("get_gravity_normal"),&Particles::get_gravity_normal);
- ClassDB::bind_method(_MD("set_variable","variable","value"),&Particles::set_variable);
- ClassDB::bind_method(_MD("get_variable","variable"),&Particles::get_variable);
- ClassDB::bind_method(_MD("set_randomness","variable","randomness"),&Particles::set_randomness);
- ClassDB::bind_method(_MD("get_randomness","variable"),&Particles::get_randomness);
- ClassDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles::set_color_phase_pos);
- ClassDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles::get_color_phase_pos);
- ClassDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles::set_color_phase_color);
- ClassDB::bind_method(_MD("get_color_phase_color","phase"),&Particles::get_color_phase_color);
- ClassDB::bind_method(_MD("set_material","material:Material"),&Particles::set_material);
- ClassDB::bind_method(_MD("get_material:Material"),&Particles::get_material);
- ClassDB::bind_method(_MD("set_emit_timeout","timeout"),&Particles::set_emit_timeout);
- ClassDB::bind_method(_MD("get_emit_timeout"),&Particles::get_emit_timeout);
- ClassDB::bind_method(_MD("set_height_from_velocity","enable"),&Particles::set_height_from_velocity);
- ClassDB::bind_method(_MD("has_height_from_velocity"),&Particles::has_height_from_velocity);
- ClassDB::bind_method(_MD("set_use_local_coordinates","enable"),&Particles::set_use_local_coordinates);
- ClassDB::bind_method(_MD("is_using_local_coordinates"),&Particles::is_using_local_coordinates);
-
- ClassDB::bind_method(_MD("set_color_phases","count"),&Particles::set_color_phases);
- ClassDB::bind_method(_MD("get_color_phases"),&Particles::get_color_phases);
-
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material" ), _SCS("set_material"), _SCS("get_material") );
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,1024,1" ), _SCS("set_amount"), _SCS("get_amount") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "emitting" ), _SCS("set_emitting"), _SCS("is_emitting") );
- ADD_PROPERTY( PropertyInfo( Variant::_AABB, "visibility" ), _SCS("set_visibility_aabb"), _SCS("get_visibility_aabb") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_extents" ), _SCS("set_emission_half_extents"), _SCS("get_emission_half_extents") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_base_velocity" ), _SCS("set_emission_base_velocity"), _SCS("get_emission_base_velocity") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "emission_points" ), _SCS("set_emission_points"), _SCS("get_emission_points") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "gravity_normal" ), _SCS("set_gravity_normal"), _SCS("get_gravity_normal") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "local_coords" ), _SCS("set_use_local_coordinates"), _SCS("is_using_local_coordinates") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "emit_timeout",PROPERTY_HINT_RANGE,"0,256,0.01"), _SCS("set_emit_timeout"), _SCS("get_emit_timeout") );
-
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/lifetime", PROPERTY_HINT_RANGE,"0.1,60,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LIFETIME );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/spread", PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_SPREAD );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/gravity", PROPERTY_HINT_RANGE,"-48,48,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_GRAVITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_VELOCITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/angular_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_ANGULAR_VELOCITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_ACCELERATION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/radial_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DRAG );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/tan_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_TANGENTIAL_ACCELERATION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/damping", PROPERTY_HINT_RANGE,"0,128,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DAMPING );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_size", PROPERTY_HINT_RANGE,"0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_SIZE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/final_size", PROPERTY_HINT_RANGE,"0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_FINAL_SIZE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_angle",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_ANGLE );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "vars/height_from_velocity"), _SCS("set_height_from_velocity"), _SCS("has_height_from_velocity") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height_speed_scale",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT_SPEED_SCALE );
+ ClassDB::bind_method(D_METHOD("set_amount","amount"),&Particles::set_amount);
+ ClassDB::bind_method(D_METHOD("get_amount"),&Particles::get_amount);
+ ClassDB::bind_method(D_METHOD("set_emitting","enabled"),&Particles::set_emitting);
+ ClassDB::bind_method(D_METHOD("is_emitting"),&Particles::is_emitting);
+ ClassDB::bind_method(D_METHOD("set_visibility_aabb","aabb"),&Particles::set_visibility_aabb);
+ ClassDB::bind_method(D_METHOD("get_visibility_aabb"),&Particles::get_visibility_aabb);
+ ClassDB::bind_method(D_METHOD("set_emission_half_extents","half_extents"),&Particles::set_emission_half_extents);
+ ClassDB::bind_method(D_METHOD("get_emission_half_extents"),&Particles::get_emission_half_extents);
+ ClassDB::bind_method(D_METHOD("set_emission_base_velocity","base_velocity"),&Particles::set_emission_base_velocity);
+ ClassDB::bind_method(D_METHOD("get_emission_base_velocity"),&Particles::get_emission_base_velocity);
+ ClassDB::bind_method(D_METHOD("set_emission_points","points"),&Particles::set_emission_points);
+ ClassDB::bind_method(D_METHOD("get_emission_points"),&Particles::get_emission_points);
+ ClassDB::bind_method(D_METHOD("set_gravity_normal","normal"),&Particles::set_gravity_normal);
+ ClassDB::bind_method(D_METHOD("get_gravity_normal"),&Particles::get_gravity_normal);
+ ClassDB::bind_method(D_METHOD("set_variable","variable","value"),&Particles::set_variable);
+ ClassDB::bind_method(D_METHOD("get_variable","variable"),&Particles::get_variable);
+ ClassDB::bind_method(D_METHOD("set_randomness","variable","randomness"),&Particles::set_randomness);
+ ClassDB::bind_method(D_METHOD("get_randomness","variable"),&Particles::get_randomness);
+ ClassDB::bind_method(D_METHOD("set_color_phase_pos","phase","pos"),&Particles::set_color_phase_pos);
+ ClassDB::bind_method(D_METHOD("get_color_phase_pos","phase"),&Particles::get_color_phase_pos);
+ ClassDB::bind_method(D_METHOD("set_color_phase_color","phase","color"),&Particles::set_color_phase_color);
+ ClassDB::bind_method(D_METHOD("get_color_phase_color","phase"),&Particles::get_color_phase_color);
+ ClassDB::bind_method(D_METHOD("set_material","material:Material"),&Particles::set_material);
+ ClassDB::bind_method(D_METHOD("get_material:Material"),&Particles::get_material);
+ ClassDB::bind_method(D_METHOD("set_emit_timeout","timeout"),&Particles::set_emit_timeout);
+ ClassDB::bind_method(D_METHOD("get_emit_timeout"),&Particles::get_emit_timeout);
+ ClassDB::bind_method(D_METHOD("set_height_from_velocity","enable"),&Particles::set_height_from_velocity);
+ ClassDB::bind_method(D_METHOD("has_height_from_velocity"),&Particles::has_height_from_velocity);
+ ClassDB::bind_method(D_METHOD("set_use_local_coordinates","enable"),&Particles::set_use_local_coordinates);
+ ClassDB::bind_method(D_METHOD("is_using_local_coordinates"),&Particles::is_using_local_coordinates);
+
+ ClassDB::bind_method(D_METHOD("set_color_phases","count"),&Particles::set_color_phases);
+ ClassDB::bind_method(D_METHOD("get_color_phases"),&Particles::get_color_phases);
+
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material" ), "set_material", "get_material") ;
+
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,1024,1" ), "set_amount", "get_amount") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "emitting" ), "set_emitting", "is_emitting") ;
+ ADD_PROPERTY( PropertyInfo( Variant::_AABB, "visibility" ), "set_visibility_aabb", "get_visibility_aabb") ;
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_extents" ), "set_emission_half_extents", "get_emission_half_extents") ;
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_base_velocity" ), "set_emission_base_velocity", "get_emission_base_velocity") ;
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "emission_points" ), "set_emission_points", "get_emission_points") ;
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "gravity_normal" ), "set_gravity_normal", "get_gravity_normal") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "local_coords" ), "set_use_local_coordinates", "is_using_local_coordinates") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "emit_timeout",PROPERTY_HINT_RANGE,"0,256,0.01"), "set_emit_timeout", "get_emit_timeout") ;
+
+
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/lifetime", PROPERTY_HINT_RANGE,"0.1,60,0.01"), "set_variable", "get_variable", VAR_LIFETIME );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/spread", PROPERTY_HINT_RANGE,"0,1,0.01"), "set_variable", "get_variable", VAR_SPREAD );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/gravity", PROPERTY_HINT_RANGE,"-48,48,0.01"), "set_variable", "get_variable", VAR_GRAVITY );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), "set_variable", "get_variable", VAR_LINEAR_VELOCITY );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/angular_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), "set_variable", "get_variable", VAR_ANGULAR_VELOCITY );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), "set_variable", "get_variable", VAR_LINEAR_ACCELERATION );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/radial_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), "set_variable", "get_variable", VAR_DRAG );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/tan_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), "set_variable", "get_variable", VAR_TANGENTIAL_ACCELERATION );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/damping", PROPERTY_HINT_RANGE,"0,128,0.01"), "set_variable", "get_variable", VAR_DAMPING );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_size", PROPERTY_HINT_RANGE,"0,100,0.01"), "set_variable", "get_variable", VAR_INITIAL_SIZE );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/final_size", PROPERTY_HINT_RANGE,"0,100,0.01"), "set_variable", "get_variable", VAR_FINAL_SIZE );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_angle",PROPERTY_HINT_RANGE,"0,1,0.01"), "set_variable", "get_variable", VAR_INITIAL_ANGLE );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "vars/height_from_velocity"), "set_height_from_velocity", "has_height_from_velocity") ;
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height",PROPERTY_HINT_RANGE,"0,4096,0.01"), "set_variable", "get_variable", VAR_HEIGHT);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height_speed_scale",PROPERTY_HINT_RANGE,"0,4096,0.01"), "set_variable", "get_variable", VAR_HEIGHT_SPEED_SCALE );
for(int i=0;i<VAR_MAX;i++)
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, _rand_names[i], PROPERTY_HINT_RANGE,"-16.0,16.0,0.01"),_SCS("set_randomness"), _SCS("get_randomness"),_var_indices[i] );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, _rand_names[i], PROPERTY_HINT_RANGE,"-16.0,16.0,0.01"),"set_randomness", "get_randomness",_var_indices[i] );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1"), _SCS("set_color_phases"), _SCS("get_color_phases"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1"), "set_color_phases", "get_color_phases");
for(int i=0;i<VS::MAX_PARTICLE_COLOR_PHASES;i++) {
String phase="phase_"+itos(i)+"/";
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_color_phase_pos"),_SCS("get_color_phase_pos"),i );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color"),_SCS("set_color_phase_color"),_SCS("get_color_phase_color"),i );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01"),"set_color_phase_pos","get_color_phase_pos",i );
+ ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color"),"set_color_phase_color","get_color_phase_color",i );
}
BIND_CONSTANT( VAR_LIFETIME );
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index 5e8ded3867..ead150e40b 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -80,11 +80,11 @@ Ref<Curve3D> Path::get_curve() const{
void Path::_bind_methods() {
- ClassDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve);
- ClassDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve);
- ClassDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed);
+ ClassDB::bind_method(D_METHOD("set_curve","curve:Curve3D"),&Path::set_curve);
+ ClassDB::bind_method(D_METHOD("get_curve:Curve3D","curve"),&Path::get_curve);
+ ClassDB::bind_method(D_METHOD("_curve_changed"),&Path::_curve_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"),_SCS("get_curve"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), "set_curve","get_curve");
}
Path::Path() {
@@ -257,26 +257,26 @@ void PathFollow::_get_property_list( List<PropertyInfo> *p_list) const{
void PathFollow::_bind_methods() {
- ClassDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&PathFollow::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&PathFollow::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&PathFollow::get_offset);
- ClassDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset);
- ClassDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset);
+ ClassDB::bind_method(D_METHOD("set_h_offset","h_offset"),&PathFollow::set_h_offset);
+ ClassDB::bind_method(D_METHOD("get_h_offset"),&PathFollow::get_h_offset);
- ClassDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset);
- ClassDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset);
+ ClassDB::bind_method(D_METHOD("set_v_offset","v_offset"),&PathFollow::set_v_offset);
+ ClassDB::bind_method(D_METHOD("get_v_offset"),&PathFollow::get_v_offset);
- ClassDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset);
- ClassDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset);
+ ClassDB::bind_method(D_METHOD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset);
+ ClassDB::bind_method(D_METHOD("get_unit_offset"),&PathFollow::get_unit_offset);
- ClassDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode);
- ClassDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode);
+ ClassDB::bind_method(D_METHOD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode);
+ ClassDB::bind_method(D_METHOD("get_rotation_mode"),&PathFollow::get_rotation_mode);
- ClassDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation);
- ClassDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation);
+ ClassDB::bind_method(D_METHOD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation);
- ClassDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&PathFollow::has_loop);
+ ClassDB::bind_method(D_METHOD("set_loop","loop"),&PathFollow::set_loop);
+ ClassDB::bind_method(D_METHOD("has_loop"),&PathFollow::has_loop);
BIND_CONSTANT( ROTATION_NONE );
BIND_CONSTANT( ROTATION_Y );
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index f923ba1aaf..af514a171f 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -58,13 +58,13 @@ float PhysicsBody::get_inverse_mass() const {
}
-void PhysicsBody::set_layer_mask(uint32_t p_mask) {
+void PhysicsBody::set_collision_layer(uint32_t p_mask) {
layer_mask=p_mask;
PhysicsServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
}
-uint32_t PhysicsBody::get_layer_mask() const {
+uint32_t PhysicsBody::get_collision_layer() const {
return layer_mask;
}
@@ -97,20 +97,20 @@ bool PhysicsBody::get_collision_mask_bit(int p_bit) const{
}
-void PhysicsBody::set_layer_mask_bit(int p_bit, bool p_value) {
+void PhysicsBody::set_collision_layer_bit(int p_bit, bool p_value) {
- uint32_t mask = get_layer_mask();
+ uint32_t mask = get_collision_layer();
if (p_value)
mask|=1<<p_bit;
else
mask&=~(1<<p_bit);
- set_layer_mask(mask);
+ set_collision_layer(mask);
}
-bool PhysicsBody::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody::get_collision_layer_bit(int p_bit) const{
- return get_layer_mask()&(1<<p_bit);
+ return get_collision_layer()&(1<<p_bit);
}
void PhysicsBody::add_collision_exception_with(Node* p_node) {
@@ -137,33 +137,34 @@ void PhysicsBody::remove_collision_exception_with(Node* p_node) {
}
void PhysicsBody::_set_layers(uint32_t p_mask) {
- set_layer_mask(p_mask);
+ set_collision_layer(p_mask);
set_collision_mask(p_mask);
}
uint32_t PhysicsBody::_get_layers() const{
- return get_layer_mask();
+ return get_collision_layer();
}
void PhysicsBody::_bind_methods() {
- ClassDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_layer","layer"),&PhysicsBody::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("get_collision_layer"),&PhysicsBody::get_collision_layer);
- ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask);
- ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask);
+ ClassDB::bind_method(D_METHOD("get_collision_mask"),&PhysicsBody::get_collision_mask);
- ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit);
- ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit);
- ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody::set_layer_mask_bit);
- ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody::get_layer_mask_bit);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit","bit","value"),&PhysicsBody::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit","bit"),&PhysicsBody::get_collision_layer_bit);
- ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody::_set_layers);
- ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody::_get_layers);
+ ClassDB::bind_method(D_METHOD("_set_layers","mask"),&PhysicsBody::_set_layers);
+ ClassDB::bind_method(D_METHOD("_get_layers"),&PhysicsBody::_get_layers);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ 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");
}
@@ -229,25 +230,25 @@ Vector3 StaticBody::get_constant_angular_velocity() const {
void StaticBody::_bind_methods() {
- ClassDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody::set_constant_linear_velocity);
- ClassDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody::set_constant_angular_velocity);
- ClassDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody::get_constant_linear_velocity);
- ClassDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody::get_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_linear_velocity","vel"),&StaticBody::set_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_constant_angular_velocity","vel"),&StaticBody::set_constant_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_linear_velocity"),&StaticBody::get_constant_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_constant_angular_velocity"),&StaticBody::get_constant_angular_velocity);
- ClassDB::bind_method(_MD("set_friction","friction"),&StaticBody::set_friction);
- ClassDB::bind_method(_MD("get_friction"),&StaticBody::get_friction);
+ ClassDB::bind_method(D_METHOD("set_friction","friction"),&StaticBody::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"),&StaticBody::get_friction);
- ClassDB::bind_method(_MD("set_bounce","bounce"),&StaticBody::set_bounce);
- ClassDB::bind_method(_MD("get_bounce"),&StaticBody::get_bounce);
+ ClassDB::bind_method(D_METHOD("set_bounce","bounce"),&StaticBody::set_bounce);
+ ClassDB::bind_method(D_METHOD("get_bounce"),&StaticBody::get_bounce);
- ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
- ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
+ ClassDB::bind_method(D_METHOD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_friction","get_friction");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_bounce","get_bounce");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_linear_velocity"),"set_constant_linear_velocity","get_constant_linear_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_angular_velocity"),"set_constant_angular_velocity","get_constant_angular_velocity");
}
StaticBody::StaticBody() : PhysicsBody(PhysicsServer::BODY_MODE_STATIC) {
@@ -436,7 +437,7 @@ void RigidBody::_direct_state_changed(Object *p_state) {
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ //bool found=false;
Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
if (!E) {
@@ -799,88 +800,88 @@ Array RigidBody::get_colliding_bodies() const {
void RigidBody::_bind_methods() {
- ClassDB::bind_method(_MD("set_mode","mode"),&RigidBody::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&RigidBody::get_mode);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&RigidBody::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&RigidBody::get_mode);
- ClassDB::bind_method(_MD("set_mass","mass"),&RigidBody::set_mass);
- ClassDB::bind_method(_MD("get_mass"),&RigidBody::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass","mass"),&RigidBody::set_mass);
+ ClassDB::bind_method(D_METHOD("get_mass"),&RigidBody::get_mass);
- ClassDB::bind_method(_MD("set_weight","weight"),&RigidBody::set_weight);
- ClassDB::bind_method(_MD("get_weight"),&RigidBody::get_weight);
+ ClassDB::bind_method(D_METHOD("set_weight","weight"),&RigidBody::set_weight);
+ ClassDB::bind_method(D_METHOD("get_weight"),&RigidBody::get_weight);
- ClassDB::bind_method(_MD("set_friction","friction"),&RigidBody::set_friction);
- ClassDB::bind_method(_MD("get_friction"),&RigidBody::get_friction);
+ ClassDB::bind_method(D_METHOD("set_friction","friction"),&RigidBody::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"),&RigidBody::get_friction);
- ClassDB::bind_method(_MD("set_bounce","bounce"),&RigidBody::set_bounce);
- ClassDB::bind_method(_MD("get_bounce"),&RigidBody::get_bounce);
+ ClassDB::bind_method(D_METHOD("set_bounce","bounce"),&RigidBody::set_bounce);
+ ClassDB::bind_method(D_METHOD("get_bounce"),&RigidBody::get_bounce);
- ClassDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody::set_linear_velocity);
- ClassDB::bind_method(_MD("get_linear_velocity"),&RigidBody::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity","linear_velocity"),&RigidBody::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"),&RigidBody::get_linear_velocity);
- ClassDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody::set_angular_velocity);
- ClassDB::bind_method(_MD("get_angular_velocity"),&RigidBody::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity","angular_velocity"),&RigidBody::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"),&RigidBody::get_angular_velocity);
- ClassDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody::set_gravity_scale);
- ClassDB::bind_method(_MD("get_gravity_scale"),&RigidBody::get_gravity_scale);
+ ClassDB::bind_method(D_METHOD("set_gravity_scale","gravity_scale"),&RigidBody::set_gravity_scale);
+ ClassDB::bind_method(D_METHOD("get_gravity_scale"),&RigidBody::get_gravity_scale);
- ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody::set_linear_damp);
- ClassDB::bind_method(_MD("get_linear_damp"),&RigidBody::get_linear_damp);
+ ClassDB::bind_method(D_METHOD("set_linear_damp","linear_damp"),&RigidBody::set_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_linear_damp"),&RigidBody::get_linear_damp);
- ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody::set_angular_damp);
- ClassDB::bind_method(_MD("get_angular_damp"),&RigidBody::get_angular_damp);
+ ClassDB::bind_method(D_METHOD("set_angular_damp","angular_damp"),&RigidBody::set_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_angular_damp"),&RigidBody::get_angular_damp);
- ClassDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody::set_max_contacts_reported);
- ClassDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody::get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("set_max_contacts_reported","amount"),&RigidBody::set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("get_max_contacts_reported"),&RigidBody::get_max_contacts_reported);
- ClassDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody::set_use_custom_integrator);
- ClassDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody::is_using_custom_integrator);
+ ClassDB::bind_method(D_METHOD("set_use_custom_integrator","enable"),&RigidBody::set_use_custom_integrator);
+ ClassDB::bind_method(D_METHOD("is_using_custom_integrator"),&RigidBody::is_using_custom_integrator);
- ClassDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody::set_contact_monitor);
- ClassDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody::is_contact_monitor_enabled);
+ ClassDB::bind_method(D_METHOD("set_contact_monitor","enabled"),&RigidBody::set_contact_monitor);
+ ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"),&RigidBody::is_contact_monitor_enabled);
- ClassDB::bind_method(_MD("set_use_continuous_collision_detection","enable"),&RigidBody::set_use_continuous_collision_detection);
- ClassDB::bind_method(_MD("is_using_continuous_collision_detection"),&RigidBody::is_using_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("set_use_continuous_collision_detection","enable"),&RigidBody::set_use_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"),&RigidBody::is_using_continuous_collision_detection);
- ClassDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody::set_axis_velocity);
- ClassDB::bind_method(_MD("apply_impulse","pos","impulse"),&RigidBody::apply_impulse);
+ ClassDB::bind_method(D_METHOD("set_axis_velocity","axis_velocity"),&RigidBody::set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("apply_impulse","pos","impulse"),&RigidBody::apply_impulse);
- ClassDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody::set_sleeping);
- ClassDB::bind_method(_MD("is_sleeping"),&RigidBody::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleeping","sleeping"),&RigidBody::set_sleeping);
+ ClassDB::bind_method(D_METHOD("is_sleeping"),&RigidBody::is_sleeping);
- ClassDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody::set_can_sleep);
- ClassDB::bind_method(_MD("is_able_to_sleep"),&RigidBody::is_able_to_sleep);
+ ClassDB::bind_method(D_METHOD("set_can_sleep","able_to_sleep"),&RigidBody::set_can_sleep);
+ ClassDB::bind_method(D_METHOD("is_able_to_sleep"),&RigidBody::is_able_to_sleep);
- ClassDB::bind_method(_MD("_direct_state_changed"),&RigidBody::_direct_state_changed);
- ClassDB::bind_method(_MD("_body_enter_tree"),&RigidBody::_body_enter_tree);
- ClassDB::bind_method(_MD("_body_exit_tree"),&RigidBody::_body_exit_tree);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"),&RigidBody::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_body_enter_tree"),&RigidBody::_body_enter_tree);
+ ClassDB::bind_method(D_METHOD("_body_exit_tree"),&RigidBody::_body_exit_tree);
- ClassDB::bind_method(_MD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock);
- ClassDB::bind_method(_MD("get_axis_lock"),&RigidBody::get_axis_lock);
+ ClassDB::bind_method(D_METHOD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock);
+ ClassDB::bind_method(D_METHOD("get_axis_lock"),&RigidBody::get_axis_lock);
- ClassDB::bind_method(_MD("get_colliding_bodies"),&RigidBody::get_colliding_bodies);
+ ClassDB::bind_method(D_METHOD("get_colliding_bodies"),&RigidBody::get_colliding_bodies);
BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:PhysicsDirectBodyState")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),_SCS("set_weight"),_SCS("get_weight"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),_SCS("set_gravity_scale"),_SCS("get_gravity_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),_SCS("set_use_custom_integrator"),_SCS("is_using_custom_integrator"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"continuous_cd"),_SCS("set_use_continuous_collision_detection"),_SCS("is_using_continuous_collision_detection"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"axis_lock",PROPERTY_HINT_ENUM,"Disabled,Lock X,Lock Y,Lock Z"),_SCS("set_axis_lock"),_SCS("get_axis_lock"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),"set_mode","get_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),"set_mass","get_mass");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),"set_weight","get_weight");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_friction","get_friction");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_bounce","get_bounce");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),"set_gravity_scale","get_gravity_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),"set_use_custom_integrator","is_using_custom_integrator");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"continuous_cd"),"set_use_continuous_collision_detection","is_using_continuous_collision_detection");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),"set_max_contacts_reported","get_max_contacts_reported");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),"set_contact_monitor","is_contact_monitor_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),"set_sleeping","is_sleeping");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),"set_can_sleep","is_able_to_sleep");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"axis_lock",PROPERTY_HINT_ENUM,"Disabled,Lock X,Lock Y,Lock Z"),"set_axis_lock","get_axis_lock");
ADD_GROUP("Linear","linear_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"linear_velocity"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"linear_velocity"),"set_linear_velocity","get_linear_velocity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),"set_linear_damp","get_linear_damp");
ADD_GROUP("Angular","angular_");
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"angular_velocity"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"angular_velocity"),"set_angular_velocity","get_angular_velocity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),"set_angular_damp","get_angular_damp");
ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
@@ -999,7 +1000,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
if (collide_character)
mask|=PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+ //print_line("motion: "+p_motion+" margin: "+rtos(margin));
//print_line("margin: "+rtos(margin));
@@ -1014,7 +1015,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
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_layer_mask(),mask)) {
+ 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;
}
@@ -1037,10 +1038,10 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
#if 0
float d = a.distance_to(b);
- //if (d<margin)
- /// continue;
- ///
- ///
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.2;
#else
float dist = a.distance_to(b);
@@ -1096,7 +1097,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
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_layer_mask(),mask,&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;
@@ -1137,13 +1138,13 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
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_layer_mask(),mask);
+ 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);
+ //print_line("Rest Travel: "+rest.normal);
}
@@ -1158,8 +1159,10 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
}
Vector3 motion=p_motion*safe;
- //if (colliding)
- // motion+=normal*0.001;
+ /*
+ if (colliding)
+ motion+=normal*0.001;
+ */
Transform gt = get_global_transform();
gt.origin+=motion;
set_global_transform(gt);
@@ -1200,7 +1203,7 @@ bool KinematicBody::can_teleport_to(const Vector3& p_position) {
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_layer_mask(),mask);
+ 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;
}
@@ -1295,40 +1298,40 @@ float KinematicBody::get_collision_margin() const{
void KinematicBody::_bind_methods() {
- ClassDB::bind_method(_MD("move","rel_vec"),&KinematicBody::move);
- ClassDB::bind_method(_MD("move_to","position"),&KinematicBody::move_to);
+ ClassDB::bind_method(D_METHOD("move","rel_vec"),&KinematicBody::move);
+ ClassDB::bind_method(D_METHOD("move_to","position"),&KinematicBody::move_to);
- ClassDB::bind_method(_MD("can_teleport_to","position"),&KinematicBody::can_teleport_to);
+ ClassDB::bind_method(D_METHOD("can_teleport_to","position"),&KinematicBody::can_teleport_to);
- ClassDB::bind_method(_MD("is_colliding"),&KinematicBody::is_colliding);
+ ClassDB::bind_method(D_METHOD("is_colliding"),&KinematicBody::is_colliding);
- ClassDB::bind_method(_MD("get_collision_pos"),&KinematicBody::get_collision_pos);
- ClassDB::bind_method(_MD("get_collision_normal"),&KinematicBody::get_collision_normal);
- ClassDB::bind_method(_MD("get_collider_velocity"),&KinematicBody::get_collider_velocity);
- ClassDB::bind_method(_MD("get_collider:Variant"),&KinematicBody::_get_collider);
- ClassDB::bind_method(_MD("get_collider_shape"),&KinematicBody::get_collider_shape);
+ 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(_MD("set_collide_with_static_bodies","enable"),&KinematicBody::set_collide_with_static_bodies);
- ClassDB::bind_method(_MD("can_collide_with_static_bodies"),&KinematicBody::can_collide_with_static_bodies);
+ 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(_MD("set_collide_with_kinematic_bodies","enable"),&KinematicBody::set_collide_with_kinematic_bodies);
- ClassDB::bind_method(_MD("can_collide_with_kinematic_bodies"),&KinematicBody::can_collide_with_kinematic_bodies);
+ 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(_MD("set_collide_with_rigid_bodies","enable"),&KinematicBody::set_collide_with_rigid_bodies);
- ClassDB::bind_method(_MD("can_collide_with_rigid_bodies"),&KinematicBody::can_collide_with_rigid_bodies);
+ 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(_MD("set_collide_with_character_bodies","enable"),&KinematicBody::set_collide_with_character_bodies);
- ClassDB::bind_method(_MD("can_collide_with_character_bodies"),&KinematicBody::can_collide_with_character_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(_MD("set_collision_margin","pixels"),&KinematicBody::set_collision_margin);
- ClassDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody::get_collision_margin);
+ 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);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/static"),_SCS("set_collide_with_static_bodies"),_SCS("can_collide_with_static_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/kinematic"),_SCS("set_collide_with_kinematic_bodies"),_SCS("can_collide_with_kinematic_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/rigid"),_SCS("set_collide_with_rigid_bodies"),_SCS("can_collide_with_rigid_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/character"),_SCS("set_collide_with_character_bodies"),_SCS("can_collide_with_character_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin"));
+ 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");
}
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 9f317745b3..86be98f81e 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -55,14 +55,14 @@ public:
virtual Vector3 get_angular_velocity() const;
virtual float get_inverse_mass() const;
- void set_layer_mask(uint32_t p_mask);
- uint32_t get_layer_mask() const;
+ void set_collision_layer(uint32_t p_mask);
+ uint32_t get_collision_layer() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
- void set_layer_mask_bit(int p_bit, bool p_value);
- bool get_layer_mask_bit(int p_bit) const;
+ void set_collision_layer_bit(int p_bit, bool p_value);
+ bool get_collision_layer_bit(int p_bit) const;
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index a27e558e45..d48d75f464 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -167,23 +167,23 @@ bool Joint::get_exclude_nodes_from_collision() const{
void Joint::_bind_methods() {
- ClassDB::bind_method( _MD("set_node_a","node"), &Joint::set_node_a );
- ClassDB::bind_method( _MD("get_node_a"), &Joint::get_node_a );
+ ClassDB::bind_method( D_METHOD("set_node_a","node"), &Joint::set_node_a );
+ ClassDB::bind_method( D_METHOD("get_node_a"), &Joint::get_node_a );
- ClassDB::bind_method( _MD("set_node_b","node"), &Joint::set_node_b );
- ClassDB::bind_method( _MD("get_node_b"), &Joint::get_node_b );
+ ClassDB::bind_method( D_METHOD("set_node_b","node"), &Joint::set_node_b );
+ ClassDB::bind_method( D_METHOD("get_node_b"), &Joint::get_node_b );
- ClassDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority );
- ClassDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority );
+ ClassDB::bind_method( D_METHOD("set_solver_priority","priority"), &Joint::set_solver_priority );
+ ClassDB::bind_method( D_METHOD("get_solver_priority"), &Joint::get_solver_priority );
- ClassDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
- ClassDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
+ ClassDB::bind_method( D_METHOD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
+ ClassDB::bind_method( D_METHOD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "solver/priority",PROPERTY_HINT_RANGE,"1,8,1"), _SCS("set_solver_priority"),_SCS("get_solver_priority") );
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), "set_node_a","get_node_a") ;
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), "set_node_b","get_node_b") ;
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "solver/priority",PROPERTY_HINT_RANGE,"1,8,1"), "set_solver_priority","get_solver_priority") ;
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), "set_exclude_nodes_from_collision","get_exclude_nodes_from_collision") ;
@@ -195,6 +195,7 @@ Joint::Joint() {
exclude_from_collision=true;
solver_priority=1;
+ set_notify_transform(true);
}
@@ -202,12 +203,12 @@ Joint::Joint() {
void PinJoint::_bind_methods() {
- ClassDB::bind_method(_MD("set_param","param","value"),&PinJoint::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&PinJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&PinJoint::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&PinJoint::get_param);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/damping",PROPERTY_HINT_RANGE,"0.01,8.0,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_DAMPING );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/impulse_clamp",PROPERTY_HINT_RANGE,"0.0,64.0,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_IMPULSE_CLAMP );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),"set_param","get_param", PARAM_BIAS );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/damping",PROPERTY_HINT_RANGE,"0.01,8.0,0.01"),"set_param","get_param", PARAM_DAMPING );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/impulse_clamp",PROPERTY_HINT_RANGE,"0.0,64.0,0.01"),"set_param","get_param", PARAM_IMPULSE_CLAMP );
BIND_CONSTANT( PARAM_BIAS );
BIND_CONSTANT( PARAM_DAMPING );
@@ -291,30 +292,30 @@ float HingeJoint::_get_lower_limit() const {
void HingeJoint::_bind_methods() {
- ClassDB::bind_method(_MD("set_param","param","value"),&HingeJoint::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&HingeJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&HingeJoint::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&HingeJoint::get_param);
- ClassDB::bind_method(_MD("set_flag","flag","enabled"),&HingeJoint::set_flag);
- ClassDB::bind_method(_MD("get_flag","flag"),&HingeJoint::get_flag);
+ ClassDB::bind_method(D_METHOD("set_flag","flag","enabled"),&HingeJoint::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag","flag"),&HingeJoint::get_flag);
- ClassDB::bind_method(_MD("_set_upper_limit","upper_limit"),&HingeJoint::_set_upper_limit);
- ClassDB::bind_method(_MD("_get_upper_limit"),&HingeJoint::_get_upper_limit);
+ ClassDB::bind_method(D_METHOD("_set_upper_limit","upper_limit"),&HingeJoint::_set_upper_limit);
+ ClassDB::bind_method(D_METHOD("_get_upper_limit"),&HingeJoint::_get_upper_limit);
- ClassDB::bind_method(_MD("_set_lower_limit","lower_limit"),&HingeJoint::_set_lower_limit);
- ClassDB::bind_method(_MD("_get_lower_limit"),&HingeJoint::_get_lower_limit);
+ ClassDB::bind_method(D_METHOD("_set_lower_limit","lower_limit"),&HingeJoint::_set_lower_limit);
+ ClassDB::bind_method(D_METHOD("_get_lower_limit"),&HingeJoint::_get_lower_limit);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),"set_param","get_param", PARAM_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"angular_limit/enable"),_SCS("set_flag"),_SCS("get_flag"), FLAG_USE_LIMIT );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_upper_limit"),_SCS("_get_upper_limit") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_lower_limit"),_SCS("_get_lower_limit") );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_SOFTNESS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/relaxation",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_RELAXATION );
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"angular_limit/enable"),"set_flag","get_flag", FLAG_USE_LIMIT );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper",PROPERTY_HINT_RANGE,"-180,180,0.1"),"_set_upper_limit","_get_upper_limit") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower",PROPERTY_HINT_RANGE,"-180,180,0.1"),"_set_lower_limit","_get_lower_limit") ;
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),"set_param","get_param", PARAM_LIMIT_BIAS );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param","get_param", PARAM_LIMIT_SOFTNESS );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/relaxation",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param","get_param", PARAM_LIMIT_RELAXATION );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"motor/enable"),_SCS("set_flag"),_SCS("get_flag"), FLAG_ENABLE_MOTOR );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/target_velocity",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_MOTOR_TARGET_VELOCITY );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/max_impulse",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_MOTOR_MAX_IMPULSE);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"motor/enable"),"set_flag","get_flag", FLAG_ENABLE_MOTOR );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/target_velocity",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),"set_param","get_param", PARAM_MOTOR_TARGET_VELOCITY );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/max_impulse",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),"set_param","get_param", PARAM_MOTOR_MAX_IMPULSE);
BIND_CONSTANT( PARAM_BIAS );
@@ -446,40 +447,40 @@ float SliderJoint::_get_lower_limit_angular() const {
void SliderJoint::_bind_methods() {
- ClassDB::bind_method(_MD("set_param","param","value"),&SliderJoint::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&SliderJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&SliderJoint::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&SliderJoint::get_param);
- ClassDB::bind_method(_MD("_set_upper_limit_angular","upper_limit_angular"),&SliderJoint::_set_upper_limit_angular);
- ClassDB::bind_method(_MD("_get_upper_limit_angular"),&SliderJoint::_get_upper_limit_angular);
+ ClassDB::bind_method(D_METHOD("_set_upper_limit_angular","upper_limit_angular"),&SliderJoint::_set_upper_limit_angular);
+ ClassDB::bind_method(D_METHOD("_get_upper_limit_angular"),&SliderJoint::_get_upper_limit_angular);
- ClassDB::bind_method(_MD("_set_lower_limit_angular","lower_limit_angular"),&SliderJoint::_set_lower_limit_angular);
- ClassDB::bind_method(_MD("_get_lower_limit_angular"),&SliderJoint::_get_lower_limit_angular);
+ ClassDB::bind_method(D_METHOD("_set_lower_limit_angular","lower_limit_angular"),&SliderJoint::_set_lower_limit_angular);
+ ClassDB::bind_method(D_METHOD("_get_lower_limit_angular"),&SliderJoint::_get_lower_limit_angular);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/upper_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_UPPER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/lower_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_LOWER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_DAMPING);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/upper_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),"set_param","get_param", PARAM_LINEAR_LIMIT_UPPER);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/lower_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),"set_param","get_param", PARAM_LINEAR_LIMIT_LOWER);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_LIMIT_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_LIMIT_DAMPING);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_MOTION_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_MOTION_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_MOTION_DAMPING);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_LINEAR_ORTHOGONAL_DAMPING);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_upper_limit_angular"),_SCS("_get_upper_limit_angular") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_lower_limit_angular"),_SCS("_get_lower_limit_angular") );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_DAMPING);
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),"_set_upper_limit_angular","_get_upper_limit_angular") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),"_set_lower_limit_angular","_get_lower_limit_angular") ;
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_LIMIT_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_LIMIT_DAMPING);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_MOTION_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_MOTION_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_MOTION_DAMPING);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,"set_param","get_param", PARAM_ANGULAR_ORTHOGONAL_DAMPING);
BIND_CONSTANT( PARAM_LINEAR_LIMIT_UPPER);
@@ -611,24 +612,24 @@ float ConeTwistJoint::_get_twist_span() const {
void ConeTwistJoint::_bind_methods() {
- ClassDB::bind_method(_MD("set_param","param","value"),&ConeTwistJoint::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&ConeTwistJoint::get_param);
+ ClassDB::bind_method(D_METHOD("set_param","param","value"),&ConeTwistJoint::set_param);
+ ClassDB::bind_method(D_METHOD("get_param","param"),&ConeTwistJoint::get_param);
- ClassDB::bind_method(_MD("_set_swing_span","swing_span"),&ConeTwistJoint::_set_swing_span);
- ClassDB::bind_method(_MD("_get_swing_span"),&ConeTwistJoint::_get_swing_span);
+ ClassDB::bind_method(D_METHOD("_set_swing_span","swing_span"),&ConeTwistJoint::_set_swing_span);
+ ClassDB::bind_method(D_METHOD("_get_swing_span"),&ConeTwistJoint::_get_swing_span);
- ClassDB::bind_method(_MD("_set_twist_span","twist_span"),&ConeTwistJoint::_set_twist_span);
- ClassDB::bind_method(_MD("_get_twist_span"),&ConeTwistJoint::_get_twist_span);
+ ClassDB::bind_method(D_METHOD("_set_twist_span","twist_span"),&ConeTwistJoint::_set_twist_span);
+ ClassDB::bind_method(D_METHOD("_get_twist_span"),&ConeTwistJoint::_get_twist_span);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"swing_span",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_swing_span"),_SCS("_get_swing_span") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"twist_span",PROPERTY_HINT_RANGE,"-40000,40000,0.1"),_SCS("_set_twist_span"),_SCS("_get_twist_span") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"swing_span",PROPERTY_HINT_RANGE,"-180,180,0.1"),"_set_swing_span","_get_swing_span") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"twist_span",PROPERTY_HINT_RANGE,"-40000,40000,0.1"),"_set_twist_span","_get_twist_span") ;
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bias",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"relaxation",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_RELAXATION);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bias",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_BIAS );
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_SOFTNESS);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"relaxation",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,"set_param","get_param", PARAM_RELAXATION);
BIND_CONSTANT( PARAM_SWING_SPAN );
BIND_CONSTANT( PARAM_TWIST_SPAN );
@@ -770,96 +771,96 @@ float Generic6DOFJoint::_get_angular_lo_limit_z() const{
void Generic6DOFJoint::_bind_methods(){
- ClassDB::bind_method(_MD("_set_angular_hi_limit_x","angle"),&Generic6DOFJoint::_set_angular_hi_limit_x);
- ClassDB::bind_method(_MD("_get_angular_hi_limit_x"),&Generic6DOFJoint::_get_angular_hi_limit_x);
-
- ClassDB::bind_method(_MD("_set_angular_lo_limit_x","angle"),&Generic6DOFJoint::_set_angular_lo_limit_x);
- ClassDB::bind_method(_MD("_get_angular_lo_limit_x"),&Generic6DOFJoint::_get_angular_lo_limit_x);
-
- ClassDB::bind_method(_MD("_set_angular_hi_limit_y","angle"),&Generic6DOFJoint::_set_angular_hi_limit_y);
- ClassDB::bind_method(_MD("_get_angular_hi_limit_y"),&Generic6DOFJoint::_get_angular_hi_limit_y);
-
- ClassDB::bind_method(_MD("_set_angular_lo_limit_y","angle"),&Generic6DOFJoint::_set_angular_lo_limit_y);
- ClassDB::bind_method(_MD("_get_angular_lo_limit_y"),&Generic6DOFJoint::_get_angular_lo_limit_y);
-
- ClassDB::bind_method(_MD("_set_angular_hi_limit_z","angle"),&Generic6DOFJoint::_set_angular_hi_limit_z);
- ClassDB::bind_method(_MD("_get_angular_hi_limit_z"),&Generic6DOFJoint::_get_angular_hi_limit_z);
-
- ClassDB::bind_method(_MD("_set_angular_lo_limit_z","angle"),&Generic6DOFJoint::_set_angular_lo_limit_z);
- ClassDB::bind_method(_MD("_get_angular_lo_limit_z"),&Generic6DOFJoint::_get_angular_lo_limit_z);
-
- ClassDB::bind_method(_MD("set_param_x","param","value"),&Generic6DOFJoint::set_param_x);
- ClassDB::bind_method(_MD("get_param_x","param"),&Generic6DOFJoint::get_param_x);
-
- ClassDB::bind_method(_MD("set_param_y","param","value"),&Generic6DOFJoint::set_param_y);
- ClassDB::bind_method(_MD("get_param_y","param"),&Generic6DOFJoint::get_param_y);
-
- ClassDB::bind_method(_MD("set_param_z","param","value"),&Generic6DOFJoint::set_param_z);
- ClassDB::bind_method(_MD("get_param_z","param"),&Generic6DOFJoint::get_param_z);
-
- ClassDB::bind_method(_MD("set_flag_x","flag","value"),&Generic6DOFJoint::set_flag_x);
- ClassDB::bind_method(_MD("get_flag_x","flag"),&Generic6DOFJoint::get_flag_x);
-
- ClassDB::bind_method(_MD("set_flag_y","flag","value"),&Generic6DOFJoint::set_flag_y);
- ClassDB::bind_method(_MD("get_flag_y","flag"),&Generic6DOFJoint::get_flag_y);
-
- ClassDB::bind_method(_MD("set_flag_z","flag","value"),&Generic6DOFJoint::set_flag_z);
- ClassDB::bind_method(_MD("get_flag_z","flag"),&Generic6DOFJoint::get_flag_z);
-
-
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/upper_distance"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/lower_distance"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_x"),_SCS("_get_angular_hi_limit_x"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_x"),_SCS("_get_angular_lo_limit_x"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/force_limit"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/erp"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/target_velocity"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/force_limit"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
-
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/upper_distance"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/lower_distance"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_y"),_SCS("_get_angular_hi_limit_y"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_y"),_SCS("_get_angular_lo_limit_y"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/force_limit"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/erp"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/target_velocity"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/force_limit"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
-
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/upper_distance"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/lower_distance"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_z"),_SCS("_get_angular_hi_limit_z"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_z"),_SCS("_get_angular_lo_limit_z"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/force_limit"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/erp"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/target_velocity"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/force_limit"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x","angle"),&Generic6DOFJoint::_set_angular_hi_limit_x);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"),&Generic6DOFJoint::_get_angular_hi_limit_x);
+
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_x","angle"),&Generic6DOFJoint::_set_angular_lo_limit_x);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_x"),&Generic6DOFJoint::_get_angular_lo_limit_x);
+
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_y","angle"),&Generic6DOFJoint::_set_angular_hi_limit_y);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_y"),&Generic6DOFJoint::_get_angular_hi_limit_y);
+
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_y","angle"),&Generic6DOFJoint::_set_angular_lo_limit_y);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_y"),&Generic6DOFJoint::_get_angular_lo_limit_y);
+
+ ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_z","angle"),&Generic6DOFJoint::_set_angular_hi_limit_z);
+ ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_z"),&Generic6DOFJoint::_get_angular_hi_limit_z);
+
+ ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_z","angle"),&Generic6DOFJoint::_set_angular_lo_limit_z);
+ ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_z"),&Generic6DOFJoint::_get_angular_lo_limit_z);
+
+ ClassDB::bind_method(D_METHOD("set_param_x","param","value"),&Generic6DOFJoint::set_param_x);
+ ClassDB::bind_method(D_METHOD("get_param_x","param"),&Generic6DOFJoint::get_param_x);
+
+ ClassDB::bind_method(D_METHOD("set_param_y","param","value"),&Generic6DOFJoint::set_param_y);
+ ClassDB::bind_method(D_METHOD("get_param_y","param"),&Generic6DOFJoint::get_param_y);
+
+ ClassDB::bind_method(D_METHOD("set_param_z","param","value"),&Generic6DOFJoint::set_param_z);
+ ClassDB::bind_method(D_METHOD("get_param_z","param"),&Generic6DOFJoint::get_param_z);
+
+ ClassDB::bind_method(D_METHOD("set_flag_x","flag","value"),&Generic6DOFJoint::set_flag_x);
+ ClassDB::bind_method(D_METHOD("get_flag_x","flag"),&Generic6DOFJoint::get_flag_x);
+
+ ClassDB::bind_method(D_METHOD("set_flag_y","flag","value"),&Generic6DOFJoint::set_flag_y);
+ ClassDB::bind_method(D_METHOD("get_flag_y","flag"),&Generic6DOFJoint::get_flag_y);
+
+ ClassDB::bind_method(D_METHOD("set_flag_z","flag","value"),&Generic6DOFJoint::set_flag_z);
+ ClassDB::bind_method(D_METHOD("get_flag_z","flag"),&Generic6DOFJoint::get_flag_z);
+
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_x/enabled"),"set_flag_x","get_flag_x",FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/upper_distance"),"set_param_x","get_param_x",PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/lower_distance"),"set_param_x","get_param_x",PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_x/enabled"),"set_flag_x","get_flag_x",FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_hi_limit_x","_get_angular_hi_limit_x");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_lo_limit_x","_get_angular_lo_limit_x");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_x","get_param_x",PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/force_limit"),"set_param_x","get_param_x",PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/erp"),"set_param_x","get_param_x",PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_x/enabled"),"set_flag_x","get_flag_x",FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/target_velocity"),"set_param_x","get_param_x",PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/force_limit"),"set_param_x","get_param_x",PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_y/enabled"),"set_flag_y","get_flag_y",FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/upper_distance"),"set_param_y","get_param_y",PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/lower_distance"),"set_param_y","get_param_y",PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_y/enabled"),"set_flag_y","get_flag_y",FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_hi_limit_y","_get_angular_hi_limit_y");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_lo_limit_y","_get_angular_lo_limit_y");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_y","get_param_y",PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/force_limit"),"set_param_y","get_param_y",PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/erp"),"set_param_y","get_param_y",PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_y/enabled"),"set_flag_y","get_flag_y",FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/target_velocity"),"set_param_y","get_param_y",PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/force_limit"),"set_param_y","get_param_y",PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_z/enabled"),"set_flag_z","get_flag_z",FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/upper_distance"),"set_param_z","get_param_z",PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/lower_distance"),"set_param_z","get_param_z",PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_z/enabled"),"set_flag_z","get_flag_z",FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_hi_limit_z","_get_angular_hi_limit_z");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),"_set_angular_lo_limit_z","_get_angular_lo_limit_z");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_param_z","get_param_z",PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/force_limit"),"set_param_z","get_param_z",PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/erp"),"set_param_z","get_param_z",PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_z/enabled"),"set_flag_z","get_flag_z",FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/target_velocity"),"set_param_z","get_param_z",PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/force_limit"),"set_param_z","get_param_z",PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
BIND_CONSTANT( PARAM_LINEAR_LOWER_LIMIT);
@@ -1170,22 +1171,22 @@ RID PhysicsJoint::_get_visual_instance_rid() const {
void PhysicsJoint::_bind_methods() {
- ClassDB::bind_method(_MD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid);
- ClassDB::bind_method(_MD("set_body_A","path"),&PhysicsJoint::set_body_A);
- ClassDB::bind_method(_MD("set_body_B"),&PhysicsJoint::set_body_B);
- ClassDB::bind_method(_MD("get_body_A","path"),&PhysicsJoint::get_body_A);
- ClassDB::bind_method(_MD("get_body_B"),&PhysicsJoint::get_body_B);
+ ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid);
+ ClassDB::bind_method(D_METHOD("set_body_A","path"),&PhysicsJoint::set_body_A);
+ ClassDB::bind_method(D_METHOD("set_body_B"),&PhysicsJoint::set_body_B);
+ ClassDB::bind_method(D_METHOD("get_body_A","path"),&PhysicsJoint::get_body_A);
+ ClassDB::bind_method(D_METHOD("get_body_B"),&PhysicsJoint::get_body_B);
- ClassDB::bind_method(_MD("set_active","active"),&PhysicsJoint::set_active);
- ClassDB::bind_method(_MD("is_active"),&PhysicsJoint::is_active);
+ ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsJoint::set_active);
+ ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active);
- ClassDB::bind_method(_MD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision);
- ClassDB::bind_method(_MD("has_disable_collision"),&PhysicsJoint::has_disable_collision);
+ ClassDB::bind_method(D_METHOD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision);
+ ClassDB::bind_method(D_METHOD("has_disable_collision"),&PhysicsJoint::has_disable_collision);
ClassDB::bind_method("reconnect",&PhysicsJoint::reconnect);
- ClassDB::bind_method(_MD("get_rid"),&PhysicsJoint::get_rid);
+ ClassDB::bind_method(D_METHOD("get_rid"),&PhysicsJoint::get_rid);
}
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 054b61a4ed..19f1261238 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -29,7 +29,7 @@
#include "portal.h"
#include "servers/visual_server.h"
#include "scene/resources/surface_tool.h"
-#include "globals.h"
+#include "global_config.h"
bool Portal::_set(const StringName& p_name, const Variant& p_value) {
@@ -197,20 +197,20 @@ Color Portal::get_disabled_color() const {
void Portal::_bind_methods() {
- ClassDB::bind_method(_MD("set_shape","points"),&Portal::set_shape);
- ClassDB::bind_method(_MD("get_shape"),&Portal::get_shape);
+ ClassDB::bind_method(D_METHOD("set_shape","points"),&Portal::set_shape);
+ ClassDB::bind_method(D_METHOD("get_shape"),&Portal::get_shape);
- ClassDB::bind_method(_MD("set_enabled","enable"),&Portal::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&Portal::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enable"),&Portal::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&Portal::is_enabled);
- ClassDB::bind_method(_MD("set_disable_distance","distance"),&Portal::set_disable_distance);
- ClassDB::bind_method(_MD("get_disable_distance"),&Portal::get_disable_distance);
+ ClassDB::bind_method(D_METHOD("set_disable_distance","distance"),&Portal::set_disable_distance);
+ ClassDB::bind_method(D_METHOD("get_disable_distance"),&Portal::get_disable_distance);
- ClassDB::bind_method(_MD("set_disabled_color","color"),&Portal::set_disabled_color);
- ClassDB::bind_method(_MD("get_disabled_color"),&Portal::get_disabled_color);
+ ClassDB::bind_method(D_METHOD("set_disabled_color","color"),&Portal::set_disabled_color);
+ ClassDB::bind_method(D_METHOD("get_disabled_color"),&Portal::get_disabled_color);
- ClassDB::bind_method(_MD("set_connect_range","range"),&Portal::set_connect_range);
- ClassDB::bind_method(_MD("get_connect_range"),&Portal::get_connect_range);
+ ClassDB::bind_method(D_METHOD("set_connect_range","range"),&Portal::set_connect_range);
+ ClassDB::bind_method(D_METHOD("get_connect_range"),&Portal::get_connect_range);
}
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp
index c3cb20bfdd..f0dc8cb2ed 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group.cpp
@@ -135,7 +135,7 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) {
E = groups.front();
while (E) {
- get_tree()->call_group(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
E = E->next();
};
@@ -171,14 +171,14 @@ Vector3 ProximityGroup::get_grid_radius() const {
void ProximityGroup::_bind_methods() {
- ClassDB::bind_method(_MD("set_group_name","name"), &ProximityGroup::set_group_name);
- ClassDB::bind_method(_MD("broadcast","name", "parameters"), &ProximityGroup::broadcast);
- ClassDB::bind_method(_MD("set_dispatch_mode","mode"), &ProximityGroup::set_dispatch_mode);
- ClassDB::bind_method(_MD("_proximity_group_broadcast","name","params"), &ProximityGroup::_proximity_group_broadcast);
- ClassDB::bind_method(_MD("set_grid_radius","radius"), &ProximityGroup::set_grid_radius);
- ClassDB::bind_method(_MD("get_grid_radius"), &ProximityGroup::get_grid_radius);
+ ClassDB::bind_method(D_METHOD("set_group_name","name"), &ProximityGroup::set_group_name);
+ ClassDB::bind_method(D_METHOD("broadcast","name", "parameters"), &ProximityGroup::broadcast);
+ ClassDB::bind_method(D_METHOD("set_dispatch_mode","mode"), &ProximityGroup::set_dispatch_mode);
+ ClassDB::bind_method(D_METHOD("_proximity_group_broadcast","name","params"), &ProximityGroup::_proximity_group_broadcast);
+ ClassDB::bind_method(D_METHOD("set_grid_radius","radius"), &ProximityGroup::set_grid_radius);
+ ClassDB::bind_method(D_METHOD("get_grid_radius"), &ProximityGroup::get_grid_radius);
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "grid_radius"), _SCS("set_grid_radius"), _SCS("get_grid_radius"));
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "grid_radius"), "set_grid_radius", "get_grid_radius");
ADD_SIGNAL( MethodInfo("broadcast", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::ARRAY, "parameters")) );
};
@@ -190,6 +190,7 @@ ProximityGroup::ProximityGroup() {
dispatch_mode = MODE_PROXY;
grid_radius = Vector3(1, 1, 1);
+ set_notify_transform(true);
};
diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp
index d1cef0e851..e740769bd4 100644
--- a/scene/3d/quad.cpp
+++ b/scene/3d/quad.cpp
@@ -199,22 +199,22 @@ Rect3 Quad::get_aabb() const {
void Quad::_bind_methods(){
- ClassDB::bind_method(_MD("set_axis","axis"),&Quad::set_axis);
- ClassDB::bind_method(_MD("get_axis"),&Quad::get_axis);
+ ClassDB::bind_method(D_METHOD("set_axis","axis"),&Quad::set_axis);
+ ClassDB::bind_method(D_METHOD("get_axis"),&Quad::get_axis);
- ClassDB::bind_method(_MD("set_size","size"),&Quad::set_size);
- ClassDB::bind_method(_MD("get_size"),&Quad::get_size);
+ ClassDB::bind_method(D_METHOD("set_size","size"),&Quad::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"),&Quad::get_size);
- ClassDB::bind_method(_MD("set_centered","centered"),&Quad::set_centered);
- ClassDB::bind_method(_MD("is_centered"),&Quad::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered","centered"),&Quad::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"),&Quad::is_centered);
- ClassDB::bind_method(_MD("set_offset","offset"),&Quad::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&Quad::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&Quad::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&Quad::get_offset);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "axis", PROPERTY_HINT_ENUM,"X,Y,Z" ), _SCS("set_axis"), _SCS("get_axis"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "size" ), _SCS("set_size"), _SCS("get_size"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset" ), _SCS("set_offset"), _SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered" ), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "axis", PROPERTY_HINT_ENUM,"X,Y,Z" ), "set_axis", "get_axis");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "size" ), "set_size", "get_size");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset" ), "set_offset", "get_offset");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered" ), "set_centered", "is_centered");
}
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 8216d7295f..6be8b89441 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -210,38 +210,38 @@ void RayCast::clear_exceptions(){
void RayCast::_bind_methods() {
- ClassDB::bind_method(_MD("set_enabled","enabled"),&RayCast::set_enabled);
- ClassDB::bind_method(_MD("is_enabled"),&RayCast::is_enabled);
+ ClassDB::bind_method(D_METHOD("set_enabled","enabled"),&RayCast::set_enabled);
+ ClassDB::bind_method(D_METHOD("is_enabled"),&RayCast::is_enabled);
- ClassDB::bind_method(_MD("set_cast_to","local_point"),&RayCast::set_cast_to);
- ClassDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
+ ClassDB::bind_method(D_METHOD("set_cast_to","local_point"),&RayCast::set_cast_to);
+ ClassDB::bind_method(D_METHOD("get_cast_to"),&RayCast::get_cast_to);
- ClassDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
- ClassDB::bind_method(_MD("force_raycast_update"),&RayCast::force_raycast_update);
+ ClassDB::bind_method(D_METHOD("is_colliding"),&RayCast::is_colliding);
+ ClassDB::bind_method(D_METHOD("force_raycast_update"),&RayCast::force_raycast_update);
- ClassDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
- ClassDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
- ClassDB::bind_method(_MD("get_collision_point"),&RayCast::get_collision_point);
- ClassDB::bind_method(_MD("get_collision_normal"),&RayCast::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider"),&RayCast::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"),&RayCast::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collision_point"),&RayCast::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"),&RayCast::get_collision_normal);
- ClassDB::bind_method(_MD("add_exception_rid","rid"),&RayCast::add_exception_rid);
- ClassDB::bind_method(_MD("add_exception","node"),&RayCast::add_exception);
+ ClassDB::bind_method(D_METHOD("add_exception_rid","rid"),&RayCast::add_exception_rid);
+ ClassDB::bind_method(D_METHOD("add_exception","node"),&RayCast::add_exception);
- ClassDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
- ClassDB::bind_method(_MD("remove_exception","node"),&RayCast::remove_exception);
+ ClassDB::bind_method(D_METHOD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
+ ClassDB::bind_method(D_METHOD("remove_exception","node"),&RayCast::remove_exception);
- ClassDB::bind_method(_MD("clear_exceptions"),&RayCast::clear_exceptions);
+ ClassDB::bind_method(D_METHOD("clear_exceptions"),&RayCast::clear_exceptions);
- ClassDB::bind_method(_MD("set_layer_mask","mask"),&RayCast::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&RayCast::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","mask"),&RayCast::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&RayCast::get_layer_mask);
- ClassDB::bind_method(_MD("set_type_mask","mask"),&RayCast::set_type_mask);
- ClassDB::bind_method(_MD("get_type_mask"),&RayCast::get_type_mask);
+ ClassDB::bind_method(D_METHOD("set_type_mask","mask"),&RayCast::set_type_mask);
+ ClassDB::bind_method(D_METHOD("get_type_mask"),&RayCast::get_type_mask);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),"set_enabled","is_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"cast_to"),"set_cast_to","get_cast_to");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),"set_layer_mask","get_layer_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),"set_type_mask","get_type_mask");
}
RayCast::RayCast() {
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index d9592d9484..bcda7ca0ae 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -185,57 +185,57 @@ void ReflectionProbe::_validate_property(PropertyInfo& property) const {
void ReflectionProbe::_bind_methods() {
- ClassDB::bind_method(_MD("set_intensity","intensity"),&ReflectionProbe::set_intensity);
- ClassDB::bind_method(_MD("get_intensity"),&ReflectionProbe::get_intensity);
+ ClassDB::bind_method(D_METHOD("set_intensity","intensity"),&ReflectionProbe::set_intensity);
+ ClassDB::bind_method(D_METHOD("get_intensity"),&ReflectionProbe::get_intensity);
- ClassDB::bind_method(_MD("set_interior_ambient","ambient"),&ReflectionProbe::set_interior_ambient);
- ClassDB::bind_method(_MD("get_interior_ambient"),&ReflectionProbe::get_interior_ambient);
+ ClassDB::bind_method(D_METHOD("set_interior_ambient","ambient"),&ReflectionProbe::set_interior_ambient);
+ ClassDB::bind_method(D_METHOD("get_interior_ambient"),&ReflectionProbe::get_interior_ambient);
- ClassDB::bind_method(_MD("set_interior_ambient_energy","ambient_energy"),&ReflectionProbe::set_interior_ambient_energy);
- ClassDB::bind_method(_MD("get_interior_ambient_energy"),&ReflectionProbe::get_interior_ambient_energy);
+ ClassDB::bind_method(D_METHOD("set_interior_ambient_energy","ambient_energy"),&ReflectionProbe::set_interior_ambient_energy);
+ ClassDB::bind_method(D_METHOD("get_interior_ambient_energy"),&ReflectionProbe::get_interior_ambient_energy);
- ClassDB::bind_method(_MD("set_interior_ambient_probe_contribution","ambient_probe_contribution"),&ReflectionProbe::set_interior_ambient_probe_contribution);
- ClassDB::bind_method(_MD("get_interior_ambient_probe_contribution"),&ReflectionProbe::get_interior_ambient_probe_contribution);
+ ClassDB::bind_method(D_METHOD("set_interior_ambient_probe_contribution","ambient_probe_contribution"),&ReflectionProbe::set_interior_ambient_probe_contribution);
+ ClassDB::bind_method(D_METHOD("get_interior_ambient_probe_contribution"),&ReflectionProbe::get_interior_ambient_probe_contribution);
- ClassDB::bind_method(_MD("set_max_distance","max_distance"),&ReflectionProbe::set_max_distance);
- ClassDB::bind_method(_MD("get_max_distance"),&ReflectionProbe::get_max_distance);
+ ClassDB::bind_method(D_METHOD("set_max_distance","max_distance"),&ReflectionProbe::set_max_distance);
+ ClassDB::bind_method(D_METHOD("get_max_distance"),&ReflectionProbe::get_max_distance);
- ClassDB::bind_method(_MD("set_extents","extents"),&ReflectionProbe::set_extents);
- ClassDB::bind_method(_MD("get_extents"),&ReflectionProbe::get_extents);
+ ClassDB::bind_method(D_METHOD("set_extents","extents"),&ReflectionProbe::set_extents);
+ ClassDB::bind_method(D_METHOD("get_extents"),&ReflectionProbe::get_extents);
- ClassDB::bind_method(_MD("set_origin_offset","origin_offset"),&ReflectionProbe::set_origin_offset);
- ClassDB::bind_method(_MD("get_origin_offset"),&ReflectionProbe::get_origin_offset);
+ ClassDB::bind_method(D_METHOD("set_origin_offset","origin_offset"),&ReflectionProbe::set_origin_offset);
+ ClassDB::bind_method(D_METHOD("get_origin_offset"),&ReflectionProbe::get_origin_offset);
- ClassDB::bind_method(_MD("set_as_interior","enable"),&ReflectionProbe::set_as_interior);
- ClassDB::bind_method(_MD("is_set_as_interior"),&ReflectionProbe::is_set_as_interior);
+ ClassDB::bind_method(D_METHOD("set_as_interior","enable"),&ReflectionProbe::set_as_interior);
+ ClassDB::bind_method(D_METHOD("is_set_as_interior"),&ReflectionProbe::is_set_as_interior);
- ClassDB::bind_method(_MD("set_enable_box_projection","enable"),&ReflectionProbe::set_enable_box_projection);
- ClassDB::bind_method(_MD("is_box_projection_enabled"),&ReflectionProbe::is_box_projection_enabled);
+ ClassDB::bind_method(D_METHOD("set_enable_box_projection","enable"),&ReflectionProbe::set_enable_box_projection);
+ ClassDB::bind_method(D_METHOD("is_box_projection_enabled"),&ReflectionProbe::is_box_projection_enabled);
- ClassDB::bind_method(_MD("set_enable_shadows","enable"),&ReflectionProbe::set_enable_shadows);
- ClassDB::bind_method(_MD("are_shadows_enabled"),&ReflectionProbe::are_shadows_enabled);
+ ClassDB::bind_method(D_METHOD("set_enable_shadows","enable"),&ReflectionProbe::set_enable_shadows);
+ ClassDB::bind_method(D_METHOD("are_shadows_enabled"),&ReflectionProbe::are_shadows_enabled);
- ClassDB::bind_method(_MD("set_cull_mask","layers"),&ReflectionProbe::set_cull_mask);
- ClassDB::bind_method(_MD("get_cull_mask"),&ReflectionProbe::get_cull_mask);
+ ClassDB::bind_method(D_METHOD("set_cull_mask","layers"),&ReflectionProbe::set_cull_mask);
+ ClassDB::bind_method(D_METHOD("get_cull_mask"),&ReflectionProbe::get_cull_mask);
- ClassDB::bind_method(_MD("set_update_mode","mode"),&ReflectionProbe::set_update_mode);
- ClassDB::bind_method(_MD("get_update_mode"),&ReflectionProbe::get_update_mode);
+ ClassDB::bind_method(D_METHOD("set_update_mode","mode"),&ReflectionProbe::set_update_mode);
+ ClassDB::bind_method(D_METHOD("get_update_mode"),&ReflectionProbe::get_update_mode);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"update_mode",PROPERTY_HINT_ENUM,"Once,Always"),_SCS("set_update_mode"),_SCS("get_update_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"intensity",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_intensity"),_SCS("get_intensity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"max_distance",PROPERTY_HINT_RANGE,"0,16384,0.1"),_SCS("set_max_distance"),_SCS("get_max_distance"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),_SCS("set_extents"),_SCS("get_extents"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"origin_offset"),_SCS("set_origin_offset"),_SCS("get_origin_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"box_projection"),_SCS("set_enable_box_projection"),_SCS("is_box_projection_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enable_shadows"),_SCS("set_enable_shadows"),_SCS("are_shadows_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER),_SCS("set_cull_mask"),_SCS("get_cull_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"update_mode",PROPERTY_HINT_ENUM,"Once,Always"),"set_update_mode","get_update_mode");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"intensity",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_intensity","get_intensity");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"max_distance",PROPERTY_HINT_RANGE,"0,16384,0.1"),"set_max_distance","get_max_distance");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),"set_extents","get_extents");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"origin_offset"),"set_origin_offset","get_origin_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"box_projection"),"set_enable_box_projection","is_box_projection_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enable_shadows"),"set_enable_shadows","are_shadows_enabled");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mask",PROPERTY_HINT_LAYERS_3D_RENDER),"set_cull_mask","get_cull_mask");
ADD_GROUP("Interior","interior_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior_enable"),_SCS("set_as_interior"),_SCS("is_set_as_interior"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"interior_ambient_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_interior_ambient"),_SCS("get_interior_ambient"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_interior_ambient_energy"),_SCS("get_interior_ambient_energy"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_contrib",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_interior_ambient_probe_contribution"),_SCS("get_interior_ambient_probe_contribution"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"interior_enable"),"set_as_interior","is_set_as_interior");
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"interior_ambient_color",PROPERTY_HINT_COLOR_NO_ALPHA),"set_interior_ambient","get_interior_ambient");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_interior_ambient_energy","get_interior_ambient_energy");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"interior_ambient_contrib",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_interior_ambient_probe_contribution","get_interior_ambient_probe_contribution");
BIND_CONSTANT( UPDATE_ONCE );
diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp
index 931f075a84..21ec65f5e0 100644
--- a/scene/3d/remote_transform.cpp
+++ b/scene/3d/remote_transform.cpp
@@ -118,15 +118,16 @@ String RemoteTransform::get_configuration_warning() const {
void RemoteTransform::_bind_methods() {
- ClassDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform::set_remote_node);
- ClassDB::bind_method(_MD("get_remote_node"),&RemoteTransform::get_remote_node);
+ 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);
- ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
+ ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),"set_remote_node","get_remote_node");
}
RemoteTransform::RemoteTransform() {
cache=0;
+ set_notify_transform(true);
}
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 0b19aaf151..b363c05ef7 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -31,7 +31,7 @@
#include "servers/visual_server.h"
#include "geometry.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/resources/surface_tool.h"
@@ -56,17 +56,11 @@ void Room::_notification(int p_what) {
}
- if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space());
-
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- SpatialSoundServer::get_singleton()->room_set_transform(sound_room,get_global_transform());
} break;
case NOTIFICATION_EXIT_WORLD: {
- if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID());
} break;
@@ -158,69 +152,36 @@ void Room::_parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) co
-void Room::set_simulate_acoustics(bool p_enable) {
-
- if (sound_enabled==p_enable)
- return;
-
- sound_enabled=p_enable;
- if (!is_inside_world())
- return; //nothing to do
-
- if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space());
- else
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID());
-
-
-}
-
void Room::_bounds_changed() {
update_gizmo();
}
-bool Room::is_simulating_acoustics() const {
-
- return sound_enabled;
-}
-
-
-RID Room::get_sound_room() const {
-
- return RID();
-}
void Room::_bind_methods() {
- ClassDB::bind_method(_MD("set_room","room:Room"),&Room::set_room );
- ClassDB::bind_method(_MD("get_room:Room"),&Room::get_room );
+ ClassDB::bind_method(D_METHOD("set_room","room:Room"),&Room::set_room );
+ ClassDB::bind_method(D_METHOD("get_room:Room"),&Room::get_room );
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area" ), "set_room", "get_room") ;
- ClassDB::bind_method(_MD("set_simulate_acoustics","enable"),&Room::set_simulate_acoustics );
- ClassDB::bind_method(_MD("is_simulating_acoustics"),&Room::is_simulating_acoustics );
-
-
-
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area" ), _SCS("set_room"), _SCS("get_room") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "room/simulate_acoustics"), _SCS("set_simulate_acoustics"), _SCS("is_simulating_acoustics") );
}
Room::Room() {
- sound_enabled=false;
- sound_room=SpatialSoundServer::get_singleton()->room_create();
+// sound_enabled=false;
level=0;
+
}
Room::~Room() {
- SpatialSoundServer::get_singleton()->free(sound_room);
+
}
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index 145589a780..cbc1b12b7e 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -31,7 +31,7 @@
#include "scene/3d/visual_instance.h"
#include "scene/resources/room.h"
-#include "servers/spatial_sound_server.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -58,9 +58,6 @@ public:
private:
Ref<RoomBounds> room;
- RID sound_room;
-
- bool sound_enabled;
int level;
void _parse_node_faces(PoolVector<Face3> &all_faces,const Node *p_node) const;
@@ -88,11 +85,6 @@ public:
void set_room( const Ref<RoomBounds>& p_room );
Ref<RoomBounds> get_room() const;
- void set_simulate_acoustics(bool p_enable);
- bool is_simulating_acoustics() const;
-
-
- RID get_sound_room() const;
Room();
~Room();
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index 95ba2c990a..145242ba7c 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -83,7 +83,7 @@ Ref<Environment> WorldEnvironment::get_environment() const {
String WorldEnvironment::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree() || !environment.is_valid())
+ if (!is_visible_in_tree() || !is_inside_tree() || !environment.is_valid())
return String();
List<Node*> nodes;
@@ -99,9 +99,9 @@ String WorldEnvironment::get_configuration_warning() const {
void WorldEnvironment::_bind_methods() {
- ClassDB::bind_method(_MD("set_environment","env:Environment"),&WorldEnvironment::set_environment);
- ClassDB::bind_method(_MD("get_environment:Environment"),&WorldEnvironment::get_environment);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
+ ClassDB::bind_method(D_METHOD("set_environment","env:Environment"),&WorldEnvironment::set_environment);
+ ClassDB::bind_method(D_METHOD("get_environment:Environment"),&WorldEnvironment::get_environment);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),"set_environment","get_environment");
}
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 5e576b4960..04e82ba914 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -31,7 +31,7 @@
#include "message_queue.h"
#include "scene/resources/surface_tool.h"
-#include "core/globals.h"
+#include "core/global_config.h"
bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
@@ -482,7 +482,7 @@ Transform Skeleton::get_bone_pose(int p_bone) const {
void Skeleton::set_bone_custom_pose(int p_bone, const Transform& p_custom_pose) {
ERR_FAIL_INDEX( p_bone, bones.size() );
-// ERR_FAIL_COND( !is_inside_scene() );
+ //ERR_FAIL_COND( !is_inside_scene() );
bones[p_bone].custom_pose_enable=(p_custom_pose!=Transform());
@@ -530,39 +530,39 @@ void Skeleton::_bind_methods() {
- ClassDB::bind_method(_MD("add_bone","name"),&Skeleton::add_bone);
- ClassDB::bind_method(_MD("find_bone","name"),&Skeleton::find_bone);
- ClassDB::bind_method(_MD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
+ ClassDB::bind_method(D_METHOD("add_bone","name"),&Skeleton::add_bone);
+ ClassDB::bind_method(D_METHOD("find_bone","name"),&Skeleton::find_bone);
+ ClassDB::bind_method(D_METHOD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
- ClassDB::bind_method(_MD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
- ClassDB::bind_method(_MD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
+ ClassDB::bind_method(D_METHOD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
+ ClassDB::bind_method(D_METHOD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
- ClassDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
+ ClassDB::bind_method(D_METHOD("get_bone_count"),&Skeleton::get_bone_count);
- ClassDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
+ ClassDB::bind_method(D_METHOD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
- ClassDB::bind_method(_MD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
- ClassDB::bind_method(_MD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
+ ClassDB::bind_method(D_METHOD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
+ ClassDB::bind_method(D_METHOD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
- ClassDB::bind_method(_MD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
- ClassDB::bind_method(_MD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
+ ClassDB::bind_method(D_METHOD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
+ ClassDB::bind_method(D_METHOD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
- ClassDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
- ClassDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
- ClassDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
+ ClassDB::bind_method(D_METHOD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
+ ClassDB::bind_method(D_METHOD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
+ ClassDB::bind_method(D_METHOD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
- ClassDB::bind_method(_MD("clear_bones"),&Skeleton::clear_bones);
+ ClassDB::bind_method(D_METHOD("clear_bones"),&Skeleton::clear_bones);
- ClassDB::bind_method(_MD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
- ClassDB::bind_method(_MD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
+ ClassDB::bind_method(D_METHOD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
+ ClassDB::bind_method(D_METHOD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
- ClassDB::bind_method(_MD("set_bone_global_pose","bone_idx","pose"),&Skeleton::set_bone_global_pose);
- ClassDB::bind_method(_MD("get_bone_global_pose","bone_idx"),&Skeleton::get_bone_global_pose);
+ ClassDB::bind_method(D_METHOD("set_bone_global_pose","bone_idx","pose"),&Skeleton::set_bone_global_pose);
+ ClassDB::bind_method(D_METHOD("get_bone_global_pose","bone_idx"),&Skeleton::get_bone_global_pose);
- ClassDB::bind_method(_MD("get_bone_custom_pose","bone_idx"),&Skeleton::get_bone_custom_pose);
- ClassDB::bind_method(_MD("set_bone_custom_pose","bone_idx","custom_pose"),&Skeleton::set_bone_custom_pose);
+ ClassDB::bind_method(D_METHOD("get_bone_custom_pose","bone_idx"),&Skeleton::get_bone_custom_pose);
+ ClassDB::bind_method(D_METHOD("set_bone_custom_pose","bone_idx","custom_pose"),&Skeleton::set_bone_custom_pose);
- ClassDB::bind_method(_MD("get_bone_transform","bone_idx"),&Skeleton::get_bone_transform);
+ ClassDB::bind_method(D_METHOD("get_bone_transform","bone_idx"),&Skeleton::get_bone_transform);
BIND_CONSTANT( NOTIFICATION_UPDATE_SKELETON );
}
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 60580911da..58a6a24567 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -74,7 +74,7 @@ SpatialGizmo::SpatialGizmo() {
void Spatial::_notify_dirty() {
- if (!data.ignore_notification && !xform_change.in_list()) {
+ if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
}
@@ -95,8 +95,10 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
return;
}
-// if (data.dirty&DIRTY_GLOBAL)
-// return; //already dirty
+ /*
+ if (data.dirty&DIRTY_GLOBAL)
+ return; //already dirty
+ */
data.children_lock++;
@@ -108,7 +110,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
}
- if (!data.ignore_notification && !xform_change.in_list()) {
+ if (data.notify_transform && !data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
@@ -179,8 +181,8 @@ void Spatial::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint()) {
-// get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
- get_tree()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ get_tree()->call_group_flags(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
if (!data.gizmo_disabled) {
if (data.gizmo.is_valid())
@@ -482,7 +484,7 @@ void Spatial::_update_gizmo() {
data.gizmo_dirty=false;
if (data.gizmo.is_valid()) {
- if (is_visible())
+ if (is_visible_in_tree())
data.gizmo->redraw();
else
data.gizmo->clear();
@@ -573,7 +575,7 @@ void Spatial::show() {
if (!is_inside_tree())
return;
- if (!data.parent || is_visible()) {
+ if (!data.parent || is_visible_in_tree()) {
_propagate_visibility_changed();
}
@@ -584,7 +586,7 @@ void Spatial::hide(){
if (!data.visible)
return;
- bool was_visible = is_visible();
+ bool was_visible = is_visible_in_tree();
data.visible=false;
if (!data.parent || was_visible) {
@@ -593,7 +595,7 @@ void Spatial::hide(){
}
}
-bool Spatial::is_visible() const{
+bool Spatial::is_visible_in_tree() const{
const Spatial *s=this;
@@ -608,21 +610,7 @@ bool Spatial::is_visible() const{
}
-bool Spatial::is_hidden() const{
-
- return !data.visible;
-}
-
-void Spatial::set_hidden(bool p_hidden) {
-
- if (data.visible != p_hidden) {
- return;
- }
-
- _set_visible_(!p_hidden);
-}
-
-void Spatial::_set_visible_(bool p_visible) {
+void Spatial::set_visible(bool p_visible) {
if (p_visible)
show();
@@ -630,9 +618,9 @@ void Spatial::_set_visible_(bool p_visible) {
hide();
}
-bool Spatial::_is_visible_() const {
+bool Spatial::is_visible() const {
- return !is_hidden();
+ return data.visible;
}
void Spatial::rotate(const Vector3& p_normal,float p_radians) {
@@ -736,6 +724,14 @@ void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, con
}
+void Spatial::set_notify_transform(bool p_enable) {
+ data.notify_transform=p_enable;
+}
+
+bool Spatial::is_transform_notification_enabled() const {
+ return data.notify_transform;
+}
+
void Spatial::set_notify_local_transform(bool p_enable) {
data.notify_local_transform=p_enable;
}
@@ -746,50 +742,50 @@ bool Spatial::is_local_transform_notification_enabled() const {
void Spatial::_bind_methods() {
- ClassDB::bind_method(_MD("set_transform","local"), &Spatial::set_transform);
- ClassDB::bind_method(_MD("get_transform"), &Spatial::get_transform);
- ClassDB::bind_method(_MD("set_translation","translation"), &Spatial::set_translation);
- ClassDB::bind_method(_MD("get_translation"), &Spatial::get_translation);
- ClassDB::bind_method(_MD("set_rotation","rotation_rad"), &Spatial::set_rotation);
- ClassDB::bind_method(_MD("get_rotation"), &Spatial::get_rotation);
- ClassDB::bind_method(_MD("set_rotation_deg","rotation_deg"), &Spatial::set_rotation_in_degrees);
- ClassDB::bind_method(_MD("get_rotation_deg"), &Spatial::get_rotation_in_degrees);
- ClassDB::bind_method(_MD("set_scale","scale"), &Spatial::set_scale);
- ClassDB::bind_method(_MD("get_scale"), &Spatial::get_scale);
- ClassDB::bind_method(_MD("set_global_transform","global"), &Spatial::set_global_transform);
- ClassDB::bind_method(_MD("get_global_transform"), &Spatial::get_global_transform);
- ClassDB::bind_method(_MD("get_parent_spatial"), &Spatial::get_parent_spatial);
- ClassDB::bind_method(_MD("set_ignore_transform_notification","enabled"), &Spatial::set_ignore_transform_notification);
- ClassDB::bind_method(_MD("set_as_toplevel","enable"), &Spatial::set_as_toplevel);
- ClassDB::bind_method(_MD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
- ClassDB::bind_method(_MD("get_world:World"), &Spatial::get_world);
+ ClassDB::bind_method(D_METHOD("set_transform","local"), &Spatial::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform);
+ ClassDB::bind_method(D_METHOD("set_translation","translation"), &Spatial::set_translation);
+ ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation);
+ ClassDB::bind_method(D_METHOD("set_rotation","rotation_rad"), &Spatial::set_rotation);
+ ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation_deg","rotation_deg"), &Spatial::set_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Spatial::get_rotation_in_degrees);
+ ClassDB::bind_method(D_METHOD("set_scale","scale"), &Spatial::set_scale);
+ 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("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);
+ ClassDB::bind_method(D_METHOD("get_world:World"), &Spatial::get_world);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ClassDB::bind_method(_MD("_set_rotation_deg","rotation_deg"), &Spatial::_set_rotation_deg);
- ClassDB::bind_method(_MD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
+ ClassDB::bind_method(D_METHOD("_set_rotation_deg","rotation_deg"), &Spatial::_set_rotation_deg);
+ ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
#ifdef TOOLS_ENABLED
- ClassDB::bind_method(_MD("_update_gizmo"), &Spatial::_update_gizmo);
- ClassDB::bind_method(_MD("_set_import_transform"), &Spatial::set_import_transform);
- ClassDB::bind_method(_MD("_get_import_transform"), &Spatial::get_import_transform);
- ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"_import_transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_transform"),_SCS("_get_import_transform"));
+ ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo);
+ ClassDB::bind_method(D_METHOD("_set_import_transform"), &Spatial::set_import_transform);
+ ClassDB::bind_method(D_METHOD("_get_import_transform"), &Spatial::get_import_transform);
+ ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"_import_transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_import_transform","_get_import_transform");
#endif
- ClassDB::bind_method(_MD("update_gizmo"), &Spatial::update_gizmo);
- ClassDB::bind_method(_MD("set_gizmo","gizmo:SpatialGizmo"), &Spatial::set_gizmo);
- ClassDB::bind_method(_MD("get_gizmo:SpatialGizmo"), &Spatial::get_gizmo);
+ ClassDB::bind_method(D_METHOD("update_gizmo"), &Spatial::update_gizmo);
+ 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(_MD("show"), &Spatial::show);
- ClassDB::bind_method(_MD("hide"), &Spatial::hide);
- ClassDB::bind_method(_MD("is_visible"), &Spatial::is_visible);
- ClassDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden);
- ClassDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden);
+ ClassDB::bind_method(D_METHOD("set_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);
+ ClassDB::bind_method(D_METHOD("hide"), &Spatial::hide);
- ClassDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_);
- ClassDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_);
+ ClassDB::bind_method(D_METHOD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
+ ClassDB::bind_method(D_METHOD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
- ClassDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
- ClassDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
+ ClassDB::bind_method(D_METHOD("set_notify_transform","enable"), &Spatial::set_notify_transform);
+ ClassDB::bind_method(D_METHOD("is_transform_notification_enabled"), &Spatial::is_transform_notification_enabled);
void rotate(const Vector3& p_normal,float p_radians);
void rotate_x(float p_radians);
@@ -800,35 +796,35 @@ void Spatial::_bind_methods() {
void global_rotate(const Vector3& p_normal,float p_radians);
void global_translate(const Vector3& p_offset);
- ClassDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
- ClassDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
- ClassDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
- ClassDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
- ClassDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
- ClassDB::bind_method( _MD("translate","offset"),&Spatial::translate );
- ClassDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
- ClassDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
- ClassDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
+ ClassDB::bind_method( D_METHOD("rotate","normal","radians"),&Spatial::rotate );
+ ClassDB::bind_method( D_METHOD("global_rotate","normal","radians"),&Spatial::global_rotate );
+ ClassDB::bind_method( D_METHOD("rotate_x","radians"),&Spatial::rotate_x );
+ ClassDB::bind_method( D_METHOD("rotate_y","radians"),&Spatial::rotate_y );
+ ClassDB::bind_method( D_METHOD("rotate_z","radians"),&Spatial::rotate_z );
+ ClassDB::bind_method( D_METHOD("translate","offset"),&Spatial::translate );
+ ClassDB::bind_method( D_METHOD("global_translate","offset"),&Spatial::global_translate );
+ ClassDB::bind_method( D_METHOD("orthonormalize"),&Spatial::orthonormalize );
+ ClassDB::bind_method( D_METHOD("set_identity"),&Spatial::set_identity );
- ClassDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
- ClassDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
+ 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 );
BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
BIND_CONSTANT( NOTIFICATION_ENTER_WORLD );
BIND_CONSTANT( NOTIFICATION_EXIT_WORLD );
BIND_CONSTANT( NOTIFICATION_VISIBILITY_CHANGED );
- //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), _SCS("set_global_transform"), _SCS("get_global_transform") );
+ //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), "set_global_transform", "get_global_transform") ;
ADD_GROUP("Transform","");
- ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"transform",PROPERTY_HINT_NONE,""), _SCS("set_transform"), _SCS("get_transform") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"global_transform",PROPERTY_HINT_NONE,"",0), _SCS("set_global_transform"), _SCS("get_global_transform") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"translation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_translation"), _SCS("get_translation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation_deg",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_rotation_deg"), _SCS("get_rotation_deg") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation",PROPERTY_HINT_NONE,"",0), _SCS("set_rotation"), _SCS("get_rotation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"transform",PROPERTY_HINT_NONE,""), "set_transform", "get_transform") ;
+ ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"global_transform",PROPERTY_HINT_NONE,"",0), "set_global_transform", "get_global_transform") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"translation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), "set_translation", "get_translation") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation_deg",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), "set_rotation_deg", "get_rotation_deg") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"rotation",PROPERTY_HINT_NONE,"",0), "set_rotation", "get_rotation") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), "set_scale", "get_scale") ;
ADD_GROUP("Visibility","");
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("_set_visible_"), _SCS("_is_visible_") );
- //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), _SCS("set_transform"), _SCS("get_transform") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), "set_visible", "is_visible") ;
+ //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), "set_transform", "get_transform") ;
ADD_SIGNAL( MethodInfo("visibility_changed" ) );
@@ -848,11 +844,13 @@ Spatial::Spatial() : xform_change(this)
data.viewport=NULL;
data.inside_world=false;
data.visible=true;
+
#ifdef TOOLS_ENABLED
data.gizmo_disabled=false;
data.gizmo_dirty=false;
#endif
data.notify_local_transform=false;
+ data.notify_transform=false;
data.parent=NULL;
data.C=NULL;
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index 8121eaa8c2..72daa472bd 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -92,6 +92,7 @@ class Spatial : public Node {
bool ignore_notification;
bool notify_local_transform;
+ bool notify_transform;
bool visible;
@@ -126,8 +127,6 @@ protected:
void _notification(int p_what);
static void _bind_methods();
- void _set_visible_(bool p_visible);
- bool _is_visible_() const;
public:
enum {
@@ -184,17 +183,20 @@ 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);
+ void set_notify_transform(bool p_enable);
+ bool is_transform_notification_enabled() const;
+
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
void orthonormalize();
void set_identity();
+ void set_visible(bool p_visible);
+ bool is_visible() const;
void show();
void hide();
- bool is_visible() const;
- bool is_hidden() const;
- void set_hidden(bool p_hidden);
+ bool is_visible_in_tree() const;
#ifdef TOOLS_ENABLED
void set_import_transform(const Transform& p_transform) ;
diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp
index 0cc6d1abd0..6d6c272c25 100644
--- a/scene/3d/spatial_indexer.cpp
+++ b/scene/3d/spatial_indexer.cpp
@@ -112,7 +112,7 @@ void SpatialIndexer::_update_pairs() {
void SpatialIndexer::_bind_methods() {
- ClassDB::bind_method(_MD("_update_pairs"),&SpatialIndexer::_update_pairs);
+ ClassDB::bind_method(D_METHOD("_update_pairs"),&SpatialIndexer::_update_pairs);
}
diff --git a/scene/3d/spatial_player.cpp b/scene/3d/spatial_player.cpp
deleted file mode 100644
index 0a8b9053c1..0000000000
--- a/scene/3d/spatial_player.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*************************************************************************/
-/* spatial_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_player.h"
-
-#include "servers/audio_server.h"
-#include "camera.h"
-#include "servers/spatial_sound_server.h"
-#include "scene/resources/surface_tool.h"
-
-
-void SpatialPlayer::_notification(int p_what) {
-
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_WORLD: {
- //find the sound space
-
- source_rid = SpatialSoundServer::get_singleton()->source_create(get_world()->get_sound_space());
- for(int i=0;i<PARAM_MAX;i++)
- set_param(Param(i),params[i]);
-
-
- } break;
- case NOTIFICATION_TRANSFORM_CHANGED: {
-
- SpatialSoundServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
-
- } break;
- case NOTIFICATION_EXIT_WORLD: {
-
- if (source_rid.is_valid())
- SpatialSoundServer::get_singleton()->free(source_rid);
-
- } break;
- }
-
-}
-
-
-void SpatialPlayer::set_param( Param p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
- if (p_param==PARAM_EMISSION_CONE_DEGREES) {
- update_gizmo();
- }
- if (source_rid.is_valid())
- SpatialSoundServer::get_singleton()->source_set_param(source_rid,(SpatialSoundServer::SourceParam)p_param,p_value);
-
-}
-
-float SpatialPlayer::get_param( Param p_param) const {
-
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
- return params[p_param];
-
-}
-
-bool SpatialPlayer::_can_gizmo_scale() const {
-
- return false;
-}
-
-void SpatialPlayer::_bind_methods() {
-
-
- ClassDB::bind_method(_MD("set_param","param","value"),&SpatialPlayer::set_param);
- ClassDB::bind_method(_MD("get_param","param"),&SpatialPlayer::get_param);
-
- BIND_CONSTANT( PARAM_VOLUME_DB );
- BIND_CONSTANT( PARAM_PITCH_SCALE );
- BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP );
- BIND_CONSTANT( PARAM_EMISSION_CONE_DEGREES );
- BIND_CONSTANT( PARAM_EMISSION_CONE_ATTENUATION_DB );
- BIND_CONSTANT( PARAM_MAX );
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_GROUP("Attenuation","attenuation_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_min_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_max_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "attenuation_distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
- ADD_GROUP("Emission Cone","emission_cone_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_degrees",PROPERTY_HINT_RANGE, "0,180,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_DEGREES);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "emission_cone_attenuation_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_ATTENUATION_DB);
-
-}
-
-
-SpatialPlayer::SpatialPlayer() {
-
- params[PARAM_VOLUME_DB]=0.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[PARAM_ATTENUATION_MAX_DISTANCE]=100;
- params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
- params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled
- params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation
-
-}
-
-SpatialPlayer::~SpatialPlayer() {
-
-
-}
diff --git a/scene/3d/spatial_player.h b/scene/3d/spatial_player.h
deleted file mode 100644
index 16671a0cb5..0000000000
--- a/scene/3d/spatial_player.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*************************************************************************/
-/* spatial_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_PLAYER_H
-#define SPATIAL_PLAYER_H
-
-
-#include "scene/3d/spatial.h"
-#include "scene/main/node.h"
-#include "scene/resources/sample_library.h"
-#include "servers/spatial_sound_server.h"
-#include "scene/main/viewport.h"
-
-class SpatialPlayer : public Spatial {
-
- GDCLASS(SpatialPlayer,Spatial);
-public:
-
-
- enum Param {
-
- PARAM_VOLUME_DB=SpatialSoundServer::SOURCE_PARAM_VOLUME_DB,
- PARAM_PITCH_SCALE=SpatialSoundServer::SOURCE_PARAM_PITCH_SCALE,
- PARAM_ATTENUATION_MIN_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- PARAM_ATTENUATION_MAX_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- PARAM_ATTENUATION_DISTANCE_EXP=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- PARAM_EMISSION_CONE_DEGREES=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_DEGREES,
- PARAM_EMISSION_CONE_ATTENUATION_DB=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB,
- PARAM_MAX=SpatialSoundServer::SOURCE_PARAM_MAX
- };
-
-private:
-
- float params[PARAM_MAX];
- RID source_rid;
-
- virtual bool _can_gizmo_scale() const;
-
-
-
-protected:
-
- _FORCE_INLINE_ RID get_source_rid() const { return source_rid; }
-
- void _notification(int p_what);
-
- static void _bind_methods();
-
-public:
-
- void set_param( Param p_param, float p_value);
- float get_param( Param p_param) const;
-
-
- SpatialPlayer();
- ~SpatialPlayer();
-
-
-};
-
-VARIANT_ENUM_CAST( SpatialPlayer::Param );
-#endif // SPATIAL_PLAYER_H
diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp
deleted file mode 100644
index 3e1c0e9947..0000000000
--- a/scene/3d/spatial_sample_player.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/*************************************************************************/
-/* spatial_sample_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_sample_player.h"
-
-#include "servers/audio_server.h"
-#include "camera.h"
-#include "servers/spatial_sound_server.h"
-#include "scene/scene_string_names.h"
-
-bool SpatialSamplePlayer::_set(const StringName& p_name, const Variant& p_value) {
-
- String name=p_name;
-
- if (name==SceneStringNames::get_singleton()->play_play) {
- if (library.is_valid()) {
-
- String what=p_value;
- if (what=="")
- stop_all();
- else
- play(what);
-
- played_back=what;
- }
- return true;
-
- }
-
- return false;
-}
-
-bool SpatialSamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
-
-
- String name=p_name;
-
- if (name==SceneStringNames::get_singleton()->play_play) {
- r_ret=played_back;
- return true;
- }
-
- return false;
-}
-
-void SpatialSamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
-
- String en="";
- if (library.is_valid()) {
- List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
- ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
-
- en+=",";
- en+=E->get();
- }
- }
-
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
-
-}
-void SpatialSamplePlayer::_notification(int p_what) {
-
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_WORLD: {
-
- SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
-
- } break;
- }
-
-}
-
-void SpatialSamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) {
-
- library=p_library;
- _change_notify();
- update_configuration_warning();
-}
-
-Ref<SampleLibrary> SpatialSamplePlayer::get_sample_library() const {
-
- return library;
-}
-
-void SpatialSamplePlayer::set_polyphony(int p_voice_count) {
-
- ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64);
- polyphony=p_voice_count;
- if (get_source_rid().is_valid())
- SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
-}
-
-int SpatialSamplePlayer::get_polyphony() const {
-
- return polyphony;
-}
-
-SpatialSamplePlayer::VoiceID SpatialSamplePlayer::play(const String& p_sample,int p_voice) {
-
- if (!get_source_rid().is_valid())
- return INVALID_VOICE;
- if (library.is_null())
- return INVALID_VOICE;
- if (!library->has_sample(p_sample))
- return INVALID_VOICE;
- Ref<Sample> sample = library->get_sample(p_sample);
- float vol_change = library->sample_get_volume_db(p_sample);
- float pitch_change = library->sample_get_pitch_scale(p_sample);
-
- VoiceID vid = SpatialSoundServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice);
- if (vol_change)
- SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change);
-
- return vid;
-
-
-}
-//voices
-void SpatialSamplePlayer::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) {
-
- if (!get_source_rid().is_valid())
- return;
-
- SpatialSoundServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale);
-
-}
-
-void SpatialSamplePlayer::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) {
-
- if (!get_source_rid().is_valid())
- return;
- SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db);
-
-}
-
-bool SpatialSamplePlayer::is_voice_active(VoiceID p_voice) const {
-
- if (!get_source_rid().is_valid())
- return false;
- return SpatialSoundServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice);
-
-}
-
-void SpatialSamplePlayer::stop_voice(VoiceID p_voice) {
-
- if (!get_source_rid().is_valid())
- return;
- SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice);
-
-}
-
-void SpatialSamplePlayer::stop_all() {
-
- if (!get_source_rid().is_valid())
- return;
-
- for(int i=0;i<polyphony;i++) {
-
- SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),i);
- }
-}
-
-String SpatialSamplePlayer::get_configuration_warning() const {
-
- if (library.is_null()) {
- return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SpatialSamplePlayer to play sound.");
- }
-
- return String();
-}
-
-
-void SpatialSamplePlayer::_bind_methods() {
-
-
- ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SpatialSamplePlayer::set_sample_library);
- ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SpatialSamplePlayer::get_sample_library);
-
- ClassDB::bind_method(_MD("set_polyphony","voices"),&SpatialSamplePlayer::set_polyphony);
- ClassDB::bind_method(_MD("get_polyphony"),&SpatialSamplePlayer::get_polyphony);
-
- ClassDB::bind_method(_MD("play","sample","voice"),&SpatialSamplePlayer::play,DEFVAL(NEXT_VOICE));
- //voices,DEV
- ClassDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SpatialSamplePlayer::voice_set_pitch_scale);
- ClassDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SpatialSamplePlayer::voice_set_volume_scale_db);
-
- ClassDB::bind_method(_MD("is_voice_active","voice"),&SpatialSamplePlayer::is_voice_active);
- ClassDB::bind_method(_MD("stop_voice","voice"),&SpatialSamplePlayer::stop_voice);
- ClassDB::bind_method(_MD("stop_all"),&SpatialSamplePlayer::stop_all);
-
- BIND_CONSTANT( INVALID_VOICE );
- BIND_CONSTANT( NEXT_VOICE );
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
-
-
-}
-
-
-SpatialSamplePlayer::SpatialSamplePlayer() {
-
- polyphony=1;
-
-}
-
-SpatialSamplePlayer::~SpatialSamplePlayer() {
-
-
-}
diff --git a/scene/3d/spatial_sample_player.h b/scene/3d/spatial_sample_player.h
deleted file mode 100644
index d30ff6e908..0000000000
--- a/scene/3d/spatial_sample_player.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*************************************************************************/
-/* spatial_sample_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_SAMPLE_PLAYER_H
-#define SPATIAL_SAMPLE_PLAYER_H
-
-#include "scene/3d/spatial_player.h"
-#include "scene/resources/sample_library.h"
-#include "servers/spatial_sound_server.h"
-
-class SpatialSamplePlayer : public SpatialPlayer {
-
- GDCLASS(SpatialSamplePlayer,SpatialPlayer);
-public:
-
- enum {
-
- INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE,
- NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE
- };
-
- typedef int VoiceID;
-
-
-private:
-
- Ref<SampleLibrary> library;
- int polyphony;
- String played_back;
-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;
-
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
- Ref<SampleLibrary> get_sample_library() const;
-
- void set_polyphony(int p_voice_count);
- int get_polyphony() const;
-
- VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE);
- //voices
- void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
- void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db);
-
- bool is_voice_active(VoiceID p_voice) const;
- void stop_voice(VoiceID p_voice);
- void stop_all();
-
- String get_configuration_warning() const;
-
- SpatialSamplePlayer();
- ~SpatialSamplePlayer();
-
-
-};
-
-
-#endif // SPATIAL_SAMPLE_PLAYER_H
diff --git a/scene/3d/spatial_stream_player.cpp b/scene/3d/spatial_stream_player.cpp
deleted file mode 100644
index 087e60b48b..0000000000
--- a/scene/3d/spatial_stream_player.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/*************************************************************************/
-/* spatial_stream_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_stream_player.h"
-
-
-
-int SpatialStreamPlayer::InternalStream::get_channel_count() const {
-
- return player->sp_get_channel_count();
-}
-void SpatialStreamPlayer::InternalStream::set_mix_rate(int p_rate){
-
- return player->sp_set_mix_rate(p_rate);
-}
-bool SpatialStreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
-
- return player->sp_mix(p_buffer,p_frames);
-}
-void SpatialStreamPlayer::InternalStream::update(){
-
- player->sp_update();
-}
-
-
-int SpatialStreamPlayer::sp_get_channel_count() const {
-
- return playback->get_channels();
-}
-
-void SpatialStreamPlayer::sp_set_mix_rate(int p_rate){
-
- server_mix_rate=p_rate;
-}
-
-bool SpatialStreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
-
- if (resampler.is_ready() && !paused) {
- return resampler.mix(p_buffer,p_frames);
- }
-
- return false;
-}
-
-void SpatialStreamPlayer::sp_update() {
-
- _THREAD_SAFE_METHOD_
- if (!paused && resampler.is_ready() && playback.is_valid()) {
-
- if (!playback->is_playing()) {
- //stream depleted data, but there's still audio in the ringbuffer
- //check that all this audio has been flushed before stopping the stream
- int to_mix = resampler.get_total() - resampler.get_todo();
- if (to_mix==0) {
- stop();
- return;
- }
-
- return;
- }
-
- int todo =resampler.get_todo();
- int wrote = playback->mix(resampler.get_write_buffer(),todo);
- resampler.write(wrote);
- }
-}
-
-
-
-void SpatialStreamPlayer::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- //set_idle_process(false); //don't annoy
- if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint())
- play();
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- stop(); //wathever it may be doing, stop
- } break;
- }
-}
-
-
-
-void SpatialStreamPlayer::set_stream(const Ref<AudioStream> &p_stream) {
-
- stop();
-
- stream=p_stream;
-
- if (!stream.is_null()) {
- playback=stream->instance_playback();
- playback->set_loop(loops);
- playback->set_loop_restart_time(loop_point);
- AudioServer::get_singleton()->lock();
- resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size());
- AudioServer::get_singleton()->unlock();
- } else {
- AudioServer::get_singleton()->lock();
- resampler.clear();
- playback.unref();
- AudioServer::get_singleton()->unlock();
- }
-}
-
-Ref<AudioStream> SpatialStreamPlayer::get_stream() const {
-
- return stream;
-}
-
-
-void SpatialStreamPlayer::play(float p_from_offset) {
-
- ERR_FAIL_COND(!is_inside_tree());
- if (playback.is_null())
- return;
- if (playback->is_playing())
- stop();
-
- _THREAD_SAFE_METHOD_
- playback->play(p_from_offset);
- //feed the ringbuffer as long as no update callback is going on
- sp_update();
-
- SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),&internal_stream);
-
-// AudioServer::get_singleton()->stream_set_active(stream_rid,true);
-// AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
-
-}
-
-void SpatialStreamPlayer::stop() {
-
- if (!is_inside_tree())
- return;
- if (playback.is_null())
- return;
-
- _THREAD_SAFE_METHOD_
- //AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),NULL);
- playback->stop();
- resampler.flush();
- //set_idle_process(false);
-}
-
-bool SpatialStreamPlayer::is_playing() const {
-
- if (playback.is_null())
- return false;
-
- return playback->is_playing();
-}
-
-void SpatialStreamPlayer::set_loop(bool p_enable) {
-
- loops=p_enable;
- if (playback.is_null())
- return;
- playback->set_loop(loops);
-
-}
-bool SpatialStreamPlayer::has_loop() const {
-
- return loops;
-}
-
-void SpatialStreamPlayer::set_volume(float p_vol) {
-
- volume=p_vol;
- if (stream_rid.is_valid())
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-}
-
-float SpatialStreamPlayer::get_volume() const {
-
- return volume;
-}
-
-void SpatialStreamPlayer::set_loop_restart_time(float p_secs) {
-
- loop_point=p_secs;
- if (playback.is_valid())
- playback->set_loop_restart_time(p_secs);
-}
-
-float SpatialStreamPlayer::get_loop_restart_time() const {
-
- return loop_point;
-}
-
-
-void SpatialStreamPlayer::set_volume_db(float p_db) {
-
- if (p_db<-79)
- set_volume(0);
- else
- set_volume(Math::db2linear(p_db));
-}
-
-float SpatialStreamPlayer::get_volume_db() const {
-
- if (volume==0)
- return -80;
- else
- return Math::linear2db(volume);
-}
-
-
-String SpatialStreamPlayer::get_stream_name() const {
-
- if (stream.is_null())
- return "<No Stream>";
- return stream->get_name();
-
-}
-
-int SpatialStreamPlayer::get_loop_count() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_loop_count();
-
-}
-
-float SpatialStreamPlayer::get_pos() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_pos();
-
-}
-
-float SpatialStreamPlayer::get_length() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_length();
-}
-void SpatialStreamPlayer::seek_pos(float p_time) {
-
- if (playback.is_null())
- return;
- return playback->seek_pos(p_time);
-
-}
-
-void SpatialStreamPlayer::set_autoplay(bool p_enable) {
-
- autoplay=p_enable;
-}
-
-bool SpatialStreamPlayer::has_autoplay() const {
-
- return autoplay;
-}
-
-void SpatialStreamPlayer::set_paused(bool p_paused) {
-
- paused=p_paused;
- //if (stream.is_valid())
- // stream->set_paused(p_paused);
-}
-
-bool SpatialStreamPlayer::is_paused() const {
-
- return paused;
-}
-
-void SpatialStreamPlayer::_set_play(bool p_play) {
-
- _play=p_play;
- if (is_inside_tree()) {
- if(_play)
- play();
- else
- stop();
- }
-
-}
-
-bool SpatialStreamPlayer::_get_play() const{
-
- return _play;
-}
-
-void SpatialStreamPlayer::set_buffering_msec(int p_msec) {
-
- buffering_ms=p_msec;
-}
-
-int SpatialStreamPlayer::get_buffering_msec() const{
-
- return buffering_ms;
-}
-
-
-
-void SpatialStreamPlayer::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&SpatialStreamPlayer::set_stream);
- ClassDB::bind_method(_MD("get_stream:AudioStream"),&SpatialStreamPlayer::get_stream);
-
- ClassDB::bind_method(_MD("play","offset"),&SpatialStreamPlayer::play,DEFVAL(0));
- ClassDB::bind_method(_MD("stop"),&SpatialStreamPlayer::stop);
-
- ClassDB::bind_method(_MD("is_playing"),&SpatialStreamPlayer::is_playing);
-
- ClassDB::bind_method(_MD("set_paused","paused"),&SpatialStreamPlayer::set_paused);
- ClassDB::bind_method(_MD("is_paused"),&SpatialStreamPlayer::is_paused);
-
- ClassDB::bind_method(_MD("set_loop","enabled"),&SpatialStreamPlayer::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&SpatialStreamPlayer::has_loop);
-
- ClassDB::bind_method(_MD("set_volume","volume"),&SpatialStreamPlayer::set_volume);
- ClassDB::bind_method(_MD("get_volume"),&SpatialStreamPlayer::get_volume);
-
- ClassDB::bind_method(_MD("set_volume_db","db"),&SpatialStreamPlayer::set_volume_db);
- ClassDB::bind_method(_MD("get_volume_db"),&SpatialStreamPlayer::get_volume_db);
-
- ClassDB::bind_method(_MD("set_buffering_msec","msec"),&SpatialStreamPlayer::set_buffering_msec);
- ClassDB::bind_method(_MD("get_buffering_msec"),&SpatialStreamPlayer::get_buffering_msec);
-
- ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&SpatialStreamPlayer::set_loop_restart_time);
- ClassDB::bind_method(_MD("get_loop_restart_time"),&SpatialStreamPlayer::get_loop_restart_time);
-
- ClassDB::bind_method(_MD("get_stream_name"),&SpatialStreamPlayer::get_stream_name);
- ClassDB::bind_method(_MD("get_loop_count"),&SpatialStreamPlayer::get_loop_count);
-
- ClassDB::bind_method(_MD("get_pos"),&SpatialStreamPlayer::get_pos);
- ClassDB::bind_method(_MD("seek_pos","time"),&SpatialStreamPlayer::seek_pos);
-
- ClassDB::bind_method(_MD("set_autoplay","enabled"),&SpatialStreamPlayer::set_autoplay);
- ClassDB::bind_method(_MD("has_autoplay"),&SpatialStreamPlayer::has_autoplay);
-
- ClassDB::bind_method(_MD("get_length"),&SpatialStreamPlayer::get_length);
-
- ClassDB::bind_method(_MD("_set_play","play"),&SpatialStreamPlayer::_set_play);
- ClassDB::bind_method(_MD("_get_play"),&SpatialStreamPlayer::_get_play);
-
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
-}
-
-
-SpatialStreamPlayer::SpatialStreamPlayer() {
-
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- server_mix_rate=1;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
- buffering_ms=500;
- loop_point=0;
-
-}
-
-SpatialStreamPlayer::~SpatialStreamPlayer() {
- AudioServer::get_singleton()->free(stream_rid);
- resampler.clear();
-
-
-}
diff --git a/scene/3d/spatial_stream_player.h b/scene/3d/spatial_stream_player.h
deleted file mode 100644
index 27533d3f6e..0000000000
--- a/scene/3d/spatial_stream_player.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*************************************************************************/
-/* spatial_stream_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_STREAM_PLAYER_H
-#define SPATIAL_STREAM_PLAYER_H
-
-#include "scene/resources/audio_stream.h"
-#include "scene/3d/spatial_player.h"
-#include "servers/audio/audio_rb_resampler.h"
-
-class SpatialStreamPlayer : public SpatialPlayer {
-
- GDCLASS(SpatialStreamPlayer,SpatialPlayer);
-
- _THREAD_SAFE_CLASS_
-
- struct InternalStream : public AudioServer::AudioStream {
- SpatialStreamPlayer *player;
- virtual int get_channel_count() const;
- virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
- virtual void update();
- };
-
-
- InternalStream internal_stream;
- Ref<AudioStreamPlayback> playback;
- Ref<AudioStream> stream;
-
- int sp_get_channel_count() const;
- void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
- bool sp_mix(int32_t *p_buffer,int p_frames);
- void sp_update();
-
- int server_mix_rate;
-
- RID stream_rid;
- bool paused;
- bool autoplay;
- bool loops;
- float volume;
- float loop_point;
- int buffering_ms;
-
- AudioRBResampler resampler;
-
- bool _play;
- void _set_play(bool p_play);
- bool _get_play() const;
-protected:
- void _notification(int p_what);
-
- static void _bind_methods();
-public:
-
- void set_stream(const Ref<AudioStream> &p_stream);
- Ref<AudioStream> get_stream() const;
-
- void play(float p_from_offset=0);
- void stop();
- bool is_playing() const;
-
- void set_paused(bool p_paused);
- bool is_paused() const;
-
- void set_loop(bool p_enable);
- bool has_loop() const;
-
- void set_volume(float p_vol);
- float get_volume() const;
-
- void set_loop_restart_time(float p_secs);
- float get_loop_restart_time() const;
-
- void set_volume_db(float p_db);
- float get_volume_db() const;
-
- String get_stream_name() const;
-
- int get_loop_count() const;
-
- float get_pos() const;
- void seek_pos(float p_time);
- float get_length() const;
- void set_autoplay(bool p_vol);
- bool has_autoplay() const;
-
- void set_buffering_msec(int p_msec);
- int get_buffering_msec() const;
-
- SpatialStreamPlayer();
- ~SpatialStreamPlayer();
-};
-
-#endif // SPATIAL_STREAM_PLAYER_H
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index a2a96d7d0e..5adb7050f8 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -246,55 +246,55 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const{
void SpriteBase3D::_bind_methods() {
- ClassDB::bind_method(_MD("set_centered","centered"),&SpriteBase3D::set_centered);
- ClassDB::bind_method(_MD("is_centered"),&SpriteBase3D::is_centered);
+ ClassDB::bind_method(D_METHOD("set_centered","centered"),&SpriteBase3D::set_centered);
+ ClassDB::bind_method(D_METHOD("is_centered"),&SpriteBase3D::is_centered);
- ClassDB::bind_method(_MD("set_offset","offset"),&SpriteBase3D::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&SpriteBase3D::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&SpriteBase3D::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&SpriteBase3D::get_offset);
- ClassDB::bind_method(_MD("set_flip_h","flip_h"),&SpriteBase3D::set_flip_h);
- ClassDB::bind_method(_MD("is_flipped_h"),&SpriteBase3D::is_flipped_h);
+ ClassDB::bind_method(D_METHOD("set_flip_h","flip_h"),&SpriteBase3D::set_flip_h);
+ ClassDB::bind_method(D_METHOD("is_flipped_h"),&SpriteBase3D::is_flipped_h);
- ClassDB::bind_method(_MD("set_flip_v","flip_v"),&SpriteBase3D::set_flip_v);
- ClassDB::bind_method(_MD("is_flipped_v"),&SpriteBase3D::is_flipped_v);
+ ClassDB::bind_method(D_METHOD("set_flip_v","flip_v"),&SpriteBase3D::set_flip_v);
+ ClassDB::bind_method(D_METHOD("is_flipped_v"),&SpriteBase3D::is_flipped_v);
- ClassDB::bind_method(_MD("set_modulate","modulate"),&SpriteBase3D::set_modulate);
- ClassDB::bind_method(_MD("get_modulate"),&SpriteBase3D::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_modulate","modulate"),&SpriteBase3D::set_modulate);
+ ClassDB::bind_method(D_METHOD("get_modulate"),&SpriteBase3D::get_modulate);
- ClassDB::bind_method(_MD("set_opacity","opacity"),&SpriteBase3D::set_opacity);
- ClassDB::bind_method(_MD("get_opacity"),&SpriteBase3D::get_opacity);
+ ClassDB::bind_method(D_METHOD("set_opacity","opacity"),&SpriteBase3D::set_opacity);
+ ClassDB::bind_method(D_METHOD("get_opacity"),&SpriteBase3D::get_opacity);
- ClassDB::bind_method(_MD("set_pixel_size","pixel_size"),&SpriteBase3D::set_pixel_size);
- ClassDB::bind_method(_MD("get_pixel_size"),&SpriteBase3D::get_pixel_size);
+ ClassDB::bind_method(D_METHOD("set_pixel_size","pixel_size"),&SpriteBase3D::set_pixel_size);
+ ClassDB::bind_method(D_METHOD("get_pixel_size"),&SpriteBase3D::get_pixel_size);
- ClassDB::bind_method(_MD("set_axis","axis"),&SpriteBase3D::set_axis);
- ClassDB::bind_method(_MD("get_axis"),&SpriteBase3D::get_axis);
+ ClassDB::bind_method(D_METHOD("set_axis","axis"),&SpriteBase3D::set_axis);
+ ClassDB::bind_method(D_METHOD("get_axis"),&SpriteBase3D::get_axis);
- ClassDB::bind_method(_MD("set_draw_flag","flag","enabled"),&SpriteBase3D::set_draw_flag);
- ClassDB::bind_method(_MD("get_draw_flag","flag"),&SpriteBase3D::get_draw_flag);
+ ClassDB::bind_method(D_METHOD("set_draw_flag","flag","enabled"),&SpriteBase3D::set_draw_flag);
+ ClassDB::bind_method(D_METHOD("get_draw_flag","flag"),&SpriteBase3D::get_draw_flag);
- ClassDB::bind_method(_MD("set_alpha_cut_mode","mode"),&SpriteBase3D::set_alpha_cut_mode);
- ClassDB::bind_method(_MD("get_alpha_cut_mode"),&SpriteBase3D::get_alpha_cut_mode);
+ ClassDB::bind_method(D_METHOD("set_alpha_cut_mode","mode"),&SpriteBase3D::set_alpha_cut_mode);
+ ClassDB::bind_method(D_METHOD("get_alpha_cut_mode"),&SpriteBase3D::get_alpha_cut_mode);
- ClassDB::bind_method(_MD("get_item_rect"),&SpriteBase3D::get_item_rect);
+ ClassDB::bind_method(D_METHOD("get_item_rect"),&SpriteBase3D::get_item_rect);
- ClassDB::bind_method(_MD("_queue_update"),&SpriteBase3D::_queue_update);
- ClassDB::bind_method(_MD("_im_update"),&SpriteBase3D::_im_update);
+ ClassDB::bind_method(D_METHOD("_queue_update"),&SpriteBase3D::_queue_update);
+ ClassDB::bind_method(D_METHOD("_im_update"),&SpriteBase3D::_im_update);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "opacity",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "pixel_size",PROPERTY_HINT_RANGE,"0.0001,128,0.0001"), _SCS("set_pixel_size"),_SCS("get_pixel_size"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "axis",PROPERTY_HINT_ENUM,"X-Axis,Y-Axis,Z-Axis"), _SCS("set_axis"),_SCS("get_axis"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), "set_centered","is_centered");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), "set_offset","get_offset");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), "set_flip_h","is_flipped_h");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), "set_flip_v","is_flipped_v");
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), "set_modulate","get_modulate");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "opacity",PROPERTY_HINT_RANGE,"0,1,0.01"), "set_opacity","get_opacity");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "pixel_size",PROPERTY_HINT_RANGE,"0.0001,128,0.0001"), "set_pixel_size","get_pixel_size");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "axis",PROPERTY_HINT_ENUM,"X-Axis,Y-Axis,Z-Axis"), "set_axis","get_axis");
ADD_GROUP("Flags","");
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "transparent"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_TRANSPARENT);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "shaded"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_SHADED);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "alpha_cut",PROPERTY_HINT_ENUM,"Disabled,Discard,Opaque Pre-Pass"), _SCS("set_alpha_cut_mode"),_SCS("get_alpha_cut_mode"));
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "transparent"), "set_draw_flag","get_draw_flag",FLAG_TRANSPARENT);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "shaded"), "set_draw_flag","get_draw_flag",FLAG_SHADED);
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "alpha_cut",PROPERTY_HINT_ENUM,"Disabled,Discard,Opaque Pre-Pass"), "set_alpha_cut_mode","get_alpha_cut_mode");
BIND_CONSTANT( FLAG_TRANSPARENT );
@@ -563,8 +563,10 @@ Rect2 Sprite3D::get_item_rect() const {
if (texture.is_null())
return Rect2(0,0,1,1);
- //if (texture.is_null())
- // return CanvasItem::get_item_rect();
+ /*
+ if (texture.is_null())
+ return CanvasItem::get_item_rect();
+ */
Size2i s;
@@ -599,30 +601,30 @@ void Sprite3D::_validate_property(PropertyInfo& property) const {
void Sprite3D::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture);
- ClassDB::bind_method(_MD("get_texture:Texture"),&Sprite3D::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","texture:Texture"),&Sprite3D::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"),&Sprite3D::get_texture);
- ClassDB::bind_method(_MD("set_region","enabled"),&Sprite3D::set_region);
- ClassDB::bind_method(_MD("is_region"),&Sprite3D::is_region);
+ ClassDB::bind_method(D_METHOD("set_region","enabled"),&Sprite3D::set_region);
+ ClassDB::bind_method(D_METHOD("is_region"),&Sprite3D::is_region);
- ClassDB::bind_method(_MD("set_region_rect","rect"),&Sprite3D::set_region_rect);
- ClassDB::bind_method(_MD("get_region_rect"),&Sprite3D::get_region_rect);
+ ClassDB::bind_method(D_METHOD("set_region_rect","rect"),&Sprite3D::set_region_rect);
+ ClassDB::bind_method(D_METHOD("get_region_rect"),&Sprite3D::get_region_rect);
- ClassDB::bind_method(_MD("set_frame","frame"),&Sprite3D::set_frame);
- ClassDB::bind_method(_MD("get_frame"),&Sprite3D::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame","frame"),&Sprite3D::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"),&Sprite3D::get_frame);
- ClassDB::bind_method(_MD("set_vframes","vframes"),&Sprite3D::set_vframes);
- ClassDB::bind_method(_MD("get_vframes"),&Sprite3D::get_vframes);
+ ClassDB::bind_method(D_METHOD("set_vframes","vframes"),&Sprite3D::set_vframes);
+ ClassDB::bind_method(D_METHOD("get_vframes"),&Sprite3D::get_vframes);
- ClassDB::bind_method(_MD("set_hframes","hframes"),&Sprite3D::set_hframes);
- ClassDB::bind_method(_MD("get_hframes"),&Sprite3D::get_hframes);
+ ClassDB::bind_method(D_METHOD("set_hframes","hframes"),&Sprite3D::set_hframes);
+ ClassDB::bind_method(D_METHOD("get_hframes"),&Sprite3D::get_hframes);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_texture","get_texture");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), "set_vframes","get_vframes");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), "set_hframes","get_hframes");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), "set_region","is_region");
+ ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), "set_region_rect","get_region_rect");
ADD_SIGNAL(MethodInfo("frame_changed"));
@@ -762,13 +764,13 @@ void AnimatedSprite3D::_draw() {
void AnimatedSprite3D::_bind_methods(){
- ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
- ClassDB::bind_method(_MD("get_sprite_frames:Texture"),&AnimatedSprite3D::get_sprite_frames);
- ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
- ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
+ ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
+ ClassDB::bind_method(D_METHOD("get_sprite_frames:Texture"),&AnimatedSprite3D::get_sprite_frames);
+ ClassDB::bind_method(D_METHOD("set_frame","frame"),&AnimatedSprite3D::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"),&AnimatedSprite3D::get_frame);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), "set_sprite_frames","get_sprite_frames");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame");
ADD_SIGNAL(MethodInfo("frame_changed"));
@@ -1130,7 +1132,7 @@ void AnimatedSprite3D::_notification(int p_what) {
//texture->draw_rect(ci,dst_rect,false,modulate);
texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate);
-// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
+ //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;
#endif
@@ -1188,7 +1190,7 @@ void AnimatedSprite3D::set_frame(int p_frame) {
frame=p_frame;
_reset_timeout();
- _queue_update();;
+ _queue_update();
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
@@ -1291,7 +1293,7 @@ void AnimatedSprite3D::set_animation(const StringName& p_animation){
_reset_timeout();
set_frame(0);
_change_notify();
- _queue_update();;
+ _queue_update();
}
StringName AnimatedSprite3D::get_animation() const{
@@ -1310,31 +1312,31 @@ String AnimatedSprite3D::get_configuration_warning() const {
void AnimatedSprite3D::_bind_methods() {
- ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
- ClassDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite3D::get_sprite_frames);
+ ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
+ ClassDB::bind_method(D_METHOD("get_sprite_frames:SpriteFrames"),&AnimatedSprite3D::get_sprite_frames);
- ClassDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite3D::set_animation);
- ClassDB::bind_method(_MD("get_animation"),&AnimatedSprite3D::get_animation);
+ ClassDB::bind_method(D_METHOD("set_animation","animation"),&AnimatedSprite3D::set_animation);
+ ClassDB::bind_method(D_METHOD("get_animation"),&AnimatedSprite3D::get_animation);
- ClassDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite3D::_set_playing);
- ClassDB::bind_method(_MD("_is_playing"),&AnimatedSprite3D::_is_playing);
+ ClassDB::bind_method(D_METHOD("_set_playing","playing"),&AnimatedSprite3D::_set_playing);
+ ClassDB::bind_method(D_METHOD("_is_playing"),&AnimatedSprite3D::_is_playing);
- ClassDB::bind_method(_MD("play","anim"),&AnimatedSprite3D::play,DEFVAL(StringName()));
- ClassDB::bind_method(_MD("stop"),&AnimatedSprite3D::stop);
- ClassDB::bind_method(_MD("is_playing"),&AnimatedSprite3D::is_playing);
+ ClassDB::bind_method(D_METHOD("play","anim"),&AnimatedSprite3D::play,DEFVAL(StringName()));
+ ClassDB::bind_method(D_METHOD("stop"),&AnimatedSprite3D::stop);
+ ClassDB::bind_method(D_METHOD("is_playing"),&AnimatedSprite3D::is_playing);
- ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
- ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
+ ClassDB::bind_method(D_METHOD("set_frame","frame"),&AnimatedSprite3D::set_frame);
+ ClassDB::bind_method(D_METHOD("get_frame"),&AnimatedSprite3D::get_frame);
- ClassDB::bind_method(_MD("_res_changed"),&AnimatedSprite3D::_res_changed);
+ ClassDB::bind_method(D_METHOD("_res_changed"),&AnimatedSprite3D::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
- ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), _SCS("_set_playing"),_SCS("_is_playing"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), "set_sprite_frames","get_sprite_frames");
+ ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), "set_animation","get_animation");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), "_set_playing","_is_playing");
}
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index f5d3957370..a14ce40495 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -185,7 +185,7 @@ public:
virtual Rect2 get_item_rect() const;
Sprite3D();
-// ~Sprite3D();
+ //~Sprite3D();
};
#if 0
@@ -215,7 +215,7 @@ public:
virtual Rect2 get_item_rect() const;
AnimatedSprite3D();
-// ~AnimatedSprite3D();
+ //~AnimatedSprite3D();
};
#endif
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index 1cb443225c..4b32c62d14 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -232,52 +232,52 @@ float VehicleWheel::get_friction_slip() const{
void VehicleWheel::_bind_methods() {
- ClassDB::bind_method(_MD("set_radius","length"),&VehicleWheel::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&VehicleWheel::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius","length"),&VehicleWheel::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&VehicleWheel::get_radius);
- ClassDB::bind_method(_MD("set_suspension_rest_length","length"),&VehicleWheel::set_suspension_rest_length);
- ClassDB::bind_method(_MD("get_suspension_rest_length"),&VehicleWheel::get_suspension_rest_length);
+ ClassDB::bind_method(D_METHOD("set_suspension_rest_length","length"),&VehicleWheel::set_suspension_rest_length);
+ ClassDB::bind_method(D_METHOD("get_suspension_rest_length"),&VehicleWheel::get_suspension_rest_length);
- ClassDB::bind_method(_MD("set_suspension_travel","length"),&VehicleWheel::set_suspension_travel);
- ClassDB::bind_method(_MD("get_suspension_travel"),&VehicleWheel::get_suspension_travel);
+ ClassDB::bind_method(D_METHOD("set_suspension_travel","length"),&VehicleWheel::set_suspension_travel);
+ ClassDB::bind_method(D_METHOD("get_suspension_travel"),&VehicleWheel::get_suspension_travel);
- ClassDB::bind_method(_MD("set_suspension_stiffness","length"),&VehicleWheel::set_suspension_stiffness);
- ClassDB::bind_method(_MD("get_suspension_stiffness"),&VehicleWheel::get_suspension_stiffness);
+ ClassDB::bind_method(D_METHOD("set_suspension_stiffness","length"),&VehicleWheel::set_suspension_stiffness);
+ ClassDB::bind_method(D_METHOD("get_suspension_stiffness"),&VehicleWheel::get_suspension_stiffness);
- ClassDB::bind_method(_MD("set_suspension_max_force","length"),&VehicleWheel::set_suspension_max_force);
- ClassDB::bind_method(_MD("get_suspension_max_force"),&VehicleWheel::get_suspension_max_force);
+ ClassDB::bind_method(D_METHOD("set_suspension_max_force","length"),&VehicleWheel::set_suspension_max_force);
+ ClassDB::bind_method(D_METHOD("get_suspension_max_force"),&VehicleWheel::get_suspension_max_force);
- ClassDB::bind_method(_MD("set_damping_compression","length"),&VehicleWheel::set_damping_compression);
- ClassDB::bind_method(_MD("get_damping_compression"),&VehicleWheel::get_damping_compression);
+ ClassDB::bind_method(D_METHOD("set_damping_compression","length"),&VehicleWheel::set_damping_compression);
+ ClassDB::bind_method(D_METHOD("get_damping_compression"),&VehicleWheel::get_damping_compression);
- ClassDB::bind_method(_MD("set_damping_relaxation","length"),&VehicleWheel::set_damping_relaxation);
- ClassDB::bind_method(_MD("get_damping_relaxation"),&VehicleWheel::get_damping_relaxation);
+ ClassDB::bind_method(D_METHOD("set_damping_relaxation","length"),&VehicleWheel::set_damping_relaxation);
+ ClassDB::bind_method(D_METHOD("get_damping_relaxation"),&VehicleWheel::get_damping_relaxation);
- ClassDB::bind_method(_MD("set_use_as_traction","enable"),&VehicleWheel::set_use_as_traction);
- ClassDB::bind_method(_MD("is_used_as_traction"),&VehicleWheel::is_used_as_traction);
+ ClassDB::bind_method(D_METHOD("set_use_as_traction","enable"),&VehicleWheel::set_use_as_traction);
+ ClassDB::bind_method(D_METHOD("is_used_as_traction"),&VehicleWheel::is_used_as_traction);
- ClassDB::bind_method(_MD("set_use_as_steering","enable"),&VehicleWheel::set_use_as_steering);
- ClassDB::bind_method(_MD("is_used_as_steering"),&VehicleWheel::is_used_as_steering);
+ ClassDB::bind_method(D_METHOD("set_use_as_steering","enable"),&VehicleWheel::set_use_as_steering);
+ ClassDB::bind_method(D_METHOD("is_used_as_steering"),&VehicleWheel::is_used_as_steering);
- ClassDB::bind_method(_MD("set_friction_slip","length"),&VehicleWheel::set_friction_slip);
- ClassDB::bind_method(_MD("get_friction_slip"),&VehicleWheel::get_friction_slip);
+ ClassDB::bind_method(D_METHOD("set_friction_slip","length"),&VehicleWheel::set_friction_slip);
+ ClassDB::bind_method(D_METHOD("get_friction_slip"),&VehicleWheel::get_friction_slip);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_traction"),_SCS("set_use_as_traction"),_SCS("is_used_as_traction"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_steering"),_SCS("set_use_as_steering"),_SCS("is_used_as_steering"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_traction"),"set_use_as_traction","is_used_as_traction");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_as_steering"),"set_use_as_steering","is_used_as_steering");
ADD_GROUP("Wheel","wheel_");
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_radius"),_SCS("set_radius"),_SCS("get_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_rest_length"),_SCS("set_suspension_rest_length"),_SCS("get_suspension_rest_length"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_friction_slip"),_SCS("set_friction_slip"),_SCS("get_friction_slip"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_radius"),"set_radius","get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_rest_length"),"set_suspension_rest_length","get_suspension_rest_length");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel_friction_slip"),"set_friction_slip","get_friction_slip");
ADD_GROUP("Suspension","suspension_");
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_travel"),_SCS("set_suspension_travel"),_SCS("get_suspension_travel"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_stiffness"),_SCS("set_suspension_stiffness"),_SCS("get_suspension_stiffness"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_max_force"),_SCS("set_suspension_max_force"),_SCS("get_suspension_max_force"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_travel"),"set_suspension_travel","get_suspension_travel");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_stiffness"),"set_suspension_stiffness","get_suspension_stiffness");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension_max_force"),"set_suspension_max_force","get_suspension_max_force");
ADD_GROUP("Damping","damping_");
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_compression"),_SCS("set_damping_compression"),_SCS("get_damping_compression"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_relaxation"),_SCS("set_damping_relaxation"),_SCS("get_damping_relaxation"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_compression"),"set_damping_compression","get_damping_compression");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping_relaxation"),"set_damping_relaxation","get_damping_relaxation");
}
@@ -340,10 +340,11 @@ void VehicleBody::_update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBody
wheel.m_raycastInfo.m_isInContact = false;
Transform chassisTrans = s->get_transform();
- //if (interpolatedTransform && (getRigidBody()->getMotionState()))
- //{
- // getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
- //}
+ /*
+ if (interpolatedTransform && (getRigidBody()->getMotionState())) {
+ getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
+ }
+ */
wheel.m_raycastInfo.m_hardPointWS = chassisTrans.xform( wheel.m_chassisConnectionPointCS );
//wheel.m_raycastInfo.m_hardPointWS+=s->get_linear_velocity()*s->get_step();
@@ -360,8 +361,8 @@ void VehicleBody::_update_wheel(int p_idx,PhysicsDirectBodyState *s) {
const Vector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
Vector3 fwd = up.cross(right);
fwd = fwd.normalized();
-// up = right.cross(fwd);
-// up.normalize();
+ //up = right.cross(fwd);
+ //up.normalize();
//rotate around steering over de wheelAxleWS
real_t steering = wheel.steers?m_steeringValue:0.0;
@@ -371,8 +372,10 @@ void VehicleBody::_update_wheel(int p_idx,PhysicsDirectBodyState *s) {
Basis rotatingMat(right,-wheel.m_rotation);
-// if (p_idx==1)
-// print_line("steeringMat " +steeringMat);
+ /*
+ if (p_idx==1)
+ print_line("steeringMat " +steeringMat);
+ */
Basis basis2(
right[0],up[0],fwd[0],
@@ -502,7 +505,7 @@ void VehicleBody::_update_suspension(PhysicsDirectBodyState *s)
if ( wheel_info.m_raycastInfo.m_isInContact )
{
real_t force;
- // Spring
+ //Spring
{
real_t susp_length = wheel_info.m_suspensionRestLength;
real_t current_length = wheel_info.m_raycastInfo.m_suspensionLength;
@@ -1023,32 +1026,32 @@ Vector3 VehicleBody::get_linear_velocity() const
void VehicleBody::_bind_methods(){
- ClassDB::bind_method(_MD("set_mass","mass"),&VehicleBody::set_mass);
- ClassDB::bind_method(_MD("get_mass"),&VehicleBody::get_mass);
+ ClassDB::bind_method(D_METHOD("set_mass","mass"),&VehicleBody::set_mass);
+ ClassDB::bind_method(D_METHOD("get_mass"),&VehicleBody::get_mass);
- ClassDB::bind_method(_MD("set_friction","friction"),&VehicleBody::set_friction);
- ClassDB::bind_method(_MD("get_friction"),&VehicleBody::get_friction);
+ ClassDB::bind_method(D_METHOD("set_friction","friction"),&VehicleBody::set_friction);
+ ClassDB::bind_method(D_METHOD("get_friction"),&VehicleBody::get_friction);
- ClassDB::bind_method(_MD("set_engine_force","engine_force"),&VehicleBody::set_engine_force);
- ClassDB::bind_method(_MD("get_engine_force"),&VehicleBody::get_engine_force);
+ ClassDB::bind_method(D_METHOD("set_engine_force","engine_force"),&VehicleBody::set_engine_force);
+ ClassDB::bind_method(D_METHOD("get_engine_force"),&VehicleBody::get_engine_force);
- ClassDB::bind_method(_MD("set_brake","brake"),&VehicleBody::set_brake);
- ClassDB::bind_method(_MD("get_brake"),&VehicleBody::get_brake);
+ ClassDB::bind_method(D_METHOD("set_brake","brake"),&VehicleBody::set_brake);
+ ClassDB::bind_method(D_METHOD("get_brake"),&VehicleBody::get_brake);
- ClassDB::bind_method(_MD("set_steering","steering"),&VehicleBody::set_steering);
- ClassDB::bind_method(_MD("get_steering"),&VehicleBody::get_steering);
+ ClassDB::bind_method(D_METHOD("set_steering","steering"),&VehicleBody::set_steering);
+ ClassDB::bind_method(D_METHOD("get_steering"),&VehicleBody::get_steering);
- ClassDB::bind_method(_MD("get_linear_velocity"),&VehicleBody::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"),&VehicleBody::get_linear_velocity);
- ClassDB::bind_method(_MD("_direct_state_changed"),&VehicleBody::_direct_state_changed);
+ ClassDB::bind_method(D_METHOD("_direct_state_changed"),&VehicleBody::_direct_state_changed);
ADD_GROUP("Motion","");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),_SCS("set_engine_force"),_SCS("get_engine_force"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"brake",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_brake"),_SCS("get_brake"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"steering",PROPERTY_HINT_RANGE,"-180,180.0,0.01"),_SCS("set_steering"),_SCS("get_steering"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),"set_engine_force","get_engine_force");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"brake",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),"set_brake","get_brake");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"steering",PROPERTY_HINT_RANGE,"-180,180.0,0.01"),"set_steering","get_steering");
ADD_GROUP("Mass","");
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),"set_mass","get_mass");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),"set_friction","get_friction");
}
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index cd627f8998..273e63d741 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -63,7 +63,7 @@ friend class VehicleBody;
VehicleBody *body;
-// btVector3 m_wheelAxleCS; // const or modified by steering ?
+ //btVector3 m_wheelAxleCS; // const or modified by steering ?
real_t m_steering;
real_t m_rotation;
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index 206421f939..0633846b5a 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -109,11 +109,11 @@ bool VisibilityNotifier::is_on_screen() const {
void VisibilityNotifier::_bind_methods(){
- ClassDB::bind_method(_MD("set_aabb","rect"),&VisibilityNotifier::set_aabb);
- ClassDB::bind_method(_MD("get_aabb"),&VisibilityNotifier::get_aabb);
- ClassDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier::is_on_screen);
+ ClassDB::bind_method(D_METHOD("set_aabb","rect"),&VisibilityNotifier::set_aabb);
+ ClassDB::bind_method(D_METHOD("get_aabb"),&VisibilityNotifier::get_aabb);
+ ClassDB::bind_method(D_METHOD("is_on_screen"),&VisibilityNotifier::is_on_screen);
- ADD_PROPERTY( PropertyInfo(Variant::RECT3,"aabb"),_SCS("set_aabb"),_SCS("get_aabb"));
+ ADD_PROPERTY( PropertyInfo(Variant::RECT3,"aabb"),"set_aabb","get_aabb");
ADD_SIGNAL( MethodInfo("camera_entered",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
ADD_SIGNAL( MethodInfo("camera_exited",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
@@ -125,6 +125,7 @@ void VisibilityNotifier::_bind_methods(){
VisibilityNotifier::VisibilityNotifier() {
aabb=Rect3(Vector3(-1,-1,-1),Vector3(2,2,2));
+ set_notify_transform(true);
}
@@ -267,12 +268,12 @@ void VisibilityEnabler::_node_removed(Node* p_node) {
void VisibilityEnabler::_bind_methods(){
- ClassDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler::set_enabler);
- ClassDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler::is_enabler_enabled);
- ClassDB::bind_method(_MD("_node_removed"),&VisibilityEnabler::_node_removed);
+ ClassDB::bind_method(D_METHOD("set_enabler","enabler","enabled"),&VisibilityEnabler::set_enabler);
+ ClassDB::bind_method(D_METHOD("is_enabler_enabled","enabler"),&VisibilityEnabler::is_enabler_enabled);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&VisibilityEnabler::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),"set_enabler","is_enabler_enabled", ENABLER_PAUSE_ANIMATIONS );
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),"set_enabler","is_enabler_enabled", ENABLER_FREEZE_BODIES);
BIND_CONSTANT( ENABLER_FREEZE_BODIES );
BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 466c273154..bbcd54b36b 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -45,7 +45,7 @@ void VisualInstance::_update_visibility() {
return;
_change_notify("visible");
- VS::get_singleton()->instance_set_visible(get_instance(),is_visible());
+ VS::get_singleton()->instance_set_visible(get_instance(),is_visible_in_tree());
}
@@ -102,7 +102,7 @@ void VisualInstance::_notification(int p_what) {
VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
VisualServer::get_singleton()->instance_set_room(instance,RID());
VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
- // VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
+ //VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -137,14 +137,14 @@ uint32_t VisualInstance::get_layer_mask() const {
void VisualInstance::_bind_methods() {
- ClassDB::bind_method(_MD("_get_visual_instance_rid"),&VisualInstance::_get_visual_instance_rid);
- ClassDB::bind_method(_MD("set_base","base"), &VisualInstance::set_base);
- ClassDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&VisualInstance::_get_visual_instance_rid);
+ ClassDB::bind_method(D_METHOD("set_base","base"), &VisualInstance::set_base);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"), &VisualInstance::get_layer_mask);
- ClassDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
+ ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_LAYERS_3D_RENDER), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_LAYERS_3D_RENDER), "set_layer_mask", "get_layer_mask");
}
@@ -162,6 +162,7 @@ VisualInstance::VisualInstance()
instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_attach_object_instance_ID( instance, get_instance_ID() );
layers=1;
+ set_notify_transform(true);
}
@@ -323,51 +324,51 @@ float GeometryInstance::get_extra_cull_margin() const{
void GeometryInstance::_bind_methods() {
- ClassDB::bind_method(_MD("set_material_override","material"), &GeometryInstance::set_material_override);
- ClassDB::bind_method(_MD("get_material_override"), &GeometryInstance::get_material_override);
+ ClassDB::bind_method(D_METHOD("set_material_override","material"), &GeometryInstance::set_material_override);
+ ClassDB::bind_method(D_METHOD("get_material_override"), &GeometryInstance::get_material_override);
- ClassDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
- ClassDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
+ ClassDB::bind_method(D_METHOD("set_flag","flag","value"), &GeometryInstance::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag","flag"), &GeometryInstance::get_flag);
- ClassDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
- ClassDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
+ ClassDB::bind_method(D_METHOD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
+ ClassDB::bind_method(D_METHOD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
- ClassDB::bind_method(_MD("set_lod_max_hysteresis","mode"), &GeometryInstance::set_lod_max_hysteresis);
- ClassDB::bind_method(_MD("get_lod_max_hysteresis"), &GeometryInstance::get_lod_max_hysteresis);
+ ClassDB::bind_method(D_METHOD("set_lod_max_hysteresis","mode"), &GeometryInstance::set_lod_max_hysteresis);
+ ClassDB::bind_method(D_METHOD("get_lod_max_hysteresis"), &GeometryInstance::get_lod_max_hysteresis);
- ClassDB::bind_method(_MD("set_lod_max_distance","mode"), &GeometryInstance::set_lod_max_distance);
- ClassDB::bind_method(_MD("get_lod_max_distance"), &GeometryInstance::get_lod_max_distance);
+ ClassDB::bind_method(D_METHOD("set_lod_max_distance","mode"), &GeometryInstance::set_lod_max_distance);
+ ClassDB::bind_method(D_METHOD("get_lod_max_distance"), &GeometryInstance::get_lod_max_distance);
- ClassDB::bind_method(_MD("set_lod_min_hysteresis","mode"), &GeometryInstance::set_lod_min_hysteresis);
- ClassDB::bind_method(_MD("get_lod_min_hysteresis"), &GeometryInstance::get_lod_min_hysteresis);
+ ClassDB::bind_method(D_METHOD("set_lod_min_hysteresis","mode"), &GeometryInstance::set_lod_min_hysteresis);
+ ClassDB::bind_method(D_METHOD("get_lod_min_hysteresis"), &GeometryInstance::get_lod_min_hysteresis);
- ClassDB::bind_method(_MD("set_lod_min_distance","mode"), &GeometryInstance::set_lod_min_distance);
- ClassDB::bind_method(_MD("get_lod_min_distance"), &GeometryInstance::get_lod_min_distance);
+ ClassDB::bind_method(D_METHOD("set_lod_min_distance","mode"), &GeometryInstance::set_lod_min_distance);
+ ClassDB::bind_method(D_METHOD("get_lod_min_distance"), &GeometryInstance::get_lod_min_distance);
- ClassDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
- ClassDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+ ClassDB::bind_method(D_METHOD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
+ ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
- ClassDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
+ ClassDB::bind_method(D_METHOD("get_aabb"),&GeometryInstance::get_aabb);
ADD_GROUP("Geometry","");
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
- ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_y_billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE_IN_ALL_ROOMS);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_in_baked_light"), _SCS("set_flag"), _SCS("get_flag"),FLAG_USE_BAKED_LIGHT);
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), "set_material_override", "get_material_override");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), "set_extra_cull_margin", "get_extra_cull_margin");
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_billboard"), "set_flag", "get_flag",FLAG_BILLBOARD);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_as_y_billboard"), "set_flag", "get_flag",FLAG_BILLBOARD_FIX_Y);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_depth_scale"), "set_flag", "get_flag",FLAG_DEPH_SCALE);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "visible_in_all_rooms"), "set_flag", "get_flag",FLAG_VISIBLE_IN_ALL_ROOMS);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag",FLAG_USE_BAKED_LIGHT);
ADD_GROUP("LOD","lod_");
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_distance"), _SCS("get_lod_min_distance"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_hysteresis"), _SCS("get_lod_min_hysteresis"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_distance"), _SCS("get_lod_max_distance"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_hysteresis"), _SCS("get_lod_max_hysteresis"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), "set_lod_min_distance", "get_lod_min_distance");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_min_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), "set_lod_min_hysteresis", "get_lod_min_hysteresis");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), "set_lod_max_distance", "get_lod_max_distance");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod_max_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), "set_lod_max_hysteresis", "get_lod_max_hysteresis");
-// ADD_SIGNAL( MethodInfo("visibility_changed"));
+ //ADD_SIGNAL( MethodInfo("visibility_changed"));
BIND_CONSTANT(FLAG_CAST_SHADOW );
BIND_CONSTANT(FLAG_BILLBOARD );
@@ -398,7 +399,7 @@ GeometryInstance::GeometryInstance() {
shadow_casting_setting=SHADOW_CASTING_SETTING_ON;
extra_cull_margin=0;
-// VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
+ //VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
}
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index 25ca74de9f..960356d9cf 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -62,7 +62,7 @@ void AnimationCache::_clear_cache() {
connected_nodes.front()->get()->disconnect("tree_exited",this,"_node_exit_tree");
connected_nodes.erase(connected_nodes.front());
}
- path_cache.clear();;
+ path_cache.clear();
cache_valid=false;
cache_dirty=true;
}
@@ -368,8 +368,8 @@ void AnimationCache::set_animation(const Ref<Animation>& p_animation) {
void AnimationCache::_bind_methods() {
- ClassDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree);
- ClassDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed);
+ ClassDB::bind_method(D_METHOD("_node_exit_tree"),&AnimationCache::_node_exit_tree);
+ ClassDB::bind_method(D_METHOD("_animation_changed"),&AnimationCache::_animation_changed);
}
void AnimationCache::set_root(Node* p_root) {
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index fa0700584c..e9f1904fe9 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -36,7 +36,7 @@ bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility
- set_speed(p_value);
+ set_speed_scale(p_value);
} else if (p_name==SceneStringNames::get_singleton()->playback_active) {
set_active(p_value);
@@ -118,17 +118,20 @@ bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const {
} else if (name=="blend_times") {
- Array array;
-
- array.resize(blend_times.size()*3);
- int idx=0;
+ Vector<BlendKey> keys;
for(Map<BlendKey, float >::Element *E=blend_times.front();E;E=E->next()) {
- array.set(idx*3+0,E->key().from);
- array.set(idx*3+1,E->key().to);
- array.set(idx*3+2,E->get());
- idx++;
+ keys.ordered_insert(E->key());
}
+
+ Array array;
+ for(int i=0;i<keys.size();i++) {
+
+ array.push_back(keys[i].from);
+ array.push_back(keys[i].to);
+ array.push_back(blend_times[keys[i]]);
+ }
+
r_ret=array;
} else if (name=="autoplay") {
r_ret=autoplay;
@@ -426,8 +429,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
Variant value=a->value_track_interpolate(i,p_time);
//thanks to trigger mode, this should be solved now..
- //if (p_delta==0 && value.get_type()==Variant::STRING)
- // continue; // doing this with strings is messy, should find another way
+ /*
+ if (p_delta==0 && value.get_type()==Variant::STRING)
+ continue; // doing this with strings is messy, should find another way
+ */
if (pa->accum_pass!=accum_pass) {
ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX );
cache_update_prop[cache_update_prop_size++]=pa;
@@ -474,7 +479,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
}
#endif
- static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(value));
+ static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad((double)value));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
@@ -583,35 +588,26 @@ void AnimationPlayer::_animation_process2(float p_delta) {
Playback &c=playback;
- float prev_blend=1.0;
accum_pass++;
- int pop_count=1;
- int pop=0; // if >0, then amount of elements to pop from the back
+ _animation_process_data(c.current,p_delta,1.0f);
-
- for (List<Blend>::Element *E=c.blend.back();E;E=E->prev(),pop_count++) {
+ List<Blend>::Element *prev = NULL;
+ for (List<Blend>::Element *E=c.blend.back();E;E=prev) {
Blend& b=E->get();
- _animation_process_data(b.data,p_delta,prev_blend);
-
- prev_blend=1.0-b.blend_left/b.blend_time;
+ float blend=b.blend_left/b.blend_time;
+ _animation_process_data(b.data,p_delta,blend);
b.blend_left-=Math::absf(speed_scale*p_delta);
+ prev = E->prev();
if (b.blend_left<0) {
- pop=pop_count;
+ c.blend.erase(E);
}
}
-
- while(pop--) {
-
- c.blend.pop_back();
- }
-
-
- _animation_process_data(c.current,p_delta,prev_blend);
+
}
@@ -688,7 +684,7 @@ void AnimationPlayer::_animation_update_transforms() {
}
#endif
- static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad(pa->value_accum));
+ static_cast<Node2D*>(pa->object)->set_rotation(Math::deg2rad((double)pa->value_accum));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
@@ -713,7 +709,7 @@ void AnimationPlayer::_animation_process(float p_delta) {
-// bool any_active=false;
+ //bool any_active=false;
if (playback.current.from) {
@@ -853,7 +849,7 @@ void AnimationPlayer::rename_animation(const StringName& p_name,const StringName
while(to_erase.size()) {
blend_times.erase(to_erase.front()->get());
- to_erase.pop_front();;
+ to_erase.pop_front();
}
while(to_insert.size()) {
@@ -1082,13 +1078,13 @@ void AnimationPlayer::stop_all() {
}
-void AnimationPlayer::set_speed(float p_speed) {
+void AnimationPlayer::set_speed_scale(float p_speed) {
speed_scale=p_speed;
}
-float AnimationPlayer::get_speed() const {
+float AnimationPlayer::get_speed_scale() const {
return speed_scale;
}
@@ -1291,67 +1287,67 @@ void AnimationPlayer::get_argument_options(const StringName& p_function,int p_id
void AnimationPlayer::_bind_methods() {
- ClassDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed);
- ClassDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&AnimationPlayer::_node_removed);
+ ClassDB::bind_method(D_METHOD("_animation_changed"),&AnimationPlayer::_animation_changed);
- ClassDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation);
- ClassDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation);
- ClassDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation);
- ClassDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation);
- ClassDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation);
- ClassDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list);
+ ClassDB::bind_method(D_METHOD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation);
+ ClassDB::bind_method(D_METHOD("remove_animation","name"),&AnimationPlayer::remove_animation);
+ ClassDB::bind_method(D_METHOD("rename_animation","name","newname"),&AnimationPlayer::rename_animation);
+ ClassDB::bind_method(D_METHOD("has_animation","name"),&AnimationPlayer::has_animation);
+ ClassDB::bind_method(D_METHOD("get_animation:Animation","name"),&AnimationPlayer::get_animation);
+ ClassDB::bind_method(D_METHOD("get_animation_list"),&AnimationPlayer::_get_animation_list);
- ClassDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next);
- ClassDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next);
+ ClassDB::bind_method(D_METHOD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next);
+ ClassDB::bind_method(D_METHOD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next);
- ClassDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time);
- ClassDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time);
+ ClassDB::bind_method(D_METHOD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time);
+ ClassDB::bind_method(D_METHOD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time);
- ClassDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time);
- ClassDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);
+ ClassDB::bind_method(D_METHOD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time);
+ ClassDB::bind_method(D_METHOD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);
- ClassDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
- ClassDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1));
- ClassDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
- ClassDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all);
- ClassDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing);
- ClassDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
- ClassDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation);
- ClassDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue);
- ClassDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue);
+ ClassDB::bind_method(D_METHOD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("stop_all"),&AnimationPlayer::stop_all);
+ ClassDB::bind_method(D_METHOD("is_playing"),&AnimationPlayer::is_playing);
+ ClassDB::bind_method(D_METHOD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
+ ClassDB::bind_method(D_METHOD("get_current_animation"),&AnimationPlayer::get_current_animation);
+ ClassDB::bind_method(D_METHOD("queue","name"),&AnimationPlayer::queue);
+ ClassDB::bind_method(D_METHOD("clear_queue"),&AnimationPlayer::clear_queue);
- ClassDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active);
- ClassDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active);
+ ClassDB::bind_method(D_METHOD("set_active","active"),&AnimationPlayer::set_active);
+ ClassDB::bind_method(D_METHOD("is_active"),&AnimationPlayer::is_active);
- ClassDB::bind_method(_MD("set_speed","speed"),&AnimationPlayer::set_speed);
- ClassDB::bind_method(_MD("get_speed"),&AnimationPlayer::get_speed);
+ ClassDB::bind_method(D_METHOD("set_speed_scale","speed"),&AnimationPlayer::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"),&AnimationPlayer::get_speed_scale);
- ClassDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay);
- ClassDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay);
+ ClassDB::bind_method(D_METHOD("set_autoplay","name"),&AnimationPlayer::set_autoplay);
+ ClassDB::bind_method(D_METHOD("get_autoplay"),&AnimationPlayer::get_autoplay);
- ClassDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root);
- ClassDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root);
+ ClassDB::bind_method(D_METHOD("set_root","path"),&AnimationPlayer::set_root);
+ ClassDB::bind_method(D_METHOD("get_root"),&AnimationPlayer::get_root);
- ClassDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false));
- ClassDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos);
+ ClassDB::bind_method(D_METHOD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_pos"),&AnimationPlayer::get_current_animation_pos);
- ClassDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation);
+ ClassDB::bind_method(D_METHOD("find_animation","animation:Animation"),&AnimationPlayer::find_animation);
- ClassDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches);
+ ClassDB::bind_method(D_METHOD("clear_caches"),&AnimationPlayer::clear_caches);
- ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode);
- ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode);
+ ClassDB::bind_method(D_METHOD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode);
+ ClassDB::bind_method(D_METHOD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode);
- ClassDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos);
- ClassDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length);
+ ClassDB::bind_method(D_METHOD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos);
+ ClassDB::bind_method(D_METHOD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length);
- ClassDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance);
+ ClassDB::bind_method(D_METHOD("advance","delta"),&AnimationPlayer::advance);
ADD_GROUP("Playback","playback_");
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time"));
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root_node"), _SCS("set_root"), _SCS("get_root"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_animation_process_mode", "get_animation_process_mode");
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time");
+ ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root_node"), "set_root", "get_root");
ADD_SIGNAL( MethodInfo("animation_finished", PropertyInfo(Variant::STRING,"name")) );
ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) );
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 94955bec60..7fab651213 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -142,7 +142,7 @@ private:
StringName from;
StringName to;
- bool operator<(const BlendKey& bk) const { return from==bk.from?to<bk.to:from<bk.from; }
+ bool operator<(const BlendKey& bk) const { return from==bk.from?String(to)<String(bk.to):String(from)<String(bk.from); }
};
@@ -271,8 +271,8 @@ public:
bool is_active() const;
bool is_valid() const;
- void set_speed(float p_speed);
- float get_speed() const;
+ void set_speed_scale(float p_speed);
+ float get_speed_scale() const;
void set_autoplay(const String& pname);
String get_autoplay() const;
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index dbcdb284be..d7e98ddd2b 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -214,7 +214,7 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value)
StringName src = connections[i*3+0];
StringName dst = connections[i*3+1];
int dst_in = connections[i*3+2];
- connect(src,dst,dst_in);
+ connect_nodes(src,dst,dst_in);
}
set_active(data.get_valid("active"));
@@ -506,10 +506,10 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
float rem = 0;
if (!an->animation.is_null()) {
- // float pos = an->time;
-// float delta = p_time;
+ //float pos = an->time;
+ //float delta = p_time;
- // const Animation *a = an->animation.operator->();
+ //const Animation *a = an->animation.operator->();
if (p_seek) {
an->time=p_time;
@@ -711,7 +711,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
else
rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_time*tsn->scale,false,p_fallback_weight,p_weights);
if (tsn->scale == 0)
- return INFINITY;
+ return Math_INF;
else
return rem / tsn->scale;
@@ -1496,17 +1496,17 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN
}
-Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) {
+Error AnimationTreePlayer::connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) {
ERR_FAIL_COND_V( !node_map.has(p_src_node) , ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V( !node_map.has(p_dst_node) , ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V( p_src_node==p_dst_node , ERR_INVALID_PARAMETER);
-// NodeBase *src = node_map[p_src_node];
+ //NodeBase *src = node_map[p_src_node];
NodeBase *dst = node_map[p_dst_node];
ERR_FAIL_INDEX_V( p_dst_input, dst->inputs.size(), ERR_INVALID_PARAMETER);
-// int oldval = dst->inputs[p_dst_input].node;
+ //int oldval = dst->inputs[p_dst_input].node;
for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
@@ -1538,7 +1538,7 @@ Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName
return OK;
}
-bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const {
+bool AnimationTreePlayer::are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const {
ERR_FAIL_COND_V( !node_map.has(p_src_node) , false);
ERR_FAIL_COND_V( !node_map.has(p_dst_node) , false);
@@ -1550,7 +1550,7 @@ bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const String
}
-void AnimationTreePlayer::disconnect(const StringName& p_node, int p_input) {
+void AnimationTreePlayer::disconnect_nodes(const StringName& p_node, int p_input) {
ERR_FAIL_COND( !node_map.has(p_node));
@@ -1643,7 +1643,7 @@ void AnimationTreePlayer::_recompute_caches(const StringName& p_node) {
if (nb->type==NODE_ANIMATION) {
AnimationNode *an = static_cast<AnimationNode*>(nb);
- an->tref.clear();;
+ an->tref.clear();
if (!an->animation.is_null()) {
@@ -1828,106 +1828,106 @@ Error AnimationTreePlayer::node_rename(const StringName& p_node,const StringName
void AnimationTreePlayer::_bind_methods() {
- ClassDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node);
+ ClassDB::bind_method(D_METHOD("add_node","type","id"),&AnimationTreePlayer::add_node);
- ClassDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists);
- ClassDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename);
+ ClassDB::bind_method(D_METHOD("node_exists","node"),&AnimationTreePlayer::node_exists);
+ ClassDB::bind_method(D_METHOD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename);
- ClassDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type);
- ClassDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count);
- ClassDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source);
+ ClassDB::bind_method(D_METHOD("node_get_type","id"),&AnimationTreePlayer::node_get_type);
+ ClassDB::bind_method(D_METHOD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count);
+ ClassDB::bind_method(D_METHOD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source);
- ClassDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation);
- ClassDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation);
+ ClassDB::bind_method(D_METHOD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation);
+ ClassDB::bind_method(D_METHOD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation);
- ClassDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
- ClassDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
- ClassDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
+ ClassDB::bind_method(D_METHOD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
+ ClassDB::bind_method(D_METHOD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
+ ClassDB::bind_method(D_METHOD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
- ClassDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
- ClassDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
+ ClassDB::bind_method(D_METHOD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
- ClassDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time);
- ClassDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time);
+ ClassDB::bind_method(D_METHOD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time);
- ClassDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart);
- ClassDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay);
- ClassDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
- ClassDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart);
- ClassDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay);
- ClassDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
+ ClassDB::bind_method(D_METHOD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart);
+ ClassDB::bind_method(D_METHOD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay);
+ ClassDB::bind_method(D_METHOD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
- ClassDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start);
- ClassDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop);
- ClassDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active);
- ClassDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path);
+ ClassDB::bind_method(D_METHOD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start);
+ ClassDB::bind_method(D_METHOD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop);
+ ClassDB::bind_method(D_METHOD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active);
+ ClassDB::bind_method(D_METHOD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path);
- ClassDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount);
- ClassDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount);
+ ClassDB::bind_method(D_METHOD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount);
+ ClassDB::bind_method(D_METHOD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount);
- ClassDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount);
- ClassDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount);
- ClassDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path);
+ ClassDB::bind_method(D_METHOD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount);
+ ClassDB::bind_method(D_METHOD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount);
+ ClassDB::bind_method(D_METHOD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path);
- ClassDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount);
- ClassDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount);
+ ClassDB::bind_method(D_METHOD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount);
+ ClassDB::bind_method(D_METHOD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount);
- ClassDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount);
- ClassDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount);
+ ClassDB::bind_method(D_METHOD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount);
+ ClassDB::bind_method(D_METHOD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount);
- ClassDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale);
- ClassDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale);
+ ClassDB::bind_method(D_METHOD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale);
+ ClassDB::bind_method(D_METHOD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale);
- ClassDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek);
+ ClassDB::bind_method(D_METHOD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek);
- ClassDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count);
- ClassDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count);
- ClassDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input);
+ ClassDB::bind_method(D_METHOD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count);
+ ClassDB::bind_method(D_METHOD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count);
+ ClassDB::bind_method(D_METHOD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input);
- ClassDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance);
- ClassDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance);
+ ClassDB::bind_method(D_METHOD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance);
+ ClassDB::bind_method(D_METHOD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance);
- ClassDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time);
- ClassDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time);
+ ClassDB::bind_method(D_METHOD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time);
+ ClassDB::bind_method(D_METHOD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time);
- ClassDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current);
- ClassDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current);
+ ClassDB::bind_method(D_METHOD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current);
+ ClassDB::bind_method(D_METHOD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current);
- ClassDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos);
- ClassDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos);
+ ClassDB::bind_method(D_METHOD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos);
+ ClassDB::bind_method(D_METHOD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos);
- ClassDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node);
- ClassDB::bind_method(_MD("connect","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect);
- ClassDB::bind_method(_MD("is_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::is_connected);
- ClassDB::bind_method(_MD("disconnect","id","dst_input_idx"),&AnimationTreePlayer::disconnect);
+ ClassDB::bind_method(D_METHOD("remove_node","id"),&AnimationTreePlayer::remove_node);
+ ClassDB::bind_method(D_METHOD("connect_nodes","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect_nodes);
+ ClassDB::bind_method(D_METHOD("are_nodes_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::are_nodes_connected);
+ ClassDB::bind_method(D_METHOD("disconnect_nodes","id","dst_input_idx"),&AnimationTreePlayer::disconnect_nodes);
- ClassDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active);
- ClassDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active);
+ ClassDB::bind_method(D_METHOD("set_active","enabled"),&AnimationTreePlayer::set_active);
+ ClassDB::bind_method(D_METHOD("is_active"),&AnimationTreePlayer::is_active);
- ClassDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path);
- ClassDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path);
+ ClassDB::bind_method(D_METHOD("set_base_path","path"),&AnimationTreePlayer::set_base_path);
+ ClassDB::bind_method(D_METHOD("get_base_path"),&AnimationTreePlayer::get_base_path);
- ClassDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player);
- ClassDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player);
+ ClassDB::bind_method(D_METHOD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player);
+ ClassDB::bind_method(D_METHOD("get_master_player"),&AnimationTreePlayer::get_master_player);
- ClassDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list);
+ ClassDB::bind_method(D_METHOD("get_node_list"),&AnimationTreePlayer::_get_node_list);
- ClassDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode);
- ClassDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode);
+ ClassDB::bind_method(D_METHOD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode);
+ ClassDB::bind_method(D_METHOD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode);
- ClassDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance);
+ ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationTreePlayer::advance);
- ClassDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset);
+ ClassDB::bind_method(D_METHOD("reset"),&AnimationTreePlayer::reset);
- ClassDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches);
+ ClassDB::bind_method(D_METHOD("recompute_caches"),&AnimationTreePlayer::recompute_caches);
ADD_GROUP("Playback","playback_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_animation_process_mode", "get_animation_process_mode");
BIND_CONSTANT( NODE_OUTPUT );
BIND_CONSTANT( NODE_ANIMATION );
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index ae2fe8c2bb..5e118be034 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -397,9 +397,9 @@ public:
void get_node_list(List<StringName> *p_node_list) const;
void remove_node(const StringName& p_node);
- Error connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input);
- bool is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const;
- void disconnect(const StringName& p_src_node, int p_input);
+ Error connect_nodes(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input);
+ bool are_nodes_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const;
+ void disconnect_nodes(const StringName& p_src_node, int p_input);
void set_base_path(const NodePath& p_path);
NodePath get_base_path() const;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index b2ae1fd3d5..c422e765b5 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -109,7 +109,7 @@ bool Tween::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
if (name=="playback/speed" || name=="speed") { //bw compatibility
- set_speed(p_value);
+ set_speed_scale(p_value);
} else if (name=="playback/active") {
set_active(p_value);
@@ -186,46 +186,46 @@ void Tween::_notification(int p_what) {
void Tween::_bind_methods() {
- ClassDB::bind_method(_MD("is_active"),&Tween::is_active );
- ClassDB::bind_method(_MD("set_active","active"),&Tween::set_active );
-
- ClassDB::bind_method(_MD("is_repeat"),&Tween::is_repeat );
- ClassDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat );
-
- ClassDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed);
- ClassDB::bind_method(_MD("get_speed"),&Tween::get_speed);
-
- ClassDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode);
- ClassDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode);
-
- ClassDB::bind_method(_MD("start"),&Tween::start );
- ClassDB::bind_method(_MD("reset","object","key"),&Tween::reset, DEFVAL("") );
- ClassDB::bind_method(_MD("reset_all"),&Tween::reset_all );
- ClassDB::bind_method(_MD("stop","object","key"),&Tween::stop, DEFVAL("") );
- ClassDB::bind_method(_MD("stop_all"),&Tween::stop_all );
- ClassDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") );
- ClassDB::bind_method(_MD("resume_all"),&Tween::resume_all );
- ClassDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") );
- ClassDB::bind_method(_MD("_remove","object","key","first_only"),&Tween::_remove );
- ClassDB::bind_method(_MD("remove_all"),&Tween::remove_all );
- ClassDB::bind_method(_MD("seek","time"),&Tween::seek );
- ClassDB::bind_method(_MD("tell"),&Tween::tell );
- ClassDB::bind_method(_MD("get_runtime"),&Tween::get_runtime );
-
- ClassDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
- ClassDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
- ClassDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ClassDB::bind_method(_MD("interpolate_deferred_callback","object","times_in_sec","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ClassDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
- ClassDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
- ClassDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
- ClassDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("is_active"),&Tween::is_active );
+ ClassDB::bind_method(D_METHOD("set_active","active"),&Tween::set_active );
+
+ ClassDB::bind_method(D_METHOD("is_repeat"),&Tween::is_repeat );
+ ClassDB::bind_method(D_METHOD("set_repeat","repeat"),&Tween::set_repeat );
+
+ ClassDB::bind_method(D_METHOD("set_speed_scale","speed"),&Tween::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"),&Tween::get_speed_scale);
+
+ ClassDB::bind_method(D_METHOD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode);
+ ClassDB::bind_method(D_METHOD("get_tween_process_mode"),&Tween::get_tween_process_mode);
+
+ ClassDB::bind_method(D_METHOD("start"),&Tween::start );
+ ClassDB::bind_method(D_METHOD("reset","object","key"),&Tween::reset, DEFVAL("") );
+ ClassDB::bind_method(D_METHOD("reset_all"),&Tween::reset_all );
+ ClassDB::bind_method(D_METHOD("stop","object","key"),&Tween::stop, DEFVAL("") );
+ ClassDB::bind_method(D_METHOD("stop_all"),&Tween::stop_all );
+ ClassDB::bind_method(D_METHOD("resume","object","key"),&Tween::resume, DEFVAL("") );
+ ClassDB::bind_method(D_METHOD("resume_all"),&Tween::resume_all );
+ ClassDB::bind_method(D_METHOD("remove","object","key"),&Tween::remove, DEFVAL("") );
+ ClassDB::bind_method(D_METHOD("_remove","object","key","first_only"),&Tween::_remove );
+ ClassDB::bind_method(D_METHOD("remove_all"),&Tween::remove_all );
+ ClassDB::bind_method(D_METHOD("seek","time"),&Tween::seek );
+ ClassDB::bind_method(D_METHOD("tell"),&Tween::tell );
+ ClassDB::bind_method(D_METHOD("get_runtime"),&Tween::get_runtime );
+
+ ClassDB::bind_method(D_METHOD("interpolate_property","object","property","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("interpolate_method","object","method","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("interpolate_callback","object","duration","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
+ ClassDB::bind_method(D_METHOD("interpolate_deferred_callback","object","duration","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
+ ClassDB::bind_method(D_METHOD("follow_property","object","property","initial_val","target","target_property","duration","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("follow_method","object","method","initial_val","target","target_method","duration","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("targeting_property","object","property","initial","initial_val","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
+ ClassDB::bind_method(D_METHOD("targeting_method","object","method","initial","initial_method","final_val","duration","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) );
ADD_SIGNAL( MethodInfo("tween_started", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) );
ADD_SIGNAL( MethodInfo("tween_completed", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_tween_process_mode", "get_tween_process_mode");
BIND_CONSTANT(TWEEN_PROCESS_FIXED);
BIND_CONSTANT(TWEEN_PROCESS_IDLE);
@@ -339,21 +339,21 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
Variant result;
#define APPLY_EQUATION(element)\
- r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.times_in_sec);
+ r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.duration);
switch(initial_val.get_type())
{
case Variant::BOOL:
- result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5;
+ result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5;
break;
case Variant::INT:
- result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec);
+ result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.duration);
break;
case Variant::REAL:
- result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec);
+ result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.duration);
break;
case Variant::VECTOR2:
@@ -405,9 +405,9 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
case Variant::TRANSFORM2D:
{
- Basis i = initial_val;
- Basis d = delta_val;
- Basis r;
+ Transform2D i = initial_val;
+ Transform2D d = delta_val;
+ Transform2D r;
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
@@ -577,9 +577,9 @@ void Tween::_tween_process(float p_delta) {
_apply_tween_value(data, data.initial_val);
}
- if(data.elapsed > (data.delay + data.times_in_sec)) {
+ if(data.elapsed > (data.delay + data.duration)) {
- data.elapsed = data.delay + data.times_in_sec;
+ data.elapsed = data.delay + data.duration;
data.finish = true;
}
@@ -697,12 +697,12 @@ void Tween::set_repeat(bool p_repeat) {
repeat = p_repeat;
}
-void Tween::set_speed(float p_speed) {
+void Tween::set_speed_scale(float p_speed) {
speed_scale=p_speed;
}
-float Tween::get_speed() const {
+float Tween::get_speed_scale() const {
return speed_scale;
}
@@ -871,10 +871,10 @@ bool Tween::seek(real_t p_time) {
data.finish = false;
continue;
}
- else if(data.elapsed >= (data.delay + data.times_in_sec)) {
+ else if(data.elapsed >= (data.delay + data.duration)) {
data.finish = true;
- data.elapsed = (data.delay + data.times_in_sec);
+ data.elapsed = (data.delay + data.duration);
} else
data.finish = false;
@@ -916,7 +916,7 @@ real_t Tween::get_runtime() const {
for(const List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
const InterpolateData& data = E->get();
- real_t t = data.delay + data.times_in_sec;
+ real_t t = data.delay + data.duration;
if(t > runtime)
runtime = t;
}
@@ -1035,7 +1035,7 @@ bool Tween::interpolate_property(Object *p_object
, String p_property
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1046,7 +1046,7 @@ bool Tween::interpolate_property(Object *p_object
, p_property
, p_initial_val
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1060,7 +1060,7 @@ bool Tween::interpolate_property(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1079,7 +1079,7 @@ bool Tween::interpolate_property(Object *p_object
data.key = p_property;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1095,7 +1095,7 @@ bool Tween::interpolate_method(Object *p_object
, String p_method
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1106,7 +1106,7 @@ bool Tween::interpolate_method(Object *p_object
, p_method
, p_initial_val
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1120,7 +1120,7 @@ bool Tween::interpolate_method(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1138,7 +1138,7 @@ bool Tween::interpolate_method(Object *p_object
data.key = p_method;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1151,7 +1151,7 @@ bool Tween::interpolate_method(Object *p_object
}
bool Tween::interpolate_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
) {
@@ -1159,7 +1159,7 @@ bool Tween::interpolate_callback(Object *p_object
if(pending_update != 0) {
_add_pending_command("interpolate_callback"
, p_object
- , p_times_in_sec
+ , p_duration
, p_callback
, p_arg1
, p_arg2
@@ -1172,7 +1172,7 @@ bool Tween::interpolate_callback(Object *p_object
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
- ERR_FAIL_COND_V(p_times_in_sec < 0, false);
+ ERR_FAIL_COND_V(p_duration < 0, false);
ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
@@ -1186,7 +1186,7 @@ bool Tween::interpolate_callback(Object *p_object
data.id = p_object->get_instance_ID();
data.key = p_callback;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.delay = 0;
int args=0;
@@ -1217,7 +1217,7 @@ bool Tween::interpolate_callback(Object *p_object
}
bool Tween::interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
) {
@@ -1225,7 +1225,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
if(pending_update != 0) {
_add_pending_command("interpolate_deferred_callback"
, p_object
- , p_times_in_sec
+ , p_duration
, p_callback
, p_arg1
, p_arg2
@@ -1237,7 +1237,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
}
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
- ERR_FAIL_COND_V(p_times_in_sec < 0, false);
+ ERR_FAIL_COND_V(p_duration < 0, false);
ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
@@ -1251,7 +1251,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object
data.id = p_object->get_instance_ID();
data.key = p_callback;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.delay = 0;
int args=0;
@@ -1286,7 +1286,7 @@ bool Tween::follow_property(Object *p_object
, Variant p_initial_val
, Object *p_target
, String p_target_property
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1298,7 +1298,7 @@ bool Tween::follow_property(Object *p_object
, p_initial_val
, p_target
, p_target_property
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1312,7 +1312,7 @@ bool Tween::follow_property(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_target == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1340,7 +1340,7 @@ bool Tween::follow_property(Object *p_object
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_ID();
data.target_key = p_target_property;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1354,7 +1354,7 @@ bool Tween::follow_method(Object *p_object
, Variant p_initial_val
, Object *p_target
, String p_target_method
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1366,7 +1366,7 @@ bool Tween::follow_method(Object *p_object
, p_initial_val
, p_target
, p_target_method
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1380,7 +1380,7 @@ bool Tween::follow_method(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_target == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_target), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1409,7 +1409,7 @@ bool Tween::follow_method(Object *p_object
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_ID();
data.target_key = p_target_method;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1423,7 +1423,7 @@ bool Tween::targeting_property(Object *p_object
, Object *p_initial
, String p_initial_property
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1435,7 +1435,7 @@ bool Tween::targeting_property(Object *p_object
, p_initial
, p_initial_property
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1449,7 +1449,7 @@ bool Tween::targeting_property(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1478,7 +1478,7 @@ bool Tween::targeting_property(Object *p_object
data.target_key = p_initial_property;
data.initial_val = initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
@@ -1496,7 +1496,7 @@ bool Tween::targeting_method(Object *p_object
, Object *p_initial
, String p_initial_method
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay
@@ -1508,7 +1508,7 @@ bool Tween::targeting_method(Object *p_object
, p_initial
, p_initial_method
, p_final_val
- , p_times_in_sec
+ , p_duration
, p_trans_type
, p_ease_type
, p_delay
@@ -1522,7 +1522,7 @@ bool Tween::targeting_method(Object *p_object
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
ERR_FAIL_COND_V(p_initial == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_initial), false);
- ERR_FAIL_COND_V(p_times_in_sec <= 0, false);
+ ERR_FAIL_COND_V(p_duration <= 0, false);
ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false);
ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false);
ERR_FAIL_COND_V(p_delay < 0, false);
@@ -1552,7 +1552,7 @@ bool Tween::targeting_method(Object *p_object
data.target_key = p_initial_method;
data.initial_val = initial_val;
data.final_val = p_final_val;
- data.times_in_sec = p_times_in_sec;
+ data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
data.delay = p_delay;
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index 01c5b5680e..07c2e90da2 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -92,7 +92,7 @@ private:
Variant final_val;
ObjectID target_id;
StringName target_key;
- real_t times_in_sec;
+ real_t duration;
TransitionType trans_type;
EaseType ease_type;
real_t delay;
@@ -165,8 +165,8 @@ public:
void set_tween_process_mode(TweenProcessMode p_mode);
TweenProcessMode get_tween_process_mode() const;
- void set_speed(float p_speed);
- float get_speed() const;
+ void set_speed_scale(float p_speed);
+ float get_speed_scale() const;
bool start();
bool reset(Object *p_node, String p_key);
@@ -186,7 +186,7 @@ public:
, String p_property
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -196,20 +196,20 @@ public:
, String p_method
, Variant p_initial_val
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
);
bool interpolate_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
);
bool interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
+ , real_t p_duration
, String p_callback
, VARIANT_ARG_DECLARE
);
@@ -219,7 +219,7 @@ public:
, Variant p_initial_val
, Object *p_target
, String p_target_property
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -230,7 +230,7 @@ public:
, Variant p_initial_val
, Object *p_target
, String p_target_method
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -241,7 +241,7 @@ public:
, Object *p_initial
, String p_initial_property
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
@@ -252,7 +252,7 @@ public:
, Object *p_initial
, String p_initial_method
, Variant p_final_val
- , real_t p_times_in_sec
+ , real_t p_duration
, TransitionType p_trans_type
, EaseType p_ease_type
, real_t p_delay = 0
diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp
index 5ba9673014..25a27252f5 100644
--- a/scene/animation/tween_interpolaters.cpp
+++ b/scene/animation/tween_interpolaters.cpp
@@ -262,7 +262,8 @@ namespace cubic {
static real_t out(real_t t, real_t b, real_t c, real_t d)
{
- return c * ((t = t / d - 1) * t * t + 1) + b;
+ t = t / d - 1;
+ return c * (t * t * t + 1) + b;
}
static real_t in_out(real_t t, real_t b, real_t c, real_t d)
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
new file mode 100644
index 0000000000..e646810387
--- /dev/null
+++ b/scene/audio/audio_player.cpp
@@ -0,0 +1,301 @@
+#include "audio_player.h"
+
+
+void AudioPlayer::_mix_audio() {
+
+ if (!stream_playback.is_valid()) {
+ return;
+ }
+
+ if (!active) {
+ return;
+ }
+
+ if (setseek>=0.0) {
+ stream_playback->start(setseek);
+ setseek=-1.0; //reset seek
+
+ }
+
+ int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);
+
+ //get data
+ AudioFrame *buffer = mix_buffer.ptr();
+ int buffer_size = mix_buffer.size();
+
+ //mix
+ stream_playback->mix(buffer,1.0,buffer_size);
+
+ //multiply volume interpolating to avoid clicks if this changes
+ float vol = Math::db2linear(mix_volume_db);
+ float vol_inc = (Math::db2linear(volume_db) - vol)/float(buffer_size);
+
+ for(int i=0;i<buffer_size;i++) {
+ buffer[i]*=vol;
+ vol+=vol_inc;
+ }
+ //set volume for next mix
+ mix_volume_db = volume_db;
+
+ AudioFrame * targets[3]={NULL,NULL,NULL};
+
+ if (AudioServer::get_singleton()->get_speaker_mode()==AudioServer::SPEAKER_MODE_STEREO) {
+ targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,0);
+ } else {
+ switch(mix_target) {
+ case MIX_TARGET_STEREO: {
+ targets[0]=AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,1);
+ } break;
+ case MIX_TARGET_SURROUND: {
+ targets[0]=AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,1);
+ targets[1]=AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,2);
+ if (AudioServer::get_singleton()->get_speaker_mode()==AudioServer::SPEAKER_SURROUND_71) {
+ targets[2]=AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,3);
+ }
+ } break;
+ case MIX_TARGET_CENTER: {
+ targets[0]=AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index,0);
+ } break;
+
+ }
+ }
+
+ for(int c=0;c<3;c++) {
+ if (!targets[c])
+ break;
+ for(int i=0;i<buffer_size;i++) {
+ targets[c][i]+=buffer[i];
+ }
+ }
+
+
+}
+
+void AudioPlayer::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+
+ 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);
+
+ }
+}
+
+void AudioPlayer::set_stream(Ref<AudioStream> p_stream) {
+
+ 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> AudioPlayer::get_stream() const {
+
+ return stream;
+}
+
+void AudioPlayer::set_volume_db(float p_volume) {
+
+ volume_db=p_volume;
+}
+float AudioPlayer::get_volume_db() const {
+
+ return volume_db;
+}
+
+void AudioPlayer::play(float p_from_pos) {
+
+ if (stream_playback.is_valid()) {
+ mix_volume_db=volume_db; //reset volume ramp
+ setseek=p_from_pos;
+ active=true;
+ }
+}
+
+void AudioPlayer::seek(float p_seconds) {
+
+ if (stream_playback.is_valid()) {
+ setseek=p_seconds;
+ }
+}
+
+void AudioPlayer::stop() {
+
+ if (stream_playback.is_valid()) {
+ active=false;
+ }
+
+
+}
+
+bool AudioPlayer::is_playing() const {
+
+ if (stream_playback.is_valid()) {
+ return active && stream_playback->is_playing();
+ }
+
+ return false;
+}
+
+float AudioPlayer::get_pos() {
+
+ if (stream_playback.is_valid()) {
+ return stream_playback->get_pos();
+ }
+
+ return 0;
+}
+
+void AudioPlayer::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 AudioPlayer::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 AudioPlayer::set_autoplay(bool p_enable) {
+
+ autoplay=p_enable;
+}
+bool AudioPlayer::is_autoplay_enabled() {
+
+ return autoplay;
+}
+
+void AudioPlayer::set_mix_target(MixTarget p_target) {
+
+ mix_target=p_target;
+}
+
+AudioPlayer::MixTarget AudioPlayer::get_mix_target() const{
+
+ return mix_target;
+}
+
+void AudioPlayer::_set_playing(bool p_enable) {
+
+ if (p_enable)
+ play();
+ else
+ stop();
+}
+bool AudioPlayer::_is_active() const {
+
+ return active;
+}
+
+
+void AudioPlayer::_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 AudioPlayer::_bus_layout_changed() {
+
+ _change_notify();
+}
+
+void AudioPlayer::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_stream","stream:AudioStream"),&AudioPlayer::set_stream);
+ ClassDB::bind_method(D_METHOD("get_stream"),&AudioPlayer::get_stream);
+
+ ClassDB::bind_method(D_METHOD("set_volume_db","volume_db"),&AudioPlayer::set_volume_db);
+ ClassDB::bind_method(D_METHOD("get_volume_db"),&AudioPlayer::get_volume_db);
+
+ ClassDB::bind_method(D_METHOD("play","from_pos"),&AudioPlayer::play,DEFVAL(0.0));
+ ClassDB::bind_method(D_METHOD("seek","to_pos"),&AudioPlayer::seek);
+ ClassDB::bind_method(D_METHOD("stop"),&AudioPlayer::stop);
+
+ ClassDB::bind_method(D_METHOD("is_playing"),&AudioPlayer::is_playing);
+ ClassDB::bind_method(D_METHOD("get_pos"),&AudioPlayer::get_pos);
+
+ ClassDB::bind_method(D_METHOD("set_bus","bus"),&AudioPlayer::set_bus);
+ ClassDB::bind_method(D_METHOD("get_bus"),&AudioPlayer::get_bus);
+
+ ClassDB::bind_method(D_METHOD("set_autoplay","enable"),&AudioPlayer::set_autoplay);
+ ClassDB::bind_method(D_METHOD("is_autoplay_enabled"),&AudioPlayer::is_autoplay_enabled);
+
+ ClassDB::bind_method(D_METHOD("set_mix_target","mix_target"),&AudioPlayer::set_mix_target);
+ ClassDB::bind_method(D_METHOD("get_mix_target"),&AudioPlayer::get_mix_target);
+
+ ClassDB::bind_method(D_METHOD("_set_playing","enable"),&AudioPlayer::_set_playing);
+ ClassDB::bind_method(D_METHOD("_is_active"),&AudioPlayer::_is_active);
+
+ ClassDB::bind_method(D_METHOD("_bus_layout_changed"),&AudioPlayer::_bus_layout_changed);
+
+
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"stream",PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"),"set_stream","get_stream") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"volume_db",PROPERTY_HINT_RANGE,"-80,24"),"set_volume_db","get_volume_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::INT,"mix_target",PROPERTY_HINT_ENUM,"Stereo,Surround,Center"),"set_mix_target","get_mix_target");
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"bus",PROPERTY_HINT_ENUM,""),"set_bus","get_bus");
+
+}
+
+AudioPlayer::AudioPlayer() {
+
+ mix_volume_db=0;
+ volume_db=0;
+ autoplay=false;
+ setseek=-1;
+ active=false;
+ mix_target=MIX_TARGET_STEREO;
+
+ AudioServer::get_singleton()->connect("bus_layout_changed",this,"_bus_layout_changed");
+}
+
+
+
+AudioPlayer::~AudioPlayer() {
+
+
+}
+
diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h
new file mode 100644
index 0000000000..249e5d0381
--- /dev/null
+++ b/scene/audio/audio_player.h
@@ -0,0 +1,75 @@
+#ifndef AUDIOPLAYER_H
+#define AUDIOPLAYER_H
+
+#include "scene/main/node.h"
+#include "servers/audio/audio_stream.h"
+
+
+class AudioPlayer : public Node {
+
+ GDCLASS( AudioPlayer, Node )
+
+public:
+
+ enum MixTarget {
+ MIX_TARGET_STEREO,
+ MIX_TARGET_SURROUND,
+ MIX_TARGET_CENTER
+ };
+private:
+ Ref<AudioStreamPlayback> stream_playback;
+ Ref<AudioStream> stream;
+ Vector<AudioFrame> mix_buffer;
+
+ volatile float setseek;
+ volatile bool active;
+
+ float mix_volume_db;
+ float volume_db;
+ bool autoplay;
+ StringName bus;
+
+ MixTarget mix_target;
+
+ void _mix_audio();
+ static void _mix_audios(void *self) { reinterpret_cast<AudioPlayer*>(self)->_mix_audio(); }
+
+ void _set_playing(bool p_enable);
+ bool _is_active() const;
+
+ void _bus_layout_changed();
+
+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_volume_db(float p_volume);
+ float get_volume_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_mix_target(MixTarget p_target);
+ MixTarget get_mix_target() const;
+
+ AudioPlayer();
+ ~AudioPlayer();
+};
+
+VARIANT_ENUM_CAST(AudioPlayer::MixTarget)
+#endif // AUDIOPLAYER_H
diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp
deleted file mode 100644
index c46f4e3b89..0000000000
--- a/scene/audio/event_player.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/*************************************************************************/
-/* event_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "event_player.h"
-
-
-void EventPlayer::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- //set_idle_process(false); //don't annoy
- if (playback.is_valid() && autoplay && !get_tree()->is_editor_hint())
- play();
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- stop(); //wathever it may be doing, stop
- } break;
- }
-}
-
-
-
-void EventPlayer::set_stream(const Ref<EventStream> &p_stream) {
-
- stop();
- stream=p_stream;
- if (stream.is_valid())
- playback=stream->instance_playback();
- else
- playback.unref();
-
- if (playback.is_valid()) {
-
- playback->set_loop(loops);
- playback->set_paused(paused);
- playback->set_volume(volume);
- for(int i=0;i<(MIN(MAX_CHANNELS,stream->get_channel_count()));i++)
- playback->set_channel_volume(i,channel_volume[i]);
- }
-
-
-}
-
-Ref<EventStream> EventPlayer::get_stream() const {
-
- return stream;
-}
-
-
-void EventPlayer::play() {
-
- ERR_FAIL_COND(!is_inside_tree());
- if (playback.is_null()) {
- return;
- }
- if (playback->is_playing()) {
- AudioServer::get_singleton()->lock();
- stop();
- AudioServer::get_singleton()->unlock();
- }
-
- AudioServer::get_singleton()->lock();
- playback->play();
- AudioServer::get_singleton()->unlock();
-
-}
-
-void EventPlayer::stop() {
-
- if (!is_inside_tree())
- return;
- if (playback.is_null())
- return;
-
- AudioServer::get_singleton()->lock();
- playback->stop();
- AudioServer::get_singleton()->unlock();
-}
-
-bool EventPlayer::is_playing() const {
-
- if (playback.is_null())
- return false;
-
- return playback->is_playing();
-}
-
-void EventPlayer::set_loop(bool p_enable) {
-
- loops=p_enable;
- if (playback.is_null())
- return;
- playback->set_loop(loops);
-
-}
-bool EventPlayer::has_loop() const {
-
- return loops;
-}
-
-void EventPlayer::set_volume(float p_volume) {
-
- volume=p_volume;
- if (playback.is_valid())
- playback->set_volume(volume);
-}
-
-float EventPlayer::get_volume() const {
-
- return volume;
-}
-
-
-void EventPlayer::set_volume_db(float p_db) {
-
- if (p_db<-79)
- set_volume(0);
- else
- set_volume(Math::db2linear(p_db));
-}
-
-float EventPlayer::get_volume_db() const {
-
- if (volume==0)
- return -80;
- else
- return Math::linear2db(volume);
-}
-
-void EventPlayer::set_pitch_scale(float p_pitch_scale) {
-
- pitch_scale=p_pitch_scale;
- if (playback.is_valid())
- playback->set_pitch_scale(pitch_scale);
-}
-
-float EventPlayer::get_pitch_scale() const {
-
- return pitch_scale;
-}
-
-void EventPlayer::set_tempo_scale(float p_tempo_scale) {
-
- tempo_scale=p_tempo_scale;
- if (playback.is_valid())
- playback->set_tempo_scale(tempo_scale);
-}
-
-float EventPlayer::get_tempo_scale() const {
-
- return tempo_scale;
-}
-
-
-String EventPlayer::get_stream_name() const {
-
- if (stream.is_null())
- return "<No Stream>";
- return stream->get_name();
-
-}
-
-int EventPlayer::get_loop_count() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_loop_count();
-
-}
-
-float EventPlayer::get_pos() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_pos();
-
-}
-
-float EventPlayer::get_length() const {
-
- if (stream.is_null())
- return 0;
- return stream->get_length();
-}
-void EventPlayer::seek_pos(float p_time) {
-
- if (playback.is_null())
- return;
- return playback->seek_pos(p_time);
-
-}
-
-void EventPlayer::set_autoplay(bool p_enable) {
-
- autoplay=p_enable;
-}
-
-bool EventPlayer::has_autoplay() const {
-
- return autoplay;
-}
-
-void EventPlayer::set_paused(bool p_paused) {
-
- paused=p_paused;
- if (playback.is_valid())
- playback->set_paused(p_paused);
-}
-
-bool EventPlayer::is_paused() const {
-
- return paused;
-}
-
-void EventPlayer::_set_play(bool p_play) {
-
- _play=p_play;
- if (is_inside_tree()) {
- if(_play)
- play();
- else
- stop();
- }
-
-}
-
-bool EventPlayer::_get_play() const{
-
- return _play;
-}
-
-void EventPlayer::set_channel_volume(int p_channel,float p_volume) {
-
- ERR_FAIL_INDEX(p_channel,MAX_CHANNELS);
- channel_volume[p_channel]=p_volume;
- if (playback.is_valid())
- playback->set_channel_volume(p_channel,p_volume);
-}
-
-float EventPlayer::get_channel_volume(int p_channel) const{
-
- ERR_FAIL_INDEX_V(p_channel,MAX_CHANNELS,0);
- return channel_volume[p_channel];
-
-}
-
-float EventPlayer::get_channel_last_note_time(int p_channel) const {
-
- if (playback.is_valid())
- return playback->get_last_note_time(p_channel);
-
- return 0;
-}
-
-void EventPlayer::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_stream","stream:EventStream"),&EventPlayer::set_stream);
- ClassDB::bind_method(_MD("get_stream:EventStream"),&EventPlayer::get_stream);
-
- ClassDB::bind_method(_MD("play"),&EventPlayer::play);
- ClassDB::bind_method(_MD("stop"),&EventPlayer::stop);
-
- ClassDB::bind_method(_MD("is_playing"),&EventPlayer::is_playing);
-
- ClassDB::bind_method(_MD("set_paused","paused"),&EventPlayer::set_paused);
- ClassDB::bind_method(_MD("is_paused"),&EventPlayer::is_paused);
-
- ClassDB::bind_method(_MD("set_loop","enabled"),&EventPlayer::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&EventPlayer::has_loop);
-
- ClassDB::bind_method(_MD("set_volume","volume"),&EventPlayer::set_volume);
- ClassDB::bind_method(_MD("get_volume"),&EventPlayer::get_volume);
-
- ClassDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&EventPlayer::set_pitch_scale);
- ClassDB::bind_method(_MD("get_pitch_scale"),&EventPlayer::get_pitch_scale);
-
- ClassDB::bind_method(_MD("set_tempo_scale","tempo_scale"),&EventPlayer::set_tempo_scale);
- ClassDB::bind_method(_MD("get_tempo_scale"),&EventPlayer::get_tempo_scale);
-
- ClassDB::bind_method(_MD("set_volume_db","db"),&EventPlayer::set_volume_db);
- ClassDB::bind_method(_MD("get_volume_db"),&EventPlayer::get_volume_db);
-
- ClassDB::bind_method(_MD("get_stream_name"),&EventPlayer::get_stream_name);
- ClassDB::bind_method(_MD("get_loop_count"),&EventPlayer::get_loop_count);
-
- ClassDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos);
- ClassDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos);
-
- ClassDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
-
- ClassDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay);
- ClassDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay);
-
- ClassDB::bind_method(_MD("set_channel_volume","channel","channel_volume"),&EventPlayer::set_channel_volume);
- ClassDB::bind_method(_MD("get_channel_volume","channel"),&EventPlayer::get_channel_volume);
- ClassDB::bind_method(_MD("get_channel_last_note_time","channel"),&EventPlayer::get_channel_last_note_time);
-
- ClassDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play);
- ClassDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play);
-
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"EventStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "tempo_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
-}
-
-
-EventPlayer::EventPlayer() {
-
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- pitch_scale=1.0;
- tempo_scale=1.0;
- for(int i=0;i<MAX_CHANNELS;i++)
- channel_volume[i]=1.0;
-
-}
-
-EventPlayer::~EventPlayer() {
-
-
-}
diff --git a/scene/audio/event_player.h b/scene/audio/event_player.h
deleted file mode 100644
index 715017e0d6..0000000000
--- a/scene/audio/event_player.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*************************************************************************/
-/* event_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 EVENT_PLAYER_H
-#define EVENT_PLAYER_H
-
-
-#include "scene/main/node.h"
-#include "scene/resources/event_stream.h"
-class EventPlayer : public Node {
-
- GDCLASS(EventPlayer,Node);
-
-
- enum {
- MAX_CHANNELS=256
- };
-
- Ref<EventStreamPlayback> playback;
- Ref<EventStream> stream;
- bool paused;
- bool autoplay;
- bool loops;
- float volume;
-
- float tempo_scale;
- float pitch_scale;
-
- float channel_volume[MAX_CHANNELS];
- bool _play;
- void _set_play(bool p_play);
- bool _get_play() const;
-protected:
- void _notification(int p_what);
-
- static void _bind_methods();
-
-public:
-
- void set_stream(const Ref<EventStream> &p_stream);
- Ref<EventStream> get_stream() const;
-
- void play();
- void stop();
- bool is_playing() const;
-
- void set_paused(bool p_paused);
- bool is_paused() const;
-
- void set_loop(bool p_enable);
- bool has_loop() const;
-
- void set_volume(float p_vol);
- float get_volume() const;
-
- void set_volume_db(float p_db);
- float get_volume_db() const;
-
- void set_pitch_scale(float p_scale);
- float get_pitch_scale() const;
-
- void set_tempo_scale(float p_scale);
- float get_tempo_scale() const;
-
- String get_stream_name() const;
-
- int get_loop_count() const;
-
- float get_pos() const;
- void seek_pos(float p_time);
- float get_length() const;
- void set_autoplay(bool p_vol);
- bool has_autoplay() const;
-
- void set_channel_volume(int p_channel,float p_volume);
- float get_channel_volume(int p_channel) const;
-
- float get_channel_last_note_time(int p_channel) const;
-
- EventPlayer();
- ~EventPlayer();
-};
-
-#endif // EVENT_PLAYER_H
diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp
deleted file mode 100644
index ba2d379311..0000000000
--- a/scene/audio/sample_player.cpp
+++ /dev/null
@@ -1,718 +0,0 @@
-/*************************************************************************/
-/* sample_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "sample_player.h"
-
-#include "servers/audio_server.h"
-
-
-bool SamplePlayer::_set(const StringName& p_name, const Variant& p_value) {
-
- String name=p_name;
-
- if (name=="play/play") {
- if (library.is_valid()) {
-
- String what=p_value;
- if (what=="")
- stop_all();
- else
- play(what);
-
- played_back=what;
- }
- } else if (name=="config/samples")
- set_sample_library(p_value);
- else if (name=="config/polyphony")
- set_polyphony(p_value);
- else if (name.begins_with("default/")) {
-
- String what=name.right(8);
-
- if (what=="volume_db")
- set_default_volume_db(p_value);
- else if (what=="pitch_scale")
- set_default_pitch_scale(p_value);
- else if (what=="pan")
- _default.pan=p_value;
- else if (what=="depth")
- _default.depth=p_value;
- else if (what=="height")
- _default.height=p_value;
- else if (what=="filter/type")
- _default.filter_type=FilterType(p_value.operator int());
- else if (what=="filter/cutoff")
- _default.filter_cutoff=p_value;
- else if (what=="filter/resonance")
- _default.filter_resonance=p_value;
- else if (what=="filter/gain")
- _default.filter_gain=p_value;
- else if (what=="reverb_room")
- _default.reverb_room=ReverbRoomType(p_value.operator int());
- else if (what=="reverb_send")
- _default.reverb_send=p_value;
- else if (what=="chorus_send")
- _default.chorus_send=p_value;
- else
- return false;
-
-
- } else
- return false;
-
- return true;
-}
-
-bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
-
-
- String name=p_name;
-
- if (name=="play/play") {
- r_ret=played_back;
- } else if (name=="config/polyphony") {
- r_ret= get_polyphony();
- } else if (name=="config/samples") {
-
- r_ret= get_sample_library();
- } else if (name.begins_with("default/")) {
-
- String what=name.right(8);
-
- if (what=="volume_db")
- r_ret= get_default_volume_db();
- else if (what=="pitch_scale")
- r_ret= get_default_pitch_scale();
- else if (what=="pan")
- r_ret= _default.pan;
- else if (what=="depth")
- r_ret= _default.depth;
- else if (what=="height")
- r_ret= _default.height;
- else if (what=="filter/type")
- r_ret= _default.filter_type;
- else if (what=="filter/cutoff")
- r_ret= _default.filter_cutoff;
- else if (what=="filter/resonance")
- r_ret= _default.filter_resonance;
- else if (what=="filter/gain")
- r_ret= _default.filter_gain;
- else if (what=="reverb_room")
- r_ret= _default.reverb_room;
- else if (what=="reverb_send")
- r_ret= _default.reverb_send;
- else if (what=="chorus_send")
- r_ret= _default.chorus_send;
- else
- return false;
-
-
- } else
- return false;
-
- return true;
-}
-
-void SamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
-
- String en="";
- if (library.is_valid()) {
- List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
- ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
-
- en+=",";
- en+=E->get();
- }
- }
-
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
- p_list->push_back( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1"));
- p_list->push_back( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/pitch_scale", PROPERTY_HINT_RANGE, "0.01,48,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/depth", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/height", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::INT, "default/filter/type", PROPERTY_HINT_ENUM, "Disabled,Lowpass,Bandpass,Highpass,Notch,Peak,BandLimit,LowShelf,HighShelf"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/cutoff", PROPERTY_HINT_RANGE, "20,16384.0,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/resonance", PROPERTY_HINT_RANGE, "0,4,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/gain", PROPERTY_HINT_RANGE, "0,2,0.01"));
- p_list->push_back( PropertyInfo( Variant::INT, "default/reverb_room", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/reverb_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/chorus_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
-
-
-}
-
-
-SamplePlayer::Voice::Voice() {
-
- voice=AudioServer::get_singleton()->voice_create();
- clear();
-}
-
-
-void SamplePlayer::Voice::clear() {
-
- check=0;
-
- mix_rate=44100;
- volume=1;
- pan=0;
- pan_depth=0;
- pan_height=0;
- filter_type=FILTER_NONE;
- filter_cutoff=0;
- filter_resonance=0;
- chorus_send=0;
- reverb_room=REVERB_HALL;
- reverb_send=0;
- active=false;
-
-}
-SamplePlayer::Voice::~Voice() {
-
- AudioServer::get_singleton()->free(voice);
-}
-
-
-void SamplePlayer::set_polyphony(int p_voice_count) {
-
- ERR_FAIL_COND( p_voice_count <1 || p_voice_count >0xFFFE );
-
- voices.resize(p_voice_count);
-}
-
-int SamplePlayer::get_polyphony() const {
-
- return voices.size();
-}
-
-SamplePlayer::VoiceID SamplePlayer::play(const String& p_name,bool unique) {
-
- if (library.is_null())
- return INVALID_VOICE_ID;
- ERR_FAIL_COND_V( !library->has_sample(p_name), INVALID_VOICE_ID );
-
- Ref<Sample> sample = library->get_sample(p_name);
- float vol_change = library->sample_get_volume_db(p_name);
- float pitch_change = library->sample_get_pitch_scale(p_name);
-
- last_check++;
- last_id = (last_id + 1) % voices.size();
-
- Voice&v = voices[last_id];
- v.clear();
-
-
- v.mix_rate=sample->get_mix_rate()*(_default.pitch_scale*pitch_change);
- v.sample_mix_rate=sample->get_mix_rate();
- v.check=last_check;
- v.volume=Math::db2linear(_default.volume_db+vol_change);
- v.pan=_default.pan;
- v.pan_depth=_default.depth;
- v.pan_height=_default.height;
- v.filter_type=_default.filter_type;
- v.filter_cutoff=_default.filter_cutoff;
- v.filter_resonance=_default.filter_resonance;
- v.filter_gain=_default.filter_gain;
- v.chorus_send=_default.chorus_send;
- v.reverb_room=_default.reverb_room;
- v.reverb_send=_default.reverb_send;
-
- AudioServer::get_singleton()->voice_play(v.voice,sample->get_rid());
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
- AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height);
- AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)v.filter_type,v.filter_cutoff,v.filter_resonance,v.filter_gain);
- AudioServer::get_singleton()->voice_set_chorus(v.voice,v.chorus_send);
- AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)v.reverb_room,v.reverb_send);
-
- v.active=true;
-
- if (unique) {
-
- for(int i=0;i<voices.size();i++) {
-
- if (!voices[i].active || uint32_t(i)==last_id)
- continue;
-
- AudioServer::get_singleton()->voice_stop(voices[i].voice);
-
- voices[i].clear();
- }
-
- }
-
- return last_id | (last_check<<16);
-}
-
-void SamplePlayer::stop_all() {
-
-
- for(int i=0;i<voices.size();i++) {
-
- if (!voices[i].active)
- continue;
-
- AudioServer::get_singleton()->voice_stop(voices[i].voice);
- voices[i].clear();
- }
-
-}
-
-#define _GET_VOICE\
- uint32_t voice=p_voice&0xFFFF;\
- ERR_FAIL_COND(voice >= (uint32_t)voices.size());\
- Voice &v=voices[voice];\
- if (v.check!=uint32_t(p_voice>>16))\
- return;\
- ERR_FAIL_COND(!v.active);
-
-void SamplePlayer::stop(VoiceID p_voice) {
-
- _GET_VOICE
-
- AudioServer::get_singleton()->voice_stop(v.voice);
- v.active=false;
-
-}
-
-void SamplePlayer::set_mix_rate(VoiceID p_voice, int p_mix_rate) {
-
- _GET_VOICE
-
- v.mix_rate=p_mix_rate;
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
-
-}
-void SamplePlayer::set_pitch_scale(VoiceID p_voice, float p_pitch_scale) {
-
- _GET_VOICE
-
- v.mix_rate=v.sample_mix_rate*p_pitch_scale;
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
-
-}
-void SamplePlayer::set_volume(VoiceID p_voice, float p_volume) {
-
-
- _GET_VOICE
- v.volume=p_volume;
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
-
-}
-
-void SamplePlayer::set_volume_db(VoiceID p_voice, float p_db) {
-
- //@TODO handle 0 volume as -80db or something
- _GET_VOICE
- v.volume=Math::db2linear(p_db);
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
-
-}
-
-void SamplePlayer::set_pan(VoiceID p_voice, float p_pan,float p_pan_depth,float p_pan_height) {
-
- _GET_VOICE
- v.pan=p_pan;
- v.pan_depth=p_pan_depth;
- v.pan_height=p_pan_height;
-
- AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height);
-
-}
-
-void SamplePlayer::set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) {
-
- _GET_VOICE
- v.filter_type=p_filter;
- v.filter_cutoff=p_cutoff;
- v.filter_resonance=p_resonance;
- v.filter_gain=p_gain;
-
- AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)p_filter,p_cutoff,p_resonance);
-
-}
-void SamplePlayer::set_chorus(VoiceID p_voice,float p_send) {
-
- _GET_VOICE
- v.chorus_send=p_send;
-
- AudioServer::get_singleton()->voice_set_chorus(v.voice,p_send);
-
-}
-void SamplePlayer::set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send) {
-
- _GET_VOICE
- v.reverb_room=p_room;
- v.reverb_send=p_send;
-
- AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)p_room,p_send);
-
-}
-
-#define _GET_VOICE_V(m_ret)\
- uint32_t voice=p_voice&0xFFFF;\
- ERR_FAIL_COND_V(voice >= (uint32_t)voices.size(),m_ret);\
- const Voice &v=voices[voice];\
- if (v.check!=(p_voice>>16))\
- return m_ret;\
- ERR_FAIL_COND_V(!v.active,m_ret);
-
-
-int SamplePlayer::get_mix_rate(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.mix_rate;
-}
-float SamplePlayer::get_pitch_scale(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
- return v.sample_mix_rate/(float)v.mix_rate;
-}
-float SamplePlayer::get_volume(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
- return v.volume;
-}
-
-
-float SamplePlayer::get_volume_db(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
- return Math::linear2db(v.volume);
-}
-
-float SamplePlayer::get_pan(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
- return v.pan;
-}
-float SamplePlayer::get_pan_depth(VoiceID p_voice) const {
-
-
- _GET_VOICE_V(0);
- return v.pan_depth;
-}
-float SamplePlayer::get_pan_height(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.pan_height;
-}
-SamplePlayer::FilterType SamplePlayer::get_filter_type(VoiceID p_voice) const {
-
- _GET_VOICE_V(FILTER_NONE);
-
- return v.filter_type;
-}
-float SamplePlayer::get_filter_cutoff(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.filter_cutoff;
-}
-float SamplePlayer::get_filter_resonance(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.filter_resonance;
-}
-
-float SamplePlayer::get_filter_gain(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.filter_gain;
-}
-float SamplePlayer::get_chorus(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.chorus_send;
-}
-SamplePlayer::ReverbRoomType SamplePlayer::get_reverb_room(VoiceID p_voice) const {
-
- _GET_VOICE_V(REVERB_SMALL);
-
- return v.reverb_room;
-}
-
-float SamplePlayer::get_reverb(VoiceID p_voice) const {
-
- _GET_VOICE_V(0);
-
- return v.reverb_send;
-}
-
-bool SamplePlayer::is_voice_active(VoiceID p_voice) const {
-
- _GET_VOICE_V(false);
- return v.active && AudioServer::get_singleton()->voice_is_active(v.voice);
-
-}
-bool SamplePlayer::is_active() const {
-
- for(int i=0;i<voices.size();i++) {
-
- if (voices[i].active && AudioServer::get_singleton()->voice_is_active(voices[i].voice))
- return true;
-
-
- }
-
- return false;
-}
-
-
-
-void SamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) {
-
- library=p_library;
- _change_notify();
-}
-
-Ref<SampleLibrary> SamplePlayer::get_sample_library() const {
-
- return library;
-}
-
-
-
-void SamplePlayer::set_default_pitch_scale(float p_pitch_scale) {
-
- _default.pitch_scale=p_pitch_scale;
-}
-void SamplePlayer::set_default_volume(float p_volume) {
-
- _default.volume_db=Math::linear2db(p_volume);
-}
-void SamplePlayer::set_default_volume_db(float p_db) {
-
- _default.volume_db=p_db;
-}
-void SamplePlayer::set_default_pan(float p_pan,float p_pan_depth,float p_pan_height) {
-
- _default.pan=p_pan;
- _default.depth=p_pan_depth;
- _default.height=p_pan_height;
-
-}
-void SamplePlayer::set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) {
-
- _default.filter_type=p_filter;
- _default.filter_cutoff=p_cutoff;
- _default.filter_resonance=p_resonance;
- _default.filter_gain=p_gain;
-}
-void SamplePlayer::set_default_chorus(float p_send) {
-
- _default.chorus_send=p_send;
-
-}
-void SamplePlayer::set_default_reverb(ReverbRoomType p_room,float p_send) {
-
- _default.reverb_room=p_room;
- _default.reverb_send=p_send;
-}
-
-float SamplePlayer::get_default_volume() const {
-
- return Math::db2linear(_default.volume_db);
-}
-float SamplePlayer::get_default_volume_db() const {
-
- return _default.volume_db;
-}
-float SamplePlayer::get_default_pitch_scale() const {
-
- return _default.pitch_scale;
-}
-
-
-float SamplePlayer::get_default_pan() const {
-
- return _default.pan;
-}
-float SamplePlayer::get_default_pan_depth() const {
-
- return _default.depth;
-}
-float SamplePlayer::get_default_pan_height() const {
-
- return _default.height;
-}
-SamplePlayer::FilterType SamplePlayer::get_default_filter_type() const {
-
- return _default.filter_type;
-}
-float SamplePlayer::get_default_filter_cutoff() const {
-
- return _default.filter_cutoff;
-}
-float SamplePlayer::get_default_filter_resonance() const {
-
- return _default.filter_resonance;
-}
-float SamplePlayer::get_default_filter_gain() const {
-
- return _default.filter_gain;
-}
-float SamplePlayer::get_default_chorus() const {
-
- return _default.chorus_send;
-}
-SamplePlayer::ReverbRoomType SamplePlayer::get_default_reverb_room() const {
-
- return _default.reverb_room;
-}
-float SamplePlayer::get_default_reverb() const {
-
- return _default.reverb_send;
-}
-
-String SamplePlayer::get_configuration_warning() const {
-
- if (library.is_null()) {
- return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SamplePlayer to play sound.");
- }
-
- return String();
-}
-
-void SamplePlayer::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library );
- ClassDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library );
-
- ClassDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony );
- ClassDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony );
-
- ClassDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) );
- ClassDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop );
- ClassDB::bind_method(_MD("stop_all"),&SamplePlayer::stop_all );
-
- ClassDB::bind_method(_MD("set_mix_rate","voice","hz"),&SamplePlayer::set_mix_rate );
- ClassDB::bind_method(_MD("set_pitch_scale","voice","ratio"),&SamplePlayer::set_pitch_scale );
- ClassDB::bind_method(_MD("set_volume","voice","volume"),&SamplePlayer::set_volume );
- ClassDB::bind_method(_MD("set_volume_db","voice","db"),&SamplePlayer::set_volume_db );
- ClassDB::bind_method(_MD("set_pan","voice","pan","depth","height"),&SamplePlayer::set_pan,DEFVAL(0),DEFVAL(0) );
- ClassDB::bind_method(_MD("set_filter","voice","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_filter,DEFVAL(0) );
- ClassDB::bind_method(_MD("set_chorus","voice","send"),&SamplePlayer::set_chorus );
- ClassDB::bind_method(_MD("set_reverb","voice","room_type","send"),&SamplePlayer::set_reverb );
-
- ClassDB::bind_method(_MD("get_mix_rate","voice"),&SamplePlayer::get_mix_rate );
- ClassDB::bind_method(_MD("get_pitch_scale","voice"),&SamplePlayer::get_pitch_scale );
- ClassDB::bind_method(_MD("get_volume","voice"),&SamplePlayer::get_volume );
- ClassDB::bind_method(_MD("get_volume_db","voice"),&SamplePlayer::get_volume_db );
- ClassDB::bind_method(_MD("get_pan","voice"),&SamplePlayer::get_pan );
- ClassDB::bind_method(_MD("get_pan_depth","voice"),&SamplePlayer::get_pan_depth );
- ClassDB::bind_method(_MD("get_pan_height","voice"),&SamplePlayer::get_pan_height );
- ClassDB::bind_method(_MD("get_filter_type","voice"),&SamplePlayer::get_filter_type );
- ClassDB::bind_method(_MD("get_filter_cutoff","voice"),&SamplePlayer::get_filter_cutoff );
- ClassDB::bind_method(_MD("get_filter_resonance","voice"),&SamplePlayer::get_filter_resonance );
- ClassDB::bind_method(_MD("get_filter_gain","voice"),&SamplePlayer::get_filter_gain );
- ClassDB::bind_method(_MD("get_chorus","voice"),&SamplePlayer::get_chorus );
- ClassDB::bind_method(_MD("get_reverb_room","voice"),&SamplePlayer::get_reverb_room );
- ClassDB::bind_method(_MD("get_reverb","voice"),&SamplePlayer::get_reverb );
-
- ClassDB::bind_method(_MD("set_default_pitch_scale","ratio"),&SamplePlayer::set_default_pitch_scale );
- ClassDB::bind_method(_MD("set_default_volume","volume"),&SamplePlayer::set_default_volume );
- ClassDB::bind_method(_MD("set_default_volume_db","db"),&SamplePlayer::set_default_volume_db );
- ClassDB::bind_method(_MD("set_default_pan","pan","depth","height"),&SamplePlayer::set_default_pan,DEFVAL(0),DEFVAL(0) );
- ClassDB::bind_method(_MD("set_default_filter","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_default_filter,DEFVAL(0) );
- ClassDB::bind_method(_MD("set_default_chorus","send"),&SamplePlayer::set_default_chorus );
- ClassDB::bind_method(_MD("set_default_reverb","room_type","send"),&SamplePlayer::set_default_reverb );
-
- ClassDB::bind_method(_MD("get_default_pitch_scale"),&SamplePlayer::get_default_pitch_scale );
- ClassDB::bind_method(_MD("get_default_volume"),&SamplePlayer::get_default_volume );
- ClassDB::bind_method(_MD("get_default_volume_db"),&SamplePlayer::get_default_volume_db );
- ClassDB::bind_method(_MD("get_default_pan"),&SamplePlayer::get_default_pan );
- ClassDB::bind_method(_MD("get_default_pan_depth"),&SamplePlayer::get_default_pan_depth );
- ClassDB::bind_method(_MD("get_default_pan_height"),&SamplePlayer::get_default_pan_height );
- ClassDB::bind_method(_MD("get_default_filter_type"),&SamplePlayer::get_default_filter_type );
- ClassDB::bind_method(_MD("get_default_filter_cutoff"),&SamplePlayer::get_default_filter_cutoff );
- ClassDB::bind_method(_MD("get_default_filter_resonance"),&SamplePlayer::get_default_filter_resonance );
- ClassDB::bind_method(_MD("get_default_filter_gain"),&SamplePlayer::get_default_filter_gain );
- ClassDB::bind_method(_MD("get_default_chorus"),&SamplePlayer::get_default_chorus );
- ClassDB::bind_method(_MD("get_default_reverb_room"),&SamplePlayer::get_default_reverb_room );
- ClassDB::bind_method(_MD("get_default_reverb"),&SamplePlayer::get_default_reverb );
-
- ClassDB::bind_method(_MD("is_active"),&SamplePlayer::is_active );
- ClassDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer::is_voice_active );
-
- BIND_CONSTANT( FILTER_NONE);
- BIND_CONSTANT( FILTER_LOWPASS);
- BIND_CONSTANT( FILTER_BANDPASS);
- BIND_CONSTANT( FILTER_HIPASS);
- BIND_CONSTANT( FILTER_NOTCH);
- BIND_CONSTANT( FILTER_PEAK);
- BIND_CONSTANT( FILTER_BANDLIMIT); ///< cutoff is LP resonace is HP
- BIND_CONSTANT( FILTER_LOW_SHELF);
- BIND_CONSTANT( FILTER_HIGH_SHELF);
-
- BIND_CONSTANT( REVERB_SMALL );
- BIND_CONSTANT( REVERB_MEDIUM );
- BIND_CONSTANT( REVERB_LARGE );
- BIND_CONSTANT( REVERB_HALL );
-
- BIND_CONSTANT( INVALID_VOICE_ID );
-
-}
-
-
-SamplePlayer::SamplePlayer() {
-
- voices.resize(1);
-
- _default.pitch_scale=1;
- _default.volume_db=0;
- _default.pan=0;
- _default.depth=0;
- _default.height=0;
- _default.filter_type=FILTER_NONE;
- _default.filter_cutoff=5000;
- _default.filter_resonance=1;
- _default.filter_gain=1;
- _default.chorus_send=0;
- _default.reverb_room=REVERB_LARGE;
- _default.reverb_send=0;
- last_id=0;
- last_check=0;
-
-
-}
-
-SamplePlayer::~SamplePlayer() {
-
-
-}
diff --git a/scene/audio/sample_player.h b/scene/audio/sample_player.h
deleted file mode 100644
index 8c4e6418aa..0000000000
--- a/scene/audio/sample_player.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*************************************************************************/
-/* sample_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SAMPLE_PLAYER_H
-#define SAMPLE_PLAYER_H
-
-#include "scene/main/node.h"
-#include "scene/resources/sample_library.h"
-
-class SamplePlayer : public Node {
-
- GDCLASS( SamplePlayer, Node );
- OBJ_CATEGORY("Audio Nodes");
-public:
-
-
- enum FilterType {
- FILTER_NONE,
- FILTER_LOWPASS,
- FILTER_BANDPASS,
- FILTER_HIPASS,
- FILTER_NOTCH,
- FILTER_PEAK,
- FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP
- FILTER_LOW_SHELF,
- FILTER_HIGH_SHELF,
- };
-
- enum ReverbRoomType {
-
- REVERB_SMALL,
- REVERB_MEDIUM,
- REVERB_LARGE,
- REVERB_HALL
- };
-
- enum {
-
- INVALID_VOICE_ID=0xFFFFFFFF
- };
-
- typedef uint32_t VoiceID;
-
-private:
-
- Ref<SampleLibrary> library;
-
- struct Voice {
-
- RID voice;
- uint32_t check;
- bool active;
-
- int sample_mix_rate;
- int mix_rate;
- float volume;
- float pan;
- float pan_depth;
- float pan_height;
- FilterType filter_type;
- float filter_cutoff;
- float filter_resonance;
- float filter_gain;
- float chorus_send;
- ReverbRoomType reverb_room;
- float reverb_send;
-
- void clear();
- Voice();
- ~Voice();
- };
-
- Vector<Voice> voices;
-
- struct Default {
-
- float reverb_send;
- float pitch_scale;
- float volume_db;
- float pan;
- float depth;
- float height;
- FilterType filter_type;
- float filter_cutoff;
- float filter_resonance;
- float filter_gain;
- float chorus_send;
- ReverbRoomType reverb_room;
-
- } _default;
-
- uint32_t last_id;
- uint16_t last_check;
- String played_back;
-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;
-
- static void _bind_methods();
-
-public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
- Ref<SampleLibrary> get_sample_library() const;
-
- void set_polyphony(int p_voice_count);
- int get_polyphony() const;
-
- VoiceID play(const String& p_name,bool unique=false);
- void stop(VoiceID p_voice);
- void stop_all();
- bool is_voice_active(VoiceID) const;
- bool is_active() const;
-
- void set_mix_rate(VoiceID p_voice, int p_mix_rate);
- void set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
- void set_volume(VoiceID p_voice, float p_volume);
- void set_volume_db(VoiceID p_voice, float p_db);
- void set_pan(VoiceID p_voice, float p_pan,float p_pan_depth=0,float p_pan_height=0);
- void set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain);
- void set_chorus(VoiceID p_voice,float p_send);
- void set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send);
-
- int get_mix_rate(VoiceID p_voice) const;
- float get_pitch_scale(VoiceID p_voice) const;
- float get_volume(VoiceID p_voice) const;
- float get_volume_db(VoiceID p_voice) const;
-
- float get_pan(VoiceID p_voice) const;
- float get_pan_depth(VoiceID p_voice) const;
- float get_pan_height(VoiceID p_voice) const;
- FilterType get_filter_type(VoiceID p_voice) const;
- float get_filter_cutoff(VoiceID p_voice) const;
- float get_filter_resonance(VoiceID p_voice) const;
- float get_filter_gain(VoiceID p_voice) const;
- float get_chorus(VoiceID p_voice) const;
- ReverbRoomType get_reverb_room(VoiceID p_voice) const;
- float get_reverb(VoiceID p_voice) const;
-
-
-
- void set_default_pitch_scale(float p_pitch_scale);
- void set_default_volume(float p_volume);
- void set_default_volume_db(float p_db);
- void set_default_pan(float p_pan,float p_pan_depth=0,float p_pan_height=0);
- void set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain);
- void set_default_chorus(float p_send);
- void set_default_reverb(ReverbRoomType p_room,float p_send);
-
- float get_default_volume() const;
- float get_default_volume_db() const;
- float get_default_pitch_scale() const;
- float get_default_pan() const;
- float get_default_pan_depth() const;
- float get_default_pan_height() const;
- FilterType get_default_filter_type() const;
- float get_default_filter_cutoff() const;
- float get_default_filter_resonance() const;
- float get_default_filter_gain() const;
- float get_default_chorus() const;
- ReverbRoomType get_default_reverb_room() const;
- float get_default_reverb() const;
-
- String get_configuration_warning() const;
-
- SamplePlayer();
- ~SamplePlayer();
-};
-
-VARIANT_ENUM_CAST( SamplePlayer::FilterType );
-VARIANT_ENUM_CAST( SamplePlayer::ReverbRoomType );
-
-#endif // SAMPLE_PLAYER_H
diff --git a/scene/audio/sound_room_params.cpp b/scene/audio/sound_room_params.cpp
deleted file mode 100644
index d08bc5d6b8..0000000000
--- a/scene/audio/sound_room_params.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*************************************************************************/
-/* sound_room_params.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "sound_room_params.h"
-
-#include "scene/main/viewport.h"
-
-#ifndef _3D_DISABLED
-void SoundRoomParams::_update_sound_room() {
-
- if (!room.is_valid())
- return;
-
- for(int i=0;i<PARAM_MAX;i++) {
-
- SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(i),params[i]);
-
- }
-
- SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(reverb));
- SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,force_params_for_all_sources);
-}
-
-
-void SoundRoomParams::_notification(int p_what) {
-
-
- switch(p_what) {
-
-
- case NOTIFICATION_ENTER_TREE: {
-//#if 0
- Node *n=this;
- Room *room_instance=NULL;
- while(n) {
-
- room_instance=n->cast_to<Room>();
- if (room_instance) {
-
- break;
- }
- if (n->cast_to<Viewport>())
- break;
-
- n=n->get_parent();
- }
-
-
- if (room_instance) {
- room=room_instance->get_sound_room();
- } else {
- room=get_viewport()->find_world()->get_sound_space();
- }
-
- _update_sound_room();
-//#endif
-
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- room=RID();
-
- } break;
- }
-}
-
-
-void SoundRoomParams::set_param(Params p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
- if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(p_param),p_value);
-}
-
-float SoundRoomParams::get_param(Params p_param) const {
-
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
- return params[p_param];
-}
-
-
-void SoundRoomParams::set_reverb_mode(Reverb p_mode) {
-
- ERR_FAIL_INDEX(p_mode,4);
- reverb=p_mode;
- if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(p_mode));
-}
-
-SoundRoomParams::Reverb SoundRoomParams::get_reverb_mode() const {
-
- return reverb;
-}
-
-
-void SoundRoomParams::set_force_params_to_all_sources(bool p_force) {
-
- force_params_for_all_sources=p_force;
- if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,p_force);
-}
-
-bool SoundRoomParams::is_forcing_params_to_all_sources() {
-
- return force_params_for_all_sources;
-}
-
-
-void SoundRoomParams::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_param","param","value"),&SoundRoomParams::set_param );
- ClassDB::bind_method(_MD("get_param","param"),&SoundRoomParams::get_param );
-
- ClassDB::bind_method(_MD("set_reverb_mode","reverb_mode","value"),&SoundRoomParams::set_reverb_mode );
- ClassDB::bind_method(_MD("get_reverb_mode","reverb_mode"),&SoundRoomParams::get_reverb_mode );
-
- ClassDB::bind_method(_MD("set_force_params_to_all_sources","enabled"),&SoundRoomParams::set_force_params_to_all_sources );
- ClassDB::bind_method(_MD("is_forcing_params_to_all_sources"),&SoundRoomParams::is_forcing_params_to_all_sources );
-
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "reverb/mode", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"), _SCS("set_reverb_mode"), _SCS("get_reverb_mode") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/speed_of_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPEED_OF_SOUND_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/doppler_factor",PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DOPPLER_FACTOR );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_scale_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_SCALE_DB );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/reverb_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_REVERB_SEND );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/chorus_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_CHORUS_SEND );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_SCALE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_cutoff",PROPERTY_HINT_RANGE, "30,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_CUTOFF );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_floor_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_FLOOR_DB );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_ratio_exp",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_RATIO_EXP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_reverb_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_REVERB_SCALE );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "force_to_all_sources"),_SCS("set_force_params_to_all_sources"),_SCS("is_forcing_params_to_all_sources") );
-
-}
-
-
-SoundRoomParams::SoundRoomParams() {
-
- reverb=REVERB_HALL;
- params[PARAM_SPEED_OF_SOUND_SCALE]=1;
- params[PARAM_DOPPLER_FACTOR]=1.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_VOLUME_SCALE_DB]=0;
- params[PARAM_REVERB_SEND]=0;
- params[PARAM_CHORUS_SEND]=0;
- params[PARAM_ATTENUATION_SCALE]=1.0;
- params[PARAM_ATTENUATION_HF_CUTOFF]=5000;
- params[PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0;
- params[PARAM_ATTENUATION_HF_RATIO_EXP]=1.0;
- params[PARAM_ATTENUATION_REVERB_SCALE]=0.0;
- force_params_for_all_sources=false;
-}
-#endif
diff --git a/scene/audio/sound_room_params.h b/scene/audio/sound_room_params.h
deleted file mode 100644
index 3cdffda652..0000000000
--- a/scene/audio/sound_room_params.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*************************************************************************/
-/* sound_room_params.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SOUND_ROOM_PARAMS_H
-#define SOUND_ROOM_PARAMS_H
-
-#include "scene/main/node.h"
-#include "servers/spatial_sound_server.h"
-
-
-#ifndef _3D_DISABLED
-
-#include "scene/3d/room_instance.h"
-class SoundRoomParams : public Node {
-
- GDCLASS( SoundRoomParams, Node );
-public:
-
- enum Params {
- PARAM_SPEED_OF_SOUND_SCALE=SpatialSoundServer::ROOM_PARAM_SPEED_OF_SOUND_SCALE,
- PARAM_DOPPLER_FACTOR=SpatialSoundServer::ROOM_PARAM_DOPPLER_FACTOR,
- PARAM_PITCH_SCALE=SpatialSoundServer::ROOM_PARAM_PITCH_SCALE,
- PARAM_VOLUME_SCALE_DB=SpatialSoundServer::ROOM_PARAM_VOLUME_SCALE_DB,
- PARAM_REVERB_SEND=SpatialSoundServer::ROOM_PARAM_REVERB_SEND,
- PARAM_CHORUS_SEND=SpatialSoundServer::ROOM_PARAM_CHORUS_SEND,
- PARAM_ATTENUATION_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_SCALE,
- PARAM_ATTENUATION_HF_CUTOFF=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_CUTOFF,
- PARAM_ATTENUATION_HF_FLOOR_DB=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
- PARAM_ATTENUATION_HF_RATIO_EXP=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
- PARAM_ATTENUATION_REVERB_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_REVERB_SCALE,
- PARAM_MAX=SpatialSoundServer::ROOM_PARAM_MAX
- };
-
- enum Reverb {
- REVERB_SMALL,
- REVERB_MEDIUM,
- REVERB_LARGE,
- REVERB_HALL
- };
-private:
-
- RID room;
-
- float params[PARAM_MAX];
- Reverb reverb;
- bool force_params_for_all_sources;
- void _update_sound_room();
-
-
-protected:
-
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
-
-
- void set_param(Params p_param, float p_value);
- float get_param(Params p_param) const;
-
- void set_reverb_mode(Reverb p_mode);
- Reverb get_reverb_mode() const;
-
- void set_force_params_to_all_sources(bool p_force);
- bool is_forcing_params_to_all_sources();
-
- SoundRoomParams();
-};
-
-VARIANT_ENUM_CAST(SoundRoomParams::Params);
-VARIANT_ENUM_CAST(SoundRoomParams::Reverb);
-
-#endif
-
-#endif // SOUND_ROOM_PARAMS_H
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
deleted file mode 100644
index 2f53dc239f..0000000000
--- a/scene/audio/stream_player.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/*************************************************************************/
-/* stream_player.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "stream_player.h"
-
-int StreamPlayer::InternalStream::get_channel_count() const {
-
- return player->sp_get_channel_count();
-}
-void StreamPlayer::InternalStream::set_mix_rate(int p_rate){
-
- return player->sp_set_mix_rate(p_rate);
-}
-bool StreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
-
- return player->sp_mix(p_buffer,p_frames);
-}
-void StreamPlayer::InternalStream::update(){
-
- player->sp_update();
-}
-
-
-int StreamPlayer::sp_get_channel_count() const {
-
- return playback->get_channels();
-}
-
-void StreamPlayer::sp_set_mix_rate(int p_rate){
-
- server_mix_rate=p_rate;
-}
-
-bool StreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
-
- if (resampler.is_ready() && !paused) {
- return resampler.mix(p_buffer,p_frames);
- }
-
- return false;
-}
-
-void StreamPlayer::sp_update() {
-
- //_THREAD_SAFE_METHOD_
- if (!paused && resampler.is_ready() && playback.is_valid()) {
-
- if (!playback->is_playing()) {
- //stream depleted data, but there's still audio in the ringbuffer
- //check that all this audio has been flushed before stopping the stream
- int to_mix = resampler.get_total() - resampler.get_todo();
- if (to_mix==0) {
- if (!stop_request) {
- stop_request=true;
- call_deferred("_do_stop");
- }
- return;
- }
-
- return;
- }
-
- int todo =resampler.get_todo();
- int wrote = playback->mix(resampler.get_write_buffer(),todo);
- resampler.write(wrote);
- }
-}
-
-void StreamPlayer::_do_stop() {
- stop();
- emit_signal("finished");
-}
-
-void StreamPlayer::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
-
- //set_idle_process(false); //don't annoy
- if (stream.is_valid() && !get_tree()->is_editor_hint()) {
- if (resume_pos>=0) {
- play(resume_pos);
- resume_pos=-1;
- } else if (autoplay) {
- play();
- autoplay = false; //this line fix autoplay issues
- }
- }
-
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- if (is_playing()) {
- resume_pos=get_pos();
- }
- stop(); //wathever it may be doing, stop
- } break;
- }
-}
-
-
-
-void StreamPlayer::set_stream(const Ref<AudioStream> &p_stream) {
-
- stop();
-
- stream=p_stream;
-
- if (!stream.is_null()) {
- playback=stream->instance_playback();
- playback->set_loop(loops);
- playback->set_loop_restart_time(loop_point);
- AudioServer::get_singleton()->lock();
- resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size());
- AudioServer::get_singleton()->unlock();
- } else {
- AudioServer::get_singleton()->lock();
- resampler.clear();
- playback.unref();
- AudioServer::get_singleton()->unlock();
- }
-}
-
-Ref<AudioStream> StreamPlayer::get_stream() const {
-
- return stream;
-}
-
-
-void StreamPlayer::play(float p_from_offset) {
-
- ERR_FAIL_COND(!is_inside_tree());
- if (playback.is_null())
- return;
- //if (is_playing())
- stop();
-
- //_THREAD_SAFE_METHOD_
- playback->play(p_from_offset);
- //feed the ringbuffer as long as no update callback is going on
- sp_update();
- AudioServer::get_singleton()->stream_set_active(stream_rid,true);
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
-
-}
-
-void StreamPlayer::stop() {
-
- if (!is_inside_tree())
- return;
- if (playback.is_null())
- return;
-
- //_THREAD_SAFE_METHOD_
- AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- stop_request=false;
- playback->stop();
- resampler.flush();
-
-
- //set_idle_process(false);
-}
-
-bool StreamPlayer::is_playing() const {
-
- if (playback.is_null())
- return false;
-
- return playback->is_playing() || resampler.has_data();
-}
-
-void StreamPlayer::set_loop(bool p_enable) {
-
- loops=p_enable;
- if (playback.is_null())
- return;
- playback->set_loop(loops);
-
-}
-bool StreamPlayer::has_loop() const {
-
- return loops;
-}
-
-void StreamPlayer::set_volume(float p_vol) {
-
- volume=p_vol;
- if (stream_rid.is_valid())
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-}
-
-float StreamPlayer::get_volume() const {
-
- return volume;
-}
-
-void StreamPlayer::set_loop_restart_time(float p_secs) {
-
- loop_point=p_secs;
- if (playback.is_valid())
- playback->set_loop_restart_time(p_secs);
-}
-
-float StreamPlayer::get_loop_restart_time() const {
-
- return loop_point;
-}
-
-
-void StreamPlayer::set_volume_db(float p_db) {
-
- if (p_db<-79)
- set_volume(0);
- else
- set_volume(Math::db2linear(p_db));
-}
-
-float StreamPlayer::get_volume_db() const {
-
- if (volume==0)
- return -80;
- else
- return Math::linear2db(volume);
-}
-
-
-String StreamPlayer::get_stream_name() const {
-
- if (stream.is_null())
- return "<No Stream>";
- return stream->get_name();
-
-}
-
-int StreamPlayer::get_loop_count() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_loop_count();
-
-}
-
-float StreamPlayer::get_pos() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_pos();
-
-}
-
-float StreamPlayer::get_length() const {
-
- if (playback.is_null())
- return 0;
- return playback->get_length();
-}
-void StreamPlayer::seek_pos(float p_time) {
-
- if (playback.is_null())
- return;
- //works better...
- stop();
- playback->play(p_time);
-
-}
-
-void StreamPlayer::set_autoplay(bool p_enable) {
-
- autoplay=p_enable;
-}
-
-bool StreamPlayer::has_autoplay() const {
-
- return autoplay;
-}
-
-void StreamPlayer::set_paused(bool p_paused) {
-
- paused=p_paused;
- //if (stream.is_valid())
- // stream->set_paused(p_paused);
-}
-
-bool StreamPlayer::is_paused() const {
-
- return paused;
-}
-
-void StreamPlayer::_set_play(bool p_play) {
-
- _play=p_play;
- if (is_inside_tree()) {
- if(_play)
- play();
- else
- stop();
- }
-
-}
-
-bool StreamPlayer::_get_play() const{
-
- return _play;
-}
-
-void StreamPlayer::set_buffering_msec(int p_msec) {
-
- buffering_ms=p_msec;
-}
-
-int StreamPlayer::get_buffering_msec() const{
-
- return buffering_ms;
-}
-
-
-
-void StreamPlayer::_bind_methods() {
-
- ClassDB::bind_method(_MD("set_stream","stream:AudioStream"),&StreamPlayer::set_stream);
- ClassDB::bind_method(_MD("get_stream:AudioStream"),&StreamPlayer::get_stream);
-
- ClassDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0));
- ClassDB::bind_method(_MD("stop"),&StreamPlayer::stop);
-
- ClassDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing);
-
- ClassDB::bind_method(_MD("set_paused","paused"),&StreamPlayer::set_paused);
- ClassDB::bind_method(_MD("is_paused"),&StreamPlayer::is_paused);
-
- ClassDB::bind_method(_MD("set_loop","enabled"),&StreamPlayer::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&StreamPlayer::has_loop);
-
- ClassDB::bind_method(_MD("set_volume","volume"),&StreamPlayer::set_volume);
- ClassDB::bind_method(_MD("get_volume"),&StreamPlayer::get_volume);
-
- ClassDB::bind_method(_MD("set_volume_db","db"),&StreamPlayer::set_volume_db);
- ClassDB::bind_method(_MD("get_volume_db"),&StreamPlayer::get_volume_db);
-
- ClassDB::bind_method(_MD("set_buffering_msec","msec"),&StreamPlayer::set_buffering_msec);
- ClassDB::bind_method(_MD("get_buffering_msec"),&StreamPlayer::get_buffering_msec);
-
- ClassDB::bind_method(_MD("set_loop_restart_time","secs"),&StreamPlayer::set_loop_restart_time);
- ClassDB::bind_method(_MD("get_loop_restart_time"),&StreamPlayer::get_loop_restart_time);
-
- ClassDB::bind_method(_MD("get_stream_name"),&StreamPlayer::get_stream_name);
- ClassDB::bind_method(_MD("get_loop_count"),&StreamPlayer::get_loop_count);
-
- ClassDB::bind_method(_MD("get_pos"),&StreamPlayer::get_pos);
- ClassDB::bind_method(_MD("seek_pos","time"),&StreamPlayer::seek_pos);
-
- ClassDB::bind_method(_MD("set_autoplay","enabled"),&StreamPlayer::set_autoplay);
- ClassDB::bind_method(_MD("has_autoplay"),&StreamPlayer::has_autoplay);
-
- ClassDB::bind_method(_MD("get_length"),&StreamPlayer::get_length);
-
- ClassDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play);
- ClassDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play);
- ClassDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop);
-
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
-
- ADD_SIGNAL(MethodInfo("finished"));
-}
-
-
-StreamPlayer::StreamPlayer() {
-
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- server_mix_rate=1;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
- buffering_ms=500;
- loop_point=0;
- stop_request=false;
- resume_pos=-1;
-
-}
-
-StreamPlayer::~StreamPlayer() {
- AudioServer::get_singleton()->free(stream_rid);
- resampler.clear();
-
-
-}
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
deleted file mode 100644
index 6031d86aa2..0000000000
--- a/scene/audio/stream_player.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*************************************************************************/
-/* stream_player.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 STREAM_PLAYER_H
-#define STREAM_PLAYER_H
-
-#include "scene/resources/audio_stream.h"
-#include "scene/main/node.h"
-#include "servers/audio/audio_rb_resampler.h"
-
-class StreamPlayer : public Node {
-
- GDCLASS(StreamPlayer,Node);
-
- //_THREAD_SAFE_CLASS_
-
- struct InternalStream : public AudioServer::AudioStream {
- StreamPlayer *player;
- virtual int get_channel_count() const;
- virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
- virtual void update();
- };
-
-
- InternalStream internal_stream;
- Ref<AudioStreamPlayback> playback;
- Ref<AudioStream> stream;
-
- int sp_get_channel_count() const;
- void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
- bool sp_mix(int32_t *p_buffer,int p_frames);
- void sp_update();
-
- int server_mix_rate;
-
- RID stream_rid;
- bool paused;
- bool autoplay;
- bool loops;
- float volume;
- float loop_point;
- int buffering_ms;
- volatile bool stop_request;
- float resume_pos;
-
- AudioRBResampler resampler;
-
- void _do_stop();
-
- bool _play;
- void _set_play(bool p_play);
- bool _get_play() const;
-protected:
- void _notification(int p_what);
-
- static void _bind_methods();
-public:
-
- void set_stream(const Ref<AudioStream> &p_stream);
- Ref<AudioStream> get_stream() const;
-
- void play(float p_from_offset=0);
- void stop();
- bool is_playing() const;
-
- void set_paused(bool p_paused);
- bool is_paused() const;
-
- void set_loop(bool p_enable);
- bool has_loop() const;
-
- void set_volume(float p_vol);
- float get_volume() const;
-
- void set_loop_restart_time(float p_secs);
- float get_loop_restart_time() const;
-
- void set_volume_db(float p_db);
- float get_volume_db() const;
-
- String get_stream_name() const;
-
- int get_loop_count() const;
-
- float get_pos() const;
- void seek_pos(float p_time);
- float get_length() const;
- void set_autoplay(bool p_vol);
- bool has_autoplay() const;
-
- void set_buffering_msec(int p_msec);
- int get_buffering_msec() const;
-
- StreamPlayer();
- ~StreamPlayer();
-};
-
-#endif // AUDIO_STREAM_PLAYER_H
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 45c491cd74..79b607e2e6 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -64,7 +64,7 @@ void BaseButton::_gui_input(InputEvent p_event) {
if (status.pressing_button)
break;
- if (status.click_on_press) {
+ if (action_mode==ACTION_MODE_BUTTON_PRESS) {
if (b.pressed) {
@@ -108,7 +108,7 @@ void BaseButton::_gui_input(InputEvent p_event) {
emit_signal("button_up");
/* this is pointless if (status.press_attempt && status.pressing_inside) {
-// released();
+ //released();
emit_signal("released");
}
*/
@@ -297,7 +297,7 @@ void BaseButton::_notification(int p_what) {
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) {
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree()) {
if (!toggle_mode) {
status.pressed = false;
@@ -415,14 +415,14 @@ bool BaseButton::is_toggle_mode() const {
return toggle_mode;
}
-void BaseButton::set_click_on_press(bool p_click_on_press) {
+void BaseButton::set_action_mode(ActionMode p_mode) {
- status.click_on_press=p_click_on_press;
+ action_mode=p_mode;
}
-bool BaseButton::get_click_on_press() const {
+BaseButton::ActionMode BaseButton::get_action_mode() const {
- return status.click_on_press;
+ return action_mode;
}
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
@@ -453,7 +453,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
void BaseButton::_unhandled_input(InputEvent p_event) {
- if (!is_disabled() && is_visible() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible_in_tree() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
return; //ignore because of modal window
@@ -505,26 +505,26 @@ Ref<ButtonGroup> BaseButton::get_button_group() const {
void BaseButton::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&BaseButton::_gui_input);
- ClassDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
- ClassDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
- ClassDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
- ClassDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
- ClassDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
- ClassDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
- ClassDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
- ClassDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
- ClassDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press);
- ClassDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
- ClassDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
- ClassDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
- ClassDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
-
- ClassDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
- ClassDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
-
- ClassDB::bind_method(_MD("set_button_group","button_group"),&BaseButton::set_button_group);
- ClassDB::bind_method(_MD("get_button_group"),&BaseButton::get_button_group);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&BaseButton::_gui_input);
+ ClassDB::bind_method(D_METHOD("_unhandled_input"),&BaseButton::_unhandled_input);
+ ClassDB::bind_method(D_METHOD("set_pressed","pressed"),&BaseButton::set_pressed);
+ ClassDB::bind_method(D_METHOD("is_pressed"),&BaseButton::is_pressed);
+ ClassDB::bind_method(D_METHOD("is_hovered"),&BaseButton::is_hovered);
+ ClassDB::bind_method(D_METHOD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
+ ClassDB::bind_method(D_METHOD("is_toggle_mode"),&BaseButton::is_toggle_mode);
+ ClassDB::bind_method(D_METHOD("set_disabled","disabled"),&BaseButton::set_disabled);
+ ClassDB::bind_method(D_METHOD("is_disabled"),&BaseButton::is_disabled);
+ ClassDB::bind_method(D_METHOD("set_action_mode","mode"),&BaseButton::set_action_mode);
+ ClassDB::bind_method(D_METHOD("get_action_mode"),&BaseButton::get_action_mode);
+ ClassDB::bind_method(D_METHOD("get_draw_mode"),&BaseButton::get_draw_mode);
+ 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_button_group","button_group"),&BaseButton::set_button_group);
+ ClassDB::bind_method(D_METHOD("get_button_group"),&BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed")));
@@ -533,13 +533,13 @@ void BaseButton::_bind_methods() {
ADD_SIGNAL( MethodInfo("button_up") );
ADD_SIGNAL( MethodInfo("button_down") );
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
- ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") );
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), _SCS("set_button_group"), _SCS("get_button_group"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), "set_disabled", "is_disabled");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), "set_pressed", "is_pressed");
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "action_mode",PROPERTY_HINT_ENUM,"Button Press,Button Release"), "set_action_mode", "get_action_mode");
+ ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), "set_enabled_focus_mode", "get_enabled_focus_mode") ;
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), "set_shortcut", "get_shortcut");
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), "set_button_group", "get_button_group");
BIND_CONSTANT( DRAW_NORMAL );
@@ -547,6 +547,10 @@ void BaseButton::_bind_methods() {
BIND_CONSTANT( DRAW_HOVER );
BIND_CONSTANT( DRAW_DISABLED );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_PRESS );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_RELEASE );
+
+
}
BaseButton::BaseButton() {
@@ -557,10 +561,10 @@ BaseButton::BaseButton() {
status.hovering=false;
status.pressing_inside=false;
status.disabled = false;
- status.click_on_press=false;
status.pressing_button=0;
set_focus_mode( FOCUS_ALL );
enabled_focus_mode = FOCUS_ALL;
+ action_mode=ACTION_MODE_BUTTON_RELEASE;
if (button_group.is_valid()) {
@@ -594,7 +598,7 @@ BaseButton* ButtonGroup::get_pressed_button() {
void ButtonGroup::_bind_methods() {
- ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(D_METHOD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
}
ButtonGroup::ButtonGroup() {
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 898c19e811..def4ff7536 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -40,11 +40,20 @@ class ButtonGroup;
class BaseButton : public Control {
GDCLASS( BaseButton, Control );
+public:
+
+ enum ActionMode {
+ ACTION_MODE_BUTTON_PRESS,
+ ACTION_MODE_BUTTON_RELEASE,
+ };
+
+private:
bool toggle_mode;
FocusMode enabled_focus_mode;
Ref<ShortCut> shortcut;
+ ActionMode action_mode;
struct Status {
bool pressed;
@@ -53,7 +62,6 @@ class BaseButton : public Control {
bool pressing_inside;
bool disabled;
- bool click_on_press;
int pressing_button;
} status;
@@ -100,8 +108,8 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- void set_click_on_press(bool p_click_on_press);
- bool get_click_on_press() const;
+ void set_action_mode(ActionMode p_mode);
+ ActionMode get_action_mode() const;
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
@@ -120,6 +128,8 @@ public:
};
VARIANT_ENUM_CAST( BaseButton::DrawMode )
+VARIANT_ENUM_CAST( BaseButton::ActionMode )
+
class ButtonGroup : public Resource {
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index f31f51a5cd..1f6e0392d8 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -42,7 +42,7 @@ void BoxContainer::_resort() {
/** First pass, determine minimum size AND amount of stretchable elements */
- Size2i new_size=get_size();;
+ Size2i new_size=get_size();
int sep=get_constant("separation");//,vertical?"VBoxContainer":"HBoxContainer");
@@ -55,7 +55,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -108,7 +108,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -164,7 +164,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -227,7 +227,7 @@ Size2 BoxContainer::get_minimum_size() const {
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden()) {
+ if (!c->is_visible()) {
continue;
}
@@ -296,21 +296,21 @@ BoxContainer::BoxContainer(bool p_vertical) {
vertical=p_vertical;
align = ALIGN_BEGIN;
-// set_ignore_mouse(true);
+ //set_ignore_mouse(true);
set_mouse_filter(MOUSE_FILTER_PASS);
}
void BoxContainer::_bind_methods() {
- ClassDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
- ClassDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
- ClassDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
+ ClassDB::bind_method(D_METHOD("add_spacer","begin"),&BoxContainer::add_spacer);
+ ClassDB::bind_method(D_METHOD("get_alignment"),&BoxContainer::get_alignment);
+ ClassDB::bind_method(D_METHOD("set_alignment","alignment"),&BoxContainer::set_alignment);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
BIND_CONSTANT( ALIGN_END );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), _SCS("set_alignment"),_SCS("get_alignment") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), "set_alignment","get_alignment") ;
}
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index f28595b622..de2ccfb0b5 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -74,17 +74,21 @@ void Button::_notification(int p_what) {
//print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode()));
+ Ref<StyleBox> style = get_stylebox("normal");
+
switch( get_draw_mode() ) {
case DRAW_NORMAL: {
+ style = get_stylebox("normal");
if (!flat)
- get_stylebox("normal" )->draw( ci, Rect2(Point2(0,0), size) );
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color");
} break;
case DRAW_PRESSED: {
- get_stylebox("pressed" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("pressed");
+ style->draw( ci, Rect2(Point2(0,0), size) );
if (has_color("font_color_pressed"))
color=get_color("font_color_pressed");
else
@@ -93,13 +97,15 @@ void Button::_notification(int p_what) {
} break;
case DRAW_HOVER: {
- get_stylebox("hover" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("hover");
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color_hover");
} break;
case DRAW_DISABLED: {
- get_stylebox("disabled" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("disabled");
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color_disabled");
} break;
@@ -111,7 +117,6 @@ void Button::_notification(int p_what) {
style->draw(ci,Rect2(Point2(),size));
}
- Ref<StyleBox> style = get_stylebox("normal" );
Ref<Font> font=get_font("font");
Ref<Texture> _icon;
if (icon.is_null() && has_icon("icon"))
@@ -223,26 +228,26 @@ Button::TextAlign Button::get_text_align() const {
void Button::_bind_methods() {
- ClassDB::bind_method(_MD("set_text","text"),&Button::set_text);
- ClassDB::bind_method(_MD("get_text"),&Button::get_text);
- ClassDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
- ClassDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
- ClassDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
- ClassDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
- ClassDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
- ClassDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
- ClassDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
- ClassDB::bind_method(_MD("is_flat"),&Button::is_flat);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&Button::set_text);
+ ClassDB::bind_method(D_METHOD("get_text"),&Button::get_text);
+ ClassDB::bind_method(D_METHOD("set_button_icon","texture:Texture"),&Button::set_icon);
+ ClassDB::bind_method(D_METHOD("get_button_icon:Texture"),&Button::get_icon);
+ ClassDB::bind_method(D_METHOD("set_flat","enabled"),&Button::set_flat);
+ ClassDB::bind_method(D_METHOD("set_clip_text","enabled"),&Button::set_clip_text);
+ ClassDB::bind_method(D_METHOD("get_clip_text"),&Button::get_clip_text);
+ ClassDB::bind_method(D_METHOD("set_text_align","align"),&Button::set_text_align);
+ ClassDB::bind_method(D_METHOD("get_text_align"),&Button::get_text_align);
+ ClassDB::bind_method(D_METHOD("is_flat"),&Button::is_flat);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
BIND_CONSTANT( ALIGN_RIGHT );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") );
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), "set_text","get_text") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), "set_button_icon","get_button_icon") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), "set_flat","is_flat") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text" ), "set_clip_text","get_clip_text") ;
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), "set_text_align","get_text_align") ;
}
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index 3d7c0e2825..2fd5f0df83 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -58,9 +58,10 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
int idx=what.to_int();
ERR_FAIL_INDEX_V(idx,buttons.size(),false);
String f = n.get_slicec('/',2);
- if (f=="text")
+ if (f=="text") {
buttons[idx].text=p_value;
- else if (f=="tooltip")
+ buttons[idx].xl_text=XL_MESSAGE(p_value);
+ } else if (f=="tooltip")
buttons[idx].tooltip=p_value;
else if (f=="icon")
buttons[idx].icon=p_value;
@@ -146,7 +147,7 @@ Size2 ButtonArray::get_minimum_size() const {
Ref<Font> f = i==selected ? font_selected : font_normal;
Size2 ms;
- ms = f->get_string_size(buttons[i].text);
+ ms = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
Size2 bs = buttons[i].icon->get_size();
@@ -275,7 +276,7 @@ void ButtonArray::_notification(int p_what) {
c=color_normal;
}
- Size2 ssize = f->get_string_size(buttons[i].text);
+ Size2 ssize = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
ssize.x+=buttons[i].icon->get_width();
@@ -287,7 +288,7 @@ void ButtonArray::_notification(int p_what) {
text_ofs.x+=buttons[i].icon->get_width()+icon_sep;
}
- draw_string(f,text_ofs+r.pos,buttons[i].text,c);
+ draw_string(f,text_ofs+r.pos,buttons[i].xl_text,c);
buttons[i]._pos_cache=ofs;
buttons[i]._size_cache=s;
@@ -404,6 +405,7 @@ void ButtonArray::add_button(const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
+ button.xl_text=XL_MESSAGE(p_text);
button.tooltip=p_tooltip;
buttons.push_back(button);
update();
@@ -418,6 +420,7 @@ void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_tex
Button button;
button.text=p_text;
+ button.xl_text=XL_MESSAGE(p_text);
button.icon=p_icon;
button.tooltip=p_tooltip;
buttons.push_back(button);
@@ -432,6 +435,7 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) {
ERR_FAIL_INDEX(p_button,buttons.size());
buttons[p_button].text=p_text;
+ buttons[p_button].xl_text=XL_MESSAGE(p_text);
update();
minimum_size_changed();
@@ -527,24 +531,24 @@ void ButtonArray::get_translatable_strings(List<String> *p_strings) const {
void ButtonArray::_bind_methods() {
- ClassDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL(""));
- ClassDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL(""));
- ClassDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
- ClassDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip);
- ClassDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
- ClassDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
- ClassDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip);
- ClassDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
- ClassDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
- ClassDB::bind_method(_MD("set_flat","enabled"),&ButtonArray::set_flat);
- ClassDB::bind_method(_MD("is_flat"),&ButtonArray::is_flat);
- ClassDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
- ClassDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
- ClassDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
- ClassDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
- ClassDB::bind_method(_MD("clear"),&ButtonArray::clear);
-
- ClassDB::bind_method(_MD("_gui_input"),&ButtonArray::_gui_input);
+ ClassDB::bind_method(D_METHOD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
+ ClassDB::bind_method(D_METHOD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip);
+ ClassDB::bind_method(D_METHOD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
+ ClassDB::bind_method(D_METHOD("get_button_text","button_idx"),&ButtonArray::get_button_text);
+ ClassDB::bind_method(D_METHOD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip);
+ ClassDB::bind_method(D_METHOD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
+ ClassDB::bind_method(D_METHOD("get_button_count"),&ButtonArray::get_button_count);
+ ClassDB::bind_method(D_METHOD("set_flat","enabled"),&ButtonArray::set_flat);
+ ClassDB::bind_method(D_METHOD("is_flat"),&ButtonArray::is_flat);
+ ClassDB::bind_method(D_METHOD("get_selected"),&ButtonArray::get_selected);
+ ClassDB::bind_method(D_METHOD("get_hovered"),&ButtonArray::get_hovered);
+ ClassDB::bind_method(D_METHOD("set_selected","button_idx"),&ButtonArray::set_selected);
+ ClassDB::bind_method(D_METHOD("erase_button","button_idx"),&ButtonArray::erase_button);
+ ClassDB::bind_method(D_METHOD("clear"),&ButtonArray::clear);
+
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ButtonArray::_gui_input);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
@@ -552,7 +556,7 @@ void ButtonArray::_bind_methods() {
BIND_CONSTANT( ALIGN_FILL );
BIND_CONSTANT( ALIGN_EXPAND_FILL );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), "set_flat","is_flat") ;
ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx")));
diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h
index 37533695c9..4865ef0373 100644
--- a/scene/gui/button_array.h
+++ b/scene/gui/button_array.h
@@ -50,6 +50,7 @@ private:
struct Button {
String text;
+ String xl_text;
String tooltip;
Ref<Texture> icon;
mutable int _ms_cache;
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index 01a3f633c3..21c1559b8f 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -151,12 +151,12 @@ int ButtonGroup::get_pressed_button_index() const {
void ButtonGroup::_bind_methods() {
- ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
- ClassDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ClassDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
- ClassDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
- ClassDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
- ClassDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(D_METHOD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(D_METHOD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
+ ClassDB::bind_method(D_METHOD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
+ ClassDB::bind_method(D_METHOD("get_button_list"),&ButtonGroup::_get_button_list);
+ ClassDB::bind_method(D_METHOD("_pressed"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(D_METHOD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
}
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 4a42695c3a..c1c04ced84 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -42,7 +42,7 @@ Size2 CenterContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width , minsize.width);
@@ -92,10 +92,10 @@ void CenterContainer::_notification(int p_what) {
void CenterContainer::_bind_methods() {
- ClassDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
- ClassDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
+ ClassDB::bind_method(D_METHOD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
+ ClassDB::bind_method(D_METHOD("is_using_top_left"),&CenterContainer::is_using_top_left);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),_SCS("set_use_top_left"),_SCS("is_using_top_left"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),"set_use_top_left","is_using_top_left");
}
CenterContainer::CenterContainer() {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index ac8ce68564..d9da583bf5 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -75,7 +75,7 @@ void ColorPicker::_update_controls() {
}
-void ColorPicker::set_color(const Color& p_color) {
+void ColorPicker::set_pick_color(const Color& p_color) {
color=p_color;
if (color != last_hsv) {
@@ -121,7 +121,7 @@ void ColorPicker::_value_changed(double) {
color.components[i] = scroll[i]->get_value()/(raw_mode_enabled?1.0:255.0);
}
- set_color(color);
+ set_pick_color(color);
_update_text_value();
@@ -139,7 +139,7 @@ void ColorPicker::_html_entered(const String& p_html) {
if (!is_inside_tree())
return;
- set_color(color);
+ set_pick_color(color);
emit_signal("color_changed",color);
}
@@ -208,7 +208,7 @@ void ColorPicker::_text_type_toggled()
_update_color();
}
-Color ColorPicker::get_color() const {
+Color ColorPicker::get_pick_color() const {
return color;
}
@@ -320,7 +320,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else {
@@ -336,7 +336,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -354,7 +354,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
}
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else if (ev.type == InputEvent::MOUSE_MOTION) {
@@ -365,7 +365,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
h=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -376,7 +376,7 @@ void ColorPicker::_preset_input(const InputEvent &ev) {
const InputEventMouseButton &bev = ev.mouse_button;
if (bev.pressed && bev.button_index==BUTTON_LEFT) {
int index = bev.x/(preset->get_size().x/presets.size());
- set_color(presets[index]);
+ set_pick_color(presets[index]);
} else if (bev.pressed && bev.button_index==BUTTON_RIGHT) {
int index = bev.x/(preset->get_size().x/presets.size());
presets.erase(presets[index]);
@@ -425,7 +425,7 @@ void ColorPicker::_screen_input(const InputEvent &ev)
Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 );
- set_color(c);
+ set_pick_color(c);
}
}
}
@@ -451,24 +451,24 @@ void ColorPicker::_screen_pick_pressed()
void ColorPicker::_bind_methods() {
- ClassDB::bind_method(_MD("set_color","color"),&ColorPicker::set_color);
- ClassDB::bind_method(_MD("get_color"),&ColorPicker::get_color);
- ClassDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
- ClassDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
- ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
- ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
- ClassDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
- ClassDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
- ClassDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
- ClassDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
- ClassDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
- ClassDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
- ClassDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
- ClassDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
- ClassDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
- ClassDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
- ClassDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
- ClassDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
+ ClassDB::bind_method(D_METHOD("set_pick_color","color"),&ColorPicker::set_pick_color);
+ ClassDB::bind_method(D_METHOD("get_pick_color"),&ColorPicker::get_pick_color);
+ ClassDB::bind_method(D_METHOD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
+ 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("_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);
+ ClassDB::bind_method(D_METHOD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
+ ClassDB::bind_method(D_METHOD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
+ ClassDB::bind_method(D_METHOD("_sample_draw"),&ColorPicker::_sample_draw);
+ ClassDB::bind_method(D_METHOD("_hsv_draw"),&ColorPicker::_hsv_draw);
+ ClassDB::bind_method(D_METHOD("_uv_input"),&ColorPicker::_uv_input);
+ ClassDB::bind_method(D_METHOD("_w_input"),&ColorPicker::_w_input);
+ ClassDB::bind_method(D_METHOD("_preset_input"),&ColorPicker::_preset_input);
+ ClassDB::bind_method(D_METHOD("_screen_input"),&ColorPicker::_screen_input);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
}
@@ -487,7 +487,7 @@ ColorPicker::ColorPicker() :
btn_pick = memnew( ToolButton );
btn_pick->connect("pressed",this,"_screen_pick_pressed");
- sample = memnew( TextureFrame );
+ sample = memnew( TextureRect );
sample->set_h_size_flags(SIZE_EXPAND_FILL);
sample->connect("draw",this,"_sample_draw");
@@ -584,13 +584,13 @@ ColorPicker::ColorPicker() :
//_update_color();
updating=false;
- set_color(Color(1,1,1));
+ set_pick_color(Color(1,1,1));
HBoxContainer *bbc = memnew( HBoxContainer );
add_child(bbc);
- preset = memnew( TextureFrame );
+ preset = memnew( TextureRect );
bbc->add_child(preset);
//preset->set_ignore_mouse(false);
preset->connect("gui_input", this, "_preset_input");
@@ -632,20 +632,20 @@ void ColorPickerButton::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
Ref<StyleBox> normal = get_stylebox("normal" );
- draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_color());
+ draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_pick_color());
}
}
-void ColorPickerButton::set_color(const Color& p_color){
+void ColorPickerButton::set_pick_color(const Color& p_color){
- picker->set_color(p_color);
+ picker->set_pick_color(p_color);
update();
emit_signal("color_changed",p_color);
}
-Color ColorPickerButton::get_color() const{
+Color ColorPickerButton::get_pick_color() const{
- return picker->get_color();
+ return picker->get_pick_color();
}
void ColorPickerButton::set_edit_alpha(bool p_show) {
@@ -665,16 +665,16 @@ ColorPicker *ColorPickerButton::get_picker() {
void ColorPickerButton::_bind_methods(){
- ClassDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color);
- ClassDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color);
- ClassDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
- ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
- ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
- ClassDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
+ ClassDB::bind_method(D_METHOD("set_pick_color","color"),&ColorPickerButton::set_pick_color);
+ ClassDB::bind_method(D_METHOD("get_pick_color"),&ColorPickerButton::get_pick_color);
+ ClassDB::bind_method(D_METHOD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
+ ClassDB::bind_method(D_METHOD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
+ ClassDB::bind_method(D_METHOD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
+ ClassDB::bind_method(D_METHOD("_color_changed"),&ColorPickerButton::_color_changed);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),_SCS("set_edit_alpha"),_SCS("is_editing_alpha") );
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),"set_pick_color","get_pick_color") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),"set_edit_alpha","is_editing_alpha") ;
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index c6a8ef7725..d9db9c89f7 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -36,7 +36,7 @@
#include "scene/gui/button.h"
#include "scene/gui/popup.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/check_button.h"
@@ -50,8 +50,8 @@ private:
Image last_capture;
Control *uv_edit;
Control *w_edit;
- TextureFrame *sample;
- TextureFrame *preset;
+ TextureRect *sample;
+ TextureRect *preset;
Button *bt_add_preset;
List<Color> presets;
ToolButton *btn_pick;
@@ -98,8 +98,8 @@ public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void add_preset(const Color& p_color);
void set_raw_mode(bool p_enabled);
@@ -126,8 +126,8 @@ protected:
static void _bind_methods();
public:
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp
index c3ed3d821d..81bc5ca9bb 100644
--- a/scene/gui/color_ramp_edit.cpp
+++ b/scene/gui/color_ramp_edit.cpp
@@ -60,7 +60,7 @@ void ColorRampEdit::_show_color_picker() {
if (grabbed==-1)
return;
Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10);
- picker->set_color(points[grabbed].color);
+ picker->set_pick_color(points[grabbed].color);
popup->set_pos(get_global_pos()-Vector2(ms.width-get_size().width,ms.height));
popup->set_size(ms);
popup->popup();
@@ -446,7 +446,7 @@ Vector<ColorRamp::Point>& ColorRampEdit::get_points() {
}
void ColorRampEdit::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&ColorRampEdit::_gui_input);
- ClassDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ColorRampEdit::_gui_input);
+ ClassDB::bind_method(D_METHOD("_color_changed"),&ColorRampEdit::_color_changed);
ADD_SIGNAL(MethodInfo("ramp_changed"));
}
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index fee96d1ca9..d72dffcae3 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -1,36 +1,61 @@
+/*************************************************************************/
+/* color_rect.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "color_rect.h"
-
-
-void ColorFrame::set_frame_color(const Color& p_color) {
+void ColorRect::set_frame_color(const Color& p_color) {
color=p_color;
update();
}
-Color ColorFrame::get_frame_color() const{
+Color ColorRect::get_frame_color() const{
return color;
}
-void ColorFrame::_notification(int p_what) {
+void ColorRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
draw_rect(Rect2(Point2(),get_size()),color);
}
}
-void ColorFrame::_bind_methods() {
+void ColorRect::_bind_methods() {
- ClassDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color);
- ClassDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color);
+ ClassDB::bind_method(D_METHOD("set_frame_color","color"),&ColorRect::set_frame_color);
+ ClassDB::bind_method(D_METHOD("get_frame_color"),&ColorRect::get_frame_color);
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),"set_frame_color","get_frame_color") ;
}
-ColorFrame::ColorFrame() {
+ColorRect::ColorRect() {
color=Color(1,1,1);
}
-
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
index f313bbc4f9..55e413ce27 100644
--- a/scene/gui/color_rect.h
+++ b/scene/gui/color_rect.h
@@ -1,10 +1,38 @@
-#ifndef COLORRECT_H
-#define COLORRECT_H
+/*************************************************************************/
+/* color_rect.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 COLOR_RECT_H
+#define COLOR_RECT_H
#include "scene/gui/control.h"
-class ColorFrame : public Control {
- GDCLASS(ColorFrame,Control)
+class ColorRect : public Control {
+ GDCLASS(ColorRect,Control)
Color color;
protected:
@@ -16,7 +44,7 @@ public:
void set_frame_color(const Color& p_color);
Color get_frame_color() const;
- ColorFrame();
+ ColorRect();
};
-#endif // COLORRECT_H
+#endif // COLOR_RECT_H
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index a5a5c61082..655c6e1bbf 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -147,7 +147,7 @@ void Container::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
queue_sort();
}
} break;
@@ -156,11 +156,11 @@ void Container::_notification(int p_what) {
void Container::_bind_methods() {
- ClassDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
- ClassDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
+ ClassDB::bind_method(D_METHOD("_sort_children"),&Container::_sort_children);
+ ClassDB::bind_method(D_METHOD("_child_minsize_changed"),&Container::_child_minsize_changed);
- ClassDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
- ClassDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
+ ClassDB::bind_method(D_METHOD("queue_sort"),&Container::queue_sort);
+ ClassDB::bind_method(D_METHOD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
BIND_CONSTANT( NOTIFICATION_SORT_CHILDREN );
ADD_SIGNAL(MethodInfo("sort_children"));
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 054622668b..4161725ad5 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -30,7 +30,7 @@
#include "servers/visual_server.h"
#include "scene/main/viewport.h"
#include "scene/main/canvas_layer.h"
-#include "globals.h"
+#include "global_config.h"
#include "print_string.h"
#include "os/keyboard.h"
@@ -468,10 +468,12 @@ void Control::_notification(int p_notification) {
}
- //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- // data.theme_owner=data.parent->data.theme_owner;
- // notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ data.theme_owner=data.parent->data.theme_owner;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -503,10 +505,12 @@ void Control::_notification(int p_notification) {
data.parent=NULL;
data.parent_canvas_item=NULL;
- //if (data.theme_owner && data.theme.is_null()) {
- // data.theme_owner=NULL;
- //notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme_owner && data.theme.is_null()) {
+ data.theme_owner=NULL;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
@@ -565,7 +569,7 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible()) {
+ if (!is_visible_in_tree()) {
if(get_viewport() != NULL)
get_viewport()->_gui_hid_control(this);
@@ -1660,7 +1664,7 @@ static Control *_next_control(Control *p_from) {
for(int i=(next+1);i<parent->get_child_count();i++) {
Control *c = parent->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
return c;
@@ -1685,7 +1689,7 @@ Control *Control::find_next_valid_focus() const {
for(int i=0;i<from->get_child_count();i++) {
Control *c = from->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1711,7 +1715,7 @@ Control *Control::find_next_valid_focus() const {
if (!next_child) {
- next_child=const_cast<Control*>(this);;
+ next_child=const_cast<Control*>(this);
while(next_child) {
if (next_child->data.SI || next_child->data.RI)
@@ -1751,7 +1755,7 @@ static Control *_prev_control(Control *p_from) {
for(int i=p_from->get_child_count()-1;i>=0;i--) {
Control *c = p_from->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
child=c;
@@ -1791,7 +1795,7 @@ Control *Control::find_prev_valid_focus() const {
Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1875,7 +1879,7 @@ void Control::show_modal(bool p_exclusive) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(!data.SI);
- if (is_visible())
+ if (is_visible_in_tree())
hide();
ERR_FAIL_COND( data.MI!=NULL );
@@ -1883,7 +1887,7 @@ void Control::show_modal(bool p_exclusive) {
raise();
data.modal_exclusive=p_exclusive;
data.MI=get_viewport()->_gui_show_modal(this);
- data.modal_frame=OS::get_singleton()->get_frames_drawn();
+ data.modal_frame=Engine::get_singleton()->get_frames_drawn();
}
@@ -2053,7 +2057,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
return NULL;
}
bool valid=true;
- if (c->is_hidden())
+ if (!c->is_visible())
valid=false;
if (c->get_focus_mode()==FOCUS_NONE)
valid=false;
@@ -2126,7 +2130,7 @@ void Control::_window_find_focus_neighbour(const Vector2& p_dir, Node *p_at,cons
Control *c = p_at->cast_to<Control>();
- if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible()) {
+ if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible_in_tree()) {
Point2 points[4];
@@ -2417,8 +2421,6 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S
Theme::get_default()->get_font_list(get_class(),&sn);
} else if (pf=="add_constant_override" || pf=="has_constant" || pf=="has_constant_override" || pf=="get_constant") {
Theme::get_default()->get_constant_list(get_class(),&sn);
- } else if (pf=="add_color_override" || pf=="has_color" || pf=="has_color_override" || pf=="get_color") {
- Theme::get_default()->get_color_list(get_class(),&sn);
}
sn.sort_custom<StringName::AlphCompare>();
@@ -2444,125 +2446,125 @@ bool Control::is_clipping_contents() {
void Control::_bind_methods() {
-// ClassDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
- ClassDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
- ClassDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
-
- ClassDB::bind_method(_MD("accept_event"),&Control::accept_event);
- ClassDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
- ClassDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
- ClassDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
- ClassDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
- ClassDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
- ClassDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
- ClassDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
- ClassDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
- ClassDB::bind_method(_MD("set_end","pos"),&Control::set_end);
- ClassDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
- ClassDB::bind_method(_MD("set_size","size"),&Control::set_size);
- ClassDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
- ClassDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
- ClassDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
- ClassDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
+ //ClassDB::bind_method(D_METHOD("_window_resize_event"),&Control::_window_resize_event);
+ ClassDB::bind_method(D_METHOD("_size_changed"),&Control::_size_changed);
+ ClassDB::bind_method(D_METHOD("_update_minimum_size"),&Control::_update_minimum_size);
+
+ ClassDB::bind_method(D_METHOD("accept_event"),&Control::accept_event);
+ ClassDB::bind_method(D_METHOD("get_minimum_size"),&Control::get_minimum_size);
+ ClassDB::bind_method(D_METHOD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
+ ClassDB::bind_method(D_METHOD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
+ ClassDB::bind_method(D_METHOD("get_anchor","margin"),&Control::get_anchor);
+ ClassDB::bind_method(D_METHOD("set_margin","margin","offset"),&Control::set_margin);
+ ClassDB::bind_method(D_METHOD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
+ ClassDB::bind_method(D_METHOD("set_begin","pos"),&Control::set_begin);
+ ClassDB::bind_method(D_METHOD("set_end","pos"),&Control::set_end);
+ ClassDB::bind_method(D_METHOD("set_pos","pos"),&Control::set_pos);
+ ClassDB::bind_method(D_METHOD("set_size","size"),&Control::set_size);
+ ClassDB::bind_method(D_METHOD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
+ ClassDB::bind_method(D_METHOD("set_global_pos","pos"),&Control::set_global_pos);
+ ClassDB::bind_method(D_METHOD("set_rotation","radians"),&Control::set_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ClassDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
- ClassDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
- ClassDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
- ClassDB::bind_method(_MD("get_begin"),&Control::get_begin);
- ClassDB::bind_method(_MD("get_end"),&Control::get_end);
- ClassDB::bind_method(_MD("get_pos"),&Control::get_pos);
- ClassDB::bind_method(_MD("get_size"),&Control::get_size);
- ClassDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
- ClassDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
+ 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("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);
+ ClassDB::bind_method(D_METHOD("get_pos"),&Control::get_pos);
+ ClassDB::bind_method(D_METHOD("get_size"),&Control::get_size);
+ ClassDB::bind_method(D_METHOD("get_rotation"),&Control::get_rotation);
+ ClassDB::bind_method(D_METHOD("get_rotation_deg"),&Control::get_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ClassDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
- ClassDB::bind_method(_MD("get_scale"),&Control::get_scale);
- ClassDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
- ClassDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
- ClassDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
- ClassDB::bind_method(_MD("get_rect"),&Control::get_rect);
- ClassDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
- ClassDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
- ClassDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
- ClassDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
- ClassDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
- ClassDB::bind_method(_MD("has_focus"),&Control::has_focus);
- ClassDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
- ClassDB::bind_method(_MD("release_focus"),&Control::release_focus);
- ClassDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
+ 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_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_pos"),&Control::get_global_pos);
+ ClassDB::bind_method(D_METHOD("get_rect"),&Control::get_rect);
+ ClassDB::bind_method(D_METHOD("get_global_rect"),&Control::get_global_rect);
+ ClassDB::bind_method(D_METHOD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_focus_mode","mode"),&Control::set_focus_mode);
+ ClassDB::bind_method(D_METHOD("get_focus_mode"),&Control::get_focus_mode);
+ ClassDB::bind_method(D_METHOD("has_focus"),&Control::has_focus);
+ ClassDB::bind_method(D_METHOD("grab_focus"),&Control::grab_focus);
+ ClassDB::bind_method(D_METHOD("release_focus"),&Control::release_focus);
+ ClassDB::bind_method(D_METHOD("get_focus_owner:Control"),&Control::get_focus_owner);
- ClassDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
- ClassDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
+ ClassDB::bind_method(D_METHOD("set_h_size_flags","flags"),&Control::set_h_size_flags);
+ ClassDB::bind_method(D_METHOD("get_h_size_flags"),&Control::get_h_size_flags);
- ClassDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
- ClassDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
+ ClassDB::bind_method(D_METHOD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
+ ClassDB::bind_method(D_METHOD("get_stretch_ratio"),&Control::get_stretch_ratio);
- ClassDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
- ClassDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
+ ClassDB::bind_method(D_METHOD("set_v_size_flags","flags"),&Control::set_v_size_flags);
+ ClassDB::bind_method(D_METHOD("get_v_size_flags"),&Control::get_v_size_flags);
- ClassDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
- ClassDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
+ ClassDB::bind_method(D_METHOD("set_theme","theme:Theme"),&Control::set_theme);
+ ClassDB::bind_method(D_METHOD("get_theme:Theme"),&Control::get_theme);
- ClassDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
- ClassDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
- ClassDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
- ClassDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
- ClassDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
- ClassDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
+ ClassDB::bind_method(D_METHOD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
+ ClassDB::bind_method(D_METHOD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
+ ClassDB::bind_method(D_METHOD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
+ ClassDB::bind_method(D_METHOD("add_font_override","name","font:Font"),&Control::add_font_override);
+ ClassDB::bind_method(D_METHOD("add_color_override","name","color"),&Control::add_color_override);
+ ClassDB::bind_method(D_METHOD("add_constant_override","name","constant"),&Control::add_constant_override);
- ClassDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
- ClassDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
- ClassDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
- ClassDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
- ClassDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_color","name","type"),&Control::get_color,DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
- ClassDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
- ClassDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
- ClassDB::bind_method(_MD("has_font_override", "name"), &Control::has_font_override);
- ClassDB::bind_method(_MD("has_color_override", "name"), &Control::has_color_override);
- ClassDB::bind_method(_MD("has_constant_override", "name"), &Control::has_constant_override);
+ ClassDB::bind_method(D_METHOD("has_icon_override", "name"), &Control::has_icon_override);
+ ClassDB::bind_method(D_METHOD("has_stylebox_override", "name"), &Control::has_stylebox_override);
+ ClassDB::bind_method(D_METHOD("has_font_override", "name"), &Control::has_font_override);
+ ClassDB::bind_method(D_METHOD("has_color_override", "name"), &Control::has_color_override);
+ ClassDB::bind_method(D_METHOD("has_constant_override", "name"), &Control::has_constant_override);
- ClassDB::bind_method(_MD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
- ClassDB::bind_method(_MD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
- ClassDB::bind_method(_MD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
- ClassDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
- ClassDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
- ClassDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
+ ClassDB::bind_method(D_METHOD("get_parent_control:Control"),&Control::get_parent_control);
- ClassDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
- ClassDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
- ClassDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
+ 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);
- ClassDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
- ClassDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
- ClassDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
+ ClassDB::bind_method(D_METHOD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
+ ClassDB::bind_method(D_METHOD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
+ ClassDB::bind_method(D_METHOD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
- ClassDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
- ClassDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
+ 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(_MD("force_drag","data","preview"),&Control::force_drag);
+ ClassDB::bind_method(D_METHOD("force_drag","data","preview"),&Control::force_drag);
- ClassDB::bind_method(_MD("set_mouse_filter","filter"),&Control::set_mouse_filter);
- ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter);
+ 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);
- ClassDB::bind_method(_MD("set_clip_contents","enable"),&Control::set_clip_contents);
- ClassDB::bind_method(_MD("is_clipping_contents"),&Control::is_clipping_contents);
+ ClassDB::bind_method(D_METHOD("set_clip_contents","enable"),&Control::set_clip_contents);
+ ClassDB::bind_method(D_METHOD("is_clipping_contents"),&Control::is_clipping_contents);
- ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
+ ClassDB::bind_method(D_METHOD("grab_click_focus"),&Control::grab_click_focus);
- ClassDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
- ClassDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
+ ClassDB::bind_method(D_METHOD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
+ ClassDB::bind_method(D_METHOD("set_drag_preview","control:Control"),&Control::set_drag_preview);
- ClassDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
+ ClassDB::bind_method(D_METHOD("warp_mouse","to_pos"),&Control::warp_mouse);
- ClassDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
+ ClassDB::bind_method(D_METHOD("minimum_size_changed"), &Control::minimum_size_changed);
- ClassDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
+ ClassDB::bind_method(D_METHOD("_theme_changed"), &Control::_theme_changed);
- ClassDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
+ ClassDB::bind_method(D_METHOD("_font_changed"), &Control::_font_changed);
BIND_VMETHOD(MethodInfo("_gui_input",PropertyInfo(Variant::INPUT_EVENT,"event")));
BIND_VMETHOD(MethodInfo(Variant::VECTOR2,"get_minimum_size"));
@@ -2571,44 +2573,44 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
ADD_GROUP("Anchor","anchor_");
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Center"), "_set_anchor","get_anchor", MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Center"), "_set_anchor","get_anchor", MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Center"), "_set_anchor","get_anchor", MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Center"), "_set_anchor","get_anchor", MARGIN_BOTTOM );
ADD_GROUP("Margin","margin_");
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_BOTTOM );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin","get_margin",MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin","get_margin",MARGIN_TOP );
+ 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("Rect","rect_");
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect_rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
- ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect_scale"), _SCS("set_scale"),_SCS("get_scale") );
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"rect_clip_content"), _SCS("set_clip_contents"),_SCS("is_clipping_contents") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), "set_pos","get_pos") ;
+ 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::BOOL,"rect_clip_content"), "set_clip_contents","is_clipping_contents") ;
ADD_GROUP("Hint","hint_");
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), "set_tooltip","_get_tooltip") ;
ADD_GROUP("Focus","focus_");
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_left" ), "set_focus_neighbour","get_focus_neighbour",MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_top" ), "set_focus_neighbour","get_focus_neighbour",MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_right" ), "set_focus_neighbour","get_focus_neighbour",MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_bottom" ), "set_focus_neighbour","get_focus_neighbour",MARGIN_BOTTOM );
ADD_GROUP("Mouse","mouse_");
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mouse_filter",PROPERTY_HINT_ENUM,"Stop,Pass,Ignore"), _SCS("set_mouse_filter"),_SCS("get_mouse_filter") );
+ 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"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
+ 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_GROUP("Theme","");
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), "set_theme","get_theme") ;
ADD_GROUP("","");
BIND_CONSTANT( ANCHOR_BEGIN );
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index cc6fe7cae8..6d06f8c59c 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -33,76 +33,173 @@
void WindowDialog::_post_popup() {
- dragging=false; //just in case
+ drag_type = DRAG_NONE; // just in case
+}
+
+void WindowDialog::_fix_size() {
+
+ // Perhaps this should be called when the viewport resizes aswell or windows go out of bounds...
+
+ // Ensure the whole window is visible.
+ Point2i pos = get_global_pos();
+ Size2i size = get_size();
+ Size2i viewport_size = get_viewport_rect().size;
+
+ // Windows require additional padding to keep the window chrome visible.
+ Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
+ float top = panel->get_margin(MARGIN_TOP);
+ float left = panel->get_margin(MARGIN_LEFT);
+ float bottom = panel->get_margin(MARGIN_BOTTOM);
+ float right = panel->get_margin(MARGIN_RIGHT);
+
+ pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right));
+ pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom));
+ set_global_pos(pos);
+
+ // Also resize the window to fit if a resize should be possible at all.
+ if (resizable) {
+ size.x = MIN(size.x, viewport_size.x - left - right);
+ size.y = MIN(size.y, viewport_size.y - top - bottom);
+ set_size(size);
+ }
}
bool WindowDialog::has_point(const Point2& p_point) const {
+ Rect2 r(Point2(), get_size());
- int extra = get_constant("titlebar_height","WindowDialog");
- Rect2 r( Point2(), get_size() );
- r.pos.y-=extra;
- r.size.y+=extra;
- return r.has_point(p_point);
+ // Enlarge upwards for title bar.
+ int titlebar_height = get_constant("titlebar_height", "WindowDialog");
+ r.pos.y -= titlebar_height;
+ r.size.y += titlebar_height;
+ // Inflate by the resizable border thickness.
+ if (resizable) {
+ int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
+ r.pos.x -= scaleborder_size;
+ r.size.width += scaleborder_size * 2;
+ r.pos.y -= scaleborder_size;
+ r.size.height += scaleborder_size * 2;
+ }
+
+ return r.has_point(p_point);
}
void WindowDialog::_gui_input(const InputEvent& p_event) {
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
-
- if (p_event.mouse_button.pressed && p_event.mouse_button.y < 0)
- dragging=true;
- else if (dragging && !p_event.mouse_button.pressed)
- dragging=false;
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_LEFT) {
+
+ if (p_event.mouse_button.pressed) {
+ // Begin a possible dragging operation.
+ drag_type = _drag_hit_test(Point2(p_event.mouse_button.x, p_event.mouse_button.y));
+ if (drag_type != DRAG_NONE)
+ drag_offset = get_global_mouse_pos() - get_pos();
+ drag_offset_far = get_pos() + get_size() - get_global_mouse_pos();
+ } else if (drag_type != DRAG_NONE && !p_event.mouse_button.pressed) {
+ // End a dragging operation.
+ drag_type = DRAG_NONE;
+ }
}
-
- if (p_event.type == InputEvent::MOUSE_MOTION && dragging) {
-
- Point2 rel( p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y );
- Point2 pos = get_pos();
-
- pos+=rel;
-
- if (pos.y<0)
- pos.y=0;
-
- set_pos(pos);
+ if (p_event.type == InputEvent::MOUSE_MOTION) {
+
+ if (drag_type == DRAG_NONE) {
+ // Update the cursor while moving along the borders.
+ CursorShape cursor = CURSOR_ARROW;
+ if (resizable) {
+ int preview_drag_type = _drag_hit_test(Point2(p_event.mouse_button.x, p_event.mouse_button.y));
+ switch (preview_drag_type) {
+ case DRAG_RESIZE_TOP:
+ case DRAG_RESIZE_BOTTOM:
+ cursor = CURSOR_VSIZE;
+ break;
+ case DRAG_RESIZE_LEFT:
+ case DRAG_RESIZE_RIGHT:
+ cursor = CURSOR_HSIZE;
+ break;
+ case DRAG_RESIZE_TOP + DRAG_RESIZE_LEFT:
+ case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_RIGHT:
+ cursor = CURSOR_FDIAGSIZE;
+ break;
+ case DRAG_RESIZE_TOP + DRAG_RESIZE_RIGHT:
+ case DRAG_RESIZE_BOTTOM + DRAG_RESIZE_LEFT:
+ cursor = CURSOR_BDIAGSIZE;
+ break;
+ }
+ }
+ if (get_cursor_shape() != cursor)
+ set_default_cursor_shape(cursor);
+ } else {
+ // Update while in a dragging operation.
+ Point2 global_pos = get_global_mouse_pos();
+ global_pos.y = MAX(global_pos.y, 0); // Ensure title bar stays visible.
+
+ Rect2 rect = get_rect();
+ Size2 min_size = get_minimum_size();
+
+ if (drag_type == DRAG_MOVE) {
+ rect.pos = global_pos - drag_offset;
+ } else {
+ if (drag_type & DRAG_RESIZE_TOP) {
+ int bottom = rect.pos.y + rect.size.height;
+ int max_y = bottom - min_size.height;
+ rect.pos.y = MIN(global_pos.y - drag_offset.y, max_y);
+ rect.size.height = bottom - rect.pos.y;
+ } else if (drag_type & DRAG_RESIZE_BOTTOM) {
+ rect.size.height = global_pos.y - rect.pos.y + drag_offset_far.y;
+ }
+ if (drag_type & DRAG_RESIZE_LEFT) {
+ int right = rect.pos.x + rect.size.width;
+ int max_x = right - min_size.width;
+ rect.pos.x = MIN(global_pos.x - drag_offset.x, max_x);
+ rect.size.width = right - rect.pos.x;
+ } else if (drag_type & DRAG_RESIZE_RIGHT) {
+ rect.size.width = global_pos.x - rect.pos.x + drag_offset_far.x;
+ }
+ }
+
+ set_size(rect.size);
+ set_pos(rect.pos);
+ }
}
}
void WindowDialog::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_DRAW: {
- RID ci = get_canvas_item();
- Size2 s = get_size();
- Ref<StyleBox> st = get_stylebox("panel","WindowDialog");
- st->draw(ci,Rect2(Point2(),s));
- int th = get_constant("title_height","WindowDialog");
- Color tc = get_color("title_color","WindowDialog");
- Ref<Font> font = get_font("title_font","WindowDialog");
- int ofs = (s.width-font->get_string_size(title).width)/2;
- //int ofs = st->get_margin(MARGIN_LEFT);
- draw_string(font,Point2(ofs,-th+font->get_ascent()),title,tc,s.width - st->get_minimum_size().width);
+ RID canvas = get_canvas_item();
+ Size2 size = get_size();
+
+ Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog");
+ panel->draw(canvas, Rect2(Point2(), size));
+ int title_height = get_constant("title_height", "WindowDialog");
+ Color title_color = get_color("title_color", "WindowDialog");
+ Ref<Font> font = get_font("title_font", "WindowDialog");
+ int ofs = (size.width - font->get_string_size(title).width) / 2;
+ draw_string(font, Point2(ofs, -title_height + font->get_ascent()), title, title_color, size.width - panel->get_minimum_size().width);
} break;
+
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
+ close_button->set_normal_texture(get_icon("close", "WindowDialog"));
+ close_button->set_pressed_texture(get_icon("close", "WindowDialog"));
+ close_button->set_hover_texture(get_icon("close_hilite", "WindowDialog"));
+ close_button->set_anchor(MARGIN_LEFT, ANCHOR_END);
+ close_button->set_begin(Point2(get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
+ } break;
- close_button->set_normal_texture( get_icon("close","WindowDialog"));
- close_button->set_pressed_texture( get_icon("close","WindowDialog"));
- close_button->set_hover_texture( get_icon("close_hilite","WindowDialog"));
- close_button->set_anchor(MARGIN_LEFT,ANCHOR_END);
- close_button->set_begin( Point2( get_constant("close_h_ofs","WindowDialog"), -get_constant("close_v_ofs","WindowDialog") ));
-
+ case NOTIFICATION_MOUSE_EXIT: {
+ // Reset the mouse cursor when leaving the resizable window border.
+ if (resizable && !drag_type) {
+ if (get_default_cursor_shape() != CURSOR_ARROW)
+ set_default_cursor_shape(CURSOR_ARROW);
+ }
} break;
}
-
}
void WindowDialog::_closed() {
@@ -111,11 +208,48 @@ void WindowDialog::_closed() {
hide();
}
+int WindowDialog::_drag_hit_test(const Point2& pos) const {
+ int drag_type = DRAG_NONE;
+
+ if (resizable) {
+ int titlebar_height = get_constant("titlebar_height", "WindowDialog");
+ int scaleborder_size = get_constant("scaleborder_size", "WindowDialog");
+
+ Rect2 rect = get_rect();
+
+ if (pos.y < (-titlebar_height + scaleborder_size))
+ drag_type = DRAG_RESIZE_TOP;
+ else if (pos.y >= (rect.size.height - scaleborder_size))
+ drag_type = DRAG_RESIZE_BOTTOM;
+ if (pos.x < scaleborder_size)
+ drag_type |= DRAG_RESIZE_LEFT;
+ else if (pos.x >= (rect.size.width - scaleborder_size))
+ drag_type |= DRAG_RESIZE_RIGHT;
+ }
+
+ if (drag_type == DRAG_NONE && pos.y < 0)
+ drag_type = DRAG_MOVE;
+
+ return drag_type;
+}
+
void WindowDialog::set_title(const String& p_title) {
title=XL_MESSAGE(p_title);
update();
}
+String WindowDialog::get_title() const {
+
+ return title;
+}
+
+void WindowDialog::set_resizable(bool p_resizable) {
+ resizable = p_resizable;
+}
+bool WindowDialog::get_resizable() const {
+ return resizable;
+}
+
Size2 WindowDialog::get_minimum_size() const {
@@ -127,11 +261,6 @@ Size2 WindowDialog::get_minimum_size() const {
}
-String WindowDialog::get_title() const {
-
- return title;
-}
-
TextureButton *WindowDialog::get_close_button() {
@@ -141,22 +270,26 @@ TextureButton *WindowDialog::get_close_button() {
void WindowDialog::_bind_methods() {
- ClassDB::bind_method( _MD("_gui_input"),&WindowDialog::_gui_input);
- ClassDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
- ClassDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
- ClassDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
- ClassDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
+ ClassDB::bind_method( D_METHOD("_gui_input"),&WindowDialog::_gui_input);
+ ClassDB::bind_method( D_METHOD("set_title","title"),&WindowDialog::set_title);
+ ClassDB::bind_method( D_METHOD("get_title"),&WindowDialog::get_title);
+ ClassDB::bind_method( D_METHOD("set_resizable","resizable"),&WindowDialog::set_resizable);
+ ClassDB::bind_method( D_METHOD("get_resizable"), &WindowDialog::get_resizable);
+ ClassDB::bind_method( D_METHOD("_closed"),&WindowDialog::_closed);
+ ClassDB::bind_method( D_METHOD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"window_title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"window_title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),"set_title","get_title");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizable",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),"set_resizable","get_resizable");
}
WindowDialog::WindowDialog() {
//title="Hello!";
- dragging=false;
- close_button = memnew( TextureButton );
+ drag_type = DRAG_NONE;
+ resizable = false;
+ close_button = memnew(TextureButton);
add_child(close_button);
- close_button->connect("pressed",this,"_closed");
+ close_button->connect("pressed", this, "_closed");
}
@@ -186,7 +319,7 @@ PopupDialog::~PopupDialog() {
}
-//
+// AcceptDialog
void AcceptDialog::_post_popup() {
@@ -201,7 +334,7 @@ void AcceptDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_MODAL_CLOSE) {
cancel_pressed();
- } if (p_what==NOTIFICATION_RESIZED) {
+ } else if (p_what==NOTIFICATION_RESIZED) {
_update_child_rects();
}
@@ -272,7 +405,7 @@ void AcceptDialog::_update_child_rects() {
if (!c)
continue;
- if (c==hbc || c==label || c==get_close_button())
+ if (c==hbc || c==label || c==get_close_button() || c->is_set_as_toplevel())
continue;
c->set_pos(cpos);
@@ -299,7 +432,7 @@ Size2 AcceptDialog::get_minimum_size() const {
if (!c)
continue;
- if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button())
+ if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button() || c->is_set_as_toplevel())
continue;
Size2 cminsize = c->get_combined_minimum_size();
@@ -361,25 +494,25 @@ Button* AcceptDialog::add_cancel(const String &p_cancel) {
void AcceptDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
- ClassDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
- ClassDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
- ClassDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
- ClassDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
- ClassDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
- ClassDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
- ClassDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
- ClassDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
- ClassDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
- ClassDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
- ClassDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
+ ClassDB::bind_method(D_METHOD("_ok"),&AcceptDialog::_ok_pressed);
+ ClassDB::bind_method(D_METHOD("get_ok"),&AcceptDialog::get_ok);
+ ClassDB::bind_method(D_METHOD("get_label"),&AcceptDialog::get_label);
+ ClassDB::bind_method(D_METHOD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
+ ClassDB::bind_method(D_METHOD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
+ ClassDB::bind_method(D_METHOD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
+ ClassDB::bind_method(D_METHOD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
+ ClassDB::bind_method(D_METHOD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
+ ClassDB::bind_method(D_METHOD("_custom_action"),&AcceptDialog::_custom_action);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&AcceptDialog::set_text);
+ ClassDB::bind_method(D_METHOD("get_text"),&AcceptDialog::get_text);
ADD_SIGNAL( MethodInfo("confirmed") );
ADD_SIGNAL( MethodInfo("custom_action",PropertyInfo(Variant::STRING,"action")) );
ADD_GROUP("Dialog","dialog");
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog_text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog_text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),"set_text","get_text");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"),"set_hide_on_ok","get_hide_on_ok") ;
}
@@ -429,7 +562,7 @@ AcceptDialog::~AcceptDialog()
void ConfirmationDialog::_bind_methods() {
- ClassDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
+ ClassDB::bind_method(D_METHOD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
}
Button *ConfirmationDialog::get_cancel() {
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index c7beeea7a3..dd75b76c8e 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -44,15 +44,29 @@ class WindowDialog : public Popup {
GDCLASS(WindowDialog,Popup);
+ enum DRAG_TYPE {
+ DRAG_NONE = 0,
+ DRAG_MOVE = 1,
+ DRAG_RESIZE_TOP = 1 << 1,
+ DRAG_RESIZE_RIGHT = 1 << 2,
+ DRAG_RESIZE_BOTTOM = 1 << 3,
+ DRAG_RESIZE_LEFT = 1 << 4
+ };
+
TextureButton *close_button;
String title;
- bool dragging;
+ int drag_type;
+ Point2 drag_offset;
+ Point2 drag_offset_far;
+ bool resizable;
void _gui_input(const InputEvent& p_event);
void _closed();
+ int _drag_hit_test(const Point2& pos) const;
+
protected:
virtual void _post_popup();
-
+ virtual void _fix_size();
virtual void _close_pressed() {}
virtual bool has_point(const Point2& p_point) const;
void _notification(int p_what);
@@ -63,6 +77,8 @@ public:
void set_title(const String& p_title);
String get_title() const;
+ void set_resizable(bool p_resizable);
+ bool get_resizable() const;
Size2 get_minimum_size() const;
@@ -94,7 +110,7 @@ class AcceptDialog : public WindowDialog {
HBoxContainer *hbc;
Label *label;
Button *ok;
-// Button *cancel; no more cancel (there is X on tht titlebar)
+ //Button *cancel; no more cancel (there is X on tht titlebar)
bool hide_on_ok;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 1cd04551c5..357a70a25b 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -615,7 +615,7 @@ void FileDialog::set_access(Access p_access) {
void FileDialog::invalidate() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
update_file_list();
invalidated=false;
} else {
@@ -686,41 +686,41 @@ bool FileDialog::default_show_hidden_files=false;
void FileDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
-
- ClassDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
- ClassDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
- ClassDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
- ClassDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
- ClassDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
- ClassDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
- ClassDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
- ClassDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
-
- ClassDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
- ClassDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
- ClassDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
- ClassDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
- ClassDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
- ClassDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
- ClassDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
- ClassDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
- ClassDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
- ClassDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
- ClassDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
- ClassDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
- ClassDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
- ClassDB::bind_method(_MD("get_access"),&FileDialog::get_access);
- ClassDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
- ClassDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
- ClassDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
- ClassDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
- ClassDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
- ClassDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
- ClassDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
-
- ClassDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
+ ClassDB::bind_method(D_METHOD("_unhandled_input"),&FileDialog::_unhandled_input);
+
+ ClassDB::bind_method(D_METHOD("_tree_selected"),&FileDialog::_tree_selected);
+ ClassDB::bind_method(D_METHOD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
+ ClassDB::bind_method(D_METHOD("_dir_entered"),&FileDialog::_dir_entered);
+ ClassDB::bind_method(D_METHOD("_file_entered"),&FileDialog::_file_entered);
+ ClassDB::bind_method(D_METHOD("_action_pressed"),&FileDialog::_action_pressed);
+ ClassDB::bind_method(D_METHOD("_cancel_pressed"),&FileDialog::_cancel_pressed);
+ ClassDB::bind_method(D_METHOD("_filter_selected"),&FileDialog::_filter_selected);
+ ClassDB::bind_method(D_METHOD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
+
+ ClassDB::bind_method(D_METHOD("clear_filters"),&FileDialog::clear_filters);
+ ClassDB::bind_method(D_METHOD("add_filter","filter"),&FileDialog::add_filter);
+ ClassDB::bind_method(D_METHOD("set_filters","filters"),&FileDialog::set_filters);
+ ClassDB::bind_method(D_METHOD("get_filters"),&FileDialog::get_filters);
+ ClassDB::bind_method(D_METHOD("get_current_dir"),&FileDialog::get_current_dir);
+ ClassDB::bind_method(D_METHOD("get_current_file"),&FileDialog::get_current_file);
+ ClassDB::bind_method(D_METHOD("get_current_path"),&FileDialog::get_current_path);
+ ClassDB::bind_method(D_METHOD("set_current_dir","dir"),&FileDialog::set_current_dir);
+ ClassDB::bind_method(D_METHOD("set_current_file","file"),&FileDialog::set_current_file);
+ ClassDB::bind_method(D_METHOD("set_current_path","path"),&FileDialog::set_current_path);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&FileDialog::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&FileDialog::get_mode);
+ ClassDB::bind_method(D_METHOD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
+ ClassDB::bind_method(D_METHOD("set_access","access"),&FileDialog::set_access);
+ ClassDB::bind_method(D_METHOD("get_access"),&FileDialog::get_access);
+ ClassDB::bind_method(D_METHOD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
+ ClassDB::bind_method(D_METHOD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
+ ClassDB::bind_method(D_METHOD("_select_drive"),&FileDialog::_select_drive);
+ ClassDB::bind_method(D_METHOD("_make_dir"),&FileDialog::_make_dir);
+ ClassDB::bind_method(D_METHOD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("_update_file_list"),&FileDialog::update_file_list);
+ ClassDB::bind_method(D_METHOD("_update_dir"),&FileDialog::update_dir);
+
+ ClassDB::bind_method(D_METHOD("invalidate"),&FileDialog::invalidate);
ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::POOL_STRING_ARRAY,"paths")));
@@ -737,10 +737,10 @@ void FileDialog::_bind_methods() {
BIND_CONSTANT( ACCESS_USERDATA );
BIND_CONSTANT( ACCESS_FILESYSTEM );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"),_SCS("set_mode"),_SCS("get_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"),_SCS("set_access"),_SCS("get_access") );
- ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "show_hidden_files"),_SCS("set_show_hidden_files"),_SCS("is_showing_hidden_files") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"),"set_mode","get_mode") ;
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"),"set_access","get_access") ;
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY, "filters"),"set_filters","get_filters") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "show_hidden_files"),"set_show_hidden_files","is_showing_hidden_files") ;
}
@@ -868,11 +868,11 @@ FileDialog::~FileDialog() {
void LineEditFileChooser::_bind_methods() {
- ClassDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
- ClassDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
- ClassDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
- ClassDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
- ClassDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
+ ClassDB::bind_method(D_METHOD("_browse"),&LineEditFileChooser::_browse);
+ ClassDB::bind_method(D_METHOD("_chosen"),&LineEditFileChooser::_chosen);
+ ClassDB::bind_method(D_METHOD("get_button:Button"),&LineEditFileChooser::get_button);
+ ClassDB::bind_method(D_METHOD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
+ ClassDB::bind_method(D_METHOD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index b919f0649d..a6954a2c77 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -295,7 +295,7 @@ void GraphEdit::_notification(int p_what) {
zoom_reset->set_icon(get_icon("reset"));
zoom_plus->set_icon(get_icon("more"));
snap_button->set_icon(get_icon("snap"));
-// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
+ //zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
}
if (p_what==NOTIFICATION_DRAW) {
@@ -1054,7 +1054,7 @@ void GraphEdit::set_zoom(float p_zoom) {
_update_scroll();
connections_layer->update();
- if (is_visible()) {
+ if (is_visible_in_tree()) {
Vector2 ofs = sbofs*zoom - get_size()/2;
h_scroll->set_value( ofs.x );
@@ -1201,44 +1201,44 @@ void GraphEdit::_snap_value_changed(double) {
void GraphEdit::_bind_methods() {
- ClassDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
- ClassDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
- ClassDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
- ClassDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
- ClassDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
- ClassDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
+ ClassDB::bind_method(D_METHOD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
+ ClassDB::bind_method(D_METHOD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
+ ClassDB::bind_method(D_METHOD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
+ ClassDB::bind_method(D_METHOD("get_connection_list"),&GraphEdit::_get_connection_list);
+ ClassDB::bind_method(D_METHOD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
+ ClassDB::bind_method(D_METHOD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
- ClassDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
- ClassDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
+ ClassDB::bind_method(D_METHOD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
+ ClassDB::bind_method(D_METHOD("get_zoom"),&GraphEdit::get_zoom);
- ClassDB::bind_method(_MD("set_snap","pixels"),&GraphEdit::set_snap);
- ClassDB::bind_method(_MD("get_snap"),&GraphEdit::get_snap);
+ ClassDB::bind_method(D_METHOD("set_snap","pixels"),&GraphEdit::set_snap);
+ ClassDB::bind_method(D_METHOD("get_snap"),&GraphEdit::get_snap);
- ClassDB::bind_method(_MD("set_use_snap","enable"),&GraphEdit::set_use_snap);
- ClassDB::bind_method(_MD("is_using_snap"),&GraphEdit::is_using_snap);
+ ClassDB::bind_method(D_METHOD("set_use_snap","enable"),&GraphEdit::set_use_snap);
+ ClassDB::bind_method(D_METHOD("is_using_snap"),&GraphEdit::is_using_snap);
- ClassDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
- ClassDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
+ ClassDB::bind_method(D_METHOD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
+ ClassDB::bind_method(D_METHOD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
- ClassDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
- ClassDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
+ ClassDB::bind_method(D_METHOD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
+ ClassDB::bind_method(D_METHOD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
- ClassDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
- ClassDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
- ClassDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
- ClassDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
- ClassDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
- ClassDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
- ClassDB::bind_method(_MD("_snap_toggled"),&GraphEdit::_snap_toggled);
- ClassDB::bind_method(_MD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
+ ClassDB::bind_method(D_METHOD("_top_layer_input"),&GraphEdit::_top_layer_input);
+ ClassDB::bind_method(D_METHOD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
+ ClassDB::bind_method(D_METHOD("_scroll_moved"),&GraphEdit::_scroll_moved);
+ ClassDB::bind_method(D_METHOD("_zoom_minus"),&GraphEdit::_zoom_minus);
+ ClassDB::bind_method(D_METHOD("_zoom_reset"),&GraphEdit::_zoom_reset);
+ ClassDB::bind_method(D_METHOD("_zoom_plus"),&GraphEdit::_zoom_plus);
+ ClassDB::bind_method(D_METHOD("_snap_toggled"),&GraphEdit::_snap_toggled);
+ ClassDB::bind_method(D_METHOD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
- ClassDB::bind_method(_MD("_gui_input"),&GraphEdit::_gui_input);
- ClassDB::bind_method(_MD("_update_scroll_offset"),&GraphEdit::_update_scroll_offset);
- ClassDB::bind_method(_MD("_connections_layer_draw"),&GraphEdit::_connections_layer_draw);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&GraphEdit::_gui_input);
+ 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(_MD("set_selected","node"),&GraphEdit::set_selected);
+ ClassDB::bind_method(D_METHOD("set_selected","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 86b976c4fe..3e9944332f 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -34,7 +34,7 @@
#include "scene/gui/slider.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/spin_box.h"
-#include "texture_frame.h"
+#include "scene/gui/texture_rect.h"
class GraphEdit;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 8b7b84910d..58d3f42483 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -217,8 +217,8 @@ void GraphNode::_notification(int p_what) {
sb = get_stylebox( selected ? "selectedframe" : "frame");
}
- sb=sb->duplicate();
- sb->call("set_modulate",modulate);
+ //sb=sb->duplicate();
+ //sb->call("set_modulate",modulate);
Ref<Texture> port =get_icon("port");
Ref<Texture> close =get_icon("close");
Ref<Texture> resizer =get_icon("resizer");
@@ -675,16 +675,6 @@ void GraphNode::_gui_input(const InputEvent& p_ev) {
}
-void GraphNode::set_modulate(const Color &p_color) {
-
- modulate=p_color;
- update();
-}
-
-Color GraphNode::get_modulate() const{
-
- return modulate;
-}
void GraphNode::set_overlay(Overlay p_overlay) {
overlay=p_overlay;
@@ -722,54 +712,51 @@ bool GraphNode::is_resizeable() const{
void GraphNode::_bind_methods() {
- ClassDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
- ClassDB::bind_method(_MD("get_title"),&GraphNode::get_title);
- ClassDB::bind_method(_MD("_gui_input"),&GraphNode::_gui_input);
-
- ClassDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
- ClassDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
- ClassDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
- ClassDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
- ClassDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
- ClassDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
- ClassDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
- ClassDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
- ClassDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
+ ClassDB::bind_method(D_METHOD("set_title","title"),&GraphNode::set_title);
+ ClassDB::bind_method(D_METHOD("get_title"),&GraphNode::get_title);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&GraphNode::_gui_input);
- ClassDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
+ ClassDB::bind_method(D_METHOD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(D_METHOD("clear_slot","idx"),&GraphNode::clear_slot);
+ ClassDB::bind_method(D_METHOD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
+ ClassDB::bind_method(D_METHOD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
+ ClassDB::bind_method(D_METHOD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
+ ClassDB::bind_method(D_METHOD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
+ ClassDB::bind_method(D_METHOD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
+ ClassDB::bind_method(D_METHOD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
+ ClassDB::bind_method(D_METHOD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
- ClassDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
- ClassDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&GraphNode::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&GraphNode::get_offset);
- ClassDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
- ClassDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
+ ClassDB::bind_method(D_METHOD("set_comment","comment"),&GraphNode::set_comment);
+ ClassDB::bind_method(D_METHOD("is_comment"),&GraphNode::is_comment);
- ClassDB::bind_method(_MD("set_selected","selected"),&GraphNode::set_selected);
- ClassDB::bind_method(_MD("is_selected"),&GraphNode::is_selected);
+ ClassDB::bind_method(D_METHOD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
+ ClassDB::bind_method(D_METHOD("is_resizeable"),&GraphNode::is_resizeable);
- ClassDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
- ClassDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
+ ClassDB::bind_method(D_METHOD("set_selected","selected"),&GraphNode::set_selected);
+ ClassDB::bind_method(D_METHOD("is_selected"),&GraphNode::is_selected);
- ClassDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
- ClassDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
- ClassDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
- ClassDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
- ClassDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
- ClassDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
+ ClassDB::bind_method(D_METHOD("get_connection_output_count"),&GraphNode::get_connection_output_count);
+ ClassDB::bind_method(D_METHOD("get_connection_input_count"),&GraphNode::get_connection_input_count);
- ClassDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate);
- ClassDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate);
+ ClassDB::bind_method(D_METHOD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
+ ClassDB::bind_method(D_METHOD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
+ ClassDB::bind_method(D_METHOD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
+ ClassDB::bind_method(D_METHOD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
+ ClassDB::bind_method(D_METHOD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
+ ClassDB::bind_method(D_METHOD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
- ClassDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
- ClassDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
+ ClassDB::bind_method(D_METHOD("set_show_close_button","show"),&GraphNode::set_show_close_button);
+ ClassDB::bind_method(D_METHOD("is_close_button_visible"),&GraphNode::is_close_button_visible);
- ClassDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
- ClassDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
+ ClassDB::bind_method(D_METHOD("set_overlay","overlay"),&GraphNode::set_overlay);
+ ClassDB::bind_method(D_METHOD("get_overlay"),&GraphNode::get_overlay);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizeable"),_SCS("set_resizeable"),_SCS("is_resizeable"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),"set_title","get_title");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),"set_show_close_button","is_close_button_visible");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizeable"),"set_resizeable","is_resizeable");
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
@@ -788,7 +775,6 @@ GraphNode::GraphNode() {
show_close=false;
connpos_dirty=true;
set_mouse_filter(MOUSE_FILTER_PASS);
- modulate=Color(1,1,1,1);
comment=false;
resizeable=false;
resizing=false;
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index a128426d38..9cb46fc49c 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -92,8 +92,6 @@ private:
Overlay overlay;
- Color modulate;
-
bool has_point(const Point2& p_point) const;
protected:
@@ -147,9 +145,6 @@ public:
Color get_connection_output_color(int p_idx);
- void set_modulate(const Color& p_color);
- Color get_modulate() const;
-
void set_overlay(Overlay p_overlay);
Overlay get_overlay() const;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 7dffaa2fd5..ee1d642110 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -53,7 +53,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
@@ -70,7 +70,7 @@ void GridContainer::_notification(int p_what) {
else
row_minh[row]=ms.height;
- // print_line("store row "+itos(row)+" mw "+itos(ms.height));
+ //print_line("store row "+itos(row)+" mw "+itos(ms.height));
if (c->get_h_size_flags()&SIZE_EXPAND)
col_expanded.insert(col);
@@ -112,7 +112,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
@@ -136,7 +136,7 @@ void GridContainer::_notification(int p_what) {
Point2 p(col_ofs,row_ofs);
-// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
+ //print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
fit_child_in_rect(c,Rect2(p,s));
//print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s));
@@ -170,10 +170,10 @@ int GridContainer::get_columns() const{
void GridContainer::_bind_methods(){
- ClassDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
- ClassDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
+ ClassDB::bind_method(D_METHOD("set_columns","columns"),&GridContainer::set_columns);
+ ClassDB::bind_method(D_METHOD("get_columns"),&GridContainer::get_columns);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),_SCS("set_columns"),_SCS("get_columns"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),"set_columns","get_columns");
}
Size2 GridContainer::get_minimum_size() const {
@@ -191,7 +191,7 @@ Size2 GridContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
diff --git a/scene/gui/input_action.cpp b/scene/gui/input_action.cpp
index 77026dfdb1..06787fca9e 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/input_action.cpp
@@ -109,15 +109,15 @@ bool ShortCut::is_valid() const {
void ShortCut::_bind_methods() {
- ClassDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
- ClassDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
+ ClassDB::bind_method(D_METHOD("set_shortcut","event"),&ShortCut::set_shortcut);
+ ClassDB::bind_method(D_METHOD("get_shortcut"),&ShortCut::get_shortcut);
- ClassDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
+ ClassDB::bind_method(D_METHOD("is_valid"),&ShortCut::is_valid);
- ClassDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
- ClassDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
+ ClassDB::bind_method(D_METHOD("is_shortcut","event"),&ShortCut::is_shortcut);
+ ClassDB::bind_method(D_METHOD("get_as_text"),&ShortCut::get_as_text);
- ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT,"shortcut"),_SCS("set_shortcut"),_SCS("get_shortcut"));
+ ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT,"shortcut"),"set_shortcut","get_shortcut");
}
ShortCut::ShortCut(){
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index ece6171b6e..91bd16ee0b 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "item_list.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool p_selectable) {
@@ -300,7 +300,7 @@ void ItemList::move_item(int p_item,int p_to_pos) {
ERR_FAIL_INDEX(p_to_pos,items.size()+1);
Item it=items[p_item];
- items.remove(p_item);;
+ items.remove(p_item);
if (p_to_pos>p_item) {
p_to_pos--;
@@ -314,7 +314,7 @@ void ItemList::move_item(int p_item,int p_to_pos) {
if (current<0) {
//do none
- } if (p_item==current) {
+ } else if (p_item==current) {
current=p_to_pos;
} else if (p_to_pos>p_item && current>p_item && current<p_to_pos) {
current--;
@@ -801,7 +801,7 @@ void ItemList::_notification(int p_what) {
float page = size.height-bg->get_minimum_size().height;
int width = size.width-bg->get_minimum_size().width;
- if (!scroll_bar->is_hidden()){
+ if (scroll_bar->is_visible()){
width-=mw+bg->get_margin(MARGIN_RIGHT);
}
scroll_bar->set_page(page);
@@ -905,7 +905,7 @@ void ItemList::_notification(int p_what) {
Vector2 ofs;
int col=0;
int max_h=0;
- separators.clear();;
+ separators.clear();
for(int i=0;i<items.size();i++) {
if (current_columns>1 && items[i].rect_cache.size.width+ofs.x > fit_size) {
@@ -1204,6 +1204,22 @@ int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const {
return closest;
}
+bool ItemList::is_pos_at_end_of_items(const Point2& p_pos) const {
+
+ if (items.empty())
+ return true;
+
+ Vector2 pos=p_pos;
+ Ref<StyleBox> bg = get_stylebox("bg");
+ pos-=bg->get_offset();
+ pos.y+=scroll_bar->get_value();
+
+ Rect2 endrect = items[items.size()-1].rect_cache;
+ return (pos.y > endrect.pos.y + endrect.size.y);
+
+}
+
+
String ItemList::get_tooltip(const Point2& p_pos) const {
int closest = get_item_at_pos(p_pos);
@@ -1284,83 +1300,83 @@ Vector<int> ItemList::get_selected_items() {
void ItemList::_bind_methods(){
- ClassDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
- ClassDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
- ClassDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
- ClassDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
+ ClassDB::bind_method(D_METHOD("set_item_text","idx","text"),&ItemList::set_item_text);
+ ClassDB::bind_method(D_METHOD("get_item_text","idx"),&ItemList::get_item_text);
- ClassDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
- ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ClassDB::bind_method(D_METHOD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
+ ClassDB::bind_method(D_METHOD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
- ClassDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
- ClassDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+ ClassDB::bind_method(D_METHOD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
+ ClassDB::bind_method(D_METHOD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
- ClassDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
- ClassDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
+ ClassDB::bind_method(D_METHOD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
+ ClassDB::bind_method(D_METHOD("is_item_selectable","idx"),&ItemList::is_item_selectable);
- ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
- ClassDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
+ ClassDB::bind_method(D_METHOD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
+ ClassDB::bind_method(D_METHOD("is_item_disabled","idx"),&ItemList::is_item_disabled);
- ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
- ClassDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
+ 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(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
- ClassDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
+ 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);
- ClassDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
- ClassDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
+ ClassDB::bind_method(D_METHOD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
+ ClassDB::bind_method(D_METHOD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
- ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
- ClassDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
+ ClassDB::bind_method(D_METHOD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
+ ClassDB::bind_method(D_METHOD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
- ClassDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
- ClassDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
- ClassDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
- ClassDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
+ ClassDB::bind_method(D_METHOD("select","idx","single"),&ItemList::select,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("unselect","idx"),&ItemList::unselect);
+ ClassDB::bind_method(D_METHOD("is_selected","idx"),&ItemList::is_selected);
+ ClassDB::bind_method(D_METHOD("get_selected_items"),&ItemList::get_selected_items);
- ClassDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
- ClassDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
+ ClassDB::bind_method(D_METHOD("get_item_count"),&ItemList::get_item_count);
+ ClassDB::bind_method(D_METHOD("remove_item","idx"),&ItemList::remove_item);
- ClassDB::bind_method(_MD("clear"),&ItemList::clear);
- ClassDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
+ ClassDB::bind_method(D_METHOD("clear"),&ItemList::clear);
+ ClassDB::bind_method(D_METHOD("sort_items_by_text"),&ItemList::sort_items_by_text);
- ClassDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
- ClassDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
+ ClassDB::bind_method(D_METHOD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
+ ClassDB::bind_method(D_METHOD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
- ClassDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
- ClassDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
+ ClassDB::bind_method(D_METHOD("set_same_column_width","enable"),&ItemList::set_same_column_width);
+ ClassDB::bind_method(D_METHOD("is_same_column_width"),&ItemList::is_same_column_width);
- ClassDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
- ClassDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
+ ClassDB::bind_method(D_METHOD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
+ ClassDB::bind_method(D_METHOD("get_max_text_lines"),&ItemList::get_max_text_lines);
- ClassDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
- ClassDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
+ ClassDB::bind_method(D_METHOD("set_max_columns","amount"),&ItemList::set_max_columns);
+ ClassDB::bind_method(D_METHOD("get_max_columns"),&ItemList::get_max_columns);
- ClassDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
- ClassDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
+ ClassDB::bind_method(D_METHOD("set_select_mode","mode"),&ItemList::set_select_mode);
+ ClassDB::bind_method(D_METHOD("get_select_mode"),&ItemList::get_select_mode);
- ClassDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
- ClassDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
+ ClassDB::bind_method(D_METHOD("set_icon_mode","mode"),&ItemList::set_icon_mode);
+ ClassDB::bind_method(D_METHOD("get_icon_mode"),&ItemList::get_icon_mode);
- ClassDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
- ClassDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
+ ClassDB::bind_method(D_METHOD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
+ ClassDB::bind_method(D_METHOD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
- ClassDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
- ClassDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
+ ClassDB::bind_method(D_METHOD("set_icon_scale","scale"),&ItemList::set_icon_scale);
+ ClassDB::bind_method(D_METHOD("get_icon_scale"),&ItemList::get_icon_scale);
- ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
- ClassDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
+ 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(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
- ClassDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
+ ClassDB::bind_method(D_METHOD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
- ClassDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("get_v_scroll"),&ItemList::get_v_scroll);
- ClassDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
- ClassDB::bind_method(_MD("_gui_input"),&ItemList::_gui_input);
+ ClassDB::bind_method(D_METHOD("_scroll_changed"),&ItemList::_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ItemList::_gui_input);
BIND_CONSTANT( ICON_MODE_TOP );
BIND_CONSTANT( ICON_MODE_LEFT );
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index f4a864c782..35ffb1be9c 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -191,6 +191,7 @@ public:
virtual String get_tooltip(const Point2& p_pos) const;
int get_item_at_pos(const Point2& p_pos,bool p_exact=false) const;
+ bool is_pos_at_end_of_items(const Point2& p_pos) const;
void set_icon_scale(real_t p_scale);
real_t get_icon_scale() const;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index cd500a62bc..915eaa2f45 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "label.h"
#include "print_string.h"
-#include "globals.h"
+#include "global_config.h"
#include "translation.h"
@@ -204,7 +204,7 @@ void Label::_notification(int p_what) {
} break;
case ALIGN_CENTER: {
- x_ofs=int(size.width-(taken+spaces*space_w))/2;;
+ x_ofs=int(size.width-(taken+spaces*space_w))/2;
} break;
case ALIGN_RIGHT: {
@@ -648,30 +648,30 @@ int Label::get_total_character_count() const {
void Label::_bind_methods() {
- ClassDB::bind_method(_MD("set_align","align"),&Label::set_align);
- ClassDB::bind_method(_MD("get_align"),&Label::get_align);
- ClassDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
- ClassDB::bind_method(_MD("get_valign"),&Label::get_valign);
- ClassDB::bind_method(_MD("set_text","text"),&Label::set_text);
- ClassDB::bind_method(_MD("get_text"),&Label::get_text);
- ClassDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
- ClassDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
- ClassDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
- ClassDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
- ClassDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
- ClassDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
- ClassDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
- ClassDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
- ClassDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
- ClassDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
- ClassDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
- ClassDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
- ClassDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
- ClassDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
- ClassDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
- ClassDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
- ClassDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
- ClassDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
+ ClassDB::bind_method(D_METHOD("set_align","align"),&Label::set_align);
+ ClassDB::bind_method(D_METHOD("get_align"),&Label::get_align);
+ ClassDB::bind_method(D_METHOD("set_valign","valign"),&Label::set_valign);
+ ClassDB::bind_method(D_METHOD("get_valign"),&Label::get_valign);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&Label::set_text);
+ ClassDB::bind_method(D_METHOD("get_text"),&Label::get_text);
+ ClassDB::bind_method(D_METHOD("set_autowrap","enable"),&Label::set_autowrap);
+ ClassDB::bind_method(D_METHOD("has_autowrap"),&Label::has_autowrap);
+ ClassDB::bind_method(D_METHOD("set_clip_text","enable"),&Label::set_clip_text);
+ ClassDB::bind_method(D_METHOD("is_clipping_text"),&Label::is_clipping_text);
+ ClassDB::bind_method(D_METHOD("set_uppercase","enable"),&Label::set_uppercase);
+ ClassDB::bind_method(D_METHOD("is_uppercase"),&Label::is_uppercase);
+ ClassDB::bind_method(D_METHOD("get_line_height"),&Label::get_line_height);
+ ClassDB::bind_method(D_METHOD("get_line_count"),&Label::get_line_count);
+ ClassDB::bind_method(D_METHOD("get_visible_line_count"),&Label::get_visible_line_count);
+ ClassDB::bind_method(D_METHOD("get_total_character_count"),&Label::get_total_character_count);
+ ClassDB::bind_method(D_METHOD("set_visible_characters","amount"),&Label::set_visible_characters);
+ ClassDB::bind_method(D_METHOD("get_visible_characters"),&Label::get_visible_characters);
+ ClassDB::bind_method(D_METHOD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
+ ClassDB::bind_method(D_METHOD("get_percent_visible"),&Label::get_percent_visible);
+ ClassDB::bind_method(D_METHOD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
+ ClassDB::bind_method(D_METHOD("get_lines_skipped"),&Label::get_lines_skipped);
+ ClassDB::bind_method(D_METHOD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
+ ClassDB::bind_method(D_METHOD("get_max_lines_visible"),&Label::get_max_lines_visible);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
@@ -683,15 +683,15 @@ void Label::_bind_methods() {
BIND_CONSTANT( VALIGN_BOTTOM );
BIND_CONSTANT( VALIGN_FILL );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text"),_SCS("set_clip_text"),_SCS("is_clipping_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lines_skipped", PROPERTY_HINT_RANGE,"0,999,1"),_SCS("set_lines_skipped"),_SCS("get_lines_skipped") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "max_lines_visible", PROPERTY_HINT_RANGE,"-1,999,1"),_SCS("set_max_lines_visible"),_SCS("get_max_lines_visible") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), "set_text","get_text") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),"set_align","get_align") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),"set_valign","get_valign") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "autowrap"),"set_autowrap","has_autowrap") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text"),"set_clip_text","is_clipping_text") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "uppercase"),"set_uppercase","is_uppercase") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),"set_percent_visible","get_percent_visible") ;
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lines_skipped", PROPERTY_HINT_RANGE,"0,999,1"),"set_lines_skipped","get_lines_skipped") ;
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "max_lines_visible", PROPERTY_HINT_RANGE,"-1,999,1"),"set_max_lines_visible","get_max_lines_visible") ;
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index e75785b1ff..893670efea 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -96,8 +96,6 @@ void LineEdit::_gui_input(InputEvent p_event) {
}
}
- // if (!editable)
- // non_editable_clicked_signal.call();
update();
} else {
@@ -853,7 +851,7 @@ void LineEdit::_reset_caret_blink_timer() {
void LineEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible() && has_focus() && window_has_focus) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -873,7 +871,7 @@ void LineEdit::delete_char() {
if (cursor_pos==window_pos) {
- // set_window_pos(cursor_pos-get_window_length());
+ //set_window_pos(cursor_pos-get_window_length());
}
_text_changed();
@@ -1258,42 +1256,42 @@ void LineEdit::_text_changed() {
void LineEdit::_bind_methods() {
- ClassDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
+ ClassDB::bind_method(D_METHOD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
#ifdef TOOLS_ENABLED
ClassDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
#endif
- ClassDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
- ClassDB::bind_method(_MD("get_align"), &LineEdit::get_align);
-
- ClassDB::bind_method(_MD("_gui_input"),&LineEdit::_gui_input);
- ClassDB::bind_method(_MD("clear"),&LineEdit::clear);
- ClassDB::bind_method(_MD("select_all"),&LineEdit::select_all);
- ClassDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
- ClassDB::bind_method(_MD("get_text"),&LineEdit::get_text);
- ClassDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
- ClassDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
- ClassDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
- ClassDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
- ClassDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
- ClassDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
- ClassDB::bind_method(_MD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
- ClassDB::bind_method(_MD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
- ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
- ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
- ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
- ClassDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
- ClassDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
- ClassDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
- ClassDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
- ClassDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
- ClassDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
- ClassDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
- ClassDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
- ClassDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
- ClassDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
- ClassDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
+ ClassDB::bind_method(D_METHOD("set_align", "align"), &LineEdit::set_align);
+ ClassDB::bind_method(D_METHOD("get_align"), &LineEdit::get_align);
+
+ ClassDB::bind_method(D_METHOD("_gui_input"),&LineEdit::_gui_input);
+ ClassDB::bind_method(D_METHOD("clear"),&LineEdit::clear);
+ ClassDB::bind_method(D_METHOD("select_all"),&LineEdit::select_all);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&LineEdit::set_text);
+ ClassDB::bind_method(D_METHOD("get_text"),&LineEdit::get_text);
+ ClassDB::bind_method(D_METHOD("set_placeholder","text"),&LineEdit::set_placeholder);
+ ClassDB::bind_method(D_METHOD("get_placeholder"),&LineEdit::get_placeholder);
+ ClassDB::bind_method(D_METHOD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
+ ClassDB::bind_method(D_METHOD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
+ ClassDB::bind_method(D_METHOD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
+ ClassDB::bind_method(D_METHOD("get_cursor_pos"),&LineEdit::get_cursor_pos);
+ ClassDB::bind_method(D_METHOD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
+ ClassDB::bind_method(D_METHOD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
+ ClassDB::bind_method(D_METHOD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(D_METHOD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(D_METHOD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(D_METHOD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(D_METHOD("set_max_length","chars"),&LineEdit::set_max_length);
+ ClassDB::bind_method(D_METHOD("get_max_length"),&LineEdit::get_max_length);
+ ClassDB::bind_method(D_METHOD("append_at_cursor","text"),&LineEdit::append_at_cursor);
+ ClassDB::bind_method(D_METHOD("set_editable","enabled"),&LineEdit::set_editable);
+ ClassDB::bind_method(D_METHOD("is_editable"),&LineEdit::is_editable);
+ ClassDB::bind_method(D_METHOD("set_secret","enabled"),&LineEdit::set_secret);
+ ClassDB::bind_method(D_METHOD("is_secret"),&LineEdit::is_secret);
+ ClassDB::bind_method(D_METHOD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("menu_option","option"),&LineEdit::menu_option);
+ ClassDB::bind_method(D_METHOD("get_menu:PopupMenu"),&LineEdit::get_menu);
ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) );
ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) );
@@ -1311,19 +1309,19 @@ void LineEdit::_bind_methods() {
BIND_CONSTANT( MENU_UNDO );
BIND_CONSTANT( MENU_MAX );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "secret" ), _SCS("set_secret"),_SCS("is_secret") );
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "expand_to_len" ), _SCS("set_expand_to_text_length"),_SCS("get_expand_to_text_length") );
- ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), "set_text","get_text") ;
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_align", "get_align");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), "set_max_length","get_max_length") ;
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), "set_editable","is_editable") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "secret" ), "set_secret","is_secret") ;
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "expand_to_len" ), "set_expand_to_text_length","get_expand_to_text_length") ;
+ ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), "set_focus_mode", "get_focus_mode") ;
ADD_GROUP("Placeholder","placeholder_");
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder_text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder_alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder_text" ), "set_placeholder","get_placeholder") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder_alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), "set_placeholder_alpha","get_placeholder_alpha") ;
ADD_GROUP("Caret","caret_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), "cursor_set_blink_speed","cursor_get_blink_speed") ;
}
LineEdit::LineEdit() {
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 5b791064a8..7ea88f35f3 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -130,19 +130,19 @@ void LinkButton::_notification(int p_what) {
void LinkButton::_bind_methods() {
- ClassDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
- ClassDB::bind_method(_MD("get_text"),&LinkButton::get_text);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&LinkButton::set_text);
+ ClassDB::bind_method(D_METHOD("get_text"),&LinkButton::get_text);
- ClassDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
- ClassDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
+ ClassDB::bind_method(D_METHOD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
+ ClassDB::bind_method(D_METHOD("get_underline_mode"),&LinkButton::get_underline_mode);
BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
BIND_CONSTANT( UNDERLINE_MODE_NEVER );
- ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), _SCS("set_text"), _SCS("get_text"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), "set_text", "get_text");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), "set_underline_mode", "get_underline_mode");
}
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 883364b2fd..be27c40117 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -45,7 +45,7 @@ Size2 MarginContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 s = c->get_combined_minimum_size();
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 755b296666..f15b864b95 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -36,7 +36,7 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYPAD_BUTTON)) {
- if (!get_parent() || !is_visible() || is_disabled())
+ if (!get_parent() || !is_visible_in_tree() || is_disabled())
return;
bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
@@ -67,7 +67,7 @@ void MenuButton::_gui_input(InputEvent p_event) {
/*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
clicked=p_event.mouse_button.pressed;
}
- if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible()) {
+ if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) {
Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
gt = get_global_transform().xform(gt);
@@ -98,12 +98,12 @@ void MenuButton::_set_items(const Array& p_items) {
void MenuButton::_bind_methods() {
- ClassDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
- ClassDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
- ClassDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
- ClassDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
+ ClassDB::bind_method(D_METHOD("get_popup:PopupMenu"),&MenuButton::get_popup);
+ ClassDB::bind_method(D_METHOD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("_set_items"),&MenuButton::_set_items);
+ ClassDB::bind_method(D_METHOD("_get_items"),&MenuButton::_get_items);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_items","_get_items") ;
ADD_SIGNAL( MethodInfo("about_to_show") );
}
@@ -117,7 +117,7 @@ MenuButton::MenuButton() {
add_child(popup);
popup->set_as_toplevel(true);
set_process_unhandled_key_input(true);
- set_click_on_press(true);
+ set_action_mode(ACTION_MODE_BUTTON_PRESS);
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 1b5b21ae92..9ead79b491 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -287,35 +287,35 @@ void OptionButton::get_translatable_strings(List<String> *p_strings) const {
void OptionButton::_bind_methods() {
- ClassDB::bind_method(_MD("_selected"),&OptionButton::_selected);
-
- ClassDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
- ClassDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
- ClassDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
- ClassDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
- ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
- ClassDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
- ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
- ClassDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
- ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
- ClassDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
- ClassDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
- ClassDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
- ClassDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
- ClassDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
- ClassDB::bind_method(_MD("clear"),&OptionButton::clear);
- ClassDB::bind_method(_MD("select","idx"),&OptionButton::select);
- ClassDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
- ClassDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
- ClassDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
- ClassDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
- ClassDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
-
- ClassDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
- ClassDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"selected"), _SCS("_select_int"),_SCS("get_selected") );
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
+ ClassDB::bind_method(D_METHOD("_selected"),&OptionButton::_selected);
+
+ ClassDB::bind_method(D_METHOD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
+ ClassDB::bind_method(D_METHOD("set_item_text","idx","text"),&OptionButton::set_item_text);
+ ClassDB::bind_method(D_METHOD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
+ ClassDB::bind_method(D_METHOD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
+ ClassDB::bind_method(D_METHOD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
+ ClassDB::bind_method(D_METHOD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
+ 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("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);
+ ClassDB::bind_method(D_METHOD("clear"),&OptionButton::clear);
+ 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("remove_item","idx"),&OptionButton::remove_item);
+ ClassDB::bind_method(D_METHOD("_select_int"),&OptionButton::_select_int);
+
+ ClassDB::bind_method(D_METHOD("_set_items"),&OptionButton::_set_items);
+ ClassDB::bind_method(D_METHOD("_get_items"),&OptionButton::_get_items);
+
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"selected"), "_select_int","get_selected") ;
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_items","_get_items") ;
ADD_SIGNAL( MethodInfo("item_selected", PropertyInfo( Variant::INT,"ID") ) );
}
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index 451a85cf48..48270d12c7 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -43,7 +43,7 @@ Size2 PanelContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -98,7 +98,7 @@ void PanelContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_rect.cpp
index e32f60a222..6fb35f72e5 100644
--- a/scene/gui/patch_9_frame.cpp
+++ b/scene/gui/patch_9_rect.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* patch_9_frame.cpp */
+/* patch_9_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,11 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "patch_9_frame.h"
+#include "patch_9_rect.h"
#include "servers/visual_server.h"
-void Patch9Frame::_notification(int p_what) {
+void NinePatchRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -40,7 +40,7 @@ void Patch9Frame::_notification(int p_what) {
Size2 s=get_size();
RID ci = get_canvas_item();
VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center);
-// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ //draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
/*
Vector<Point2> points;
@@ -61,57 +61,59 @@ void Patch9Frame::_notification(int p_what) {
}
}
-Size2 Patch9Frame::get_minimum_size() const {
+Size2 NinePatchRect::get_minimum_size() const {
return Size2(margin[MARGIN_LEFT]+margin[MARGIN_RIGHT],margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]);
}
-void Patch9Frame::_bind_methods() {
+void NinePatchRect::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture"), & Patch9Frame::set_texture );
- ClassDB::bind_method(_MD("get_texture"), & Patch9Frame::get_texture );
- ClassDB::bind_method(_MD("set_patch_margin","margin","value"), & Patch9Frame::set_patch_margin );
- ClassDB::bind_method(_MD("get_patch_margin","margin"), & Patch9Frame::get_patch_margin );
- ClassDB::bind_method(_MD("set_region_rect","rect"),&Patch9Frame::set_region_rect);
- ClassDB::bind_method(_MD("get_region_rect"),&Patch9Frame::get_region_rect);
- ClassDB::bind_method(_MD("set_draw_center","draw_center"), & Patch9Frame::set_draw_center );
- ClassDB::bind_method(_MD("get_draw_center"), & Patch9Frame::get_draw_center );
+ 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_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);
+ ClassDB::bind_method(D_METHOD("get_region_rect"),&NinePatchRect::get_region_rect);
+ ClassDB::bind_method(D_METHOD("set_draw_center","draw_center"), & NinePatchRect::set_draw_center );
+ ClassDB::bind_method(D_METHOD("get_draw_center"), & NinePatchRect::get_draw_center );
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "draw_center"), _SCS("set_draw_center"),_SCS("get_draw_center") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture","get_texture") ;
+ ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "draw_center"), "set_draw_center","get_draw_center") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), "set_region_rect","get_region_rect");
ADD_GROUP("Patch Margin","patch_margin_");
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_left",PROPERTY_HINT_RANGE,"0,16384,1"), "set_patch_margin","get_patch_margin",MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_top",PROPERTY_HINT_RANGE,"0,16384,1"), "set_patch_margin","get_patch_margin",MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_right",PROPERTY_HINT_RANGE,"0,16384,1"), "set_patch_margin","get_patch_margin",MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_bottom",PROPERTY_HINT_RANGE,"0,16384,1"), "set_patch_margin","get_patch_margin",MARGIN_BOTTOM );
}
-void Patch9Frame::set_texture(const Ref<Texture>& p_tex) {
+void NinePatchRect::set_texture(const Ref<Texture>& p_tex) {
if (texture==p_tex)
return;
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
emit_signal("texture_changed");
}
-Ref<Texture> Patch9Frame::get_texture() const {
+Ref<Texture> NinePatchRect::get_texture() const {
return texture;
}
-void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
+void NinePatchRect::set_patch_margin(Margin p_margin,int p_size) {
ERR_FAIL_INDEX(p_margin,4);
margin[p_margin]=p_size;
@@ -133,13 +135,13 @@ void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
}
}
-int Patch9Frame::get_patch_margin(Margin p_margin) const{
+int NinePatchRect::get_patch_margin(Margin p_margin) const{
ERR_FAIL_INDEX_V(p_margin,4,0);
return margin[p_margin];
}
-void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
+void NinePatchRect::set_region_rect(const Rect2& p_region_rect) {
if (region_rect==p_region_rect)
return;
@@ -150,23 +152,23 @@ void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
_change_notify("region_rect");
}
-Rect2 Patch9Frame::get_region_rect() const {
+Rect2 NinePatchRect::get_region_rect() const {
return region_rect;
}
-void Patch9Frame::set_draw_center(bool p_draw) {
+void NinePatchRect::set_draw_center(bool p_draw) {
draw_center=p_draw;
update();
}
-bool Patch9Frame::get_draw_center() const{
+bool NinePatchRect::get_draw_center() const{
return draw_center;
}
-Patch9Frame::Patch9Frame() {
+NinePatchRect::NinePatchRect() {
margin[MARGIN_LEFT]=0;
@@ -179,6 +181,6 @@ Patch9Frame::Patch9Frame() {
}
-Patch9Frame::~Patch9Frame()
+NinePatchRect::~NinePatchRect()
{
}
diff --git a/scene/gui/patch_9_frame.h b/scene/gui/patch_9_rect.h
index afbeca5ae8..b87f2f64ec 100644
--- a/scene/gui/patch_9_frame.h
+++ b/scene/gui/patch_9_rect.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* patch_9_frame.h */
+/* patch_9_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,9 +33,9 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Patch9Frame : public Control {
+class NinePatchRect : public Control {
- GDCLASS(Patch9Frame,Control);
+ GDCLASS(NinePatchRect,Control);
bool draw_center;
int margin[4];
@@ -61,8 +61,8 @@ public:
void set_draw_center(bool p_enable);
bool get_draw_center() const;
- Patch9Frame();
- ~Patch9Frame();
+ NinePatchRect();
+ ~NinePatchRect();
};
#endif // PATCH_9_FRAME_H
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 5126568e5f..1f0daa99ba 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -39,7 +39,7 @@ void Popup::_gui_input(InputEvent p_event) {
void Popup::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (popped_up && !is_visible()) {
+ if (popped_up && !is_visible_in_tree()) {
popped_up=false;
notification(NOTIFICATION_POPUP_HIDE);
emit_signal("popup_hide");
@@ -103,7 +103,7 @@ void Popup::set_as_minsize() {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -144,7 +144,7 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -226,12 +226,16 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
}
-void Popup::popup() {
+void Popup::popup(const Rect2& bounds) {
emit_signal("about_to_show");
show_modal(exclusive);
-
+ // Fit the popup into the optionally provided bounds.
+ if (!bounds.has_no_area()) {
+ set_pos(bounds.pos);
+ set_size(bounds.size);
+ }
_fix_size();
Control *focusable = find_next_valid_focus();
@@ -257,16 +261,16 @@ bool Popup::is_exclusive() const {
void Popup::_bind_methods() {
- ClassDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
- ClassDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
- ClassDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
- ClassDB::bind_method(_MD("popup"),&Popup::popup);
- ClassDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
- ClassDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
+ ClassDB::bind_method(D_METHOD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
+ ClassDB::bind_method(D_METHOD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
+ ClassDB::bind_method(D_METHOD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
+ ClassDB::bind_method(D_METHOD("popup","bounds"),&Popup::popup,DEFVAL(Rect2()));
+ ClassDB::bind_method(D_METHOD("set_exclusive","enable"),&Popup::set_exclusive);
+ ClassDB::bind_method(D_METHOD("is_exclusive"),&Popup::is_exclusive);
ADD_SIGNAL( MethodInfo("about_to_show") );
ADD_SIGNAL( MethodInfo("popup_hide") );
ADD_GROUP("Popup","popup_");
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup_exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup_exclusive"), "set_exclusive","is_exclusive") ;
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
@@ -283,7 +287,7 @@ Popup::Popup() {
String Popup::get_configuration_warning() const {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine though, but they will hide upon running.");
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 17ae4a938a..4e4c8b0292 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -47,7 +47,7 @@ protected:
void _gui_input(InputEvent p_event);
void _notification(int p_what);
- void _fix_size();
+ virtual void _fix_size();
static void _bind_methods();
public:
@@ -63,7 +63,7 @@ public:
void popup_centered(const Size2& p_size=Size2());
void popup_centered_minsize(const Size2& p_minsize=Size2());
void set_as_minsize();
- virtual void popup();
+ virtual void popup(const Rect2& p_bounds=Rect2());
virtual String get_configuration_warning() const;
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 9eaf393a21..884cf0312a 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -136,7 +136,7 @@ int PopupMenu::_get_mouse_over(const Point2& p_over) const {
Ref<Font> font = get_font("font");
int vseparation = get_constant("vseparation");
-// int hseparation = get_constant("hseparation");
+ //int hseparation = get_constant("hseparation");
float font_h=font->get_height();
@@ -174,7 +174,7 @@ void PopupMenu::_activate_submenu(int over) {
Popup *pm = n->cast_to<Popup>();
ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
ERR_FAIL_COND(!pm);
- if (pm->is_visible())
+ if (pm->is_visible_in_tree())
return; //already visible!
@@ -1114,64 +1114,64 @@ void PopupMenu::clear_autohide_areas(){
void PopupMenu::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&PopupMenu::_gui_input);
- ClassDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
- ClassDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
- ClassDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
- ClassDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
- ClassDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
-
- ClassDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_shortcut,DEFVAL(-1),DEFVAL(false));
- ClassDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_shortcut,DEFVAL(-1),DEFVAL(false));
- ClassDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1),DEFVAL(false));
- ClassDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_check_shortcut,DEFVAL(-1),DEFVAL(false));
-
- ClassDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
- ClassDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
- ClassDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
- ClassDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
- ClassDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
- ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ClassDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
- ClassDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
- ClassDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
- ClassDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut","global"),&PopupMenu::set_item_shortcut,DEFVAL(false));
-
- ClassDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
-
- ClassDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
- ClassDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ClassDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ClassDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ClassDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
- ClassDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ClassDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
- ClassDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ClassDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
- ClassDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
- ClassDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ClassDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
- ClassDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
-
- ClassDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
-
- ClassDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
-
- ClassDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
- ClassDB::bind_method(_MD("clear"),&PopupMenu::clear);
-
- ClassDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
- ClassDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
-
- ClassDB::bind_method(_MD("set_hide_on_item_selection","enable"),&PopupMenu::set_hide_on_item_selection);
- ClassDB::bind_method(_MD("is_hide_on_item_selection"),&PopupMenu::is_hide_on_item_selection);
-
- ClassDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
-
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL, "hide_on_item_selection" ), _SCS("set_hide_on_item_selection"), _SCS("is_hide_on_item_selection") );
+ 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_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_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_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_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_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);
+ ClassDB::bind_method(D_METHOD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
+ ClassDB::bind_method(D_METHOD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
+ ClassDB::bind_method(D_METHOD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
+ ClassDB::bind_method(D_METHOD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
+ ClassDB::bind_method(D_METHOD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
+ ClassDB::bind_method(D_METHOD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
+ ClassDB::bind_method(D_METHOD("set_item_shortcut","idx","shortcut:ShortCut","global"),&PopupMenu::set_item_shortcut,DEFVAL(false));
+
+ 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("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("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);
+ ClassDB::bind_method(D_METHOD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
+ ClassDB::bind_method(D_METHOD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
+ ClassDB::bind_method(D_METHOD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+
+ ClassDB::bind_method(D_METHOD("get_item_count"),&PopupMenu::get_item_count);
+
+ ClassDB::bind_method(D_METHOD("remove_item","idx"),&PopupMenu::remove_item);
+
+ ClassDB::bind_method(D_METHOD("add_separator"),&PopupMenu::add_separator);
+ ClassDB::bind_method(D_METHOD("clear"),&PopupMenu::clear);
+
+ ClassDB::bind_method(D_METHOD("_set_items"),&PopupMenu::_set_items);
+ ClassDB::bind_method(D_METHOD("_get_items"),&PopupMenu::_get_items);
+
+ ClassDB::bind_method(D_METHOD("set_hide_on_item_selection","enable"),&PopupMenu::set_hide_on_item_selection);
+ ClassDB::bind_method(D_METHOD("is_hide_on_item_selection"),&PopupMenu::is_hide_on_item_selection);
+
+ ClassDB::bind_method(D_METHOD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
+
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_items","_get_items") ;
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL, "hide_on_item_selection" ), "set_hide_on_item_selection", "is_hide_on_item_selection") ;
ADD_SIGNAL( MethodInfo("id_pressed", PropertyInfo( Variant::INT,"ID") ) );
ADD_SIGNAL( MethodInfo("index_pressed", PropertyInfo( Variant::INT,"index") ) );
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index ee9369fb3a..61776d3ae6 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -53,7 +53,7 @@ void ProgressBar::_notification(int p_what) {
Color font_color=get_color("font_color");
draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
+ float r = get_as_ratio();
int mp = fg->get_minimum_size().width;
int p = r*get_size().width-mp;
if (p>0) {
@@ -62,7 +62,7 @@ void ProgressBar::_notification(int p_what) {
}
if (percent_visible) {
- String txt=itos(int(get_unit_value()*100))+"%";
+ String txt=itos(int(get_as_ratio()*100))+"%";
font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
}
}
@@ -82,10 +82,10 @@ bool ProgressBar::is_percent_visible() const{
void ProgressBar::_bind_methods() {
- ClassDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
- ClassDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
+ ClassDB::bind_method(D_METHOD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
+ ClassDB::bind_method(D_METHOD("is_percent_visible"),&ProgressBar::is_percent_visible);
ADD_GROUP("Percent","percent_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent_visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent_visible"),"set_percent_visible","is_percent_visible");
}
ProgressBar::ProgressBar() {
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 2f37ed0341..f434aff08d 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -135,14 +135,14 @@ double Range::get_page() const {
return shared->page;
}
-void Range::set_unit_value(double p_value) {
+void Range::set_as_ratio(double p_value) {
double v;
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
+ double exp_min = Math::log(get_min())/Math::log((double)2);
+ double exp_max = Math::log(get_max())/Math::log((double)2);
v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
@@ -156,13 +156,13 @@ void Range::set_unit_value(double p_value) {
}
set_value( v );
}
-double Range::get_unit_value() const {
+double Range::get_as_ratio() const {
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::log(get_value())/Math::log(2);
+ double exp_min = Math::log(get_min())/Math::log((double)2);
+ double exp_max = Math::log(get_max())/Math::log((double)2);
+ double v = Math::log(get_value())/Math::log((double)2);
return (v - exp_min) / (exp_max - exp_min);
@@ -222,57 +222,57 @@ void Range::_unref_shared() {
void Range::_bind_methods() {
- ClassDB::bind_method(_MD("get_value"),&Range::get_value);
- ClassDB::bind_method(_MD("get_min"),&Range::get_min);
- ClassDB::bind_method(_MD("get_max"),&Range::get_max);
- ClassDB::bind_method(_MD("get_step"),&Range::get_step);
- ClassDB::bind_method(_MD("get_page"),&Range::get_page);
- ClassDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value);
- ClassDB::bind_method(_MD("set_value","value"),&Range::set_value);
- ClassDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
- ClassDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
- ClassDB::bind_method(_MD("set_step","step"),&Range::set_step);
- ClassDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
- ClassDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value);
- ClassDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values);
- ClassDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values);
- ClassDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value);
- ClassDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp);
-
- ClassDB::bind_method(_MD("share","with"),&Range::_share);
- ClassDB::bind_method(_MD("unshare"),&Range::unshare);
+ ClassDB::bind_method(D_METHOD("get_value"),&Range::get_value);
+ ClassDB::bind_method(D_METHOD("get_min"),&Range::get_min);
+ ClassDB::bind_method(D_METHOD("get_max"),&Range::get_max);
+ ClassDB::bind_method(D_METHOD("get_step"),&Range::get_step);
+ ClassDB::bind_method(D_METHOD("get_page"),&Range::get_page);
+ ClassDB::bind_method(D_METHOD("get_as_ratio"),&Range::get_as_ratio);
+ ClassDB::bind_method(D_METHOD("set_value","value"),&Range::set_value);
+ ClassDB::bind_method(D_METHOD("set_min","minimum"),&Range::set_min);
+ ClassDB::bind_method(D_METHOD("set_max","maximum"),&Range::set_max);
+ ClassDB::bind_method(D_METHOD("set_step","step"),&Range::set_step);
+ ClassDB::bind_method(D_METHOD("set_page","pagesize"),&Range::set_page);
+ ClassDB::bind_method(D_METHOD("set_as_ratio","value"),&Range::set_as_ratio);
+ ClassDB::bind_method(D_METHOD("set_use_rounded_values","enabled"),&Range::set_use_rounded_values);
+ ClassDB::bind_method(D_METHOD("is_using_rounded_values"),&Range::is_using_rounded_values);
+ 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("unshare"),&Range::unshare);
ADD_SIGNAL( MethodInfo("value_changed", PropertyInfo(Variant::REAL,"value")));
ADD_SIGNAL( MethodInfo("changed"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "min_value" ), _SCS("set_min"), _SCS("get_min") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "max_value" ), _SCS("set_max"), _SCS("get_max") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), _SCS("set_step"), _SCS("get_step") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), _SCS("set_page"), _SCS("get_page") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), _SCS("set_value"), _SCS("get_value") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "min_value" ), "set_min", "get_min") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "max_value" ), "set_max", "get_max") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), "set_step", "get_step") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), "set_page", "get_page") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), "set_value", "get_value") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), "set_exp_ratio", "is_ratio_exp") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), "set_use_rounded_values", "is_using_rounded_values") ;
}
-void Range::set_rounded_values(bool p_enable) {
+void Range::set_use_rounded_values(bool p_enable) {
_rounded_values = p_enable;
}
-bool Range::is_rounded_values() const {
+bool Range::is_using_rounded_values() const {
return _rounded_values;
}
-void Range::set_exp_unit_value(bool p_enable) {
+void Range::set_exp_ratio(bool p_enable) {
- shared->exp_unit_value=p_enable;
+ shared->exp_ratio=p_enable;
}
-bool Range::is_unit_value_exp() const {
+bool Range::is_ratio_exp() const {
- return shared->exp_unit_value;
+ return shared->exp_ratio;
}
@@ -285,7 +285,7 @@ Range::Range()
shared->step=1;
shared->page=0;
shared->owners.insert(this);
- shared->exp_unit_value=false;
+ shared->exp_ratio=false;
_rounded_values = false;
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 0872254fff..5f274a6901 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -41,7 +41,7 @@ class Range : public Control {
struct Shared {
double val,min,max;
double step,page;
- bool exp_unit_value;
+ bool exp_ratio;
Set<Range*> owners;
void emit_value_changed();
void emit_changed(const char *p_what="");
@@ -71,20 +71,20 @@ public:
void set_max(double p_max);
void set_step(double p_step);
void set_page(double p_page);
- void set_unit_value(double p_value);
+ void set_as_ratio(double p_value);
double get_value() const;
double get_min() const;
double get_max() const;
double get_step() const;
double get_page() const;
- double get_unit_value() const;
+ double get_as_ratio() const;
- void set_rounded_values(bool p_enable);
- bool is_rounded_values() const;
+ void set_use_rounded_values(bool p_enable);
+ bool is_using_rounded_values() const;
- void set_exp_unit_value(bool p_enable);
- bool is_unit_value_exp() const;
+ void set_exp_ratio(bool p_enable);
+ bool is_ratio_exp() const;
void share(Range *p_range);
void unshare();
diff --git a/scene/gui/reference_frame.cpp b/scene/gui/reference_rect.cpp
index 37bc3ae6fb..ff4cdf04fd 100644
--- a/scene/gui/reference_frame.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* reference_frame.cpp */
+/* reference_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,9 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "reference_frame.h"
+#include "reference_rect.h"
-void ReferenceFrame::_notification(int p_what) {
+void ReferenceRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -39,6 +39,6 @@ void ReferenceFrame::_notification(int p_what) {
}
}
-ReferenceFrame::ReferenceFrame()
+ReferenceRect::ReferenceRect()
{
}
diff --git a/scene/gui/reference_frame.h b/scene/gui/reference_rect.h
index 8b4a16cb43..be493f346c 100644
--- a/scene/gui/reference_frame.h
+++ b/scene/gui/reference_rect.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* reference_frame.h */
+/* reference_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,20 +26,20 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef REFERENCE_FRAME_H
-#define REFERENCE_FRAME_H
+#ifndef REFERENCE_RECT_H
+#define REFERENCE_RECT_H
#include "scene/gui/control.h"
-class ReferenceFrame : public Control {
+class ReferenceRect : public Control {
- GDCLASS( ReferenceFrame, Control);
+ GDCLASS( ReferenceRect, Control);
protected:
void _notification(int p_what);
public:
- ReferenceFrame();
+ ReferenceRect();
};
-#endif // REFERENCE_FRAME_H
+#endif // REFERENCE_RECT_H
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 790b7500ea..17ec71f4a4 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -103,7 +103,7 @@ void RichTextLabel::_process_line(ItemFrame *p_frame,const Vector2& p_ofs,int &y
int line_ofs=0;
int margin=_find_margin(it,p_base_font);
- Align align=_find_align(it);;
+ Align align=_find_align(it);
int line=0;
int spaces=0;
@@ -852,32 +852,32 @@ void RichTextLabel::_gui_input(InputEvent p_event) {
switch(k.scancode) {
case KEY_PAGEUP: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( vscroll->get_value() - vscroll->get_page() );
} break;
case KEY_PAGEDOWN: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( vscroll->get_value() + vscroll->get_page() );
} break;
case KEY_UP: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( vscroll->get_value() - get_font("normal_font")->get_height() );
} break;
case KEY_DOWN: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( vscroll->get_value() + get_font("normal_font")->get_height() );
} break;
case KEY_HOME: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( 0 );
} break;
case KEY_END: {
- if (vscroll->is_visible())
+ if (vscroll->is_visible_in_tree())
vscroll->set_value( vscroll->get_max() );
} break;
case KEY_INSERT:
@@ -1214,6 +1214,28 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
}
+void RichTextLabel::_remove_item(Item* p_item, const int p_line, const int p_subitem_line) {
+
+
+ int size = p_item->subitems.size();
+ if (size == 0) {
+ p_item->parent->subitems.erase(p_item);
+ if (p_item->type == ITEM_NEWLINE) {
+ current_frame->lines.remove(p_line);
+ for (int i = p_subitem_line; i < current->subitems.size(); i++) {
+ if (current->subitems[i]->line > 0)
+ current->subitems[i]->line--;
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < size; i++) {
+ _remove_item(p_item->subitems.front()->get(), p_line, p_subitem_line);
+ }
+ }
+
+}
+
void RichTextLabel::add_image(const Ref<Texture>& p_image) {
if (current->type==ITEM_TABLE)
@@ -1238,6 +1260,26 @@ void RichTextLabel::add_newline() {
}
+bool RichTextLabel::remove_line(const int p_line) {
+
+ if (p_line >= current_frame->lines.size() || p_line < 0)
+ return false;
+
+ int lines = p_line * 2;
+
+ if (current->subitems[lines]->type != ITEM_NEWLINE)
+ _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+
+ _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+
+ if (p_line == 0) {
+ main->lines[0].from = main;
+ }
+
+ main->first_invalid_line = 0;
+ return true;
+}
+
void RichTextLabel::push_font(const Ref<Font>& p_font) {
ERR_FAIL_COND(current->type==ITEM_TABLE);
@@ -1429,7 +1471,7 @@ bool RichTextLabel::is_scroll_active() const {
void RichTextLabel::set_scroll_follow(bool p_follow) {
scroll_follow=p_follow;
- if (!vscroll->is_visible() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
+ if (!vscroll->is_visible_in_tree() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
scroll_following=true;
}
@@ -1900,63 +1942,64 @@ String RichTextLabel::get_text() {
void RichTextLabel::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&RichTextLabel::_gui_input);
- ClassDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
- ClassDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
- ClassDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
- ClassDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
- ClassDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
- ClassDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
- ClassDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
- ClassDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
- ClassDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
- ClassDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
- ClassDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
- ClassDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
- ClassDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
- ClassDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
- ClassDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
- ClassDB::bind_method(_MD("pop"),&RichTextLabel::pop);
+ 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("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("push_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);
+ ClassDB::bind_method(D_METHOD("push_indent","level"),&RichTextLabel::push_indent);
+ ClassDB::bind_method(D_METHOD("push_list","type"),&RichTextLabel::push_list);
+ ClassDB::bind_method(D_METHOD("push_meta","data"),&RichTextLabel::push_meta);
+ ClassDB::bind_method(D_METHOD("push_underline"),&RichTextLabel::push_underline);
+ ClassDB::bind_method(D_METHOD("push_table","columns"),&RichTextLabel::push_table);
+ ClassDB::bind_method(D_METHOD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
+ ClassDB::bind_method(D_METHOD("push_cell"),&RichTextLabel::push_cell);
+ ClassDB::bind_method(D_METHOD("pop"),&RichTextLabel::pop);
- ClassDB::bind_method(_MD("clear"),&RichTextLabel::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&RichTextLabel::clear);
- ClassDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
- ClassDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
+ ClassDB::bind_method(D_METHOD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
+ ClassDB::bind_method(D_METHOD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
- ClassDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
- ClassDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
+ ClassDB::bind_method(D_METHOD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
+ ClassDB::bind_method(D_METHOD("is_scroll_active"),&RichTextLabel::is_scroll_active);
- ClassDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
- ClassDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
+ ClassDB::bind_method(D_METHOD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
+ ClassDB::bind_method(D_METHOD("is_scroll_following"),&RichTextLabel::is_scroll_following);
- ClassDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("get_v_scroll"),&RichTextLabel::get_v_scroll);
- ClassDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
+ ClassDB::bind_method(D_METHOD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
- ClassDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
- ClassDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
+ ClassDB::bind_method(D_METHOD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
+ ClassDB::bind_method(D_METHOD("get_tab_size"),&RichTextLabel::get_tab_size);
- ClassDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
- ClassDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
+ ClassDB::bind_method(D_METHOD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
+ ClassDB::bind_method(D_METHOD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
- ClassDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
- ClassDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
+ ClassDB::bind_method(D_METHOD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
+ ClassDB::bind_method(D_METHOD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
- ClassDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
- ClassDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
+ ClassDB::bind_method(D_METHOD("set_bbcode","text"),&RichTextLabel::set_bbcode);
+ ClassDB::bind_method(D_METHOD("get_bbcode"),&RichTextLabel::get_bbcode);
- ClassDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
- ClassDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
+ 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(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
+ ClassDB::bind_method(D_METHOD("get_total_character_count"),&RichTextLabel::get_total_character_count);
- ClassDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
- ClassDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
+ ClassDB::bind_method(D_METHOD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
+ ClassDB::bind_method(D_METHOD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
ADD_GROUP("BBCode","bbcode_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode_enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode_text",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"visible_characters",PROPERTY_HINT_RANGE,"-1,128000,1"),_SCS("set_visible_characters"),_SCS("get_visible_characters"));
+ 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_SIGNAL( MethodInfo("meta_clicked",PropertyInfo(Variant::NIL,"meta")));
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 39032185f8..3bdd2cd7e3 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -173,7 +173,7 @@ private:
struct ItemNewline : public Item {
- int line;
+ int line; // FIXME: Overriding base's line ?
ItemNewline() { type=ITEM_NEWLINE; }
};
@@ -217,6 +217,7 @@ private:
void _validate_line_caches(ItemFrame *p_frame);
void _add_item(Item *p_item, bool p_enter=false,bool p_ensure_newline=false);
+ void _remove_item(Item *p_item, const int p_line, const int p_subitem_line);
@@ -284,6 +285,7 @@ public:
void add_text(const String& p_text);
void add_image(const Ref<Texture>& p_image);
void add_newline();
+ bool remove_line(const int p_line);
void push_font(const Ref<Font>& p_font);
void push_color(const Color& p_color);
void push_underline();
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 2c44e51e5e..b2ad74eaa8 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -51,9 +51,11 @@ void ScrollBar::_gui_input(InputEvent p_event) {
if (b.button_index==5 && b.pressed) {
- //if (orientation==VERTICAL)
- // set_val( get_val() + get_page() / 4.0 );
- //else
+ /*
+ if (orientation==VERTICAL)
+ set_val( get_val() + get_page() / 4.0 );
+ else
+ */
set_value( get_value() + get_page() / 4.0 );
accept_event();
@@ -61,9 +63,11 @@ void ScrollBar::_gui_input(InputEvent p_event) {
if (b.button_index==4 && b.pressed) {
- //if (orientation==HORIZONTAL)
- // set_val( get_val() - get_page() / 4.0 );
- //else
+ /*
+ if (orientation==HORIZONTAL)
+ set_val( get_val() - get_page() / 4.0 );
+ else
+ */
set_value( get_value() - get_page() / 4.0 );
accept_event();
}
@@ -112,7 +116,7 @@ void ScrollBar::_gui_input(InputEvent p_event) {
drag.active=true;
drag.pos_at_click=grabber_ofs+ofs;
- drag.value_at_click=get_unit_value();
+ drag.value_at_click=get_as_ratio();
update();
} else {
@@ -145,7 +149,7 @@ void ScrollBar::_gui_input(InputEvent p_event) {
double diff = (ofs-drag.pos_at_click) / get_area_size();
- set_unit_value( drag.value_at_click + diff );
+ set_as_ratio( drag.value_at_click + diff );
} else {
@@ -425,8 +429,10 @@ double ScrollBar::get_grabber_size() const {
return 0;
float page = (get_page()>0)? get_page() : 0;
-// if (grabber_range < get_step())
-// grabber_range=get_step();
+ /*
+ if (grabber_range < get_step())
+ grabber_range=get_step();
+ */
double area_size=get_area_size();
double grabber_size = page / range * area_size;
@@ -497,7 +503,7 @@ double ScrollBar::get_click_pos(const Point2& p_pos) const {
double ScrollBar::get_grabber_offset() const {
- return (get_area_size()) * get_unit_value();
+ return (get_area_size()) * get_as_ratio();
}
@@ -620,12 +626,16 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
if (orientation==HORIZONTAL)
set_value(diff.x);
- //else
- // drag_slave_accum.x=0;
+ /*
+ else
+ drag_slave_accum.x=0;
+ */
if (orientation==VERTICAL)
set_value(diff.y);
- //else
- // drag_slave_accum.y=0;
+ /*
+ else
+ drag_slave_accum.y=0;
+ */
time_since_motion=0;
}
@@ -804,13 +814,13 @@ bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b.pr
void ScrollBar::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&ScrollBar::_gui_input);
- ClassDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
- ClassDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
- ClassDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
- ClassDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ScrollBar::_gui_input);
+ ClassDB::bind_method(D_METHOD("set_custom_step","step"),&ScrollBar::set_custom_step);
+ ClassDB::bind_method(D_METHOD("get_custom_step"),&ScrollBar::get_custom_step);
+ ClassDB::bind_method(D_METHOD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
+ ClassDB::bind_method(D_METHOD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), _SCS("set_custom_step"),_SCS("get_custom_step"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), "set_custom_step","get_custom_step");
}
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 43c214b0be..2296c9742d 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -59,10 +59,10 @@ Size2 ScrollContainer::get_minimum_size() const {
}
}
- if (h_scroll->is_visible()) {
+ if (h_scroll->is_visible_in_tree()) {
min_size.y+=h_scroll->get_minimum_size().y;
}
- if (v_scroll->is_visible()) {
+ if (v_scroll->is_visible_in_tree()) {
min_size.x+=v_scroll->get_minimum_size().x;
}
return min_size;
@@ -89,19 +89,19 @@ void ScrollContainer::_gui_input(const InputEvent& p_gui_input) {
const InputEventMouseButton &mb=p_gui_input.mouse_button;
if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
- if (h_scroll->is_visible() && !v_scroll->is_visible()){
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
// only horizontal is enabled, scroll horizontally
h_scroll->set_value( h_scroll->get_value()-h_scroll->get_page()/8 );
- } else if (v_scroll->is_visible()) {
+ } else if (v_scroll->is_visible_in_tree()) {
v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 );
}
}
if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
- if (h_scroll->is_visible() && !v_scroll->is_visible()){
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
// only horizontal is enabled, scroll horizontally
h_scroll->set_value( h_scroll->get_value()+h_scroll->get_page()/8 );
- } else if (v_scroll->is_visible()) {
+ } else if (v_scroll->is_visible_in_tree()) {
v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 );
}
}
@@ -216,10 +216,10 @@ void ScrollContainer::_notification(int p_what) {
child_max_size = Size2(0, 0);
Size2 size = get_size();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
size.y-=h_scroll->get_minimum_size().y;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
size.x-=h_scroll->get_minimum_size().x;
for(int i=0;i<get_child_count();i++) {
@@ -236,14 +236,14 @@ void ScrollContainer::_notification(int p_what) {
child_max_size.y = MAX(child_max_size.y, minsize.y);
Rect2 r = Rect2(-scroll,minsize);
- if (!(scroll_h || h_scroll->is_visible())) {
+ if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags()&SIZE_EXPAND)) {
r.pos.x=0;
if (c->get_h_size_flags()&SIZE_EXPAND)
r.size.width=MAX(size.width,minsize.width);
else
r.size.width=minsize.width;
}
- if (!(scroll_v || v_scroll->is_visible())) {
+ if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags()&SIZE_EXPAND)) {
r.pos.y=0;
r.size.height=size.height;
if (c->get_v_size_flags()&SIZE_EXPAND)
@@ -459,21 +459,21 @@ String ScrollContainer::get_configuration_warning() const {
void ScrollContainer::_bind_methods() {
- ClassDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
- ClassDB::bind_method(_MD("_gui_input"),&ScrollContainer::_gui_input);
- ClassDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
- ClassDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
- ClassDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
- ClassDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
- ClassDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
- ClassDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
- ClassDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
- ClassDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
- ClassDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
+ ClassDB::bind_method(D_METHOD("_scroll_moved"),&ScrollContainer::_scroll_moved);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ScrollContainer::_gui_input);
+ ClassDB::bind_method(D_METHOD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
+ ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
+ ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
+ ClassDB::bind_method(D_METHOD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
+ ClassDB::bind_method(D_METHOD("get_h_scroll"),&ScrollContainer::get_h_scroll);
+ ClassDB::bind_method(D_METHOD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
+ ClassDB::bind_method(D_METHOD("get_v_scroll"),&ScrollContainer::get_v_scroll);
ADD_GROUP("Scroll","scroll_");
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_horizontal"), "set_enable_h_scroll","is_h_scroll_enabled");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_vertical"), "set_enable_v_scroll","is_v_scroll_enabled");
};
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 5fb17e1c2e..56d8a9724f 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -45,7 +45,7 @@ protected:
void _notification(int p_what);
public:
- virtual Size2 get_minimum_size() const;;
+ virtual Size2 get_minimum_size() const;
Separator();
~Separator();
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index dacfc644ee..a6d6864b16 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -53,11 +53,11 @@ void Slider::_gui_input(InputEvent p_event) {
double grab_height = (double)grabber->get_size().height;
double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
if (orientation==VERTICAL)
- set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
+ set_as_ratio( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
else
- set_unit_value(((double)grab.pos - (grab_width/2.0)) / max);
+ set_as_ratio(((double)grab.pos - (grab_width/2.0)) / max);
grab.active=true;
- grab.uvalue=get_unit_value();
+ grab.uvalue=get_as_ratio();
} else {
grab.active=false;
}
@@ -81,7 +81,7 @@ void Slider::_gui_input(InputEvent p_event) {
if (areasize<=0)
return;
float umotion = motion / float(areasize);
- set_unit_value( grab.uvalue + umotion );
+ set_as_ratio( grab.uvalue + umotion );
}
} else {
@@ -164,8 +164,10 @@ void Slider::_notification(int p_what) {
if (orientation==VERTICAL) {
style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().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)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ */
float areasize = size.height - grabber->get_size().height;
if (ticks>1) {
int tickarea = size.height - tick->get_height();
@@ -176,11 +178,13 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height));
+ 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)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ */
float areasize = size.width - grabber->get_size().width;
if (ticks>1) {
@@ -192,7 +196,7 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
+ grabber->draw(ci,Point2i(get_as_ratio()*areasize,size.height/2-grabber->get_size().height/2));
}
} break;
@@ -231,16 +235,16 @@ void Slider::set_ticks_on_borders(bool _tob){
void Slider::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&Slider::_gui_input);
- ClassDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
- ClassDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&Slider::_gui_input);
+ ClassDB::bind_method(D_METHOD("set_ticks","count"),&Slider::set_ticks);
+ ClassDB::bind_method(D_METHOD("get_ticks"),&Slider::get_ticks);
- ClassDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
- ClassDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
+ 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);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "tick_count", PROPERTY_HINT_RANGE,"0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "ticks_on_borders" ), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders") );
- ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
+ 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") ;
}
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 070f9fc72e..f2c04d2f76 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -49,8 +49,10 @@ void SpinBox::_value_changed(double) {
void SpinBox::_text_entered(const String& p_string) {
- //if (!p_string.is_numeric())
- // return;
+ /*
+ if (!p_string.is_numeric())
+ return;
+ */
String value = p_string;
if (prefix!="" && p_string.begins_with(prefix))
value = p_string.substr(prefix.length(), p_string.length()-prefix.length());
@@ -98,8 +100,6 @@ void SpinBox::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
const InputEventMouseButton &mb=p_event.mouse_button;
- if (mb.doubleclick)
- return; //ignore doubleclick
bool up = mb.y < (get_size().height/2);
@@ -160,7 +160,7 @@ void SpinBox::_gui_input(const InputEvent& p_event) {
if (drag.enabled) {
float diff_y = drag.mouse_pos.y - cpos.y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
+ diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y);
diff_y*=0.1;
drag.mouse_pos=cpos;
@@ -251,24 +251,24 @@ bool SpinBox::is_editable() const {
void SpinBox::_bind_methods() {
- //ClassDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
- ClassDB::bind_method(_MD("_gui_input"),&SpinBox::_gui_input);
- ClassDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
- ClassDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
- ClassDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
- ClassDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
- ClassDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
- ClassDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
- ClassDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
- ClassDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
- ClassDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
- ClassDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
- ClassDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
-
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"prefix"),_SCS("set_prefix"),_SCS("get_prefix"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"suffix"),_SCS("set_suffix"),_SCS("get_suffix"));
+ //ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&SpinBox::_gui_input);
+ ClassDB::bind_method(D_METHOD("_text_entered"),&SpinBox::_text_entered);
+ ClassDB::bind_method(D_METHOD("set_suffix","suffix"),&SpinBox::set_suffix);
+ ClassDB::bind_method(D_METHOD("get_suffix"),&SpinBox::get_suffix);
+ ClassDB::bind_method(D_METHOD("set_prefix","prefix"),&SpinBox::set_prefix);
+ ClassDB::bind_method(D_METHOD("get_prefix"),&SpinBox::get_prefix);
+ 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("_line_edit_input"),&SpinBox::_line_edit_input);
+ ClassDB::bind_method(D_METHOD("_range_click_timeout"),&SpinBox::_range_click_timeout);
+
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),"set_editable","is_editable");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"prefix"),"set_prefix","get_prefix");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"suffix"),"set_suffix","get_suffix");
}
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index aae3b3fffa..14ea96a4e6 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -47,7 +47,7 @@ Control *SplitContainer::_getch(int p_idx) const {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -422,21 +422,21 @@ bool SplitContainer::is_collapsed() const {
void SplitContainer::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&SplitContainer::_gui_input);
- ClassDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
- ClassDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&SplitContainer::_gui_input);
+ ClassDB::bind_method(D_METHOD("set_split_offset","offset"),&SplitContainer::set_split_offset);
+ ClassDB::bind_method(D_METHOD("get_split_offset"),&SplitContainer::get_split_offset);
- ClassDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
- ClassDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
+ ClassDB::bind_method(D_METHOD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
+ ClassDB::bind_method(D_METHOD("is_collapsed"),&SplitContainer::is_collapsed);
- ClassDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
- ClassDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
+ ClassDB::bind_method(D_METHOD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
+ ClassDB::bind_method(D_METHOD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
ADD_SIGNAL( MethodInfo("dragged",PropertyInfo(Variant::INT,"offset")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split_offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"split_offset"),"set_split_offset","get_split_offset");
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collapsed"),"set_collapsed","is_collapsed");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),"set_dragger_visibility","get_dragger_visibility");
BIND_CONSTANT( DRAGGER_VISIBLE );
BIND_CONSTANT( DRAGGER_HIDDEN );
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 11045eaafd..1707676da2 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -31,368 +31,322 @@
#include "message_queue.h"
-
int TabContainer::_get_top_margin() const {
+ if (!tabs_visible)
+ return 0;
+
+ // Respect the minimum tab height.
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<Font> font = get_font("font");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
- int h = MAX( tab_bg->get_minimum_size().height,tab_fg->get_minimum_size().height);
+ int tab_height = MAX(MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height), tab_disabled->get_minimum_size().height);
- int ch = font->get_height();;
- for(int i=0;i<get_child_count();i++) {
+ // Font height or higher icon wins.
+ Ref<Font> font = get_font("font");
+ int content_height = font->get_height();
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
+ Vector<Control*> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
+
+ Control *c = tabs[i];
if (!c->has_meta("_tab_icon"))
continue;
Ref<Texture> tex = c->get_meta("_tab_icon");
if (!tex.is_valid())
continue;
- ch = MAX( ch, tex->get_size().height );
+ content_height = MAX(content_height, tex->get_size().height);
}
- h+=ch;
-
- return h;
-
+ return tab_height + content_height;
}
void TabContainer::_gui_input(const InputEvent& p_event) {
- if (p_event.type==InputEvent::MOUSE_BUTTON &&
- p_event.mouse_button.pressed &&
- p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON
+ && p_event.mouse_button.pressed
+ && p_event.mouse_button.button_index == BUTTON_LEFT) {
- // clicks
- Point2 pos( p_event.mouse_button.x, p_event.mouse_button.y );
+ Point2 pos(p_event.mouse_button.x, p_event.mouse_button.y);
+ Size2 size = get_size();
- int top_margin = _get_top_margin();
- if (pos.y>top_margin)
- return; // no click (too far down)
-
- if (pos.x<tabs_ofs_cache)
- return; // no click (too far left)
+ // Click must be on tabs in the tab header area.
+ if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin())
+ return;
- Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
- Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<Font> font = get_font("font");
- Ref<Texture> incr = get_icon("increment");
- Ref<Texture> decr = get_icon("decrement");
+ // Handle menu button.
Ref<Texture> menu = get_icon("menu");
- Ref<Texture> menu_hl = get_icon("menu_hl");
-
- if (popup && pos.x>get_size().width-menu->get_width()) {
-
-
+ if (popup && pos.x > size.width - menu->get_width()) {
emit_signal("pre_popup_pressed");
- Vector2 pp_pos = get_global_pos();
- pp_pos.x+=get_size().width;
- pp_pos.x-=popup->get_size().width;
- pp_pos.y+=menu->get_height();
- popup->set_global_pos( pp_pos );
- popup->popup();;
+ Vector2 popup_pos = get_global_pos();
+ popup_pos.x += size.width - popup->get_size().width;
+ popup_pos.y += menu->get_height();
+
+ popup->set_global_pos(popup_pos);
+ popup->popup();
return;
}
- pos.x-=tabs_ofs_cache;
-
- int idx=0;
- int found=-1;
- bool rightroom=false;
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
-
- if (idx<tab_display_ofs) {
- idx++;
- continue;
- }
-
- if (idx>last_tab_cache) {
- rightroom=true;
- break;
- }
-
- String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
- int tab_width=font->get_string_size(s).width;
- if (c->has_meta("_tab_icon")) {
- Ref<Texture> icon = c->get_meta("_tab_icon");
- if (icon.is_valid()) {
- tab_width+=icon->get_width();
- if (s!="")
- tab_width+=get_constant("hseparation");
-
- }
- }
-
- if (idx==current) {
-
- tab_width+=tab_fg->get_minimum_size().width;
- } else {
- tab_width+=tab_bg->get_minimum_size().width;
- }
-
- if (pos.x < tab_width) {
-
- found=idx;
- break;
- }
-
- pos.x-=tab_width;
- idx++;
- }
+ Vector<Control*> tabs = _get_tabs();
+ // Handle navigation buttons.
if (buttons_visible_cache) {
-
- if (p_event.mouse_button.x>get_size().width-incr->get_width()) {
- if (rightroom) {
- tab_display_ofs+=1;
+ Ref<Texture> increment = get_icon("increment");
+ Ref<Texture> decrement = get_icon("decrement");
+ if (pos.x > size.width - increment->get_width()) {
+ if (last_tab_cache < tabs.size() - 1) {
+ first_tab_cache += 1;
update();
}
- } else if (p_event.mouse_button.x>get_size().width-incr->get_width()-decr->get_width()) {
-
- if (tab_display_ofs>0) {
- tab_display_ofs-=1;
+ return;
+ } else if (pos.x > size.width - increment->get_width() - decrement->get_width()) {
+ if (first_tab_cache > 0) {
+ first_tab_cache -= 1;
update();
}
-
+ return;
}
}
-
- if (found!=-1) {
-
- set_current_tab(found);
+ // Activate the clicked tab.
+ pos.x -= tabs_ofs_cache;
+ for (int i = first_tab_cache; i <= last_tab_cache; i++) {
+ int tab_width = _get_tab_width(i);
+ if (pos.x < tab_width) {
+ if (!get_tab_disabled(i)) {
+ set_current_tab(i);
+ }
+ break;
+ }
+ pos.x -= tab_width;
}
}
-
}
void TabContainer::_notification(int p_what) {
-
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_DRAW: {
- RID ci = get_canvas_item();
- Ref<StyleBox> panel = get_stylebox("panel");
+ RID canvas = get_canvas_item();
Size2 size = get_size();
+ // Draw only the tab area if the header is hidden.
+ Ref<StyleBox> panel = get_stylebox("panel");
if (!tabs_visible) {
-
- panel->draw(ci, Rect2( 0, 0, size.width, size.height));
+ panel->draw(canvas, Rect2(0, 0, size.width, size.height));
return;
}
-
-
+ Vector<Control*> tabs = _get_tabs();
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
- Ref<Texture> incr = get_icon("increment");
- Ref<Texture> decr = get_icon("decrement");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
+ Ref<Texture> increment = get_icon("increment");
+ Ref<Texture> decrement = get_icon("decrement");
Ref<Texture> menu = get_icon("menu");
Ref<Texture> menu_hl = get_icon("menu_hl");
Ref<Font> font = get_font("font");
- Color color_fg = get_color("font_color_fg");
- Color color_bg = get_color("font_color_bg");
-
+ Color font_color_fg = get_color("font_color_fg");
+ Color font_color_bg = get_color("font_color_bg");
+ Color font_color_disabled = get_color("font_color_disabled");
int side_margin = get_constant("side_margin");
- int top_margin = _get_top_margin();
-
-
- Size2 top_size = Size2( size.width, top_margin );
-
-
-
- int w=0;
- int idx=0;
- Vector<int> offsets;
- Vector<Control*> controls;
- int from=0;
- int limit=get_size().width;
- if (popup) {
- top_size.width-=menu->get_width();
- limit-=menu->get_width();
- }
-
- bool notdone=false;
- last_tab_cache=-1;
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
- if (idx<tab_display_ofs) {
- idx++;
- from=idx;
- continue;
- }
-
- if (w>=get_size().width) {
- buttons_visible_cache=true;
- notdone=true;
+ int icon_text_distance = get_constant("hseparation");
+
+ // Find out start and width of the header area.
+ int header_x = side_margin;
+ int header_width = size.width - side_margin * 2;
+ int header_height = _get_top_margin();
+ if (popup)
+ header_width -= menu->get_width();
+
+ // Check if all tabs would fit into the header area.
+ int all_tabs_width = 0;
+ for (int i = 0; i < tabs.size(); i++) {
+ int tab_width = _get_tab_width(i);
+ all_tabs_width += tab_width;
+
+ if (all_tabs_width > header_width) {
+ // Not all tabs are visible at the same time - reserve space for navigation buttons.
+ buttons_visible_cache = true;
+ header_width -= decrement->get_width() + increment->get_width();
break;
- }
-
- offsets.push_back(w);
- controls.push_back(c);
-
- String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
- w+=font->get_string_size(s).width;
- if (c->has_meta("_tab_icon")) {
- Ref<Texture> icon = c->get_meta("_tab_icon");
- if (icon.is_valid()) {
- w+=icon->get_width();
- if (s!="")
- w+=get_constant("hseparation");
-
- }
- }
-
- if (idx==current) {
-
- w+=tab_fg->get_minimum_size().width;
} else {
- w+=tab_bg->get_minimum_size().width;
+ buttons_visible_cache = false;
}
-
- if (idx<tab_display_ofs) {
-
- }
- last_tab_cache=idx;
-
- idx++;
+ }
+ // With buttons, a right side margin does not need to be respected.
+ if (popup || buttons_visible_cache) {
+ header_width += side_margin;
}
+ // Go through the visible tabs to find the width they occupy.
+ all_tabs_width = 0;
+ Vector<int> tab_widths;
+ for (int i = first_tab_cache; i < tabs.size(); i++) {
+ int tab_width = _get_tab_width(i);
+ if (all_tabs_width + tab_width > header_width && tab_widths.size() > 0)
+ break;
+ all_tabs_width += tab_width;
+ tab_widths.push_back(tab_width);
+ }
- int ofs;
-
- switch(align) {
-
- case ALIGN_LEFT: ofs = side_margin; break;
- case ALIGN_CENTER: ofs = (int(limit) - w)/2; break;
- case ALIGN_RIGHT: ofs = int(limit) - w - side_margin; break;
- };
-
- tab_display_ofs=0;
-
-
- tabs_ofs_cache=ofs;
- idx=0;
-
-
-
- for(int i=0;i<controls.size();i++) {
-
- idx=i+from;
- if (current>=from && current<from+controls.size()-1) {
- //current is visible! draw it last.
- if (i==controls.size()-1) {
- idx=current;
- } else if (idx>=current) {
- idx+=1;
- }
- }
-
- Control *c = controls[idx-from];
-
- String s = c->has_meta("_tab_name")?String(c->get_meta("_tab_name")):String(c->get_name());
- int w=font->get_string_size(s).width;
- Ref<Texture> icon;
- if (c->has_meta("_tab_icon")) {
- icon = c->get_meta("_tab_icon");
- if (icon.is_valid()) {
-
- w+=icon->get_width();
- if (s!="")
- w+=get_constant("hseparation");
-
- }
- }
-
-
- Ref<StyleBox> sb;
- Color col;
-
- if (idx==current) {
+ // Find the offset at which to draw tabs, according to the alignment.
+ switch (align) {
+ case ALIGN_LEFT:
+ tabs_ofs_cache = header_x;
+ break;
+ case ALIGN_CENTER:
+ tabs_ofs_cache = header_x + (header_width / 2) - (all_tabs_width / 2);
+ break;
+ case ALIGN_RIGHT:
+ tabs_ofs_cache = header_x + header_width - all_tabs_width;
+ break;
+ }
- sb=tab_fg;
- col=color_fg;
+ // Draw all visible tabs.
+ int x = 0;
+ for (int i = 0; i < tab_widths.size(); i++) {
+ Ref<StyleBox> tab_style;
+ Color font_color;
+ if (get_tab_disabled(i + first_tab_cache)) {
+ tab_style = tab_disabled;
+ font_color = font_color_disabled;
+ } else if (i + first_tab_cache == current) {
+ tab_style = tab_fg;
+ font_color = font_color_fg;
} else {
- sb=tab_bg;
- col=color_bg;
+ tab_style = tab_bg;
+ font_color = font_color_bg;
}
- int lofs = ofs + offsets[idx-from];
-
- Size2i sb_ms = sb->get_minimum_size();
- Rect2 sb_rect = Rect2( lofs, 0, w+sb_ms.width, top_margin);
+ // Draw the tab background.
+ int tab_width = tab_widths[i];
+ Rect2 tab_rect(tabs_ofs_cache + x, 0, tab_width, header_height);
+ tab_style->draw(canvas, tab_rect);
+ // Draw the tab contents.
+ Control *control = tabs[i + first_tab_cache]->cast_to<Control>();
+ String text = control->has_meta("_tab_name")
+ ? String(XL_MESSAGE(String(control->get_meta("_tab_name"))))
+ : String(control->get_name());
- sb->draw(ci, sb_rect );
-
- Point2i lpos = sb_rect.pos;
- lpos.x+=sb->get_margin(MARGIN_LEFT);
- if (icon.is_valid()) {
-
- icon->draw(ci, Point2i( lpos.x, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-icon->get_height())/2 ) );
- if (s!="")
- lpos.x+=icon->get_width()+get_constant("hseparation");
+ int x_content = tab_rect.pos.x + tab_style->get_margin(MARGIN_LEFT);
+ int top_margin = tab_style->get_margin(MARGIN_TOP);
+ int y_center = top_margin + (tab_rect.size.y - tab_style->get_minimum_size().y) / 2;
+ // Draw the tab icon.
+ if (control->has_meta("_tab_icon")) {
+ Ref<Texture> icon = control->get_meta("_tab_icon");
+ if (icon.is_valid()) {
+ int y = y_center - (icon->get_height() / 2);
+ icon->draw(canvas, Point2i(x_content, y));
+ if (text != "")
+ x_content += icon->get_width() + icon_text_distance;
+ }
}
- font->draw(ci, Point2i( lpos.x, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-font->get_height())/2+font->get_ascent() ), s, col );
+ // Draw the tab text.
+ Point2i text_pos(x_content, y_center - (font->get_height() / 2) + font->get_ascent());
+ font->draw(canvas, text_pos, text, font_color);
- idx++;
+ x += tab_width;
+ last_tab_cache = i + first_tab_cache;
}
+ // Draw the popup menu.
+ x = get_size().width;
+ if (popup) {
+ x -= menu->get_width();
+ if (mouse_x_cache > x)
+ menu_hl->draw(get_canvas_item(), Size2(x, 0));
+ else
+ menu->draw(get_canvas_item(), Size2(x, 0));
+ }
+ // Draw the navigation buttons.
if (buttons_visible_cache) {
+ int y_center = header_height / 2;
- int vofs = (top_margin-incr->get_height())/2;
- decr->draw(ci,Point2(limit,vofs),Color(1,1,1,tab_display_ofs==0?0.5:1.0));
- incr->draw(ci,Point2(limit+incr->get_width(),vofs),Color(1,1,1,notdone?1.0:0.5));
- }
-
- if (popup) {
- int from = get_size().width-menu->get_width();
+ x -= increment->get_width();
+ increment->draw(canvas,
+ Point2(x, y_center - (increment->get_height() / 2)),
+ Color(1, 1, 1, last_tab_cache < tabs.size() - 1 ? 1.0 : 0.5));
- if (mouse_x_cache > from)
- menu_hl->draw(get_canvas_item(),Size2(from,0));
- else
- menu->draw(get_canvas_item(),Size2(from,0));
+ x -= decrement->get_width();
+ decrement->draw(canvas,
+ Point2(x, y_center - (decrement->get_height() / 2)),
+ Color(1, 1, 1, first_tab_cache > 0 ? 1.0 : 0.5));
}
- panel->draw(ci, Rect2( 0, top_size.height, size.width, size.height-top_size.height));
-
+ // Draw the tab area.
+ panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height));
} break;
case NOTIFICATION_THEME_CHANGED: {
if (get_tab_count() > 0) {
- call_deferred("set_current_tab",get_current_tab()); //wait until all changed theme
+ call_deferred("set_current_tab", get_current_tab()); //wait until all changed theme
}
} break;
}
}
+int TabContainer::_get_tab_width(int p_index) const {
+ Control *control = _get_tabs()[p_index]->cast_to<Control>();
+ if (!control || control->is_set_as_toplevel())
+ return 0;
+
+ // Get the width of the text displayed on the tab.
+ Ref<Font> font = get_font("font");
+ String text = control->has_meta("_tab_name")
+ ? String(XL_MESSAGE(String(control->get_meta("_tab_name"))))
+ : String(control->get_name());
+ int width = font->get_string_size(text).width;
+
+ // Add space for a tab icon.
+ if (control->has_meta("_tab_icon")) {
+ Ref<Texture> icon = control->get_meta("_tab_icon");
+ if (icon.is_valid()) {
+ width += icon->get_width();
+ if (text != "")
+ width += get_constant("hseparation");
+ }
+ }
+
+ // Respect a minimum size.
+ Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
+ Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
+ if (get_tab_disabled(p_index)) {
+ width += tab_disabled->get_minimum_size().width;
+ } else if (p_index == current) {
+ width += tab_fg->get_minimum_size().width;
+ } else {
+ width += tab_bg->get_minimum_size().width;
+ }
+
+ return width;
+}
+
+Vector<Control*> TabContainer::_get_tabs() const {
+
+ Vector<Control*> controls;
+ for (int i = 0; i < get_child_count(); i++) {
+
+ Control *control = get_child(i)->cast_to<Control>();
+ if (!control || control->is_toplevel_control())
+ continue;
+
+ controls.push_back(control);
+ }
+ return controls;
+}
+
void TabContainer::_child_renamed_callback() {
update();
@@ -408,78 +362,62 @@ void TabContainer::add_child_notify(Node *p_child) {
if (c->is_set_as_toplevel())
return;
- bool first=false;
+ bool first = false;
- if (get_tab_count()!=1)
+ if (get_tab_count() != 1)
c->hide();
else {
c->show();
//call_deferred("set_current_tab",0);
- first=true;
- current=0;
+ first = true;
+ current = 0;
}
c->set_area_as_parent_rect();
if (tabs_visible)
- c->set_margin(MARGIN_TOP,_get_top_margin());
+ c->set_margin(MARGIN_TOP, _get_top_margin());
Ref<StyleBox> sb = get_stylebox("panel");
- for(int i=0;i<4;i++)
- c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));
+ for (int i = 0; i < 4; i++)
+ c->set_margin(Margin(i), c->get_margin(Margin(i)) + sb->get_margin(Margin(i)));
update();
- p_child->connect("renamed", this,"_child_renamed_callback");
- if(first)
- emit_signal("tab_changed",current);
+ p_child->connect("renamed", this, "_child_renamed_callback");
+ if (first)
+ emit_signal("tab_changed", current);
}
int TabContainer::get_tab_count() const {
- int count=0;
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- count++;
- }
-
- return count;
+ return _get_tabs().size();
}
void TabContainer::set_current_tab(int p_current) {
- ERR_FAIL_INDEX( p_current, get_tab_count() );
-
- current=p_current;
+ ERR_FAIL_INDEX(p_current, get_tab_count());
- int idx=0;
+ current = p_current;
- Ref<StyleBox> sb=get_stylebox("panel");
- for(int i=0;i<get_child_count();i++) {
+ Ref<StyleBox> sb = get_stylebox("panel");
+ Vector<Control*> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
- if (idx==current) {
+ Control *c = tabs[i];
+ if (i == current) {
c->show();
c->set_area_as_parent_rect();
if (tabs_visible)
- c->set_margin(MARGIN_TOP,_get_top_margin());
- for(int i=0;i<4;i++)
- c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));
+ c->set_margin(MARGIN_TOP, _get_top_margin());
+ for (int i = 0; i < 4; i++)
+ c->set_margin(Margin(i), c->get_margin(Margin(i)) + sb->get_margin(Margin(i)));
} else
c->hide();
- idx++;
}
_change_notify("current_tab");
- emit_signal("tab_changed",current);
+ emit_signal("tab_changed", current);
update();
}
@@ -490,45 +428,19 @@ int TabContainer::get_current_tab() const {
Control* TabContainer::get_tab_control(int p_idx) const {
- int idx=0;
-
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
- if (idx==p_idx) {
- return c;
-
- }
- idx++;
- }
-
- return NULL;
+ Vector<Control*> tabs = _get_tabs();
+ if (p_idx >= 0 && p_idx < tabs.size())
+ return tabs[p_idx];
+ else
+ return NULL;
}
Control* TabContainer::get_current_tab_control() const {
- int idx=0;
-
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
- if (idx==current) {
- return c;
-
- }
- idx++;
- }
-
- return NULL;
+ Vector<Control*> tabs = _get_tabs();
+ if (current >= 0 && current < tabs.size())
+ return tabs[current];
+ else
+ return NULL;
}
void TabContainer::remove_child_notify(Node *p_child) {
@@ -536,24 +448,24 @@ void TabContainer::remove_child_notify(Node *p_child) {
Control::remove_child_notify(p_child);
int tc = get_tab_count();
- if (current==tc-1) {
+ if (current == tc - 1) {
current--;
- if (current<0)
- current=0;
+ if (current < 0)
+ current = 0;
else {
- call_deferred("set_current_tab",current);
+ call_deferred("set_current_tab", current);
}
}
- p_child->disconnect("renamed", this,"_child_renamed_callback");
+ p_child->disconnect("renamed", this, "_child_renamed_callback");
update();
}
void TabContainer::set_tab_align(TabAlign p_align) {
- ERR_FAIL_INDEX(p_align,3);
- align=p_align;
+ ERR_FAIL_INDEX(p_align, 3);
+ align = p_align;
update();
_change_notify("tab_align");
@@ -565,20 +477,19 @@ TabContainer::TabAlign TabContainer::get_tab_align() const {
void TabContainer::set_tabs_visible(bool p_visibe) {
- if (p_visibe==tabs_visible)
+ if (p_visibe == tabs_visible)
return;
- tabs_visible=p_visibe;
+ tabs_visible = p_visibe;
- for(int i=0;i<get_child_count();i++) {
+ Vector<Control*> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
+ Control *c = tabs[i];
if (p_visibe)
- c->set_margin(MARGIN_TOP,_get_top_margin());
+ c->set_margin(MARGIN_TOP, _get_top_margin());
else
- c->set_margin(MARGIN_TOP,0);
+ c->set_margin(MARGIN_TOP, 0);
}
update();
@@ -593,36 +504,22 @@ bool TabContainer::are_tabs_visible() const {
Control *TabContainer::_get_tab(int p_idx) const {
- int idx=0;
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
- if (idx==p_idx)
- return c;
- idx++;
-
- }
- return NULL;
+ return get_tab_control(p_idx);
}
-void TabContainer::set_tab_title(int p_tab,const String& p_title) {
+void TabContainer::set_tab_title(int p_tab, const String& p_title) {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
- child->set_meta("_tab_name",p_title);
+ child->set_meta("_tab_name", p_title);
}
-String TabContainer::get_tab_title(int p_tab) const{
+String TabContainer::get_tab_title(int p_tab) const {
Control *child = _get_tab(p_tab);
- ERR_FAIL_COND_V(!child,"");
+ ERR_FAIL_COND_V(!child, "");
if (child->has_meta("_tab_name"))
return child->get_meta("_tab_name");
else
@@ -630,39 +527,53 @@ String TabContainer::get_tab_title(int p_tab) const{
}
-void TabContainer::set_tab_icon(int p_tab,const Ref<Texture>& p_icon){
+void TabContainer::set_tab_icon(int p_tab, const Ref<Texture>& p_icon) {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
- child->set_meta("_tab_icon",p_icon);
+ child->set_meta("_tab_icon", p_icon);
}
-Ref<Texture> TabContainer::get_tab_icon(int p_tab) const{
+Ref<Texture> TabContainer::get_tab_icon(int p_tab) const {
Control *child = _get_tab(p_tab);
- ERR_FAIL_COND_V(!child,Ref<Texture>());
+ ERR_FAIL_COND_V(!child, Ref<Texture>());
if (child->has_meta("_tab_icon"))
return child->get_meta("_tab_icon");
else
return Ref<Texture>();
}
+void TabContainer::set_tab_disabled(int p_tab, bool p_enabled) {
+
+ Control *child = _get_tab(p_tab);
+ ERR_FAIL_COND(!child);
+ child->set_meta("_tab_disabled", p_enabled);
+ update();
+}
+bool TabContainer::get_tab_disabled(int p_tab) const {
+
+ Control *child = _get_tab(p_tab);
+ ERR_FAIL_COND_V(!child, false);
+ if (child->has_meta("_tab_disabled"))
+ return child->get_meta("_tab_disabled");
+ else
+ return false;
+}
+
void TabContainer::get_translatable_strings(List<String> *p_strings) const {
- for(int i=0;i<get_child_count();i++) {
+ Vector<Control*> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
+ Control *c = tabs[i];
if (!c->has_meta("_tab_name"))
continue;
String name = c->get_meta("_tab_name");
- if (name!="")
+ if (name != "")
p_strings->push_back(name);
}
}
@@ -672,38 +583,36 @@ Size2 TabContainer::get_minimum_size() const {
Size2 ms;
- for(int i=0;i<get_child_count();i++) {
+ Vector<Control*> tabs = _get_tabs();
+ for (int i = 0; i < tabs.size(); i++) {
- Control *c = get_child(i)->cast_to<Control>();
- if (!c)
- continue;
- if (c->is_set_as_toplevel())
- continue;
+ Control *c = tabs[i];
- if (!c->is_visible())
+ if (!c->is_visible_in_tree())
continue;
Size2 cms = c->get_combined_minimum_size();
- ms.x=MAX(ms.x,cms.x);
- ms.y=MAX(ms.y,cms.y);
+ ms.x = MAX(ms.x, cms.x);
+ ms.y = MAX(ms.y, cms.y);
}
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<Font> font = get_font("font");
- ms.y+=MAX(tab_bg->get_minimum_size().y,tab_fg->get_minimum_size().y);
- ms.y+=font->get_height();
+ ms.y += MAX(MAX(tab_bg->get_minimum_size().y, tab_fg->get_minimum_size().y), tab_disabled->get_minimum_size().y);
+ ms.y += font->get_height();
Ref<StyleBox> sb = get_stylebox("panel");
- ms+=sb->get_minimum_size();
+ ms += sb->get_minimum_size();
return ms;
}
void TabContainer::set_popup(Node *p_popup) {
ERR_FAIL_NULL(p_popup);
- popup=p_popup->cast_to<Popup>();
+ popup = p_popup->cast_to<Popup>();
update();
}
@@ -714,43 +623,45 @@ Popup* TabContainer::get_popup() const {
void TabContainer::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&TabContainer::_gui_input);
- ClassDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
- ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
- ClassDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
- ClassDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
- ClassDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
- ClassDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
- ClassDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
- ClassDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
- ClassDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
- ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
- ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
- ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
- ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
- ClassDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
- ClassDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
-
- ClassDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
-
- ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
+ ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input);
+ ClassDB::bind_method(D_METHOD("get_tab_count"), &TabContainer::get_tab_count);
+ ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &TabContainer::set_current_tab);
+ ClassDB::bind_method(D_METHOD("get_current_tab"), &TabContainer::get_current_tab);
+ ClassDB::bind_method(D_METHOD("get_current_tab_control:Control"), &TabContainer::get_current_tab_control);
+ ClassDB::bind_method(D_METHOD("get_tab_control:Control", "idx"), &TabContainer::get_tab_control);
+ ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &TabContainer::set_tab_align);
+ ClassDB::bind_method(D_METHOD("get_tab_align"), &TabContainer::get_tab_align);
+ ClassDB::bind_method(D_METHOD("set_tabs_visible", "visible"), &TabContainer::set_tabs_visible);
+ ClassDB::bind_method(D_METHOD("are_tabs_visible"), &TabContainer::are_tabs_visible);
+ ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &TabContainer::set_tab_title);
+ ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &TabContainer::get_tab_title);
+ ClassDB::bind_method(D_METHOD("set_tab_icon", "tab_idx", "icon:Texture"), &TabContainer::set_tab_icon);
+ ClassDB::bind_method(D_METHOD("get_tab_icon:Texture", "tab_idx"), &TabContainer::get_tab_icon);
+ ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &TabContainer::set_tab_disabled);
+ ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &TabContainer::get_tab_disabled);
+ ClassDB::bind_method(D_METHOD("set_popup", "popup:Popup"), &TabContainer::set_popup);
+ ClassDB::bind_method(D_METHOD("get_popup:Popup"), &TabContainer::get_popup);
+
+ ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
+
+ ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("pre_popup_pressed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT, "tab_align", PROPERTY_HINT_ENUM,"Left,Center,Right"), _SCS("set_tab_align"), _SCS("get_tab_align") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "tabs_visible"), _SCS("set_tabs_visible"), _SCS("are_tabs_visible") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_align", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_tab_align", "get_tab_align");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_visible"), "set_tabs_visible", "are_tabs_visible");
}
TabContainer::TabContainer() {
- tab_display_ofs=0;
- buttons_visible_cache=false;
- tabs_ofs_cache=0;
- current=0;
- mouse_x_cache=0;
- align=ALIGN_CENTER;
- tabs_visible=true;
- popup=NULL;
+ first_tab_cache = 0;
+ buttons_visible_cache = false;
+ tabs_ofs_cache = 0;
+ current = 0;
+ mouse_x_cache = 0;
+ align = ALIGN_CENTER;
+ tabs_visible = true;
+ popup = NULL;
-}
+} \ No newline at end of file
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 8b6ca7704e..67f631f866 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -46,7 +46,7 @@ public:
private:
int mouse_x_cache;
- int tab_display_ofs;
+ int first_tab_cache;
int tabs_ofs_cache;
int last_tab_cache;
int current;
@@ -57,6 +57,8 @@ private:
int _get_top_margin() const;
Popup *popup;
+ Vector<Control*> _get_tabs() const;
+ int _get_tab_width(int p_index) const;
protected:
@@ -83,6 +85,9 @@ public:
void set_tab_icon(int p_tab,const Ref<Texture>& p_icon);
Ref<Texture> get_tab_icon(int p_tab) const;
+ void set_tab_disabled(int p_tab, bool p_disabled);
+ bool get_tab_disabled(int p_tab) const;
+
int get_tab_count() const;
void set_current_tab(int p_current);
int get_current_tab() const;
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 98d3f6230d..4e07a495ed 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -34,9 +34,10 @@ Size2 Tabs::get_minimum_size() const {
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<Font> font = get_font("font");
- Size2 ms(0, MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height)+font->get_height());
+ Size2 ms(0, MAX(MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height), tab_disabled->get_minimum_size().height)+font->get_height());
for(int i=0;i<tabs.size();i++) {
@@ -49,7 +50,9 @@ Size2 Tabs::get_minimum_size() const {
ms.width+=font->get_string_size(tabs[i].text).width;
- if (current==i)
+ if (tabs[i].disabled)
+ ms.width += tab_disabled->get_minimum_size().width;
+ else if (current==i)
ms.width+=tab_fg->get_minimum_size().width;
else
ms.width+=tab_bg->get_minimum_size().width;
@@ -111,7 +114,7 @@ void Tabs::_gui_input(const InputEvent& p_event) {
hover_buttons = i;
break;
}
- else if (tabs[i].cb_rect.has_point(pos)) {
+ else if (!tabs[i].disabled && tabs[i].cb_rect.has_point(pos)) {
cb_hover=i;
rb_hover=-1;
hover_buttons = i;
@@ -206,7 +209,9 @@ void Tabs::_gui_input(const InputEvent& p_event) {
}
if (pos.x >=tabs[i].ofs_cache && pos.x<tabs[i].ofs_cache+tabs[i].size_cache) {
- found=i;
+ if (!tabs[i].disabled) {
+ found = i;
+ }
break;
}
}
@@ -242,9 +247,11 @@ void Tabs::_notification(int p_what) {
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<Font> font = get_font("font");
Color color_fg = get_color("font_color_fg");
Color color_bg = get_color("font_color_bg");
+ Color color_disabled = get_color("font_color_disabled");
Ref<Texture> close=get_icon("close");
int h = get_size().height;
@@ -301,7 +308,10 @@ void Tabs::_notification(int p_what) {
Ref<StyleBox> sb;
Color col;
- if (i==current) {
+ if (tabs[i].disabled) {
+ sb = tab_disabled;
+ col = color_disabled;
+ } else if (i == current) {
sb=tab_fg;
col=color_fg;
} else {
@@ -366,7 +376,7 @@ void Tabs::_notification(int p_what) {
cb_rect.pos.x=w;
cb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(cb_rect.size.y))/2;
- if (cb_hover==i) {
+ if (!tabs[i].disabled && cb_hover == i) {
if (cb_pressing)
get_stylebox("button_pressed")->draw(ci,cb_rect);
else
@@ -463,6 +473,18 @@ Ref<Texture> Tabs::get_tab_icon(int p_tab) const{
}
+void Tabs::set_tab_disabled(int p_tab, bool p_disabled) {
+
+ ERR_FAIL_INDEX(p_tab, tabs.size());
+ tabs[p_tab].disabled = p_disabled;
+ update();
+}
+bool Tabs::get_tab_disabled(int p_tab) const {
+
+ ERR_FAIL_INDEX_V(p_tab, tabs.size(), false);
+ return tabs[p_tab].disabled;
+}
+
void Tabs::set_tab_right_button(int p_tab,const Ref<Texture>& p_right_button){
ERR_FAIL_INDEX(p_tab,tabs.size());
@@ -484,6 +506,7 @@ void Tabs::add_tab(const String& p_str,const Ref<Texture>& p_icon) {
Tab t;
t.text=p_str;
t.icon=p_icon;
+ t.disabled = false;
tabs.push_back(t);
@@ -534,6 +557,7 @@ int Tabs::get_tab_width(int p_idx) const {
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
+ Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
Ref<Font> font = get_font("font");
@@ -549,7 +573,9 @@ int Tabs::get_tab_width(int p_idx) const {
x+=font->get_string_size(tabs[p_idx].text).width;
- if (current==p_idx)
+ if (tabs[p_idx].disabled)
+ x += tab_disabled->get_minimum_size().width;
+ else if (current==p_idx)
x+=tab_fg->get_minimum_size().width;
else
x+=tab_bg->get_minimum_size().width;
@@ -649,25 +675,27 @@ void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
void Tabs::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&Tabs::_gui_input);
- ClassDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
- ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
- ClassDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
- ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
- ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
- ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
- ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
- ClassDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
- ClassDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
- ClassDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
- ClassDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
- ClassDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&Tabs::_gui_input);
+ ClassDB::bind_method(D_METHOD("get_tab_count"),&Tabs::get_tab_count);
+ ClassDB::bind_method(D_METHOD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
+ ClassDB::bind_method(D_METHOD("get_current_tab"),&Tabs::get_current_tab);
+ ClassDB::bind_method(D_METHOD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
+ ClassDB::bind_method(D_METHOD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
+ ClassDB::bind_method(D_METHOD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
+ ClassDB::bind_method(D_METHOD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
+ 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("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);
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_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab") ;
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 9ba32297dc..83dcce2613 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -57,6 +57,7 @@ private:
String text;
Ref<Texture> icon;
int ofs_cache;
+ bool disabled;
int size_cache;
int x_cache;
int x_size_cache;
@@ -105,6 +106,9 @@ public:
void set_tab_icon(int p_tab,const Ref<Texture>& p_icon);
Ref<Texture> get_tab_icon(int p_tab) const;
+
+ void set_tab_disabled(int p_tab, bool p_disabled);
+ bool get_tab_disabled(int p_tab) const;
void set_tab_right_button(int p_tab,const Ref<Texture>& p_right_button);
Ref<Texture> get_tab_right_button(int p_tab) const;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index cbc0c283de..f1b061c506 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -32,7 +32,7 @@
#include "os/input.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "message_queue.h"
#include "scene/main/viewport.h"
@@ -247,7 +247,7 @@ void TextEdit::Text::clear_caches() {
void TextEdit::Text::clear() {
- text.clear();;
+ text.clear();
insert(0,"");
}
@@ -482,14 +482,6 @@ void TextEdit::_notification(int p_what) {
Color color = cache.font_color;
int in_region=-1;
- if (line_length_guideline) {
- int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
- if (x>xmargin_beg && x<xmargin_end) {
- Color guideline_color(color.r,color.g,color.b,color.a*0.25f);
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),guideline_color);
- }
- }
-
if (syntax_coloring) {
if (cache.background_color.a>0.01) {
@@ -1080,6 +1072,14 @@ void TextEdit::_notification(int p_what) {
}
}
+ if (line_length_guideline) {
+ int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
+ if (x>xmargin_beg && x<xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),cache.line_length_guideline_color);
+ }
+ }
+
+
bool completion_below = false;
if (completion_active) {
// code completion box
@@ -2431,6 +2431,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) {
if (k.mod.shift)
_post_shift_selection();
+ else if(k.mod.command || k.mod.control)
+ deselect();
} break;
#else
@@ -2440,25 +2442,30 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) {
if (k.mod.shift)
_pre_shift_selection();
- // compute whitespace symbols seq length
- int current_line_whitespace_len = 0;
- while(current_line_whitespace_len < text[cursor.line].length()) {
- CharType c = text[cursor.line][current_line_whitespace_len];
- if(c != '\t' && c != ' ')
- break;
- current_line_whitespace_len++;
- }
-
- if(cursor_get_column() == current_line_whitespace_len)
+ if (k.mod.command) {
+ cursor_set_line(0);
cursor_set_column(0);
- else
- cursor_set_column(current_line_whitespace_len);
+ }
+ else {
+ // compute whitespace symbols seq length
+ int current_line_whitespace_len = 0;
+ while( current_line_whitespace_len < text[cursor.line].length() ) {
+ CharType c = text[cursor.line][current_line_whitespace_len];
+ if( c != '\t' && c != ' ' )
+ break;
+ current_line_whitespace_len++;
+ }
- if (k.mod.command)
- cursor_set_line(0);
+ if( cursor_get_column() == current_line_whitespace_len )
+ cursor_set_column(0);
+ else
+ cursor_set_column(current_line_whitespace_len);
+ }
if (k.mod.shift)
_post_shift_selection();
+ else if(k.mod.command || k.mod.control)
+ deselect();
_cancel_completion();
completion_hint="";
@@ -2481,6 +2488,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) {
if (k.mod.shift)
_post_shift_selection();
+ else if(k.mod.command || k.mod.control)
+ deselect();
} break;
#else
@@ -2495,6 +2504,8 @@ void TextEdit::_gui_input(const InputEvent& p_gui_input) {
if (k.mod.shift)
_post_shift_selection();
+ else if(k.mod.command || k.mod.control)
+ deselect();
_cancel_completion();
completion_hint="";
@@ -3036,7 +3047,7 @@ void TextEdit::adjust_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
@@ -3044,7 +3055,7 @@ void TextEdit::adjust_viewport_to_cursor() {
//printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line);
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
if (cursor.line>=(cursor.line_ofs+visible_rows))
@@ -3078,12 +3089,12 @@ void TextEdit::center_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
int max_ofs = text.size()-(scroll_past_end_of_file_enabled?1:visible_rows);
@@ -3205,9 +3216,9 @@ void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
return;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
cursor.x_ofs=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
cursor.line_ofs=v_scroll->get_value();
update();
}
@@ -3458,7 +3469,7 @@ void TextEdit::_reset_caret_blink_timer() {
void TextEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible() && has_focus() && window_has_focus) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -3484,6 +3495,7 @@ void TextEdit::_update_caches() {
cache.selection_color=get_color("selection_color");
cache.mark_color=get_color("mark_color");
cache.current_line_color=get_color("current_line_color");
+ cache.line_length_guideline_color=get_color("line_length_guideline_color");
cache.breakpoint_color=get_color("breakpoint_color");
cache.brace_mismatch_color=get_color("brace_mismatch_color");
cache.word_highlighted_color=get_color("word_highlighted_color");
@@ -4255,7 +4267,7 @@ void TextEdit::_update_completion_candidates() {
//no completion here
//print_line("cancel!");
cancel=true;
- } if (inquote && first_quote!=-1) {
+ } else if (inquote && first_quote!=-1) {
s=l.substr(first_quote,cofs-first_quote);
//print_line("s: 1"+s);
@@ -4357,7 +4369,7 @@ void TextEdit::_update_completion_candidates() {
if (completion_options.size()==1) {
//one option to complete, just complete it automagically
_confirm_completion();
- // insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
+ //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
_cancel_completion();
return;
@@ -4608,90 +4620,90 @@ PopupMenu *TextEdit::get_menu() const {
void TextEdit::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&TextEdit::_gui_input);
- ClassDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
- ClassDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
- ClassDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
- ClassDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
- ClassDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
- ClassDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&TextEdit::_gui_input);
+ ClassDB::bind_method(D_METHOD("_scroll_moved"),&TextEdit::_scroll_moved);
+ ClassDB::bind_method(D_METHOD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
+ ClassDB::bind_method(D_METHOD("_text_changed_emit"),&TextEdit::_text_changed_emit);
+ ClassDB::bind_method(D_METHOD("_push_current_op"),&TextEdit::_push_current_op);
+ ClassDB::bind_method(D_METHOD("_click_selection_held"),&TextEdit::_click_selection_held);
+ ClassDB::bind_method(D_METHOD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
BIND_CONSTANT( SEARCH_MATCH_CASE );
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
BIND_CONSTANT( SEARCH_BACKWARDS );
/*
- ClassDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
- ClassDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
+ ClassDB::bind_method(D_METHOD("delete_char"),&TextEdit::delete_char);
+ ClassDB::bind_method(D_METHOD("delete_line"),&TextEdit::delete_line);
*/
- ClassDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
- ClassDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
+ ClassDB::bind_method(D_METHOD("set_text","text"),&TextEdit::set_text);
+ ClassDB::bind_method(D_METHOD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
- ClassDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
- ClassDB::bind_method(_MD("get_text"),&TextEdit::get_text);
- ClassDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
+ ClassDB::bind_method(D_METHOD("get_line_count"),&TextEdit::get_line_count);
+ ClassDB::bind_method(D_METHOD("get_text"),&TextEdit::get_text);
+ ClassDB::bind_method(D_METHOD("get_line","line"),&TextEdit::get_line);
- ClassDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
- ClassDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
- ClassDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
- ClassDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
- ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
- ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
- ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
- ClassDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
- ClassDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
- ClassDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
+ ClassDB::bind_method(D_METHOD("cursor_get_column"),&TextEdit::cursor_get_column);
+ ClassDB::bind_method(D_METHOD("cursor_get_line"),&TextEdit::cursor_get_line);
+ ClassDB::bind_method(D_METHOD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(D_METHOD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(D_METHOD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(D_METHOD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(D_METHOD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
+ ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
- ClassDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
- ClassDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
- ClassDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
+ ClassDB::bind_method(D_METHOD("set_readonly","enable"),&TextEdit::set_readonly);
+ ClassDB::bind_method(D_METHOD("set_wrap","enable"),&TextEdit::set_wrap);
+ ClassDB::bind_method(D_METHOD("set_max_chars","amount"),&TextEdit::set_max_chars);
- ClassDB::bind_method(_MD("cut"),&TextEdit::cut);
- ClassDB::bind_method(_MD("copy"),&TextEdit::copy);
- ClassDB::bind_method(_MD("paste"),&TextEdit::paste);
- ClassDB::bind_method(_MD("select_all"),&TextEdit::select_all);
- ClassDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
+ ClassDB::bind_method(D_METHOD("cut"),&TextEdit::cut);
+ ClassDB::bind_method(D_METHOD("copy"),&TextEdit::copy);
+ ClassDB::bind_method(D_METHOD("paste"),&TextEdit::paste);
+ ClassDB::bind_method(D_METHOD("select_all"),&TextEdit::select_all);
+ ClassDB::bind_method(D_METHOD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
- ClassDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
- ClassDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
- ClassDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
- ClassDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
- ClassDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
- ClassDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
- ClassDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
- ClassDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
+ ClassDB::bind_method(D_METHOD("is_selection_active"),&TextEdit::is_selection_active);
+ ClassDB::bind_method(D_METHOD("get_selection_from_line"),&TextEdit::get_selection_from_line);
+ ClassDB::bind_method(D_METHOD("get_selection_from_column"),&TextEdit::get_selection_from_column);
+ ClassDB::bind_method(D_METHOD("get_selection_to_line"),&TextEdit::get_selection_to_line);
+ ClassDB::bind_method(D_METHOD("get_selection_to_column"),&TextEdit::get_selection_to_column);
+ ClassDB::bind_method(D_METHOD("get_selection_text"),&TextEdit::get_selection_text);
+ ClassDB::bind_method(D_METHOD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
+ ClassDB::bind_method(D_METHOD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
- ClassDB::bind_method(_MD("undo"),&TextEdit::undo);
- ClassDB::bind_method(_MD("redo"),&TextEdit::redo);
- ClassDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
+ ClassDB::bind_method(D_METHOD("undo"),&TextEdit::undo);
+ ClassDB::bind_method(D_METHOD("redo"),&TextEdit::redo);
+ ClassDB::bind_method(D_METHOD("clear_undo_history"),&TextEdit::clear_undo_history);
- ClassDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
- ClassDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
+ ClassDB::bind_method(D_METHOD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
+ ClassDB::bind_method(D_METHOD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
- ClassDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
- ClassDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
+ ClassDB::bind_method(D_METHOD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
+ ClassDB::bind_method(D_METHOD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
- ClassDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
- ClassDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
+ ClassDB::bind_method(D_METHOD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
+ ClassDB::bind_method(D_METHOD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
- ClassDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
- ClassDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
- ClassDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
- ClassDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
- ClassDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
+ 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("get_menu:PopupMenu"),&TextEdit::get_menu);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), _SCS("set_syntax_coloring"), _SCS("is_syntax_coloring_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), _SCS("set_show_line_numbers"), _SCS("is_show_line_numbers_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), _SCS("set_highlight_all_occurrences"), _SCS("is_highlight_all_occurrences_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled");
ADD_GROUP("Caret","caret_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), "cursor_set_blink_speed","cursor_get_blink_speed") ;
ADD_SIGNAL(MethodInfo("cursor_changed"));
ADD_SIGNAL(MethodInfo("text_changed"));
@@ -4732,8 +4744,8 @@ TextEdit::TextEdit() {
tab_size=4;
text.set_tab_size(tab_size);
text.clear();
- // text.insert(1,"Mongolia..");
- // text.insert(2,"PAIS GENEROSO!!");
+ //text.insert(1,"Mongolia..");
+ //text.insert(2,"PAIS GENEROSO!!");
text.set_color_regions(&color_regions);
h_scroll = memnew( HScrollBar );
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index c7467f9b13..437e22ca40 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -91,6 +91,7 @@ class TextEdit : public Control {
Color mark_color;
Color breakpoint_color;
Color current_line_color;
+ Color line_length_guideline_color;
Color brace_mismatch_color;
Color word_highlighted_color;
Color search_result_color;
@@ -294,7 +295,7 @@ class TextEdit : public Control {
void _scroll_lines_up();
void _scroll_lines_down();
-// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
+ //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size() const;
int get_row_height() const;
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 83cd853572..2f10de054a 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -28,40 +28,35 @@
/*************************************************************************/
#include "texture_button.h"
-
Size2 TextureButton::get_minimum_size() const {
- Size2 rscale;
- if (normal.is_null()) {
- if (pressed.is_null()) {
- if (hover.is_null())
- if (click_mask.is_null())
- rscale= Size2();
+ Size2 rscale = Control::get_minimum_size();
+
+ if (!expand) {
+ if (normal.is_null()) {
+ if (pressed.is_null()) {
+ if (hover.is_null())
+ if (click_mask.is_null())
+ rscale= Size2();
+ else
+ rscale= click_mask->get_size();
else
- rscale= click_mask->get_size();
- else
- rscale= hover->get_size();
- } else
- rscale=pressed->get_size();
+ rscale= hover->get_size();
+ } else
+ rscale=pressed->get_size();
- } else
- rscale= normal->get_size();
+ } else
+ rscale= normal->get_size();
+ }
- return rscale*scale.abs();
+ return rscale.abs();
}
-
bool TextureButton::has_point(const Point2& p_point) const {
- if (scale[0] == 0 || scale[1] == 0) {
- return false;
- }
-
- Point2 ppos = p_point/scale.abs();
-
if (click_mask.is_valid()) {
- Point2i p =ppos;
+ Point2i p =p_point;
if (p.x<0 || p.x>=click_mask->get_size().width || p.y<0 || p.y>=click_mask->get_size().height)
return false;
@@ -119,49 +114,107 @@ void TextureButton::_notification(int p_what) {
}
if (texdraw.is_valid()) {
- Rect2 drect(Point2(),texdraw->get_size()*scale);
- draw_texture_rect(texdraw,drect,false,modulate);
-
+ Point2 ofs;
+ Size2 size = texdraw->get_size();
+ Rect2 tex_regin = Rect2(Point2(), texdraw->get_size());
+ bool tile = false;
+ if (expand) {
+ switch (stretch_mode) {
+ case STRETCH_KEEP:
+ size = texdraw->get_size();
+ break;
+ case STRETCH_SCALE:
+ size = get_size();
+ break;
+ case STRETCH_TILE:
+ size = get_size();
+ tile = true;
+ break;
+ case STRETCH_KEEP_CENTERED:
+ ofs = (get_size() - texdraw->get_size())/2;
+ size = texdraw->get_size();
+ break;
+ case STRETCH_KEEP_ASPECT_CENTERED:
+ case STRETCH_KEEP_ASPECT: {
+ Size2 _size=get_size();
+ float tex_width = texdraw->get_width() * _size.height / texdraw->get_height();
+ float tex_height = _size.height;
+
+ if (tex_width > _size.width) {
+ tex_width = _size.width;
+ tex_height = texdraw->get_height() * tex_width / texdraw->get_width();
+ }
+
+ if (stretch_mode==STRETCH_KEEP_ASPECT_CENTERED) {
+ ofs.x = (_size.width - tex_width)/2;
+ ofs.y = (_size.height - tex_height)/2;
+ }
+ size.width = tex_width;
+ size.height = tex_height;
+ } break;
+ case STRETCH_KEEP_ASPECT_COVERED:{
+ size = get_size();
+ Size2 tex_size = texdraw->get_size();
+ Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height);
+ float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height;
+ Size2 scaledTexSize = tex_size * scale;
+ Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f;
+ tex_regin = Rect2(ofs, size/scale);
+ } break;
+ }
+ }
+ if (tile)
+ draw_texture_rect(texdraw,Rect2(ofs,size),tile);
+ else
+ draw_texture_rect_region(texdraw, Rect2(ofs, size), tex_regin);
}
if (has_focus() && focused.is_valid()) {
- Rect2 drect(Point2(),focused->get_size()*scale);
- draw_texture_rect(focused,drect,false,modulate);
+ Rect2 drect(Point2(), get_size());
+ draw_texture_rect(focused,drect,false);
};
-
} break;
}
}
void TextureButton::_bind_methods() {
- ClassDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
- ClassDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
- ClassDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
- ClassDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
- ClassDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
- ClassDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
- ClassDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
- ClassDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate);
-
- ClassDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
- ClassDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
- ClassDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
- ClassDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
- ClassDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
- ClassDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
- ClassDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
- ClassDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
+ ClassDB::bind_method(D_METHOD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
+ ClassDB::bind_method(D_METHOD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
+ ClassDB::bind_method(D_METHOD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
+ ClassDB::bind_method(D_METHOD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
+ ClassDB::bind_method(D_METHOD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
+ ClassDB::bind_method(D_METHOD("set_expand","p_expand"),&TextureButton::set_expand);
+ ClassDB::bind_method(D_METHOD("set_stretch_mode","p_mode"),&TextureButton::set_stretch_mode);
+
+ ClassDB::bind_method(D_METHOD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
+ ClassDB::bind_method(D_METHOD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
+ ClassDB::bind_method(D_METHOD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
+ ClassDB::bind_method(D_METHOD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
+ ClassDB::bind_method(D_METHOD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
+ ClassDB::bind_method(D_METHOD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
+ ClassDB::bind_method(D_METHOD("get_expand"),&TextureButton::get_expand);
+ ClassDB::bind_method(D_METHOD("get_stretch_mode"),&TextureButton::get_stretch_mode);
ADD_GROUP("Textures","texture_");
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"texture_scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_normal_texture", "get_normal_texture");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_pressed_texture", "get_pressed_texture");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_hover_texture", "get_hover_texture");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_disabled_texture", "get_disabled_texture");
+ 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");
+
+ BIND_CONSTANT(STRETCH_SCALE);
+ BIND_CONSTANT(STRETCH_TILE);
+ BIND_CONSTANT(STRETCH_KEEP);
+ BIND_CONSTANT(STRETCH_KEEP_CENTERED);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT_CENTERED);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT_COVERED);
}
@@ -229,29 +282,26 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) {
focused = p_focused;
};
-void TextureButton::set_texture_scale(Size2 p_scale) {
+bool TextureButton::get_expand() const {
+ return expand;
+}
- scale=p_scale;
+void TextureButton::set_expand(bool p_expand) {
+ expand = p_expand;
minimum_size_changed();
update();
}
-Size2 TextureButton::get_texture_scale() const{
-
- return scale;
-}
-
-void TextureButton::set_modulate(const Color& p_modulate) {
- modulate=p_modulate;
+void TextureButton::set_stretch_mode(StretchMode p_mode) {
+ stretch_mode = p_mode;
update();
}
-Color TextureButton::get_modulate() const {
- return modulate;
+TextureButton::StretchMode TextureButton::get_stretch_mode() const {
+ return stretch_mode;
}
-
TextureButton::TextureButton() {
- scale=Size2(1.0, 1.0);
- modulate=Color(1,1,1);
+ expand = false;
+ stretch_mode = STRETCH_SCALE;
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index b6cb531c71..64103860bf 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -35,20 +35,31 @@ class TextureButton : public BaseButton {
GDCLASS( TextureButton, BaseButton );
+public:
+ enum StretchMode {
+ STRETCH_SCALE,
+ STRETCH_TILE,
+ STRETCH_KEEP,
+ STRETCH_KEEP_CENTERED,
+ STRETCH_KEEP_ASPECT,
+ STRETCH_KEEP_ASPECT_CENTERED,
+ STRETCH_KEEP_ASPECT_COVERED,
+ };
+
+private:
Ref<Texture> normal;
Ref<Texture> pressed;
Ref<Texture> hover;
Ref<Texture> disabled;
Ref<Texture> focused;
Ref<BitMap> click_mask;
- Size2 scale;
- Color modulate;
-
+ bool expand;
+ StretchMode stretch_mode;
protected:
- virtual bool has_point(const Point2& p_point) const;
virtual Size2 get_minimum_size() const;
+ virtual bool has_point(const Point2& p_point) const;
void _notification(int p_what);
static void _bind_methods();
@@ -68,13 +79,15 @@ public:
Ref<Texture> get_focused_texture() const;
Ref<BitMap> get_click_mask() const;
- void set_texture_scale(Size2 p_scale);
- Size2 get_texture_scale() const;
+ bool get_expand() const;
+ void set_expand(bool p_expand);
- void set_modulate(const Color& p_modulate);
- Color get_modulate() const;
+ void set_stretch_mode(StretchMode stretch_mode);
+ StretchMode get_stretch_mode() const;
TextureButton();
};
+
+VARIANT_ENUM_CAST( TextureButton::StretchMode );
#endif // TEXTURE_BUTTON_H
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index df0512fc96..3897647502 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -46,7 +46,9 @@ void TextureProgress::set_over_texture(const Ref<Texture>& p_texture) {
over=p_texture;
update();
- minimum_size_changed();
+ if (under.is_null()) {
+ minimum_size_changed();
+ }
}
Ref<Texture> TextureProgress::get_over_texture() const{
@@ -135,24 +137,24 @@ void TextureProgress::_notification(int p_what){
Size2 s = progress->get_size();
switch (mode) {
case FILL_LEFT_TO_RIGHT: {
- Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_RIGHT_TO_LEFT: {
- Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(s.x-s.x*get_as_ratio(),0),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_TOP_TO_BOTTOM: {
- Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_BOTTOM_TO_TOP: {
- Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(0,s.y-s.y*get_as_ratio()),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- float val=get_unit_value()*rad_max_degrees/360;
+ float val=get_as_ratio()*rad_max_degrees/360;
if (val==1) {
Rect2 region=Rect2(Point2(),s);
draw_texture_rect_region(progress,region,region);
@@ -192,7 +194,7 @@ void TextureProgress::_notification(int p_what){
}
} break;
default:
- draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
+ draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)),Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)));
}
@@ -255,36 +257,36 @@ Point2 TextureProgress::get_radial_center_offset()
void TextureProgress::_bind_methods() {
- ClassDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
- ClassDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
+ 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(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
- ClassDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_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(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
- ClassDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_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(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
- ClassDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
+ 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);
- ClassDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
- ClassDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
+ ClassDB::bind_method(D_METHOD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
+ ClassDB::bind_method(D_METHOD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
- ClassDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
- ClassDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
+ ClassDB::bind_method(D_METHOD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
+ ClassDB::bind_method(D_METHOD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
- ClassDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
- ClassDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
+ ClassDB::bind_method(D_METHOD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
+ ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
ADD_GROUP("Textures","texture_");
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"fill_mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_under_texture","get_under_texture");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_over_texture","get_over_texture");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_progress_texture","get_progress_texture");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"fill_mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),"set_fill_mode","get_fill_mode");
ADD_GROUP("Radial Fill","radial_");
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),"set_radial_initial_angle","get_radial_initial_angle");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),"set_fill_degrees","get_fill_degrees");
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_center_offset"),"set_radial_center_offset","get_radial_center_offset");
BIND_CONSTANT( FILL_LEFT_TO_RIGHT );
BIND_CONSTANT( FILL_RIGHT_TO_LEFT );
@@ -302,4 +304,5 @@ TextureProgress::TextureProgress()
rad_init_angle=0;
rad_center_off=Point2();
rad_max_degrees=360;
+ set_mouse_filter(MOUSE_FILTER_PASS);
}
diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_rect.cpp
index bfa72ef067..f2fe3eae12 100644
--- a/scene/gui/texture_frame.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_frame.cpp */
+/* texture_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,10 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "texture_frame.h"
+#include "texture_rect.h"
#include "servers/visual_server.h"
-void TextureFrame::_notification(int p_what) {
+void TextureRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -79,32 +79,40 @@ void TextureFrame::_notification(int p_what) {
draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height));
} break;
-
+ case STRETCH_KEEP_ASPECT_COVERED: {
+ Size2 size = get_size();
+ Size2 tex_size = texture->get_size();
+ Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height);
+ float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height;
+ Size2 scaledTexSize = tex_size * scale;
+ Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f;
+ draw_texture_rect_region(texture, Rect2(Point2(), size), Rect2(ofs, size/scale));
+ } break;
}
}
}
-Size2 TextureFrame::get_minimum_size() const {
+Size2 TextureRect::get_minimum_size() const {
if (!expand && !texture.is_null())
return texture->get_size();
else
return Size2();
}
-void TextureFrame::_bind_methods() {
+void TextureRect::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture"), & TextureFrame::set_texture );
- ClassDB::bind_method(_MD("get_texture"), & TextureFrame::get_texture );
- ClassDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand );
- ClassDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand );
- ClassDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode );
- ClassDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode );
+ 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_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 );
+ ClassDB::bind_method(D_METHOD("get_stretch_mode"), & TextureRect::get_stretch_mode );
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), "set_expand","has_expand");
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode");
BIND_CONSTANT( STRETCH_SCALE_ON_EXPAND );
BIND_CONSTANT( STRETCH_SCALE );
@@ -113,57 +121,59 @@ void TextureFrame::_bind_methods() {
BIND_CONSTANT( STRETCH_KEEP_CENTERED );
BIND_CONSTANT( STRETCH_KEEP_ASPECT );
BIND_CONSTANT( STRETCH_KEEP_ASPECT_CENTERED );
-
+ BIND_CONSTANT( STRETCH_KEEP_ASPECT_COVERED );
}
-void TextureFrame::set_texture(const Ref<Texture>& p_tex) {
+void TextureRect::set_texture(const Ref<Texture>& p_tex) {
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
}
-Ref<Texture> TextureFrame::get_texture() const {
+Ref<Texture> TextureRect::get_texture() const {
return texture;
}
-void TextureFrame::set_expand(bool p_expand) {
+void TextureRect::set_expand(bool p_expand) {
expand=p_expand;
update();
minimum_size_changed();
}
-bool TextureFrame::has_expand() const {
+bool TextureRect::has_expand() const {
return expand;
}
-void TextureFrame::set_stretch_mode(StretchMode p_mode) {
+void TextureRect::set_stretch_mode(StretchMode p_mode) {
stretch_mode=p_mode;
update();
}
-TextureFrame::StretchMode TextureFrame::get_stretch_mode() const {
+TextureRect::StretchMode TextureRect::get_stretch_mode() const {
return stretch_mode;
}
-TextureFrame::TextureFrame() {
+TextureRect::TextureRect() {
expand=false;
- set_mouse_filter(MOUSE_FILTER_IGNORE);
+ set_mouse_filter(MOUSE_FILTER_PASS);
stretch_mode=STRETCH_SCALE_ON_EXPAND;
}
-TextureFrame::~TextureFrame()
+TextureRect::~TextureRect()
{
}
diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_rect.h
index c311748708..0d72458909 100644
--- a/scene/gui/texture_frame.h
+++ b/scene/gui/texture_rect.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_frame.h */
+/* texture_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -33,9 +33,9 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class TextureFrame : public Control {
+class TextureRect : public Control {
- GDCLASS(TextureFrame,Control);
+ GDCLASS(TextureRect,Control);
public:
enum StretchMode {
STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
@@ -45,7 +45,7 @@ public:
STRETCH_KEEP_CENTERED,
STRETCH_KEEP_ASPECT,
STRETCH_KEEP_ASPECT_CENTERED,
-
+ STRETCH_KEEP_ASPECT_COVERED,
};
private:
bool expand;
@@ -69,10 +69,10 @@ public:
void set_stretch_mode(StretchMode p_mode);
StretchMode get_stretch_mode() const;
- TextureFrame();
- ~TextureFrame();
+ TextureRect();
+ ~TextureRect();
};
-VARIANT_ENUM_CAST( TextureFrame::StretchMode );
+VARIANT_ENUM_CAST( TextureRect::StretchMode );
#endif // TEXTURE_FRAME_H
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 9f5b9f710d..292efdcc01 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -30,7 +30,7 @@
#include "print_string.h"
#include "os/os.h"
#include "os/keyboard.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/input.h"
#include "scene/main/viewport.h"
@@ -611,7 +611,7 @@ void TreeItem::clear_custom_color(int p_column) {
ERR_FAIL_INDEX( p_column, cells.size() );
cells[p_column].custom_color=false;
- cells[p_column].color=Color();;
+ cells[p_column].color=Color();
_changed_notify(p_column);
}
@@ -642,7 +642,7 @@ void TreeItem::clear_custom_bg_color(int p_column) {
ERR_FAIL_INDEX( p_column, cells.size() );
cells[p_column].custom_bg_color=false;
- cells[p_column].bg_color=Color();;
+ cells[p_column].bg_color=Color();
_changed_notify(p_column);
}
@@ -657,76 +657,76 @@ Color TreeItem::get_custom_bg_color(int p_column) const {
void TreeItem::_bind_methods() {
- ClassDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
- ClassDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
+ ClassDB::bind_method(D_METHOD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
+ ClassDB::bind_method(D_METHOD("get_cell_mode","column"),&TreeItem::get_cell_mode);
- ClassDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
- ClassDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
+ ClassDB::bind_method(D_METHOD("set_checked","column","checked"),&TreeItem::set_checked);
+ ClassDB::bind_method(D_METHOD("is_checked","column"),&TreeItem::is_checked);
- ClassDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
- ClassDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
+ ClassDB::bind_method(D_METHOD("set_text","column","text"),&TreeItem::set_text);
+ ClassDB::bind_method(D_METHOD("get_text","column"),&TreeItem::get_text);
- ClassDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
- ClassDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
+ ClassDB::bind_method(D_METHOD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
+ ClassDB::bind_method(D_METHOD("get_icon:Texture","column"),&TreeItem::get_icon);
- ClassDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
- ClassDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
+ ClassDB::bind_method(D_METHOD("set_icon_region","column","region"),&TreeItem::set_icon_region);
+ ClassDB::bind_method(D_METHOD("get_icon_region","column"),&TreeItem::get_icon_region);
- ClassDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
- ClassDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
+ ClassDB::bind_method(D_METHOD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
+ ClassDB::bind_method(D_METHOD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
- ClassDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
- ClassDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
- ClassDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
- ClassDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
+ ClassDB::bind_method(D_METHOD("set_range","column","value"),&TreeItem::set_range);
+ ClassDB::bind_method(D_METHOD("get_range","column"),&TreeItem::get_range);
+ ClassDB::bind_method(D_METHOD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_range_config","column"),&TreeItem::_get_range_config);
- ClassDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
- ClassDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
+ ClassDB::bind_method(D_METHOD("set_metadata","column","meta"),&TreeItem::set_metadata);
+ ClassDB::bind_method(D_METHOD("get_metadata","column"),&TreeItem::get_metadata);
- ClassDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
+ ClassDB::bind_method(D_METHOD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
- ClassDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
- ClassDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
+ ClassDB::bind_method(D_METHOD("set_collapsed","enable"),&TreeItem::set_collapsed);
+ ClassDB::bind_method(D_METHOD("is_collapsed"),&TreeItem::is_collapsed);
- ClassDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
- ClassDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
- ClassDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
- ClassDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
+ ClassDB::bind_method(D_METHOD("get_next:TreeItem"),&TreeItem::get_next);
+ ClassDB::bind_method(D_METHOD("get_prev:TreeItem"),&TreeItem::get_prev);
+ ClassDB::bind_method(D_METHOD("get_parent:TreeItem"),&TreeItem::get_parent);
+ ClassDB::bind_method(D_METHOD("get_children:TreeItem"),&TreeItem::get_children);
- ClassDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
- ClassDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
+ 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(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
+ ClassDB::bind_method(D_METHOD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
- ClassDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
- ClassDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
+ ClassDB::bind_method(D_METHOD("set_selectable","column","selectable"),&TreeItem::set_selectable);
+ ClassDB::bind_method(D_METHOD("is_selectable","column"),&TreeItem::is_selectable);
- ClassDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
- ClassDB::bind_method(_MD("select","column"),&TreeItem::select);
- ClassDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
+ ClassDB::bind_method(D_METHOD("is_selected","column"),&TreeItem::is_selected);
+ ClassDB::bind_method(D_METHOD("select","column"),&TreeItem::select);
+ ClassDB::bind_method(D_METHOD("deselect","column"),&TreeItem::deselect);
- ClassDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
- ClassDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
+ ClassDB::bind_method(D_METHOD("set_editable","column","enabled"),&TreeItem::set_editable);
+ ClassDB::bind_method(D_METHOD("is_editable","column"),&TreeItem::is_editable);
- ClassDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
- ClassDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
+ ClassDB::bind_method(D_METHOD("set_custom_color","column","color"),&TreeItem::set_custom_color);
+ ClassDB::bind_method(D_METHOD("clear_custom_color","column"),&TreeItem::clear_custom_color);
- ClassDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
- ClassDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
- ClassDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
+ ClassDB::bind_method(D_METHOD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
+ ClassDB::bind_method(D_METHOD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
- ClassDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
- ClassDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
- ClassDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
- ClassDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
- ClassDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
- ClassDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
+ ClassDB::bind_method(D_METHOD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_button_count","column"),&TreeItem::get_button_count);
+ ClassDB::bind_method(D_METHOD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
+ ClassDB::bind_method(D_METHOD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
+ ClassDB::bind_method(D_METHOD("erase_button","column","button_idx"),&TreeItem::erase_button);
+ ClassDB::bind_method(D_METHOD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
- ClassDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
- ClassDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
+ ClassDB::bind_method(D_METHOD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
+ ClassDB::bind_method(D_METHOD("get_tooltip","column"),&TreeItem::get_tooltip);
- ClassDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
- ClassDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
+ ClassDB::bind_method(D_METHOD("move_to_top"),&TreeItem::move_to_top);
+ ClassDB::bind_method(D_METHOD("move_to_bottom"),&TreeItem::move_to_bottom);
BIND_CONSTANT( CELL_MODE_STRING );
BIND_CONSTANT( CELL_MODE_CHECK );
@@ -943,14 +943,16 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons
bmsize.width=p_cell.icon_max_w;
}
- p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((rect.size.y-bmsize.y)/2)),bmsize);
+ p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((real_t)(rect.size.y-bmsize.y)/2)),bmsize);
rect.pos.x+=bmsize.x+cache.hseparation;
rect.size.x-=bmsize.x+cache.hseparation;
}
-// if (p_tool)
-// rect.size.x-=Math::floor(rect.size.y/2);
+ /*
+ if (p_tool)
+ rect.size.x-=Math::floor(rect.size.y/2);
+ */
Ref<Font> font = cache.font;
@@ -1006,7 +1008,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
/* Draw label, if height fits */
- bool skip=(p_item==root && hide_root);
+ bool skip=(p_item==root && hide_root);
if (!skip && (p_pos.y+label_h-cache.offset.y)>0) {
@@ -1029,7 +1031,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
}
//draw separation.
-// if (p_item->get_parent()!=root || !hide_root)
+ //if (p_item->get_parent()!=root || !hide_root)
Ref<Font> font = cache.font;
@@ -1115,7 +1117,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
} else {
cache.selected->draw(ci,r );
}
- if (text_editor->is_visible()){
+ if (text_editor->is_visible_in_tree()){
text_editor->set_pos(get_global_pos() + r.pos);
}
}
@@ -1171,7 +1173,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Ref<Texture> checked = cache.checked;
Ref<Texture> unchecked = cache.unchecked;
Point2i check_ofs=item_rect.pos;
- check_ofs.y+=Math::floor((item_rect.size.y-checked->get_height())/2);
+ check_ofs.y+=Math::floor((real_t)(item_rect.size.y-checked->get_height())/2);
if (p_item->cells[i].checked) {
@@ -1256,13 +1258,13 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
icon_ofs+=item_rect.pos;
- 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));
//p_item->cells[i].icon->draw(ci, icon_ofs);
} break;
case TreeItem::CELL_MODE_CUSTOM: {
- // int option = (int)p_item->cells[i].val;
+ //int option = (int)p_item->cells[i].val;
@@ -1414,8 +1416,10 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
emit_signal("item_selected");
emitted_row=true;
}
- //if (p_col==i)
- // p_current->selected_signal.call(p_col);
+ /*
+ if (p_col==i)
+ p_current->selected_signal.call(p_col);
+ */
} else if (c.selected) {
@@ -1606,6 +1610,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
cache.click_id=c.buttons[j].id;
cache.click_item=p_item;
cache.click_column=col;
+ cache.click_pos=get_global_mouse_pos()-get_global_pos();
update();
//emit_signal("button_pressed");
return -1;
@@ -1672,9 +1677,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
}
}
- //if (!c.selected && select_mode==SELECT_MULTI) {
- // emit_signal("multi_selected",p_item,col,true);
- //}
+ /*
+ if (!c.selected && select_mode==SELECT_MULTI) {
+ emit_signal("multi_selected",p_item,col,true);
+ }
+ */
update();
}
@@ -1705,8 +1712,15 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
case TreeItem::CELL_MODE_CHECK: {
bring_up_editor=false; //checkboxes are not edited with editor
- p_item->set_checked(col, !c.checked);
- item_edited(col, p_item);
+ if (force_edit_checkbox_only_on_checkbox) {
+ if (x < cache.checked->get_width()) {
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ }
+ } else {
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ }
click_handled = true;
//p_item->edited_signal.call(col);
@@ -1997,7 +2011,7 @@ void Tree::_gui_input(InputEvent p_event) {
} break;
case KEY_LEFT: {
-// TreeItem *next = NULL;
+ //TreeItem *next = NULL;
if (!selected_item)
break;
if (select_mode==SELECT_ROW)
@@ -2027,7 +2041,7 @@ void Tree::_gui_input(InputEvent p_event) {
next=selected_item->get_next_visible();
-// if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
+ //if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
if (last_keypress!=0) {
//incr search next
int col;
@@ -2277,9 +2291,9 @@ void Tree::_gui_input(InputEvent p_event) {
mpos.y-=_get_title_button_height();
if (mpos.y>=0) {
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
mpos.x+=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
mpos.y+=v_scroll->get_value();
int col,h,section;
@@ -2315,7 +2329,7 @@ void Tree::_gui_input(InputEvent p_event) {
TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
float diff_y = -b.relative_y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
+ diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y);
diff_y*=0.1;
range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
popup_edited_item->set_range(popup_edited_item_col,range_drag_base);
@@ -2377,6 +2391,8 @@ void Tree::_gui_input(InputEvent p_event) {
if (cache.click_type==Cache::CLICK_BUTTON) {
+ // make sure in case of wrong reference after reconstructing whole TreeItems
+ cache.click_item=get_item_at_pos(cache.click_pos);
emit_signal("button_pressed",cache.click_item,cache.click_column,cache.click_id);
}
@@ -2470,7 +2486,7 @@ void Tree::_gui_input(InputEvent p_event) {
if (!click_handled) {
drag_speed=0;
drag_accum=0;
-// last_drag_accum=0;
+ //last_drag_accum=0;
drag_from=v_scroll->get_value();
drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel=false;
@@ -2567,7 +2583,7 @@ bool Tree::edit_selected() {
value_editor->set_max( c.max );
value_editor->set_step( c.step );
value_editor->set_value( c.val );
- value_editor->set_exp_unit_value( c.expr );
+ value_editor->set_exp_ratio( c.expr );
updating_value_editor=false;
}
@@ -2669,7 +2685,7 @@ void Tree::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- update_cache();;
+ update_cache();
}
if (p_what==NOTIFICATION_DRAG_END) {
@@ -2787,13 +2803,10 @@ void Tree::_notification(int p_what) {
}
int ofs=0;
-// int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP);
-// int size_y=exposed.size.height-bg->get_minimum_size().height;
for (int i=0;i<(columns.size()-1-1);i++) {
ofs+=get_column_width(i);
- //get_painter()->draw_fill_rect( Point2(ofs+cache.hseparation/2, from_y), Size2( 1, size_y ),color( COLOR_TREE_GRID) );
}
if (show_column_titles) {
@@ -2960,7 +2973,6 @@ void Tree::clear() {
selected_item=NULL;
edited_item=NULL;
popup_edited_item=NULL;
- selected_item=NULL;
update();
};
@@ -3016,8 +3028,10 @@ int Tree::get_edited_column() const {
TreeItem* Tree::get_next_selected( TreeItem* p_item) {
- //if (!p_item)
- // return NULL;
+ /*
+ if (!p_item)
+ return NULL;
+ */
if (!root)
return NULL;
@@ -3069,7 +3083,7 @@ int Tree::get_column_width(int p_column) const {
int expand_area=get_size().width-(bg->get_margin(MARGIN_LEFT)+bg->get_margin(MARGIN_RIGHT));
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
expand_area-=v_scroll->get_combined_minimum_size().width;
int expanding_columns=0;
@@ -3254,9 +3268,9 @@ String Tree::get_column_title(int p_column) const {
Point2 Tree::get_scroll() const {
Point2 ofs;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
ofs.x=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
ofs.y=v_scroll->get_value();
return ofs;
@@ -3325,7 +3339,7 @@ TreeItem* Tree::_find_item_at_pos(TreeItem*p_item, const Point2& p_pos,int& r_co
if (root!=p_item || ! hide_root) {
- h = compute_item_height(p_item)+cache.vseparation;;
+ h = compute_item_height(p_item)+cache.vseparation;
if (pos.y<h) {
if (drop_mode_flags==DROP_MODE_ON_ITEM) {
@@ -3395,9 +3409,9 @@ int Tree::get_column_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -1;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
pos.x+=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
pos.y+=v_scroll->get_value();
int col,h,section;
@@ -3422,9 +3436,9 @@ int Tree::get_drop_section_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -100;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
pos.x+=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
pos.y+=v_scroll->get_value();
int col,h,section;
@@ -3449,9 +3463,9 @@ TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return NULL;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
pos.x+=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
pos.y+=v_scroll->get_value();
int col,h,section;
@@ -3477,9 +3491,9 @@ String Tree::get_tooltip(const Point2& p_pos) const {
if (pos.y<0)
return Control::get_tooltip(p_pos);
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
pos.x+=h_scroll->get_value();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
pos.y+=v_scroll->get_value();
int col,h,section;
@@ -3550,6 +3564,16 @@ bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
return force_select_on_already_selected;
}
+void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
+
+ force_edit_checkbox_only_on_checkbox=p_enable;
+}
+
+bool Tree::get_edit_checkbox_cell_only_when_checkbox_is_pressed() const {
+
+ return force_edit_checkbox_only_on_checkbox;
+}
+
void Tree::set_allow_rmb_select(bool p_allow) {
@@ -3564,59 +3588,59 @@ bool Tree::get_allow_rmb_select() const{
void Tree::_bind_methods() {
- ClassDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
- ClassDB::bind_method(_MD("_gui_input"),&Tree::_gui_input);
- ClassDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
- ClassDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
- ClassDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
- ClassDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
- ClassDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
+ ClassDB::bind_method(D_METHOD("_range_click_timeout"),&Tree::_range_click_timeout);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&Tree::_gui_input);
+ ClassDB::bind_method(D_METHOD("_popup_select"),&Tree::popup_select);
+ ClassDB::bind_method(D_METHOD("_text_editor_enter"),&Tree::text_editor_enter);
+ ClassDB::bind_method(D_METHOD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
+ ClassDB::bind_method(D_METHOD("_value_editor_changed"),&Tree::value_editor_changed);
+ ClassDB::bind_method(D_METHOD("_scroll_moved"),&Tree::_scroll_moved);
- ClassDB::bind_method(_MD("clear"),&Tree::clear);
- ClassDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("clear"),&Tree::clear);
+ ClassDB::bind_method(D_METHOD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
- ClassDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
- ClassDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
- ClassDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
+ ClassDB::bind_method(D_METHOD("get_root:TreeItem"),&Tree::get_root);
+ ClassDB::bind_method(D_METHOD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
+ ClassDB::bind_method(D_METHOD("set_column_expand","column","expand"),&Tree::set_column_expand);
+ ClassDB::bind_method(D_METHOD("get_column_width","column"),&Tree::get_column_width);
- ClassDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
- ClassDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
- ClassDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
- ClassDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
- ClassDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
- ClassDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
+ ClassDB::bind_method(D_METHOD("set_hide_root","enable"),&Tree::set_hide_root);
+ ClassDB::bind_method(D_METHOD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
+ ClassDB::bind_method(D_METHOD("get_selected:TreeItem"),&Tree::get_selected);
+ ClassDB::bind_method(D_METHOD("get_selected_column"),&Tree::get_selected_column);
+ ClassDB::bind_method(D_METHOD("get_pressed_button"),&Tree::get_pressed_button);
+ ClassDB::bind_method(D_METHOD("set_select_mode","mode"),&Tree::set_select_mode);
- ClassDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
- ClassDB::bind_method(_MD("get_columns"),&Tree::get_columns);
+ ClassDB::bind_method(D_METHOD("set_columns","amount"),&Tree::set_columns);
+ ClassDB::bind_method(D_METHOD("get_columns"),&Tree::get_columns);
- ClassDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
- ClassDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
- ClassDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
- ClassDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
- ClassDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
- ClassDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
+ ClassDB::bind_method(D_METHOD("get_edited:TreeItem"),&Tree::get_edited);
+ ClassDB::bind_method(D_METHOD("get_edited_column"),&Tree::get_edited_column);
+ ClassDB::bind_method(D_METHOD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
+ ClassDB::bind_method(D_METHOD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
+ ClassDB::bind_method(D_METHOD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
- ClassDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
+ ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
- ClassDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
- ClassDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
+ ClassDB::bind_method(D_METHOD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
+ ClassDB::bind_method(D_METHOD("are_column_titles_visible"),&Tree::are_column_titles_visible);
- ClassDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
- ClassDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
- ClassDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
+ ClassDB::bind_method(D_METHOD("set_column_title","column","title"),&Tree::set_column_title);
+ ClassDB::bind_method(D_METHOD("get_column_title","column"),&Tree::get_column_title);
+ ClassDB::bind_method(D_METHOD("get_scroll"),&Tree::get_scroll);
- ClassDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
- ClassDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
+ ClassDB::bind_method(D_METHOD("set_hide_folding","hide"),&Tree::set_hide_folding);
+ ClassDB::bind_method(D_METHOD("is_folding_hidden"),&Tree::is_folding_hidden);
- ClassDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
- ClassDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ClassDB::bind_method(D_METHOD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
+ ClassDB::bind_method(D_METHOD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
- ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
- ClassDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
+ ClassDB::bind_method(D_METHOD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
+ ClassDB::bind_method(D_METHOD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
- ClassDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
- ClassDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(D_METHOD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(D_METHOD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
ADD_SIGNAL( MethodInfo("item_selected"));
ADD_SIGNAL( MethodInfo("cell_selected"));
@@ -3728,6 +3752,7 @@ Tree::Tree() {
force_select_on_already_selected=false;
allow_rmb_select=false;
+ force_edit_checkbox_only_on_checkbox=false;
set_clip_contents(true);
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 8327e356b3..14bd2efbaa 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -334,7 +334,7 @@ friend class TreeItem;
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_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);
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);
@@ -409,6 +409,7 @@ friend class TreeItem;
TreeItem *click_item;
int click_column;
int hover_index;
+ Point2 click_pos;
} cache;
@@ -452,6 +453,7 @@ friend class TreeItem;
bool scrolling;
bool force_select_on_already_selected;
+ bool force_edit_checkbox_only_on_checkbox;
bool hide_folding;
@@ -531,6 +533,10 @@ public:
void set_single_select_cell_editing_only_when_already_selected(bool p_enable);
bool get_single_select_cell_editing_only_when_already_selected() const;
+ void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
+ bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
+
+
void set_allow_rmb_select(bool p_allow);
bool get_allow_rmb_select() const;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index f7d2ad1c63..063ad8c44a 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -28,7 +28,8 @@
/*************************************************************************/
#include "video_player.h"
#include "os/os.h"
-
+#include "servers/audio_server.h"
+/*
int VideoPlayer::InternalStream::get_channel_count() const {
@@ -46,7 +47,7 @@ void VideoPlayer::InternalStream::update(){
player->sp_update();
}
-
+*/
int VideoPlayer::sp_get_channel_count() const {
@@ -234,8 +235,8 @@ void VideoPlayer::play() {
playback->stop();
playback->play();
set_process_internal(true);
- AudioServer::get_singleton()->stream_set_active(stream_rid,true);
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
+// AudioServer::get_singleton()->stream_set_active(stream_rid,true);
+// AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
last_audio_time=0;
};
@@ -247,7 +248,7 @@ void VideoPlayer::stop() {
return;
playback->stop();
- AudioServer::get_singleton()->stream_set_active(stream_rid,false);
+// AudioServer::get_singleton()->stream_set_active(stream_rid,false);
resampler.flush();
set_process_internal(false);
last_audio_time=0;
@@ -357,48 +358,48 @@ bool VideoPlayer::has_autoplay() const {
void VideoPlayer::_bind_methods() {
- ClassDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
- ClassDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
+ ClassDB::bind_method(D_METHOD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
+ ClassDB::bind_method(D_METHOD("get_stream:VideoStream"),&VideoPlayer::get_stream);
- ClassDB::bind_method(_MD("play"),&VideoPlayer::play);
- ClassDB::bind_method(_MD("stop"),&VideoPlayer::stop);
+ ClassDB::bind_method(D_METHOD("play"),&VideoPlayer::play);
+ ClassDB::bind_method(D_METHOD("stop"),&VideoPlayer::stop);
- ClassDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
+ ClassDB::bind_method(D_METHOD("is_playing"),&VideoPlayer::is_playing);
- ClassDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
- ClassDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
+ ClassDB::bind_method(D_METHOD("set_paused","paused"),&VideoPlayer::set_paused);
+ ClassDB::bind_method(D_METHOD("is_paused"),&VideoPlayer::is_paused);
- ClassDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
- ClassDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
+ ClassDB::bind_method(D_METHOD("set_volume","volume"),&VideoPlayer::set_volume);
+ ClassDB::bind_method(D_METHOD("get_volume"),&VideoPlayer::get_volume);
- ClassDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
- ClassDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
+ ClassDB::bind_method(D_METHOD("set_volume_db","db"),&VideoPlayer::set_volume_db);
+ ClassDB::bind_method(D_METHOD("get_volume_db"),&VideoPlayer::get_volume_db);
- ClassDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
- ClassDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
+ ClassDB::bind_method(D_METHOD("set_audio_track","track"),&VideoPlayer::set_audio_track);
+ ClassDB::bind_method(D_METHOD("get_audio_track"),&VideoPlayer::get_audio_track);
- ClassDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
+ ClassDB::bind_method(D_METHOD("get_stream_name"),&VideoPlayer::get_stream_name);
- ClassDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
+ ClassDB::bind_method(D_METHOD("get_stream_pos"),&VideoPlayer::get_stream_pos);
- ClassDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
- ClassDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
+ ClassDB::bind_method(D_METHOD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
+ ClassDB::bind_method(D_METHOD("has_autoplay"),&VideoPlayer::has_autoplay);
- ClassDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
- ClassDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
+ ClassDB::bind_method(D_METHOD("set_expand","enable"), &VideoPlayer::set_expand );
+ ClassDB::bind_method(D_METHOD("has_expand"), &VideoPlayer::has_expand );
- ClassDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
- ClassDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
+ ClassDB::bind_method(D_METHOD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
+ ClassDB::bind_method(D_METHOD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
- ClassDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
+ ClassDB::bind_method(D_METHOD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
-// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "audio_track",PROPERTY_HINT_RANGE,"0,128,1"), "set_audio_track", "get_audio_track") ;
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), "set_stream", "get_stream") ;
+ //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), "set_loop", "has_loop") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), "set_volume_db", "get_volume_db") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), "set_paused", "is_paused") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), "set_expand","has_expand") ;
}
@@ -416,16 +417,16 @@ VideoPlayer::VideoPlayer() {
buffering_ms=500;
server_mix_rate=44100;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
+// internal_stream.player=this;
+// stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
last_audio_time=0;
};
VideoPlayer::~VideoPlayer() {
- if (stream_rid.is_valid())
- AudioServer::get_singleton()->free(stream_rid);
+// if (stream_rid.is_valid())
+// AudioServer::get_singleton()->free(stream_rid);
resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
};
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 694cb253a4..168ea805b1 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -37,16 +37,16 @@ class VideoPlayer : public Control {
GDCLASS(VideoPlayer,Control);
- struct InternalStream : public AudioServer::AudioStream {
+/* struct InternalStream : public AudioServer::AudioStream {
VideoPlayer *player;
virtual int get_channel_count() const;
virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
virtual bool mix(int32_t *p_buffer,int p_frames);
virtual void update();
};
+*/
-
- InternalStream internal_stream;
+// InternalStream internal_stream;
Ref<VideoStreamPlayback> playback;
Ref<VideoStream> stream;
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
index 37ecd3cb2f..1121ea6029 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/viewport_container.cpp
@@ -63,7 +63,7 @@ void ViewportContainer::_notification(int p_what) {
continue;
- if (is_visible())
+ if (is_visible_in_tree())
c->set_update_mode(Viewport::UPDATE_ALWAYS);
else
c->set_update_mode(Viewport::UPDATE_DISABLED);
@@ -91,10 +91,10 @@ void ViewportContainer::_notification(int p_what) {
void ViewportContainer::_bind_methods() {
- ClassDB::bind_method(_MD("set_stretch","enable"),&ViewportContainer::set_stretch);
- ClassDB::bind_method(_MD("is_stretch_enabled"),&ViewportContainer::is_stretch_enabled);
+ ClassDB::bind_method(D_METHOD("set_stretch","enable"),&ViewportContainer::set_stretch);
+ ClassDB::bind_method(D_METHOD("is_stretch_enabled"),&ViewportContainer::is_stretch_enabled);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"stretch"),_SCS("set_stretch"),_SCS("is_stretch_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"stretch"),"set_stretch","is_stretch_enabled");
}
ViewportContainer::ViewportContainer() {
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
index cc3d9baa74..8bb07adb5f 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -27,16 +27,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_image.h"
+
+#if 0
#include "scene/resources/texture.h"
#include "io/image_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) {
if (r_error)
*r_error=ERR_CANT_OPEN;
- if (p_path.extension()=="cube") {
+ if (p_path.get_extension()=="cube") {
// open as cubemap txture
CubeMap* ptr = memnew(CubeMap);
@@ -235,7 +237,7 @@ void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extens
String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
- String ext=p_path.extension().to_lower();
+ String ext=p_path.get_extension().to_lower();
if (ext=="cube")
return "CubeMap";
@@ -260,3 +262,4 @@ ResourceFormatLoaderImage::ResourceFormatLoaderImage() {
GLOBAL_DEF("rendering/image_loader/repeat",false);
}
+#endif
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
index 6e4ead2a0b..0638e97787 100644
--- a/scene/io/resource_format_image.h
+++ b/scene/io/resource_format_image.h
@@ -29,6 +29,8 @@
#ifndef RESOURCE_FORMAT_IMAGE_H
#define RESOURCE_FORMAT_IMAGE_H
+#if 0
+
#include "io/resource_loader.h"
#include "io/resource_saver.h"
/**
@@ -49,3 +51,4 @@ public:
};
#endif
+#endif
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
index f75836d2df..1e14d01f4e 100644
--- a/scene/io/resource_format_wav.cpp
+++ b/scene/io/resource_format_wav.cpp
@@ -26,6 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#if 0
#include "resource_format_wav.h"
#include "os/file_access.h"
#include "scene/resources/sample.h"
@@ -267,8 +268,9 @@ bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const {
String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="wav")
+ if (p_path.get_extension().to_lower()=="wav")
return "Sample";
return "";
}
+#endif
diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h
index 3a278b455b..fd274625f9 100644
--- a/scene/io/resource_format_wav.h
+++ b/scene/io/resource_format_wav.h
@@ -29,6 +29,7 @@
#ifndef RESOURCE_FORMAT_WAV_H
#define RESOURCE_FORMAT_WAV_H
+#if 0
#include "io/resource_loader.h"
class ResourceFormatLoaderWAV : public ResourceFormatLoader {
@@ -40,4 +41,5 @@ public:
};
+#endif
#endif // RESOURCE_FORMAT_WAV_H
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 2e2e1d6c80..04d72b5a3d 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -176,7 +176,7 @@ void CanvasLayer::_notification(int p_what) {
}
ERR_FAIL_COND(!vp);
- viewport=vp->get_viewport();
+ viewport=vp->get_viewport_rid();
VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
@@ -232,7 +232,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
else
vp=Node::get_viewport();
- viewport = vp->get_viewport();
+ viewport = vp->get_viewport_rid();
VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
@@ -259,39 +259,39 @@ int CanvasLayer::get_sort_index() {
void CanvasLayer::_bind_methods() {
- ClassDB::bind_method(_MD("set_layer","layer"),&CanvasLayer::set_layer);
- ClassDB::bind_method(_MD("get_layer"),&CanvasLayer::get_layer);
+ ClassDB::bind_method(D_METHOD("set_layer","layer"),&CanvasLayer::set_layer);
+ ClassDB::bind_method(D_METHOD("get_layer"),&CanvasLayer::get_layer);
- ClassDB::bind_method(_MD("set_transform","transform"),&CanvasLayer::set_transform);
- ClassDB::bind_method(_MD("get_transform"),&CanvasLayer::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","transform"),&CanvasLayer::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"),&CanvasLayer::get_transform);
- ClassDB::bind_method(_MD("set_offset","offset"),&CanvasLayer::set_offset);
- ClassDB::bind_method(_MD("get_offset"),&CanvasLayer::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","offset"),&CanvasLayer::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"),&CanvasLayer::get_offset);
- ClassDB::bind_method(_MD("set_rotation","radians"),&CanvasLayer::set_rotation);
- ClassDB::bind_method(_MD("get_rotation"),&CanvasLayer::get_rotation);
+ ClassDB::bind_method(D_METHOD("set_rotation","radians"),&CanvasLayer::set_rotation);
+ ClassDB::bind_method(D_METHOD("get_rotation"),&CanvasLayer::get_rotation);
- ClassDB::bind_method(_MD("set_rotationd","degrees"),&CanvasLayer::set_rotationd);
- ClassDB::bind_method(_MD("get_rotationd"),&CanvasLayer::get_rotationd);
+ ClassDB::bind_method(D_METHOD("set_rotationd","degrees"),&CanvasLayer::set_rotationd);
+ ClassDB::bind_method(D_METHOD("get_rotationd"),&CanvasLayer::get_rotationd);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ClassDB::bind_method(_MD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd);
- ClassDB::bind_method(_MD("_get_rotationd"),&CanvasLayer::_get_rotationd);
+ ClassDB::bind_method(D_METHOD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd);
+ ClassDB::bind_method(D_METHOD("_get_rotationd"),&CanvasLayer::_get_rotationd);
- ClassDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale);
- ClassDB::bind_method(_MD("get_scale"),&CanvasLayer::get_scale);
+ ClassDB::bind_method(D_METHOD("set_scale","scale"),&CanvasLayer::set_scale);
+ ClassDB::bind_method(D_METHOD("get_scale"),&CanvasLayer::get_scale);
- ClassDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
- ClassDB::bind_method(_MD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
+ ClassDB::bind_method(D_METHOD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
+ ClassDB::bind_method(D_METHOD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
- ClassDB::bind_method(_MD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
-// ClassDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
+ ClassDB::bind_method(D_METHOD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
+ //ClassDB::bind_method(D_METHOD("get_viewport"),&CanvasLayer::get_viewport);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),_SCS("set_layer"),_SCS("get_layer") );
- //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),_SCS("set_transform"),_SCS("get_transform") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"rotation"),_SCS("set_rotationd"),_SCS("get_rotationd") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),"set_layer","get_layer") ;
+ //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),"set_transform","get_transform") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),"set_offset","get_offset") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"rotation"),"set_rotationd","get_rotationd") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scale"),"set_scale","get_scale") ;
}
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 25180b568f..77b08fd58b 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -28,10 +28,6 @@
/*************************************************************************/
#include "http_request.h"
-void HTTPRequest::set_ip_type(IP::Type p_type) {
- client->set_ip_type(p_type);
-}
-
void HTTPRequest::_redirect_request(const String& p_new_url) {
@@ -40,7 +36,7 @@ void HTTPRequest::_redirect_request(const String& p_new_url) {
Error HTTPRequest::_request() {
//print_line("Requesting:\n\tURL: "+url+"\n\tString: "+request_string+"\n\tPort: "+itos(port)+"\n\tSSL: "+itos(use_ssl)+"\n\tValidate SSL: "+itos(validate_ssl));
- return client->connect(url,port,use_ssl,validate_ssl);
+ return client->connect_to_host(url,port,use_ssl,validate_ssl);
}
Error HTTPRequest::_parse_url(const String& p_url) {
@@ -539,33 +535,32 @@ int HTTPRequest::get_body_size() const{
void HTTPRequest::_bind_methods() {
- ClassDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPRequest::set_ip_type);
- ClassDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(PoolStringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
- ClassDB::bind_method(_MD("cancel_request"),&HTTPRequest::cancel_request);
+ ClassDB::bind_method(D_METHOD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(PoolStringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("cancel_request"),&HTTPRequest::cancel_request);
- ClassDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
+ ClassDB::bind_method(D_METHOD("get_http_client_status"),&HTTPRequest::get_http_client_status);
- ClassDB::bind_method(_MD("set_use_threads","enable"),&HTTPRequest::set_use_threads);
- ClassDB::bind_method(_MD("is_using_threads"),&HTTPRequest::is_using_threads);
+ ClassDB::bind_method(D_METHOD("set_use_threads","enable"),&HTTPRequest::set_use_threads);
+ ClassDB::bind_method(D_METHOD("is_using_threads"),&HTTPRequest::is_using_threads);
- ClassDB::bind_method(_MD("set_body_size_limit","bytes"),&HTTPRequest::set_body_size_limit);
- ClassDB::bind_method(_MD("get_body_size_limit"),&HTTPRequest::get_body_size_limit);
+ ClassDB::bind_method(D_METHOD("set_body_size_limit","bytes"),&HTTPRequest::set_body_size_limit);
+ ClassDB::bind_method(D_METHOD("get_body_size_limit"),&HTTPRequest::get_body_size_limit);
- ClassDB::bind_method(_MD("set_max_redirects","amount"),&HTTPRequest::set_max_redirects);
- ClassDB::bind_method(_MD("get_max_redirects"),&HTTPRequest::get_max_redirects);
+ ClassDB::bind_method(D_METHOD("set_max_redirects","amount"),&HTTPRequest::set_max_redirects);
+ ClassDB::bind_method(D_METHOD("get_max_redirects"),&HTTPRequest::get_max_redirects);
- ClassDB::bind_method(_MD("set_download_file","path"),&HTTPRequest::set_download_file);
- ClassDB::bind_method(_MD("get_download_file"),&HTTPRequest::get_download_file);
+ ClassDB::bind_method(D_METHOD("set_download_file","path"),&HTTPRequest::set_download_file);
+ ClassDB::bind_method(D_METHOD("get_download_file"),&HTTPRequest::get_download_file);
- ClassDB::bind_method(_MD("get_downloaded_bytes"),&HTTPRequest::get_downloaded_bytes);
- ClassDB::bind_method(_MD("get_body_size"),&HTTPRequest::get_body_size);
+ ClassDB::bind_method(D_METHOD("get_downloaded_bytes"),&HTTPRequest::get_downloaded_bytes);
+ ClassDB::bind_method(D_METHOD("get_body_size"),&HTTPRequest::get_body_size);
- ClassDB::bind_method(_MD("_redirect_request"),&HTTPRequest::_redirect_request);
- ClassDB::bind_method(_MD("_request_done"),&HTTPRequest::_request_done);
+ ClassDB::bind_method(D_METHOD("_redirect_request"),&HTTPRequest::_redirect_request);
+ ClassDB::bind_method(D_METHOD("_request_done"),&HTTPRequest::_request_done);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_threads"),_SCS("set_use_threads"),_SCS("is_using_threads"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"body_size_limit",PROPERTY_HINT_RANGE,"-1,2000000000"),_SCS("set_body_size_limit"),_SCS("get_body_size_limit"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"max_redirects",PROPERTY_HINT_RANGE,"-1,1024"),_SCS("set_max_redirects"),_SCS("get_max_redirects"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_threads"),"set_use_threads","is_using_threads");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"body_size_limit",PROPERTY_HINT_RANGE,"-1,2000000000"),"set_body_size_limit","get_body_size_limit");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"max_redirects",PROPERTY_HINT_RANGE,"-1,1024"),"set_max_redirects","get_max_redirects");
ADD_SIGNAL(MethodInfo("request_completed",PropertyInfo(Variant::INT,"result"),PropertyInfo(Variant::INT,"response_code"),PropertyInfo(Variant::POOL_STRING_ARRAY,"headers"),PropertyInfo(Variant::POOL_BYTE_ARRAY,"body")));
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 51c5ddeb69..a9c495fd81 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -116,7 +116,6 @@ protected:
static void _bind_methods();
public:
- void set_ip_type(IP::Type p_type);
Error request(const String& p_url, const Vector<String>& p_custom_headers=Vector<String>(), bool p_ssl_validate_domain=true, HTTPClient::Method p_method=HTTPClient::METHOD_GET, const String& p_request_data=""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 5d1b0495c0..935811009b 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -122,9 +122,9 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
void InstancePlaceholder::_bind_methods() {
- ClassDB::bind_method(_MD("get_stored_values","with_order"),&InstancePlaceholder::get_stored_values,DEFVAL(false));
- ClassDB::bind_method(_MD("replace_by_instance","custom_scene:PackedScene"),&InstancePlaceholder::replace_by_instance,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("get_instance_path"),&InstancePlaceholder::get_instance_path);
+ ClassDB::bind_method(D_METHOD("get_stored_values","with_order"),&InstancePlaceholder::get_stored_values,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("replace_by_instance","custom_scene:PackedScene"),&InstancePlaceholder::replace_by_instance,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("get_instance_path"),&InstancePlaceholder::get_instance_path);
}
InstancePlaceholder::InstancePlaceholder() {
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 32cefa6085..a189702894 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1384,6 +1384,17 @@ String Node::_generate_serial_child_name(Node *p_child) {
if (name=="") {
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()) {
+ case NAME_CASING_PASCAL_CASE:
+ break;
+ case NAME_CASING_CAMEL_CASE:
+ name[0] = name.to_lower()[0];
+ break;
+ case NAME_CASING_SNAKE_CASE:
+ name = name.camelcase_to_underscore(true);
+ break;
+ }
}
// Extract trailing number
@@ -1620,7 +1631,7 @@ Node *Node::_get_node(const NodePath& p_path) const {
current=const_cast<Node*>(this); //start from this
} else {
- root=const_cast<Node*>(this);;
+ root=const_cast<Node*>(this);
while (root->data.parent)
root=root->data.parent; //start from root
}
@@ -2277,7 +2288,7 @@ int Node::get_position_in_parent() const {
-Node *Node::_duplicate(bool p_use_instancing) const {
+Node *Node::_duplicate(int p_flags) const {
Node *node=NULL;
@@ -2291,7 +2302,7 @@ Node *Node::_duplicate(bool p_use_instancing) const {
nip->set_instance_path( ip->get_instance_path() );
node=nip;
- } else if (p_use_instancing && get_filename()!=String()) {
+ } else if ((p_flags&DUPLICATE_USE_INSTANCING) && get_filename()!=String()) {
Ref<PackedScene> res = ResourceLoader::load(get_filename());
ERR_FAIL_COND_V(res.is_null(),NULL);
@@ -2324,20 +2335,26 @@ Node *Node::_duplicate(bool p_use_instancing) const {
if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
+ if (!(p_flags&DUPLICATE_SCRIPTS) && name=="script/script")
+ continue;
+
node->set( name, get(name) );
}
node->set_name(get_name());
- List<GroupInfo> gi;
- get_groups(&gi);
- for (List<GroupInfo>::Element *E=gi.front();E;E=E->next()) {
+ if (p_flags & DUPLICATE_GROUPS) {
+ List<GroupInfo> gi;
+ get_groups(&gi);
+ for (List<GroupInfo>::Element *E=gi.front();E;E=E->next()) {
- node->add_to_group(E->get().name, E->get().persistent);
+ node->add_to_group(E->get().name, E->get().persistent);
+ }
}
- _duplicate_signals(this, node);
+ if (p_flags & DUPLICATE_SIGNALS)
+ _duplicate_signals(this, node);
for(int i=0;i<get_child_count();i++) {
@@ -2346,7 +2363,7 @@ Node *Node::_duplicate(bool p_use_instancing) const {
if (instanced && get_child(i)->data.owner==this)
continue; //part of instance
- Node *dup = get_child(i)->duplicate(p_use_instancing);
+ Node *dup = get_child(i)->duplicate(p_flags);
if (!dup) {
memdelete(node);
@@ -2360,11 +2377,11 @@ Node *Node::_duplicate(bool p_use_instancing) const {
return node;
}
-Node *Node::duplicate(bool p_use_instancing) const {
+Node *Node::duplicate(int p_flags) const {
- Node* dupe = _duplicate(p_use_instancing);
+ Node* dupe = _duplicate(p_flags);
- if (dupe) {
+ if (dupe && (p_flags&DUPLICATE_SIGNALS)) {
_duplicate_signals(this,dupe);
}
@@ -2723,7 +2740,7 @@ void Node::_set_tree(SceneTree *p_tree) {
SceneTree *tree_changed_a=NULL;
SceneTree *tree_changed_b=NULL;
-// ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
+ //ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
if (data.tree) {
_propagate_exit_tree();
@@ -2888,100 +2905,101 @@ void Node::request_ready() {
void Node::_bind_methods() {
- _GLOBAL_DEF("editor/node_name_num_separator",0);
- GlobalConfig::get_singleton()->set_custom_property_info("editor/node_name_num_separator",PropertyInfo(Variant::INT,"editor/node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
-
-
- ClassDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
-
- ClassDB::bind_method(_MD("set_name","name"),&Node::set_name);
- ClassDB::bind_method(_MD("get_name"),&Node::get_name);
- ClassDB::bind_method(_MD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false));
- ClassDB::bind_method(_MD("remove_child","node:Node"),&Node::remove_child);
- //ClassDB::bind_method(_MD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child);
- ClassDB::bind_method(_MD("get_child_count"),&Node::get_child_count);
- ClassDB::bind_method(_MD("get_children"),&Node::_get_children);
- ClassDB::bind_method(_MD("get_child:Node","idx"),&Node::get_child);
- ClassDB::bind_method(_MD("has_node","path"),&Node::has_node);
- ClassDB::bind_method(_MD("get_node:Node","path"),&Node::get_node);
- ClassDB::bind_method(_MD("get_parent:Node"),&Node::get_parent);
- ClassDB::bind_method(_MD("find_node:Node","mask","recursive","owned"),&Node::find_node,DEFVAL(true),DEFVAL(true));
- ClassDB::bind_method(_MD("has_node_and_resource","path"),&Node::has_node_and_resource);
- ClassDB::bind_method(_MD("get_node_and_resource","path"),&Node::_get_node_and_resource);
-
- ClassDB::bind_method(_MD("is_inside_tree"),&Node::is_inside_tree);
- ClassDB::bind_method(_MD("is_a_parent_of","node:Node"),&Node::is_a_parent_of);
- ClassDB::bind_method(_MD("is_greater_than","node:Node"),&Node::is_greater_than);
- ClassDB::bind_method(_MD("get_path"),&Node::get_path);
- ClassDB::bind_method(_MD("get_path_to","node:Node"),&Node::get_path_to);
- ClassDB::bind_method(_MD("add_to_group","group","persistent"),&Node::add_to_group,DEFVAL(false));
- ClassDB::bind_method(_MD("remove_from_group","group"),&Node::remove_from_group);
- ClassDB::bind_method(_MD("is_in_group","group"),&Node::is_in_group);
- ClassDB::bind_method(_MD("move_child","child_node:Node","to_pos"),&Node::move_child);
- ClassDB::bind_method(_MD("get_groups"),&Node::_get_groups);
- ClassDB::bind_method(_MD("raise"),&Node::raise);
- ClassDB::bind_method(_MD("set_owner","owner:Node"),&Node::set_owner);
- ClassDB::bind_method(_MD("get_owner:Node"),&Node::get_owner);
- ClassDB::bind_method(_MD("remove_and_skip"),&Node::remove_and_skip);
- ClassDB::bind_method(_MD("get_index"),&Node::get_index);
- ClassDB::bind_method(_MD("print_tree"),&Node::print_tree);
- ClassDB::bind_method(_MD("set_filename","filename"),&Node::set_filename);
- ClassDB::bind_method(_MD("get_filename"),&Node::get_filename);
- ClassDB::bind_method(_MD("propagate_notification","what"),&Node::propagate_notification);
- ClassDB::bind_method(_MD("set_fixed_process","enable"),&Node::set_fixed_process);
- ClassDB::bind_method(_MD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
- ClassDB::bind_method(_MD("is_fixed_processing"),&Node::is_fixed_processing);
- ClassDB::bind_method(_MD("get_process_delta_time"),&Node::get_process_delta_time);
- ClassDB::bind_method(_MD("set_process","enable"),&Node::set_process);
- ClassDB::bind_method(_MD("is_processing"),&Node::is_processing);
- ClassDB::bind_method(_MD("set_process_input","enable"),&Node::set_process_input);
- ClassDB::bind_method(_MD("is_processing_input"),&Node::is_processing_input);
- ClassDB::bind_method(_MD("set_process_unhandled_input","enable"),&Node::set_process_unhandled_input);
- ClassDB::bind_method(_MD("is_processing_unhandled_input"),&Node::is_processing_unhandled_input);
- ClassDB::bind_method(_MD("set_process_unhandled_key_input","enable"),&Node::set_process_unhandled_key_input);
- ClassDB::bind_method(_MD("is_processing_unhandled_key_input"),&Node::is_processing_unhandled_key_input);
- ClassDB::bind_method(_MD("set_pause_mode","mode"),&Node::set_pause_mode);
- ClassDB::bind_method(_MD("get_pause_mode"),&Node::get_pause_mode);
- ClassDB::bind_method(_MD("can_process"),&Node::can_process);
- ClassDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
- ClassDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
- ClassDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
- ClassDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
-
- ClassDB::bind_method(_MD("set_process_internal","enable"),&Node::set_process_internal);
- ClassDB::bind_method(_MD("is_processing_internal"),&Node::is_processing_internal);
-
- ClassDB::bind_method(_MD("set_fixed_process_internal","enable"),&Node::set_fixed_process_internal);
- ClassDB::bind_method(_MD("is_fixed_processing_internal"),&Node::is_fixed_processing_internal);
-
- ClassDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
-
- ClassDB::bind_method(_MD("duplicate:Node","use_instancing"),&Node::duplicate,DEFVAL(false));
- ClassDB::bind_method(_MD("replace_by","node:Node","keep_data"),&Node::replace_by,DEFVAL(false));
-
- ClassDB::bind_method(_MD("set_scene_instance_load_placeholder","load_placeholder"),&Node::set_scene_instance_load_placeholder);
- ClassDB::bind_method(_MD("get_scene_instance_load_placeholder"),&Node::get_scene_instance_load_placeholder);
-
-
- ClassDB::bind_method(_MD("get_viewport"),&Node::get_viewport);
-
- ClassDB::bind_method(_MD("queue_free"),&Node::queue_delete);
-
- ClassDB::bind_method(_MD("request_ready"),&Node::request_ready);
-
- ClassDB::bind_method(_MD("set_network_mode","mode"),&Node::set_network_mode);
- ClassDB::bind_method(_MD("get_network_mode"),&Node::get_network_mode);
-
- ClassDB::bind_method(_MD("is_network_master"),&Node::is_network_master);
-
- ClassDB::bind_method(_MD("rpc_config","method","mode"),&Node::rpc_config);
- ClassDB::bind_method(_MD("rset_config","property","mode"),&Node::rset_config);
+ 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"));
+ 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"));
+
+ ClassDB::bind_method(D_METHOD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
+
+ ClassDB::bind_method(D_METHOD("set_name","name"),&Node::set_name);
+ ClassDB::bind_method(D_METHOD("get_name"),&Node::get_name);
+ ClassDB::bind_method(D_METHOD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("remove_child","node:Node"),&Node::remove_child);
+ //ClassDB::bind_method(D_METHOD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child);
+ ClassDB::bind_method(D_METHOD("get_child_count"),&Node::get_child_count);
+ ClassDB::bind_method(D_METHOD("get_children"),&Node::_get_children);
+ ClassDB::bind_method(D_METHOD("get_child:Node","idx"),&Node::get_child);
+ ClassDB::bind_method(D_METHOD("has_node","path"),&Node::has_node);
+ ClassDB::bind_method(D_METHOD("get_node:Node","path"),&Node::get_node);
+ ClassDB::bind_method(D_METHOD("get_parent:Node"),&Node::get_parent);
+ ClassDB::bind_method(D_METHOD("find_node:Node","mask","recursive","owned"),&Node::find_node,DEFVAL(true),DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("has_node_and_resource","path"),&Node::has_node_and_resource);
+ ClassDB::bind_method(D_METHOD("get_node_and_resource","path"),&Node::_get_node_and_resource);
+
+ ClassDB::bind_method(D_METHOD("is_inside_tree"),&Node::is_inside_tree);
+ ClassDB::bind_method(D_METHOD("is_a_parent_of","node:Node"),&Node::is_a_parent_of);
+ ClassDB::bind_method(D_METHOD("is_greater_than","node:Node"),&Node::is_greater_than);
+ ClassDB::bind_method(D_METHOD("get_path"),&Node::get_path);
+ ClassDB::bind_method(D_METHOD("get_path_to","node:Node"),&Node::get_path_to);
+ ClassDB::bind_method(D_METHOD("add_to_group","group","persistent"),&Node::add_to_group,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("remove_from_group","group"),&Node::remove_from_group);
+ ClassDB::bind_method(D_METHOD("is_in_group","group"),&Node::is_in_group);
+ ClassDB::bind_method(D_METHOD("move_child","child_node:Node","to_pos"),&Node::move_child);
+ ClassDB::bind_method(D_METHOD("get_groups"),&Node::_get_groups);
+ ClassDB::bind_method(D_METHOD("raise"),&Node::raise);
+ ClassDB::bind_method(D_METHOD("set_owner","owner:Node"),&Node::set_owner);
+ ClassDB::bind_method(D_METHOD("get_owner:Node"),&Node::get_owner);
+ ClassDB::bind_method(D_METHOD("remove_and_skip"),&Node::remove_and_skip);
+ ClassDB::bind_method(D_METHOD("get_index"),&Node::get_index);
+ ClassDB::bind_method(D_METHOD("print_tree"),&Node::print_tree);
+ ClassDB::bind_method(D_METHOD("set_filename","filename"),&Node::set_filename);
+ ClassDB::bind_method(D_METHOD("get_filename"),&Node::get_filename);
+ ClassDB::bind_method(D_METHOD("propagate_notification","what"),&Node::propagate_notification);
+ ClassDB::bind_method(D_METHOD("set_fixed_process","enable"),&Node::set_fixed_process);
+ ClassDB::bind_method(D_METHOD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
+ ClassDB::bind_method(D_METHOD("is_fixed_processing"),&Node::is_fixed_processing);
+ ClassDB::bind_method(D_METHOD("get_process_delta_time"),&Node::get_process_delta_time);
+ ClassDB::bind_method(D_METHOD("set_process","enable"),&Node::set_process);
+ ClassDB::bind_method(D_METHOD("is_processing"),&Node::is_processing);
+ ClassDB::bind_method(D_METHOD("set_process_input","enable"),&Node::set_process_input);
+ ClassDB::bind_method(D_METHOD("is_processing_input"),&Node::is_processing_input);
+ ClassDB::bind_method(D_METHOD("set_process_unhandled_input","enable"),&Node::set_process_unhandled_input);
+ ClassDB::bind_method(D_METHOD("is_processing_unhandled_input"),&Node::is_processing_unhandled_input);
+ ClassDB::bind_method(D_METHOD("set_process_unhandled_key_input","enable"),&Node::set_process_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("is_processing_unhandled_key_input"),&Node::is_processing_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("set_pause_mode","mode"),&Node::set_pause_mode);
+ ClassDB::bind_method(D_METHOD("get_pause_mode"),&Node::get_pause_mode);
+ ClassDB::bind_method(D_METHOD("can_process"),&Node::can_process);
+ ClassDB::bind_method(D_METHOD("print_stray_nodes"),&Node::_print_stray_nodes);
+ ClassDB::bind_method(D_METHOD("get_position_in_parent"),&Node::get_position_in_parent);
+ ClassDB::bind_method(D_METHOD("set_display_folded","fold"),&Node::set_display_folded);
+ ClassDB::bind_method(D_METHOD("is_displayed_folded"),&Node::is_displayed_folded);
+
+ ClassDB::bind_method(D_METHOD("set_process_internal","enable"),&Node::set_process_internal);
+ ClassDB::bind_method(D_METHOD("is_processing_internal"),&Node::is_processing_internal);
+
+ ClassDB::bind_method(D_METHOD("set_fixed_process_internal","enable"),&Node::set_fixed_process_internal);
+ ClassDB::bind_method(D_METHOD("is_fixed_processing_internal"),&Node::is_fixed_processing_internal);
+
+ ClassDB::bind_method(D_METHOD("get_tree:SceneTree"),&Node::get_tree);
+
+ ClassDB::bind_method(D_METHOD("duplicate:Node","flags"),&Node::duplicate,DEFVAL(DUPLICATE_USE_INSTANCING|DUPLICATE_SIGNALS|DUPLICATE_GROUPS|DUPLICATE_SCRIPTS));
+ ClassDB::bind_method(D_METHOD("replace_by","node:Node","keep_data"),&Node::replace_by,DEFVAL(false));
+
+ 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("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("is_network_master"),&Node::is_network_master);
+
+ ClassDB::bind_method(D_METHOD("rpc_config","method","mode"),&Node::rpc_config);
+ ClassDB::bind_method(D_METHOD("rset_config","property","mode"),&Node::rset_config);
#ifdef TOOLS_ENABLED
- ClassDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path);
- ClassDB::bind_method(_MD("_get_import_path"),&Node::get_import_path);
- ADD_PROPERTYNZ( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_path"),_SCS("_get_import_path"));
+ ClassDB::bind_method(D_METHOD("_set_import_path","import_path"),&Node::set_import_path);
+ ClassDB::bind_method(D_METHOD("_get_import_path"),&Node::get_import_path);
+ ADD_PROPERTYNZ( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_import_path","_get_import_path");
#endif
@@ -3006,10 +3024,10 @@ void Node::_bind_methods() {
}
- ClassDB::bind_method(_MD("rset","property","value:Variant"),&Node::rset);
- ClassDB::bind_method(_MD("rset_id","peer_id","property","value:Variant"),&Node::rset_id);
- ClassDB::bind_method(_MD("rset_unreliable","property","value:Variant"),&Node::rset_unreliable);
- ClassDB::bind_method(_MD("rset_unreliable_id","peer_id","property","value:Variant"),&Node::rset_unreliable_id);
+ ClassDB::bind_method(D_METHOD("rset","property","value:Variant"),&Node::rset);
+ ClassDB::bind_method(D_METHOD("rset_id","peer_id","property","value:Variant"),&Node::rset_id);
+ ClassDB::bind_method(D_METHOD("rset_unreliable","property","value:Variant"),&Node::rset_unreliable);
+ ClassDB::bind_method(D_METHOD("rset_unreliable_id","peer_id","property","value:Variant"),&Node::rset_unreliable_id);
BIND_CONSTANT( NOTIFICATION_ENTER_TREE );
@@ -3046,17 +3064,21 @@ void Node::_bind_methods() {
BIND_CONSTANT( PAUSE_MODE_STOP );
BIND_CONSTANT( PAUSE_MODE_PROCESS );
+ BIND_CONSTANT( DUPLICATE_SIGNALS );
+ BIND_CONSTANT( DUPLICATE_GROUPS );
+ BIND_CONSTANT( DUPLICATE_SCRIPTS );
+
ADD_SIGNAL( MethodInfo("renamed") );
ADD_SIGNAL( MethodInfo("tree_entered") );
ADD_SIGNAL( MethodInfo("tree_exited") );
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),_SCS("set_process"),_SCS("is_processing") );
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), _SCS("set_fixed_process"),_SCS("is_fixed_processing") );
- //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) );
- //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) );
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),"set_process","is_processing") ;
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), "set_fixed_process","is_fixed_processing") ;
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), "set_process_input","is_processing_input" ) ;
+ //ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), "set_process_unhandled_input","is_processing_unhandled_input" ) ;
ADD_GROUP("Pause","pause_");
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), "set_pause_mode", "get_pause_mode" );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), "set_display_folded", "is_displayed_folded");
BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_fixed_process",PropertyInfo(Variant::REAL,"delta")) );
@@ -3067,8 +3089,8 @@ void Node::_bind_methods() {
BIND_VMETHOD( MethodInfo("_unhandled_input",PropertyInfo(Variant::INPUT_EVENT,"event")) );
BIND_VMETHOD( MethodInfo("_unhandled_key_input",PropertyInfo(Variant::INPUT_EVENT,"key_event")) );
- //ClassDB::bind_method(_MD("get_child",&Node::get_child,PH("index")));
- //ClassDB::bind_method(_MD("get_node",&Node::get_node,PH("path")));
+ //ClassDB::bind_method(D_METHOD("get_child",&Node::get_child,PH("index")));
+ //ClassDB::bind_method(D_METHOD("get_node",&Node::get_node,PH("path")));
}
diff --git a/scene/main/node.h b/scene/main/node.h
index e27404d46e..b042cabb6f 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -29,11 +29,11 @@
#ifndef NODE_H
#define NODE_H
-#include "globals.h"
+#include "global_config.h"
#include "object.h"
#include "path_db.h"
#include "map.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "script_language.h"
#include "scene/main/scene_main_loop.h"
@@ -54,6 +54,14 @@ public:
PAUSE_MODE_PROCESS
};
+ enum DuplicateFlags {
+
+ DUPLICATE_SIGNALS=1,
+ DUPLICATE_GROUPS=2,
+ DUPLICATE_SCRIPTS=4,
+ DUPLICATE_USE_INSTANCING=8
+ };
+
enum NetworkMode {
NETWORK_MODE_INHERIT,
@@ -147,6 +155,12 @@ private:
} data;
+ enum NameCasing {
+ NAME_CASING_PASCAL_CASE,
+ NAME_CASING_CAMEL_CASE,
+ NAME_CASING_SNAKE_CASE
+ };
+
void _print_tree(const Node *p_node);
@@ -171,7 +185,7 @@ private:
void _duplicate_signals(const Node* p_original,Node* p_copy) const;
void _duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const;
- Node *_duplicate(bool p_use_instancing) const;
+ Node *_duplicate(int p_flags) const;
Array _get_children() const;
Array _get_groups() const;
@@ -326,7 +340,7 @@ public:
int get_position_in_parent() const;
- Node *duplicate(bool p_use_instancing=false) const;
+ Node *duplicate(int p_flags=DUPLICATE_GROUPS|DUPLICATE_SIGNALS|DUPLICATE_SCRIPTS) const;
Node *duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const;
//Node *clone_tree() const;
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index 93a836a2eb..29333ff4bc 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -163,18 +163,18 @@ void ResourcePreloader::get_resource_list(List<StringName> *p_list) {
void ResourcePreloader::_bind_methods() {
- ClassDB::bind_method(_MD("_set_resources"),&ResourcePreloader::_set_resources);
- ClassDB::bind_method(_MD("_get_resources"),&ResourcePreloader::_get_resources);
+ ClassDB::bind_method(D_METHOD("_set_resources"),&ResourcePreloader::_set_resources);
+ ClassDB::bind_method(D_METHOD("_get_resources"),&ResourcePreloader::_get_resources);
- ClassDB::bind_method(_MD("add_resource","name","resource"),&ResourcePreloader::add_resource);
- ClassDB::bind_method(_MD("remove_resource","name"),&ResourcePreloader::remove_resource);
- ClassDB::bind_method(_MD("rename_resource","name","newname"),&ResourcePreloader::rename_resource);
- ClassDB::bind_method(_MD("has_resource","name"),&ResourcePreloader::has_resource);
- ClassDB::bind_method(_MD("get_resource","name"),&ResourcePreloader::get_resource);
- ClassDB::bind_method(_MD("get_resource_list"),&ResourcePreloader::_get_resource_list);
+ ClassDB::bind_method(D_METHOD("add_resource","name","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_list"),&ResourcePreloader::_get_resource_list);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"resources",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_resources"), _SCS("_get_resources"));
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"resources",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_resources", "_get_resources");
}
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index d233bf1a72..093359ab16 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -32,10 +32,10 @@
#include "os/os.h"
#include "message_queue.h"
#include "node.h"
-#include "globals.h"
+#include "global_config.h"
#include <stdio.h>
#include "os/keyboard.h"
-#include "servers/spatial_sound_2d_server.h"
+//#include "servers/spatial_sound_2d_server.h"
#include "servers/physics_2d_server.h"
#include "servers/physics_server.h"
#include "scene/scene_string_names.h"
@@ -48,8 +48,8 @@
void SceneTreeTimer::_bind_methods() {
- ClassDB::bind_method(_MD("set_time_left","time"),&SceneTreeTimer::set_time_left);
- ClassDB::bind_method(_MD("get_time_left"),&SceneTreeTimer::get_time_left);
+ ClassDB::bind_method(D_METHOD("set_time_left","time"),&SceneTreeTimer::set_time_left);
+ ClassDB::bind_method(D_METHOD("get_time_left"),&SceneTreeTimer::get_time_left);
ADD_SIGNAL(MethodInfo("timeout"));
}
@@ -63,9 +63,19 @@ float SceneTreeTimer::get_time_left() const {
return time_left;
}
+void SceneTreeTimer::set_pause_mode_process(bool p_pause_mode_process) {
+ if (process_pause != p_pause_mode_process) {
+ process_pause = p_pause_mode_process;
+ }
+}
+
+bool SceneTreeTimer::is_pause_mode_process() {
+ return process_pause;
+}
SceneTreeTimer::SceneTreeTimer() {
time_left=0;
+ process_pause = true;
}
@@ -141,7 +151,7 @@ void SceneTree::_flush_ugc() {
for(int i=0;i<E->get().size();i++)
v[i]=E->get()[i];
- call_group(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]);
+ call_group_flags(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]);
unique_group_calls.erase(E);
}
@@ -166,7 +176,7 @@ void SceneTree::_update_group_order(Group& g) {
}
-void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
+void SceneTree::call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -216,7 +226,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
continue;
if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
+ if (p_call_flags&GROUP_CALL_MULTILEVEL)
nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
else
nodes[i]->call(p_function,VARIANT_ARG_PASS);
@@ -233,7 +243,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
continue;
if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
+ if (p_call_flags&GROUP_CALL_MULTILEVEL)
nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
else
nodes[i]->call(p_function,VARIANT_ARG_PASS);
@@ -248,7 +258,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
call_skip.clear();
}
-void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification) {
+void SceneTree::notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -298,7 +308,7 @@ void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int
call_skip.clear();
}
-void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) {
+void SceneTree::set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E)
@@ -348,6 +358,23 @@ void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const
call_skip.clear();
}
+
+void SceneTree::call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
+
+ call_group_flags(0,p_group,VARIANT_ARG_PASS);
+}
+
+void SceneTree::notify_group(const StringName& p_group,int p_notification) {
+
+ notify_group_flags(0,p_group,p_notification);
+}
+
+void SceneTree::set_group(const StringName& p_group,const String& p_name,const Variant& p_value) {
+
+ set_group_flags(0,p_group,p_name,p_value);
+}
+
+
void SceneTree::set_input_as_handled() {
input_handled=true;
@@ -357,7 +384,7 @@ void SceneTree::input_text( const String& p_text ) {
root_lock++;
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check
root_lock--;
@@ -438,21 +465,22 @@ void SceneTree::input_event( const InputEvent& p_event ) {
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev);
- /*if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) {
+ /*
+ if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) {
print_line("RAM: "+itos(Memory::get_static_mem_usage()));
print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage()));
}
-*/
- //if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) {
+ if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) {
- // Memory::dump_static_mem_to_file("memdump.txt");
- //}
+ Memory::dump_static_mem_to_file("memdump.txt");
+ }
+ */
//transform for the rest
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check
#endif
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F8) {
@@ -477,7 +505,7 @@ void SceneTree::input_event( const InputEvent& p_event ) {
}
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check
#endif
input_handled=true;
@@ -528,7 +556,7 @@ bool SceneTree::iteration(float p_time) {
_notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS);
_flush_ugc();
_flush_transform_notifications();
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds");
root_lock--;
_flush_delete_queue();
@@ -540,9 +568,9 @@ bool SceneTree::iteration(float p_time) {
bool SceneTree::idle(float p_time){
-// print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
-// print_line("node count: "+itos(get_node_count()));
-// print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
+ //print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
+ //print_line("node count: "+itos(get_node_count()));
+ //print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
root_lock++;
@@ -573,7 +601,7 @@ bool SceneTree::idle(float p_time){
_flush_ugc();
_flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds");
root_lock--;
@@ -584,7 +612,10 @@ bool SceneTree::idle(float p_time){
for (List<Ref<SceneTreeTimer> >::Element *E=timers.front();E;) {
List<Ref<SceneTreeTimer> >::Element *N = E->next();
-
+ if (pause && !E->get()->is_pause_mode_process()) {
+ E=N;
+ continue;
+ }
float time_left = E->get()->get_time_left();
time_left-=p_time;
E->get()->set_time_left(time_left);
@@ -667,7 +698,7 @@ void SceneTree::_notification(int p_notification) {
} break;
case NOTIFICATION_WM_UNFOCUS_REQUEST: {
- notify_group(GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST);
+ notify_group_flags(GROUP_CALL_REALTIME|GROUP_CALL_MULTILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST);
} break;
@@ -991,7 +1022,7 @@ uint32_t SceneTree::get_last_event_id() const {
}
-Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
+Variant SceneTree::_call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
r_error.error=Variant::CallError::CALL_OK;
@@ -1011,11 +1042,33 @@ Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::
v[i]=*p_args[i+3];
}
- call_group(flags,group,method,v[0],v[1],v[2],v[3],v[4]);
+ call_group_flags(flags,group,method,v[0],v[1],v[2],v[3],v[4]);
return Variant();
}
+Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
+
+
+ r_error.error=Variant::CallError::CALL_OK;
+
+ ERR_FAIL_COND_V(p_argcount<2,Variant());
+ ERR_FAIL_COND_V(p_args[0]->get_type()!=Variant::STRING,Variant());
+ ERR_FAIL_COND_V(p_args[1]->get_type()!=Variant::STRING,Variant());
+
+ StringName group = *p_args[0];
+ StringName method = *p_args[1];
+ Variant v[VARIANT_ARG_MAX];
+
+ for(int i=0;i<MIN(p_argcount-2,5);i++) {
+
+ v[i]=*p_args[i+2];
+ }
+
+ call_group_flags(0,group,method,v[0],v[1],v[2],v[3],v[4]);
+ return Variant();
+}
+
int64_t SceneTree::get_frame() const {
return current_frame;
@@ -1138,8 +1191,8 @@ void SceneTree::_update_root_rect() {
Size2 viewport_size;
Size2 screen_size;
- float viewport_aspect = desired_res.get_aspect();
- float video_mode_aspect = video_mode.get_aspect();
+ float viewport_aspect = desired_res.aspect();
+ float video_mode_aspect = video_mode.aspect();
if (stretch_aspect==STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect)<CMP_EPSILON) {
//same aspect or ignore aspect
@@ -1198,8 +1251,8 @@ void SceneTree::_update_root_rect() {
VisualServer::get_singleton()->black_bars_set_margins(0,0,0,0);
}
-// print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
-// print_line("SS: "+video_mode);
+ //print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
+ //print_line("SS: "+video_mode);
switch (stretch_mode) {
case STRETCH_MODE_2D: {
@@ -1674,10 +1727,11 @@ void SceneTree::drop_files(const Vector<String>& p_files,int p_from_screen) {
}
-Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec) {
+Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_pause) {
Ref<SceneTreeTimer> stt;
stt.instance();
+ stt->set_pause_mode_process(p_process_pause);
stt->set_time_left(p_delay_sec);
timers.push_back(stt);
return stt;
@@ -1749,6 +1803,10 @@ bool SceneTree::is_network_server() const {
}
+bool SceneTree::has_network_peer() const {
+ return network_peer.is_valid();
+}
+
int SceneTree::get_network_unique_id() const {
ERR_FAIL_COND_V(!network_peer.is_valid(),0);
@@ -2180,77 +2238,91 @@ void SceneTree::_network_poll() {
void SceneTree::_bind_methods() {
- //ClassDB::bind_method(_MD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group);
- ClassDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group);
+ //ClassDB::bind_method(D_METHOD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
- ClassDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group);
+ ClassDB::bind_method(D_METHOD("get_root:Viewport"),&SceneTree::get_root);
+ ClassDB::bind_method(D_METHOD("has_group","name"),&SceneTree::has_group);
- ClassDB::bind_method(_MD("get_root:Viewport"),&SceneTree::get_root);
- ClassDB::bind_method(_MD("has_group","name"),&SceneTree::has_group);
+ ClassDB::bind_method(D_METHOD("set_auto_accept_quit","enabled"),&SceneTree::set_auto_accept_quit);
- ClassDB::bind_method(_MD("set_auto_accept_quit","enabled"),&SceneTree::set_auto_accept_quit);
-
- ClassDB::bind_method(_MD("set_editor_hint","enable"),&SceneTree::set_editor_hint);
- ClassDB::bind_method(_MD("is_editor_hint"),&SceneTree::is_editor_hint);
- ClassDB::bind_method(_MD("set_debug_collisions_hint","enable"),&SceneTree::set_debug_collisions_hint);
- ClassDB::bind_method(_MD("is_debugging_collisions_hint"),&SceneTree::is_debugging_collisions_hint);
- ClassDB::bind_method(_MD("set_debug_navigation_hint","enable"),&SceneTree::set_debug_navigation_hint);
- ClassDB::bind_method(_MD("is_debugging_navigation_hint"),&SceneTree::is_debugging_navigation_hint);
+ ClassDB::bind_method(D_METHOD("set_editor_hint","enable"),&SceneTree::set_editor_hint);
+ ClassDB::bind_method(D_METHOD("is_editor_hint"),&SceneTree::is_editor_hint);
+ ClassDB::bind_method(D_METHOD("set_debug_collisions_hint","enable"),&SceneTree::set_debug_collisions_hint);
+ ClassDB::bind_method(D_METHOD("is_debugging_collisions_hint"),&SceneTree::is_debugging_collisions_hint);
+ ClassDB::bind_method(D_METHOD("set_debug_navigation_hint","enable"),&SceneTree::set_debug_navigation_hint);
+ ClassDB::bind_method(D_METHOD("is_debugging_navigation_hint"),&SceneTree::is_debugging_navigation_hint);
#ifdef TOOLS_ENABLED
- ClassDB::bind_method(_MD("set_edited_scene_root","scene"),&SceneTree::set_edited_scene_root);
- ClassDB::bind_method(_MD("get_edited_scene_root"),&SceneTree::get_edited_scene_root);
+ 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);
#endif
- ClassDB::bind_method(_MD("set_pause","enable"),&SceneTree::set_pause);
- ClassDB::bind_method(_MD("is_paused"),&SceneTree::is_paused);
- ClassDB::bind_method(_MD("set_input_as_handled"),&SceneTree::set_input_as_handled);
+ ClassDB::bind_method(D_METHOD("set_pause","enable"),&SceneTree::set_pause);
+ ClassDB::bind_method(D_METHOD("is_paused"),&SceneTree::is_paused);
+ ClassDB::bind_method(D_METHOD("set_input_as_handled"),&SceneTree::set_input_as_handled);
- ClassDB::bind_method(_MD("create_timer:SceneTreeTimer","time_sec"),&SceneTree::create_timer);
+ ClassDB::bind_method(D_METHOD("create_timer:SceneTreeTimer","time_sec", "pause_mode_process"),&SceneTree::create_timer, DEFVAL(true));
- ClassDB::bind_method(_MD("get_node_count"),&SceneTree::get_node_count);
- ClassDB::bind_method(_MD("get_frame"),&SceneTree::get_frame);
- ClassDB::bind_method(_MD("quit"),&SceneTree::quit);
+ ClassDB::bind_method(D_METHOD("get_node_count"),&SceneTree::get_node_count);
+ ClassDB::bind_method(D_METHOD("get_frame"),&SceneTree::get_frame);
+ ClassDB::bind_method(D_METHOD("quit"),&SceneTree::quit);
- ClassDB::bind_method(_MD("set_screen_stretch","mode","aspect","minsize"),&SceneTree::set_screen_stretch);
+ ClassDB::bind_method(D_METHOD("set_screen_stretch","mode","aspect","minsize"),&SceneTree::set_screen_stretch);
- ClassDB::bind_method(_MD("queue_delete","obj"),&SceneTree::queue_delete);
+ ClassDB::bind_method(D_METHOD("queue_delete","obj"),&SceneTree::queue_delete);
MethodInfo mi;
- mi.name="call_group";
+ mi.name="call_group_flags";
mi.arguments.push_back( PropertyInfo( Variant::INT, "flags"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi);
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group_flags",&SceneTree::_call_group_flags,mi);
+
+ ClassDB::bind_method(D_METHOD("notify_group_flags","call_flags","group","notification"),&SceneTree::notify_group_flags);
+ ClassDB::bind_method(D_METHOD("set_group_flags","call_flags","group","property","value"),&SceneTree::set_group_flags);
+
+ MethodInfo mi2;
+ mi2.name="call_group";
+ mi2.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
+ mi2.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
+
+
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi2);
+
+ ClassDB::bind_method(D_METHOD("notify_group","call_flags","group","notification"),&SceneTree::notify_group);
+ ClassDB::bind_method(D_METHOD("set_group","call_flags","group","property","value"),&SceneTree::set_group);
+
+ ClassDB::bind_method(D_METHOD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group);
+
- ClassDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
- ClassDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene);
+ ClassDB::bind_method(D_METHOD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
+ ClassDB::bind_method(D_METHOD("get_current_scene:Node"),&SceneTree::get_current_scene);
- ClassDB::bind_method(_MD("change_scene","path"),&SceneTree::change_scene);
- ClassDB::bind_method(_MD("change_scene_to","packed_scene:PackedScene"),&SceneTree::change_scene_to);
+ ClassDB::bind_method(D_METHOD("change_scene","path"),&SceneTree::change_scene);
+ ClassDB::bind_method(D_METHOD("change_scene_to","packed_scene:PackedScene"),&SceneTree::change_scene_to);
- ClassDB::bind_method(_MD("reload_current_scene"),&SceneTree::reload_current_scene);
+ ClassDB::bind_method(D_METHOD("reload_current_scene"),&SceneTree::reload_current_scene);
- ClassDB::bind_method(_MD("_change_scene"),&SceneTree::_change_scene);
+ ClassDB::bind_method(D_METHOD("_change_scene"),&SceneTree::_change_scene);
- ClassDB::bind_method(_MD("set_network_peer","peer:NetworkedMultiplayerPeer"),&SceneTree::set_network_peer);
- ClassDB::bind_method(_MD("is_network_server"),&SceneTree::is_network_server);
- ClassDB::bind_method(_MD("get_network_unique_id"),&SceneTree::get_network_unique_id);
- ClassDB::bind_method(_MD("set_refuse_new_network_connections","refuse"),&SceneTree::set_refuse_new_network_connections);
- ClassDB::bind_method(_MD("is_refusing_new_network_connections"),&SceneTree::is_refusing_new_network_connections);
- ClassDB::bind_method(_MD("_network_peer_connected"),&SceneTree::_network_peer_connected);
- ClassDB::bind_method(_MD("_network_peer_disconnected"),&SceneTree::_network_peer_disconnected);
- ClassDB::bind_method(_MD("_connected_to_server"),&SceneTree::_connected_to_server);
- ClassDB::bind_method(_MD("_connection_failed"),&SceneTree::_connection_failed);
- ClassDB::bind_method(_MD("_server_disconnected"),&SceneTree::_server_disconnected);
+ 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_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);
+ ClassDB::bind_method(D_METHOD("_network_peer_connected"),&SceneTree::_network_peer_connected);
+ ClassDB::bind_method(D_METHOD("_network_peer_disconnected"),&SceneTree::_network_peer_disconnected);
+ ClassDB::bind_method(D_METHOD("_connected_to_server"),&SceneTree::_connected_to_server);
+ ClassDB::bind_method(D_METHOD("_connection_failed"),&SceneTree::_connection_failed);
+ ClassDB::bind_method(D_METHOD("_server_disconnected"),&SceneTree::_server_disconnected);
ADD_SIGNAL( MethodInfo("tree_changed") );
ADD_SIGNAL( MethodInfo("node_removed",PropertyInfo( Variant::OBJECT, "node") ) );
diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h
index 9de4abe81e..7f69f5eef7 100644
--- a/scene/main/scene_main_loop.h
+++ b/scene/main/scene_main_loop.h
@@ -56,6 +56,7 @@ class SceneTreeTimer : public Reference {
GDCLASS(SceneTreeTimer,Reference);
float time_left;
+ bool process_pause;
protected:
static void _bind_methods();
public:
@@ -63,6 +64,9 @@ public:
void set_time_left(float p_time);
float get_time_left() const;
+ void set_pause_mode_process(bool p_pause_mode_process);
+ bool is_pause_mode_process();
+
SceneTreeTimer();
};
@@ -242,9 +246,11 @@ friend class Node;
void _notify_group_pause(const StringName& p_group,int p_notification);
void _call_input_pause(const StringName& p_group,const StringName& p_method,const InputEvent& p_input);
+ Variant _call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
+
static void _debugger_request_tree(void *self);
void _flush_delete_queue();
//optimization
@@ -332,17 +338,20 @@ public:
GROUP_CALL_REVERSE=1,
GROUP_CALL_REALTIME=2,
GROUP_CALL_UNIQUE=4,
- GROUP_CALL_MULIILEVEL=8,
+ GROUP_CALL_MULTILEVEL=8,
};
_FORCE_INLINE_ Viewport *get_root() const { return root; }
uint32_t get_last_event_id() const;
- void call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
- void notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification);
- void set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value);
+ void call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
+ void notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification);
+ void set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value);
+ void call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
+ void notify_group(const StringName& p_group,int p_notification);
+ void set_group(const StringName& p_group,const String& p_name,const Variant& p_value);
virtual void input_text( const String& p_text );
virtual void input_event( const InputEvent& p_event );
@@ -425,7 +434,7 @@ public:
Error change_scene_to(const Ref<PackedScene>& p_scene);
Error reload_current_scene();
- Ref<SceneTreeTimer> create_timer(float p_delay_sec);
+ Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_pause=true);
//used by Main::start, don't use otherwise
void add_current_scene(Node * p_current);
@@ -438,6 +447,7 @@ public:
void set_network_peer(const Ref<NetworkedMultiplayerPeer>& p_network_peer);
bool is_network_server() const;
+ bool has_network_peer() const;
int get_network_unique_id() const;
void set_refuse_new_network_connections(bool p_refuse);
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 7852e2b46b..d27b53d48b 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -179,32 +179,32 @@ void Timer::_set_process(bool p_process, bool p_force)
void Timer::_bind_methods() {
- ClassDB::bind_method(_MD("set_wait_time","time_sec"),&Timer::set_wait_time);
- ClassDB::bind_method(_MD("get_wait_time"),&Timer::get_wait_time);
+ ClassDB::bind_method(D_METHOD("set_wait_time","time_sec"),&Timer::set_wait_time);
+ ClassDB::bind_method(D_METHOD("get_wait_time"),&Timer::get_wait_time);
- ClassDB::bind_method(_MD("set_one_shot","enable"),&Timer::set_one_shot);
- ClassDB::bind_method(_MD("is_one_shot"),&Timer::is_one_shot);
+ ClassDB::bind_method(D_METHOD("set_one_shot","enable"),&Timer::set_one_shot);
+ ClassDB::bind_method(D_METHOD("is_one_shot"),&Timer::is_one_shot);
- ClassDB::bind_method(_MD("set_autostart","enable"),&Timer::set_autostart);
- ClassDB::bind_method(_MD("has_autostart"),&Timer::has_autostart);
+ ClassDB::bind_method(D_METHOD("set_autostart","enable"),&Timer::set_autostart);
+ ClassDB::bind_method(D_METHOD("has_autostart"),&Timer::has_autostart);
- ClassDB::bind_method(_MD("start"),&Timer::start);
- ClassDB::bind_method(_MD("stop"),&Timer::stop);
+ ClassDB::bind_method(D_METHOD("start"),&Timer::start);
+ ClassDB::bind_method(D_METHOD("stop"),&Timer::stop);
- ClassDB::bind_method(_MD("set_active", "active"), &Timer::set_active);
- ClassDB::bind_method(_MD("is_active"), &Timer::is_active);
+ ClassDB::bind_method(D_METHOD("set_active", "active"), &Timer::set_active);
+ ClassDB::bind_method(D_METHOD("is_active"), &Timer::is_active);
- ClassDB::bind_method(_MD("get_time_left"),&Timer::get_time_left);
+ ClassDB::bind_method(D_METHOD("get_time_left"),&Timer::get_time_left);
- ClassDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode);
- ClassDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode);
+ ClassDB::bind_method(D_METHOD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode);
+ ClassDB::bind_method(D_METHOD("get_timer_process_mode"), &Timer::get_timer_process_mode);
ADD_SIGNAL( MethodInfo("timeout") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_timer_process_mode"), _SCS("get_timer_process_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01" ), _SCS("set_wait_time"), _SCS("get_wait_time") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "one_shot" ), _SCS("set_one_shot"), _SCS("is_one_shot") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autostart" ), _SCS("set_autostart"), _SCS("has_autostart") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_timer_process_mode", "get_timer_process_mode") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01" ), "set_wait_time", "get_wait_time") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "one_shot" ), "set_one_shot", "is_one_shot") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autostart" ), "set_autostart", "has_autostart") ;
BIND_CONSTANT( TIMER_PROCESS_FIXED );
BIND_CONSTANT( TIMER_PROCESS_IDLE );
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index fe363d97f7..ef39dcde4b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -33,8 +33,7 @@
#include "servers/physics_2d_server.h"
//#include "scene/3d/camera.h"
-#include "servers/spatial_sound_server.h"
-#include "servers/spatial_sound_2d_server.h"
+
#include "scene/gui/control.h"
#include "scene/3d/camera.h"
#include "scene/3d/listener.h"
@@ -49,7 +48,7 @@
#include "scene/main/timer.h"
#include "scene/scene_string_names.h"
-#include "globals.h"
+#include "global_config.h"
void ViewportTexture::setup_local_to_scene() {
@@ -140,10 +139,10 @@ uint32_t ViewportTexture::get_flags() const{
void ViewportTexture::_bind_methods() {
- ClassDB::bind_method(_MD("set_viewport_path_in_scene","path"),&ViewportTexture::set_viewport_path_in_scene);
- ClassDB::bind_method(_MD("get_viewport_path_in_scene"),&ViewportTexture::get_viewport_path_in_scene);
+ ClassDB::bind_method(D_METHOD("set_viewport_path_in_scene","path"),&ViewportTexture::set_viewport_path_in_scene);
+ ClassDB::bind_method(D_METHOD("get_viewport_path_in_scene"),&ViewportTexture::get_viewport_path_in_scene);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"viewport_path"),_SCS("set_viewport_path_in_scene"),_SCS("get_viewport_path_in_scene"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"viewport_path"),"set_viewport_path_in_scene","get_viewport_path_in_scene");
}
@@ -272,7 +271,7 @@ void Viewport::_parent_visibility_changed() {
if (parent_control) {
Control *c = parent_control;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible());
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible_in_tree());
_update_listener();
_update_listener_2d();
@@ -293,12 +292,12 @@ void Viewport::_vp_enter_tree() {
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent_ci);
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
-// VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
+ //VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
parent_control->connect("resized",this,"_parent_resized");
parent_control->connect("visibility_changed",this,"_parent_visibility_changed");
} else if (!parent){
-// VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
+ //VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
}
*/
@@ -389,7 +388,7 @@ void Viewport::_notification(int p_what) {
if (get_parent()) {
parent = get_parent()->get_viewport();
- VisualServer::get_singleton()->viewport_set_parent_viewport(viewport,parent->get_viewport());
+ VisualServer::get_singleton()->viewport_set_parent_viewport(viewport,parent->get_viewport_rid());
} else {
parent=NULL;
}
@@ -462,11 +461,13 @@ void Viewport::_notification(int p_what) {
if (world_2d.is_valid())
world_2d->_remove_viewport(this);
- //if (!render_target)
- // _vp_exit_tree();
+ /*
+ if (!render_target)
+ _vp_exit_tree();
+ */
VisualServer::get_singleton()->viewport_set_scenario(viewport,RID());
- SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
+// SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
if (contact_2d_debug.is_valid()) {
VisualServer::get_singleton()->free(contact_2d_debug);
@@ -734,7 +735,7 @@ void Viewport::_notification(int p_what) {
}
}
-RID Viewport::get_viewport() const {
+RID Viewport::get_viewport_rid() const {
return viewport;
}
@@ -781,23 +782,24 @@ Size2 Viewport::get_size() const {
void Viewport::_update_listener() {
-
- if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
+/*
+ if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree()))) {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space());
} else {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
}
-
+*/
}
void Viewport::_update_listener_2d() {
- if (is_inside_tree() && audio_listener && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible())))
+ /*
+ if (is_inside_tree() && audio_listener && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible_in_tree())))
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space());
else
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, RID());
-
+*/
}
@@ -840,12 +842,12 @@ void Viewport::set_canvas_transform(const Transform2D& p_transform) {
Transform2D xform = (global_canvas_transform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
+ /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
-
+*/
}
@@ -865,12 +867,12 @@ void Viewport::_update_global_transform() {
Transform2D xform = (sxform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
+ /*SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Transform2D(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
-
+*/
}
@@ -891,8 +893,8 @@ Transform2D Viewport::get_global_canvas_transform() const{
void Viewport::_listener_transform_changed_notify() {
#ifndef _3D_DISABLED
- if (listener)
- SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform());
+ //if (listener)
+// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform());
#endif
}
@@ -955,8 +957,8 @@ void Viewport::_camera_transform_changed_notify() {
#ifndef _3D_DISABLED
// If there is an active listener in the scene, it takes priority over the camera
- if (camera && !listener)
- SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform());
+// if (camera && !listener)
+// SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform());
#endif
}
@@ -1309,7 +1311,7 @@ void Viewport::queue_screen_capture(){
}
Image Viewport::get_screen_capture() const {
-// return VS::get_singleton()->viewport_get_screen_capture(viewport);
+ //return VS::get_singleton()->viewport_get_screen_capture(viewport);
return Image();
}
@@ -1379,7 +1381,7 @@ Viewport::ShadowAtlasQuadrantSubdiv Viewport::get_shadow_atlas_quadrant_subdiv(i
void Viewport::clear() {
//clear=true;
-// VisualServer::get_singleton()->viewport_clear(viewport);
+ //VisualServer::get_singleton()->viewport_clear(viewport);
}
@@ -1399,9 +1401,11 @@ Transform2D Viewport::_get_input_pre_xform() const {
Vector2 Viewport::_get_window_offset() const {
-// if (parent_control) {
-// return (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin();
-// }
+ /*
+ if (parent_control) {
+ return (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin();
+ }
+ */
return Vector2();
}
@@ -1521,8 +1525,10 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
}
#endif
-// if (parent_control && !parent_control->is_visible())
-// return;
+ /*
+ if (parent_control && !parent_control->is_visible_in_tree())
+ return;
+ */
if (to_screen_rect==Rect2())
return; //if render target, can't get input events
@@ -1647,7 +1653,7 @@ void Viewport::_gui_show_tooltip() {
void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
-// _block();
+ //_block();
InputEvent ev = p_input;
@@ -1696,7 +1702,7 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
for (List<Control*>::Element *E=gui.subwindows.back();E;E=E->prev()) {
Control *sw = E->get();
- if (!sw->is_visible())
+ if (!sw->is_visible_in_tree())
continue;
Transform2D xform;
@@ -1716,7 +1722,7 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
for (List<Control*>::Element *E=gui.roots.back();E;E=E->prev()) {
Control *sw = E->get();
- if (!sw->is_visible())
+ if (!sw->is_visible_in_tree())
continue;
Transform2D xform;
@@ -1745,12 +1751,12 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
Control *c=p_node->cast_to<Control>();
if (c) {
- // print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
+ //print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
}
//subwindows first!!
- if (p_node->is_hidden()) {
+ if (!p_node->is_visible()) {
//return _find_next_visible_control_at_pos(p_node,p_global,r_inv_xform);
return NULL; //canvas item hidden, discard
}
@@ -1771,7 +1777,7 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
if (!ci || ci->is_set_as_toplevel())
continue;
- Control *ret=_gui_find_control_at_pos(ci,p_global,matrix,r_inv_xform);;
+ Control *ret=_gui_find_control_at_pos(ci,p_global,matrix,r_inv_xform);
if (ret)
return ret;
}
@@ -1790,6 +1796,42 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
return NULL;
}
+bool Viewport::_gui_drop(Control *p_at_control,Point2 p_at_pos,bool p_just_check) {
+
+
+ { //attempt grab, try parent controls too
+ CanvasItem *ci=p_at_control;
+ while(ci) {
+
+ Control *control = ci->cast_to<Control>();
+ if (control) {
+
+
+ if (control->can_drop_data(p_at_pos,gui.drag_data)) {
+ if (!p_just_check) {
+ control->drop_data(p_at_pos,gui.drag_data);
+ }
+
+ return true;
+ }
+
+ if (control->data.mouse_filter==Control::MOUSE_FILTER_STOP)
+ break;
+ }
+
+ p_at_pos = ci->get_transform().xform(p_at_pos);
+
+ if (ci->is_set_as_toplevel())
+ break;
+
+ ci=ci->get_parent_item();
+ }
+ }
+
+ return false;
+}
+
+
void Viewport::_gui_input_event(InputEvent p_event) {
@@ -1798,9 +1840,11 @@ void Viewport::_gui_input_event(InputEvent p_event) {
return;
}
//?
-// if (!is_visible()) {
-// return; //simple and plain
-// }
+ /*
+ if (!is_visible()) {
+ return; //simple and plain
+ }
+ */
switch(p_event.type) {
@@ -1830,7 +1874,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Vector2 pos = top->get_global_transform_with_canvas().affine_inverse().xform(mpos);
if (!top->has_point(pos)) {
- if (top->data.modal_exclusive || top->data.modal_frame==OS::get_singleton()->get_frames_drawn()) {
+ if (top->data.modal_exclusive || top->data.modal_frame==Engine::get_singleton()->get_frames_drawn()) {
//cancel event, sorry, modal exclusive EATS UP ALL
//alternative, you can't pop out a window the same frame it was made modal (fixes many issues)
get_tree()->set_input_as_handled();
@@ -1849,10 +1893,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
//Matrix32 parent_xform;
- //if (data.parent_canvas_item)
- // parent_xform=data.parent_canvas_item->get_global_transform();
-
-
+ /*
+ if (data.parent_canvas_item)
+ parent_xform=data.parent_canvas_item->get_global_transform();
+ */
gui.mouse_focus = _gui_find_control(pos);
//print_line("has mf "+itos(gui.mouse_focus!=NULL));
@@ -1893,9 +1937,28 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}*/
#endif
- if (gui.mouse_focus->get_focus_mode()!=Control::FOCUS_NONE && gui.mouse_focus!=gui.key_focus && p_event.mouse_button.button_index==BUTTON_LEFT) {
- // also get keyboard focus
- gui.mouse_focus->grab_focus();
+ if (p_event.mouse_button.button_index==BUTTON_LEFT) { //assign focus
+ CanvasItem *ci=gui.mouse_focus;
+ while(ci) {
+
+ Control *control = ci->cast_to<Control>();
+ if (control) {
+ if (control->get_focus_mode()!=Control::FOCUS_NONE) {
+ if (control!=gui.key_focus) {
+ control->grab_focus();
+ }
+ break;
+ }
+
+ if (control->data.mouse_filter==Control::MOUSE_FILTER_STOP)
+ break;
+ }
+
+ if (ci->is_set_as_toplevel())
+ break;
+
+ ci=ci->get_parent_item();
+ }
}
@@ -1903,15 +1966,15 @@ void Viewport::_gui_input_event(InputEvent p_event) {
_gui_call_input(gui.mouse_focus,p_event);
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
//alternate drop use (when using force_drag(), as proposed by #5342
- if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos,gui.drag_data)) {
- gui.mouse_focus->drop_data(pos,gui.drag_data);
+ if (gui.mouse_focus) {
+ _gui_drop(gui.mouse_focus,pos,false);
}
gui.drag_data=Variant();
@@ -1938,9 +2001,9 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (gui.mouse_over) {
Size2 pos = mpos;
pos = gui.focus_inv_xform.xform(pos);
- if (gui.mouse_over->can_drop_data(pos,gui.drag_data)) {
- gui.mouse_over->drop_data(pos,gui.drag_data);
- }
+
+ _gui_drop(gui.mouse_over,pos,false);
+
}
if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
@@ -1980,7 +2043,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}*/
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
}
@@ -1998,14 +2061,36 @@ void Viewport::_gui_input_event(InputEvent p_event) {
// D&D
if (!gui.drag_attempted && gui.mouse_focus && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
- gui.drag_accum+=Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y);;
+ gui.drag_accum+=Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y);
float len = gui.drag_accum.length();
if (len>10) {
- gui.drag_data=gui.mouse_focus->get_drag_data(gui.focus_inv_xform.xform(mpos)-gui.drag_accum);
- if (gui.drag_data.get_type()!=Variant::NIL) {
- gui.mouse_focus=NULL;
+ { //attempt grab, try parent controls too
+ CanvasItem *ci=gui.mouse_focus;
+ while(ci) {
+
+ Control *control = ci->cast_to<Control>();
+ if (control) {
+
+ gui.drag_data=control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos)-gui.drag_accum);
+ if (gui.drag_data.get_type()!=Variant::NIL) {
+
+ gui.mouse_focus=NULL;
+ }
+
+ if (control->data.mouse_filter==Control::MOUSE_FILTER_STOP)
+ break;
+ }
+
+ if (ci->is_set_as_toplevel())
+ break;
+
+ ci=ci->get_parent_item();
+ }
}
+
+
+
gui.drag_attempted=true;
if (gui.drag_data.get_type()!=Variant::NIL) {
@@ -2132,7 +2217,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
- bool can_drop = over->can_drop_data(pos,gui.drag_data);
+ bool can_drop = _gui_drop(over,pos,true);
if (!can_drop) {
OS::get_singleton()->set_cursor_shape( OS::CURSOR_FORBIDDEN );
@@ -2150,7 +2235,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
case InputEvent::KEY: {
- if (gui.key_focus && !gui.key_focus->is_visible()) {
+ if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
gui.key_focus->release_focus();
}
@@ -2282,7 +2367,7 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
if (!pfoc)
return;
- if (!pfoc->is_inside_tree() || !pfoc->is_visible())
+ if (!pfoc->is_inside_tree() || !pfoc->is_visible_in_tree())
return;
pfoc->grab_focus();
} else {
@@ -2419,7 +2504,7 @@ void Viewport::_gui_control_grab_focus(Control* p_control) {
if (gui.key_focus && gui.key_focus==p_control)
return;
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus");
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus");
gui.key_focus=p_control;
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
p_control->update();
@@ -2689,128 +2774,128 @@ bool Viewport::get_hdr() const{
void Viewport::_bind_methods() {
- ClassDB::bind_method(_MD("set_size","size"), &Viewport::set_size);
- ClassDB::bind_method(_MD("get_size"), &Viewport::get_size);
- ClassDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
- ClassDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
- ClassDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
- ClassDB::bind_method(_MD("set_world","world:World"), &Viewport::set_world);
- ClassDB::bind_method(_MD("get_world:World"), &Viewport::get_world);
- ClassDB::bind_method(_MD("find_world:World"), &Viewport::find_world);
+ 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);
+ ClassDB::bind_method(D_METHOD("get_world_2d:World2D"), &Viewport::get_world_2d);
+ ClassDB::bind_method(D_METHOD("find_world_2d:World2D"), &Viewport::find_world_2d);
+ ClassDB::bind_method(D_METHOD("set_world","world:World"), &Viewport::set_world);
+ ClassDB::bind_method(D_METHOD("get_world:World"), &Viewport::get_world);
+ ClassDB::bind_method(D_METHOD("find_world:World"), &Viewport::find_world);
- ClassDB::bind_method(_MD("set_canvas_transform","xform"), &Viewport::set_canvas_transform);
- ClassDB::bind_method(_MD("get_canvas_transform"), &Viewport::get_canvas_transform);
+ ClassDB::bind_method(D_METHOD("set_canvas_transform","xform"), &Viewport::set_canvas_transform);
+ ClassDB::bind_method(D_METHOD("get_canvas_transform"), &Viewport::get_canvas_transform);
- ClassDB::bind_method(_MD("set_global_canvas_transform","xform"), &Viewport::set_global_canvas_transform);
- ClassDB::bind_method(_MD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform);
- ClassDB::bind_method(_MD("get_final_transform"), &Viewport::get_final_transform);
+ ClassDB::bind_method(D_METHOD("set_global_canvas_transform","xform"), &Viewport::set_global_canvas_transform);
+ ClassDB::bind_method(D_METHOD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform);
+ ClassDB::bind_method(D_METHOD("get_final_transform"), &Viewport::get_final_transform);
- ClassDB::bind_method(_MD("get_visible_rect"), &Viewport::get_visible_rect);
- ClassDB::bind_method(_MD("set_transparent_background","enable"), &Viewport::set_transparent_background);
- ClassDB::bind_method(_MD("has_transparent_background"), &Viewport::has_transparent_background);
+ ClassDB::bind_method(D_METHOD("get_visible_rect"), &Viewport::get_visible_rect);
+ ClassDB::bind_method(D_METHOD("set_transparent_background","enable"), &Viewport::set_transparent_background);
+ ClassDB::bind_method(D_METHOD("has_transparent_background"), &Viewport::has_transparent_background);
- ClassDB::bind_method(_MD("_parent_visibility_changed"), &Viewport::_parent_visibility_changed);
+ ClassDB::bind_method(D_METHOD("_parent_visibility_changed"), &Viewport::_parent_visibility_changed);
- ClassDB::bind_method(_MD("_parent_resized"), &Viewport::_parent_resized);
- ClassDB::bind_method(_MD("_vp_input"), &Viewport::_vp_input);
- ClassDB::bind_method(_MD("_vp_input_text","text"), &Viewport::_vp_input_text);
- ClassDB::bind_method(_MD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
+ ClassDB::bind_method(D_METHOD("_parent_resized"), &Viewport::_parent_resized);
+ ClassDB::bind_method(D_METHOD("_vp_input"), &Viewport::_vp_input);
+ ClassDB::bind_method(D_METHOD("_vp_input_text","text"), &Viewport::_vp_input_text);
+ ClassDB::bind_method(D_METHOD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
- ClassDB::bind_method(_MD("set_size_override","enable","size","margin"), &Viewport::set_size_override,DEFVAL(Size2(-1,-1)),DEFVAL(Size2(0,0)));
- ClassDB::bind_method(_MD("get_size_override"), &Viewport::get_size_override);
- ClassDB::bind_method(_MD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
- ClassDB::bind_method(_MD("set_size_override_stretch","enabled"), &Viewport::set_size_override_stretch);
- ClassDB::bind_method(_MD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
- ClassDB::bind_method(_MD("queue_screen_capture"), &Viewport::queue_screen_capture);
- ClassDB::bind_method(_MD("get_screen_capture"), &Viewport::get_screen_capture);
+ ClassDB::bind_method(D_METHOD("set_size_override","enable","size","margin"), &Viewport::set_size_override,DEFVAL(Size2(-1,-1)),DEFVAL(Size2(0,0)));
+ ClassDB::bind_method(D_METHOD("get_size_override"), &Viewport::get_size_override);
+ ClassDB::bind_method(D_METHOD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
+ ClassDB::bind_method(D_METHOD("set_size_override_stretch","enabled"), &Viewport::set_size_override_stretch);
+ ClassDB::bind_method(D_METHOD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
+ ClassDB::bind_method(D_METHOD("queue_screen_capture"), &Viewport::queue_screen_capture);
+ ClassDB::bind_method(D_METHOD("get_screen_capture"), &Viewport::get_screen_capture);
- ClassDB::bind_method(_MD("set_vflip","enable"), &Viewport::set_vflip);
- ClassDB::bind_method(_MD("get_vflip"), &Viewport::get_vflip);
+ ClassDB::bind_method(D_METHOD("set_vflip","enable"), &Viewport::set_vflip);
+ ClassDB::bind_method(D_METHOD("get_vflip"), &Viewport::get_vflip);
- ClassDB::bind_method(_MD("set_clear_on_new_frame","enable"), &Viewport::set_clear_on_new_frame);
- ClassDB::bind_method(_MD("get_clear_on_new_frame"), &Viewport::get_clear_on_new_frame);
+ ClassDB::bind_method(D_METHOD("set_clear_on_new_frame","enable"), &Viewport::set_clear_on_new_frame);
+ ClassDB::bind_method(D_METHOD("get_clear_on_new_frame"), &Viewport::get_clear_on_new_frame);
- ClassDB::bind_method(_MD("clear"), &Viewport::clear);
- ClassDB::bind_method(_MD("set_update_mode","mode"), &Viewport::set_update_mode);
- ClassDB::bind_method(_MD("get_update_mode"), &Viewport::get_update_mode);
+ ClassDB::bind_method(D_METHOD("clear"), &Viewport::clear);
+ ClassDB::bind_method(D_METHOD("set_update_mode","mode"), &Viewport::set_update_mode);
+ ClassDB::bind_method(D_METHOD("get_update_mode"), &Viewport::get_update_mode);
- ClassDB::bind_method(_MD("set_msaa","msaa"), &Viewport::set_msaa);
- ClassDB::bind_method(_MD("get_msaa"), &Viewport::get_msaa);
+ ClassDB::bind_method(D_METHOD("set_msaa","msaa"), &Viewport::set_msaa);
+ ClassDB::bind_method(D_METHOD("get_msaa"), &Viewport::get_msaa);
- ClassDB::bind_method(_MD("set_hdr","enable"), &Viewport::set_hdr);
- ClassDB::bind_method(_MD("get_hdr"), &Viewport::get_hdr);
+ ClassDB::bind_method(D_METHOD("set_hdr","enable"), &Viewport::set_hdr);
+ ClassDB::bind_method(D_METHOD("get_hdr"), &Viewport::get_hdr);
- ClassDB::bind_method(_MD("get_texture:ViewportTexture"), &Viewport::get_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:ViewportTexture"), &Viewport::get_texture);
- ClassDB::bind_method(_MD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
- ClassDB::bind_method(_MD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
+ ClassDB::bind_method(D_METHOD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
+ ClassDB::bind_method(D_METHOD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
- ClassDB::bind_method(_MD("get_viewport"), &Viewport::get_viewport);
- ClassDB::bind_method(_MD("input","local_event"), &Viewport::input);
- ClassDB::bind_method(_MD("unhandled_input","local_event"), &Viewport::unhandled_input);
+ 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(_MD("update_worlds"), &Viewport::update_worlds);
+ ClassDB::bind_method(D_METHOD("update_worlds"), &Viewport::update_worlds);
- ClassDB::bind_method(_MD("set_use_own_world","enable"), &Viewport::set_use_own_world);
- ClassDB::bind_method(_MD("is_using_own_world"), &Viewport::is_using_own_world);
+ ClassDB::bind_method(D_METHOD("set_use_own_world","enable"), &Viewport::set_use_own_world);
+ ClassDB::bind_method(D_METHOD("is_using_own_world"), &Viewport::is_using_own_world);
- ClassDB::bind_method(_MD("get_camera:Camera"), &Viewport::get_camera);
+ ClassDB::bind_method(D_METHOD("get_camera:Camera"), &Viewport::get_camera);
- ClassDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener);
- ClassDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener);
+ ClassDB::bind_method(D_METHOD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener);
+ ClassDB::bind_method(D_METHOD("is_audio_listener","enable"), &Viewport::is_audio_listener);
- ClassDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
- ClassDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
- ClassDB::bind_method(_MD("set_attach_to_screen_rect","rect"), &Viewport::set_attach_to_screen_rect);
+ ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
+ ClassDB::bind_method(D_METHOD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
+ ClassDB::bind_method(D_METHOD("set_attach_to_screen_rect","rect"), &Viewport::set_attach_to_screen_rect);
- ClassDB::bind_method(_MD("get_mouse_pos"), &Viewport::get_mouse_pos);
- ClassDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
+ ClassDB::bind_method(D_METHOD("get_mouse_pos"), &Viewport::get_mouse_pos);
+ ClassDB::bind_method(D_METHOD("warp_mouse","to_pos"), &Viewport::warp_mouse);
- ClassDB::bind_method(_MD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
- ClassDB::bind_method(_MD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
+ ClassDB::bind_method(D_METHOD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
+ ClassDB::bind_method(D_METHOD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
- ClassDB::bind_method(_MD("set_disable_input","disable"), &Viewport::set_disable_input);
- ClassDB::bind_method(_MD("is_input_disabled"), &Viewport::is_input_disabled);
+ ClassDB::bind_method(D_METHOD("set_disable_input","disable"), &Viewport::set_disable_input);
+ ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
- ClassDB::bind_method(_MD("set_disable_3d","disable"), &Viewport::set_disable_3d);
- ClassDB::bind_method(_MD("is_3d_disabled"), &Viewport::is_3d_disabled);
+ ClassDB::bind_method(D_METHOD("set_disable_3d","disable"), &Viewport::set_disable_3d);
+ ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled);
- ClassDB::bind_method(_MD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
- ClassDB::bind_method(_MD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
+ ClassDB::bind_method(D_METHOD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
+ ClassDB::bind_method(D_METHOD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
- ClassDB::bind_method(_MD("set_shadow_atlas_size","size"), &Viewport::set_shadow_atlas_size);
- ClassDB::bind_method(_MD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size);
+ ClassDB::bind_method(D_METHOD("set_shadow_atlas_size","size"), &Viewport::set_shadow_atlas_size);
+ ClassDB::bind_method(D_METHOD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size);
- ClassDB::bind_method(_MD("set_shadow_atlas_quadrant_subdiv","quadrant","subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv);
- ClassDB::bind_method(_MD("get_shadow_atlas_quadrant_subdiv","quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv);
+ 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::RECT2,"size"), _SCS("set_size"), _SCS("get_size") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world",PROPERTY_HINT_RESOURCE_TYPE,"World"), _SCS("set_world"), _SCS("get_world") );
-// ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") );
+ 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") ;
+ //ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), "set_world_2d", "get_world_2d") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), "set_transparent_background", "has_transparent_background") ;
ADD_GROUP("Rendering","");
- ADD_PROPERTY( PropertyInfo(Variant::INT,"msaa",PROPERTY_HINT_ENUM,"Disabled,2x,4x,8x,16x"), _SCS("set_msaa"), _SCS("get_msaa") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"hdr"), _SCS("set_hdr"), _SCS("get_hdr") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"disable_3d"), _SCS("set_disable_3d"), _SCS("is_3d_disabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"msaa",PROPERTY_HINT_ENUM,"Disabled,2x,4x,8x,16x"), "set_msaa", "get_msaa") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"hdr"), "set_hdr", "get_hdr") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"disable_3d"), "set_disable_3d", "is_3d_disabled") ;
ADD_GROUP("Render Target","render_target_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_v_flip"), _SCS("set_vflip"), _SCS("get_vflip") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_clear_on_new_frame"), _SCS("set_clear_on_new_frame"), _SCS("get_clear_on_new_frame") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target_update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_update_mode"), _SCS("get_update_mode") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_v_flip"), "set_vflip", "get_vflip") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target_clear_on_new_frame"), "set_clear_on_new_frame", "get_clear_on_new_frame") ;
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target_update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode") ;
ADD_GROUP("Audio Listener","audio_listener_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_2d"), "set_as_audio_listener_2d", "is_audio_listener_2d") ;
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener_enable_3d"), "set_as_audio_listener", "is_audio_listener") ;
ADD_GROUP("Physics","physics_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics_object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics_object_picking"), "set_physics_object_picking", "get_physics_object_picking") ;
ADD_GROUP("GUI","gui_");
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gui_disable_input"), _SCS("set_disable_input"), _SCS("is_input_disabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gui_disable_input"), "set_disable_input", "is_input_disabled") ;
ADD_GROUP("Shadow Atlas","shadow_atlas_");
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_atlas_size"), _SCS("set_shadow_atlas_size"), _SCS("get_shadow_atlas_size") );
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_0",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),0 );
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_1",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),1 );
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_2",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),2 );
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_3",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), _SCS("set_shadow_atlas_quadrant_subdiv"), _SCS("get_shadow_atlas_quadrant_subdiv"),3 );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size") ;
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_0",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv",0 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_1",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv",1 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_2",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv",2 );
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"shadow_atlas_quad_3",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv",3 );
ADD_SIGNAL(MethodInfo("size_changed"));
@@ -2853,9 +2938,9 @@ Viewport::Viewport() {
default_texture->vp=const_cast<Viewport*>(this);
viewport_textures.insert(default_texture.ptr());
- internal_listener = SpatialSoundServer::get_singleton()->listener_create();
+ //internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener=false;
- internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
+ //internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
audio_listener_2d=false;
transparent_bg=false;
parent=NULL;
@@ -2922,8 +3007,8 @@ Viewport::~Viewport() {
E->get()->vp=NULL;
}
VisualServer::get_singleton()->free( viewport );
- SpatialSoundServer::get_singleton()->free(internal_listener);
- SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
+ //SpatialSoundServer::get_singleton()->free(internal_listener);
+ //SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 1f30044cef..59e34d5c62 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -306,6 +306,8 @@ friend class Control;
Vector2 _get_window_offset() const;
+ bool _gui_drop(Control *p_at_control,Point2 p_at_pos,bool p_just_check);
+
friend class Listener;
void _listener_transform_changed_notify();
void _listener_set(Listener* p_listener);
@@ -340,7 +342,7 @@ public:
Size2 get_size() const;
Rect2 get_visible_rect() const;
- RID get_viewport() const;
+ RID get_viewport_rid() const;
void set_world(const Ref<World>& p_world);
void set_world_2d(const Ref<World2D>& p_world_2d);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 2b7c95306f..ffdc85301a 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -28,13 +28,13 @@
/*************************************************************************/
#include "register_scene_types.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"
//#include "scene/io/scene_format_script.h"
#include "resources/default_theme/default_theme.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "scene/main/canvas_layer.h"
#include "scene/main/instance_placeholder.h"
#include "scene/main/viewport.h"
@@ -54,9 +54,9 @@
#include "scene/gui/spin_box.h"
#include "scene/gui/option_button.h"
#include "scene/gui/color_picker.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/color_rect.h"
-#include "scene/gui/patch_9_frame.h"
+#include "scene/gui/patch_9_rect.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@@ -81,10 +81,11 @@
#include "scene/gui/grid_container.h"
#include "scene/gui/split_container.h"
#include "scene/gui/video_player.h"
-#include "scene/gui/reference_frame.h"
+#include "scene/gui/reference_rect.h"
#include "scene/gui/graph_node.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/tool_button.h"
+#include "scene/resources/audio_stream_sample.h"
#include "scene/resources/video_stream.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
@@ -109,8 +110,8 @@
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
-#include "scene/2d/sound_player_2d.h"
-#include "scene/2d/sample_player_2d.h"
+//#include "scene/2d/sound_player_2d.h"
+//#include "scene/2d/sample_player_2d.h"
#include "scene/2d/screen_button.h"
#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/y_sort.h"
@@ -120,6 +121,8 @@
#include "scene/2d/position_2d.h"
#include "scene/2d/tile_map.h"
//#include "scene/2d/tile_map.h"
+#include "scene/2d/line_2d.h"
+
#include "scene/resources/tile_set.h"
#include "scene/animation/animation_player.h"
@@ -139,9 +142,9 @@
#include "scene/main/timer.h"
-#include "scene/audio/stream_player.h"
-#include "scene/audio/event_player.h"
-#include "scene/audio/sound_room_params.h"
+#include "scene/audio/audio_player.h"
+//#include "scene/audio/event_player.h"
+//#include "scene/audio/sound_room_params.h"
#include "scene/resources/sphere_shape.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/box_shape.h"
@@ -163,8 +166,8 @@
#include "scene/resources/polygon_path_finder.h"
-#include "scene/resources/sample.h"
-#include "scene/audio/sample_player.h"
+//#include "scene/resources/sample.h"
+//#include "scene/audio/sample_player.h"
#include "scene/resources/texture.h"
#include "scene/resources/sky_box.h"
#include "scene/resources/material.h"
@@ -176,8 +179,8 @@
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "scene/resources/sample_library.h"
-#include "scene/resources/audio_stream.h"
+//#include "scene/resources/sample_library.h"
+//#include "scene/resources/audio_stream.h"
#include "scene/resources/gibberish_stream.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/color_ramp.h"
@@ -220,8 +223,8 @@
#include "scene/3d/ray_cast.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/sprite_3d.h"
-#include "scene/3d/spatial_sample_player.h"
-#include "scene/3d/spatial_stream_player.h"
+//#include "scene/3d/spatial_sample_player.h"
+//#include "scene/3d/spatial_stream_player.h"
#include "scene/3d/proximity_group.h"
#include "scene/3d/navigation_mesh.h"
#include "scene/3d/navigation.h"
@@ -230,8 +233,7 @@
#include "scene/resources/scene_format_text.h"
-static ResourceFormatLoaderImage *resource_loader_image=NULL;
-static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
+//static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
#ifdef TOOLS_ENABLED
@@ -245,6 +247,8 @@ static ResourceFormatLoaderText *resource_loader_text=NULL;
static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font=NULL;
+static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture=NULL;
+
//static SceneStringNames *string_names;
void register_scene_types() {
@@ -255,14 +259,14 @@ void register_scene_types() {
Node::init_node_hrcr();
- resource_loader_image = memnew( ResourceFormatLoaderImage );
- ResourceLoader::add_resource_format_loader( resource_loader_image );
-
- resource_loader_wav = memnew( ResourceFormatLoaderWAV );
- ResourceLoader::add_resource_format_loader( resource_loader_wav );
+ //resource_loader_wav = memnew( ResourceFormatLoaderWAV );
+ //ResourceLoader::add_resource_format_loader( resource_loader_wav );
resource_loader_dynamic_font = memnew( ResourceFormatLoaderDynamicFont );
ResourceLoader::add_resource_format_loader( resource_loader_dynamic_font );
+ resource_loader_stream_texture = memnew( ResourceFormatLoaderStreamTexture);
+ ResourceLoader::add_resource_format_loader( resource_loader_stream_texture );
+
#ifdef TOOLS_ENABLED
//scene first!
@@ -319,7 +323,7 @@ void register_scene_types() {
ClassDB::register_class<ShortCut>();
ClassDB::register_class<Control>();
-// ClassDB::register_type<EmptyControl>();
+ //ClassDB::register_type<EmptyControl>();
ClassDB::register_class<Button>();
ClassDB::register_class<Label>();
ClassDB::register_class<HScrollBar>();
@@ -339,9 +343,9 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_class<TextureFrame>();
- ClassDB::register_class<ColorFrame>();
- ClassDB::register_class<Patch9Frame>();
+ ClassDB::register_class<TextureRect>();
+ ClassDB::register_class<ColorRect>();
+ ClassDB::register_class<NinePatchRect>();
ClassDB::register_class<TabContainer>();
ClassDB::register_class<Tabs>();
ClassDB::register_virtual_class<Separator>();
@@ -383,7 +387,7 @@ void register_scene_types() {
ClassDB::register_virtual_class<TreeItem>();
ClassDB::register_class<OptionButton>();
ClassDB::register_class<SpinBox>();
- ClassDB::register_class<ReferenceFrame>();
+ ClassDB::register_class<ReferenceRect>();
ClassDB::register_class<ColorPicker>();
ClassDB::register_class<ColorPickerButton>();
ClassDB::register_class<RichTextLabel>();
@@ -474,18 +478,12 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_class<SpatialSamplePlayer>();
- ClassDB::register_class<SpatialStreamPlayer>();
- ClassDB::register_class<SoundRoomParams>();
#endif
ClassDB::register_class<MeshLibrary>();
AcceptDialog::set_swap_ok_cancel( GLOBAL_DEF("gui/common/swap_ok_cancel",bool(OS::get_singleton()->get_swap_ok_cancel())) );
- ClassDB::register_class<SamplePlayer>();
- ClassDB::register_class<StreamPlayer>();
- ClassDB::register_class<EventPlayer>();
ClassDB::register_class<CanvasItemMaterial>();
@@ -494,10 +492,11 @@ void register_scene_types() {
ClassDB::register_class<Particles2D>();
ClassDB::register_class<ParticleAttractor2D>();
ClassDB::register_class<Sprite>();
-// ClassDB::register_type<ViewportSprite>();
+ //ClassDB::register_type<ViewportSprite>();
ClassDB::register_class<SpriteFrames>();
ClassDB::register_class<AnimatedSprite>();
ClassDB::register_class<Position2D>();
+ ClassDB::register_class<Line2D>();
ClassDB::register_virtual_class<CollisionObject2D>();
ClassDB::register_virtual_class<PhysicsBody2D>();
ClassDB::register_class<StaticBody2D>();
@@ -527,8 +526,6 @@ void register_scene_types() {
ClassDB::register_class<TileMap>();
ClassDB::register_class<ParallaxBackground>();
ClassDB::register_class<ParallaxLayer>();
- ClassDB::register_virtual_class<SoundPlayer2D>();
- ClassDB::register_class<SamplePlayer2D>();
ClassDB::register_class<TouchScreenButton>();
ClassDB::register_class<RemoteTransform2D>();
@@ -537,9 +534,9 @@ void register_scene_types() {
/* REGISTER RESOURCES */
ClassDB::register_virtual_class<Shader>();
-// ClassDB::register_virtual_type<ShaderGraph>();
+ //ClassDB::register_virtual_type<ShaderGraph>();
ClassDB::register_class<CanvasItemShader>();
-// ClassDB::register_type<CanvasItemShaderGraph>();
+ //ClassDB::register_type<CanvasItemShaderGraph>();
#ifndef _3D_DISABLED
ClassDB::register_class<Mesh>();
@@ -547,9 +544,9 @@ void register_scene_types() {
ClassDB::register_class<FixedSpatialMaterial>();
SceneTree::add_idle_callback(FixedSpatialMaterial::flush_changes);
FixedSpatialMaterial::init_shaders();
-// ClassDB::register_type<ShaderMaterial>();
+ //ClassDB::register_type<ShaderMaterial>();
ClassDB::register_class<RoomBounds>();
-// ClassDB::register_type<MaterialShaderGraph>();
+ //ClassDB::register_type<MaterialShaderGraph>();
ClassDB::register_class<SpatialShader>();
ClassDB::register_class<ParticlesShader>();
ClassDB::register_class<MultiMesh>();
@@ -578,6 +575,7 @@ void register_scene_types() {
ClassDB::register_virtual_class<Texture>();
ClassDB::register_virtual_class<SkyBox>();
ClassDB::register_class<ImageSkyBox>();
+ ClassDB::register_class<StreamTexture>();
ClassDB::register_class<ImageTexture>();
ClassDB::register_class<AtlasTexture>();
ClassDB::register_class<LargeTexture>();
@@ -600,13 +598,9 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
- ClassDB::register_class<Sample>();
- ClassDB::register_class<SampleLibrary>();
- ClassDB::register_virtual_class<AudioStream>();
- ClassDB::register_virtual_class<AudioStreamPlayback>();
-//TODO: Adapt to the new AudioStream API or drop (GH-3307)
-// ClassDB::register_type<AudioStreamGibberish>();
+ ClassDB::register_class<AudioPlayer>();
ClassDB::register_virtual_class<VideoStream>();
+ ClassDB::register_class<AudioStreamSample>();
OS::get_singleton()->yield(); //may take time to init
@@ -656,9 +650,9 @@ void unregister_scene_types() {
clear_default_theme();
- memdelete( resource_loader_image );
- memdelete( resource_loader_wav );
+// memdelete( resource_loader_wav );
memdelete( resource_loader_dynamic_font );
+ memdelete( resource_loader_stream_texture );
#ifdef TOOLS_ENABLED
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 1fbb149bf3..b743834e63 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1698,61 +1698,61 @@ float Animation::get_step() const{
void Animation::_bind_methods() {
- ClassDB::bind_method(_MD("add_track","type","at_pos"),&Animation::add_track,DEFVAL(-1));
- ClassDB::bind_method(_MD("remove_track","idx"),&Animation::remove_track);
- ClassDB::bind_method(_MD("get_track_count"),&Animation::get_track_count);
- ClassDB::bind_method(_MD("track_get_type","idx"),&Animation::track_get_type);
- ClassDB::bind_method(_MD("track_get_path","idx"),&Animation::track_get_path);
- ClassDB::bind_method(_MD("track_set_path","idx","path"),&Animation::track_set_path);
- ClassDB::bind_method(_MD("find_track","path"),&Animation::find_track);
+ ClassDB::bind_method(D_METHOD("add_track","type","at_pos"),&Animation::add_track,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("remove_track","idx"),&Animation::remove_track);
+ ClassDB::bind_method(D_METHOD("get_track_count"),&Animation::get_track_count);
+ ClassDB::bind_method(D_METHOD("track_get_type","idx"),&Animation::track_get_type);
+ ClassDB::bind_method(D_METHOD("track_get_path","idx"),&Animation::track_get_path);
+ ClassDB::bind_method(D_METHOD("track_set_path","idx","path"),&Animation::track_set_path);
+ ClassDB::bind_method(D_METHOD("find_track","path"),&Animation::find_track);
- ClassDB::bind_method(_MD("track_move_up","idx"),&Animation::track_move_up);
- ClassDB::bind_method(_MD("track_move_down","idx"),&Animation::track_move_down);
+ ClassDB::bind_method(D_METHOD("track_move_up","idx"),&Animation::track_move_up);
+ ClassDB::bind_method(D_METHOD("track_move_down","idx"),&Animation::track_move_down);
- ClassDB::bind_method(_MD("track_set_imported","idx","imported"),&Animation::track_set_imported);
- ClassDB::bind_method(_MD("track_is_imported","idx"),&Animation::track_is_imported);
+ ClassDB::bind_method(D_METHOD("track_set_imported","idx","imported"),&Animation::track_set_imported);
+ ClassDB::bind_method(D_METHOD("track_is_imported","idx"),&Animation::track_is_imported);
- ClassDB::bind_method(_MD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
- ClassDB::bind_method(_MD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
- ClassDB::bind_method(_MD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
- ClassDB::bind_method(_MD("track_remove_key_at_pos","idx","pos"),&Animation::track_remove_key_at_pos);
- ClassDB::bind_method(_MD("track_set_key_value","idx","key","value"),&Animation::track_set_key_value);
- ClassDB::bind_method(_MD("track_set_key_transition","idx","key_idx","transition"),&Animation::track_set_key_transition);
- ClassDB::bind_method(_MD("track_get_key_transition","idx","key_idx"),&Animation::track_get_key_transition);
+ ClassDB::bind_method(D_METHOD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
+ ClassDB::bind_method(D_METHOD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
+ ClassDB::bind_method(D_METHOD("track_remove_key_at_pos","idx","pos"),&Animation::track_remove_key_at_pos);
+ ClassDB::bind_method(D_METHOD("track_set_key_value","idx","key","value"),&Animation::track_set_key_value);
+ ClassDB::bind_method(D_METHOD("track_set_key_transition","idx","key_idx","transition"),&Animation::track_set_key_transition);
+ ClassDB::bind_method(D_METHOD("track_get_key_transition","idx","key_idx"),&Animation::track_get_key_transition);
- ClassDB::bind_method(_MD("track_get_key_count","idx"),&Animation::track_get_key_count);
- ClassDB::bind_method(_MD("track_get_key_value","idx","key_idx"),&Animation::track_get_key_value);
- ClassDB::bind_method(_MD("track_get_key_time","idx","key_idx"),&Animation::track_get_key_time);
- ClassDB::bind_method(_MD("track_find_key","idx","time","exact"),&Animation::track_find_key,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("track_get_key_count","idx"),&Animation::track_get_key_count);
+ ClassDB::bind_method(D_METHOD("track_get_key_value","idx","key_idx"),&Animation::track_get_key_value);
+ ClassDB::bind_method(D_METHOD("track_get_key_time","idx","key_idx"),&Animation::track_get_key_time);
+ ClassDB::bind_method(D_METHOD("track_find_key","idx","time","exact"),&Animation::track_find_key,DEFVAL(false));
- ClassDB::bind_method(_MD("track_set_interpolation_type","idx","interpolation"),&Animation::track_set_interpolation_type);
- ClassDB::bind_method(_MD("track_get_interpolation_type","idx"),&Animation::track_get_interpolation_type);
+ ClassDB::bind_method(D_METHOD("track_set_interpolation_type","idx","interpolation"),&Animation::track_set_interpolation_type);
+ ClassDB::bind_method(D_METHOD("track_get_interpolation_type","idx"),&Animation::track_get_interpolation_type);
- ClassDB::bind_method(_MD("track_set_interpolation_loop_wrap","idx","interpolation"),&Animation::track_set_interpolation_loop_wrap);
- ClassDB::bind_method(_MD("track_get_interpolation_loop_wrap","idx"),&Animation::track_get_interpolation_loop_wrap);
+ ClassDB::bind_method(D_METHOD("track_set_interpolation_loop_wrap","idx","interpolation"),&Animation::track_set_interpolation_loop_wrap);
+ ClassDB::bind_method(D_METHOD("track_get_interpolation_loop_wrap","idx"),&Animation::track_get_interpolation_loop_wrap);
- ClassDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate);
- ClassDB::bind_method(_MD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode);
- ClassDB::bind_method(_MD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode);
+ ClassDB::bind_method(D_METHOD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate);
+ ClassDB::bind_method(D_METHOD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode);
+ ClassDB::bind_method(D_METHOD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode);
- ClassDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices);
+ ClassDB::bind_method(D_METHOD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices);
- ClassDB::bind_method(_MD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices);
- ClassDB::bind_method(_MD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name);
- ClassDB::bind_method(_MD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params);
+ ClassDB::bind_method(D_METHOD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices);
+ ClassDB::bind_method(D_METHOD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name);
+ ClassDB::bind_method(D_METHOD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params);
- ClassDB::bind_method(_MD("set_length","time_sec"),&Animation::set_length);
- ClassDB::bind_method(_MD("get_length"),&Animation::get_length);
+ ClassDB::bind_method(D_METHOD("set_length","time_sec"),&Animation::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"),&Animation::get_length);
- ClassDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&Animation::has_loop);
+ ClassDB::bind_method(D_METHOD("set_loop","enabled"),&Animation::set_loop);
+ ClassDB::bind_method(D_METHOD("has_loop"),&Animation::has_loop);
- ClassDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step);
- ClassDB::bind_method(_MD("get_step"),&Animation::get_step);
+ ClassDB::bind_method(D_METHOD("set_step","size_sec"),&Animation::set_step);
+ ClassDB::bind_method(D_METHOD("get_step"),&Animation::get_step);
- ClassDB::bind_method(_MD("clear"),&Animation::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&Animation::clear);
BIND_CONSTANT( TYPE_VALUE );
BIND_CONSTANT( TYPE_TRANSFORM );
@@ -2005,11 +2005,6 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl
prev_erased=false;
norm=Vector3();
}
-
-
-
- // print_line(itos(i)+" could be eliminated: "+rtos(tr));
- //}
}
diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp
index 7b49ec0849..b2f314a55e 100644
--- a/scene/resources/audio_stream_resampled.cpp
+++ b/scene/resources/audio_stream_resampled.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_stream_resampled.h"
-#include "globals.h"
+#include "global_config.h"
#if 0
diff --git a/scene/resources/audio_stream_resampled.h b/scene/resources/audio_stream_resampled.h
index 761643b027..7ceb6cef84 100644
--- a/scene/resources/audio_stream_resampled.h
+++ b/scene/resources/audio_stream_resampled.h
@@ -29,7 +29,7 @@
#ifndef AUDIO_STREAM_RESAMPLED_H
#define AUDIO_STREAM_RESAMPLED_H
-#include "scene/resources/audio_stream.h"
+//#include "scene/resources/audio_stream.h"
#if 0
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
new file mode 100644
index 0000000000..297cec0c83
--- /dev/null
+++ b/scene/resources/audio_stream_sample.cpp
@@ -0,0 +1,557 @@
+#include "audio_stream_sample.h"
+
+void AudioStreamPlaybackSample::start(float p_from_pos) {
+
+ for(int i=0;i<2;i++) {
+ ima_adpcm[i].step_index=0;
+ ima_adpcm[i].predictor=0;
+ ima_adpcm[i].loop_step_index=0;
+ ima_adpcm[i].loop_predictor=0;
+ ima_adpcm[i].last_nibble=-1;
+ ima_adpcm[i].loop_pos=0x7FFFFFFF;
+ ima_adpcm[i].window_ofs=0;
+ ima_adpcm[i].ptr=(const uint8_t*)base->data;
+ ima_adpcm[i].ptr+=AudioStreamSample::DATA_PAD;
+ }
+
+ seek_pos(p_from_pos);
+ sign=1;
+ active=true;
+}
+
+void AudioStreamPlaybackSample::stop() {
+
+ active=false;
+}
+
+bool AudioStreamPlaybackSample::is_playing() const {
+
+ return active;
+}
+
+int AudioStreamPlaybackSample::get_loop_count() const {
+
+ return 0;
+}
+
+float AudioStreamPlaybackSample::get_pos() const {
+
+ return float(offset>>MIX_FRAC_BITS)/base->mix_rate;
+}
+void AudioStreamPlaybackSample::seek_pos(float p_time) {
+
+ if (base->format==AudioStreamSample::FORMAT_IMA_ADPCM)
+ return; //no seeking in ima-adpcm
+
+ float max=get_length();
+ if (p_time<0) {
+ p_time=0;
+ } else if (p_time>=max) {
+ p_time=max-0.001;
+ }
+
+ offset = uint64_t(p_time * base->mix_rate)<<MIX_FRAC_BITS;
+}
+
+
+template<class Depth,bool is_stereo,bool is_ima_adpcm>
+void AudioStreamPlaybackSample::do_resample(const Depth* p_src, AudioFrame *p_dst,int64_t &offset,int32_t &increment,uint32_t amount,IMA_ADPCM_State *ima_adpcm) {
+
+ // this function will be compiled branchless by any decent compiler
+
+ int32_t final,final_r,next,next_r;
+ while (amount--) {
+
+ int64_t pos=offset >> MIX_FRAC_BITS;
+ if (is_stereo && !is_ima_adpcm)
+ pos<<=1;
+
+ if (is_ima_adpcm) {
+
+ int64_t sample_pos = pos + ima_adpcm[0].window_ofs;
+
+ while(sample_pos>ima_adpcm[0].last_nibble) {
+
+
+ static const int16_t _ima_adpcm_step_table[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+ };
+
+ static const int8_t _ima_adpcm_index_table[16] = {
+ -1, -1, -1, -1, 2, 4, 6, 8,
+ -1, -1, -1, -1, 2, 4, 6, 8
+ };
+
+ for(int i=0;i<(is_stereo?2:1);i++) {
+
+
+ int16_t nibble,diff,step;
+
+ ima_adpcm[i].last_nibble++;
+ const uint8_t *src_ptr=ima_adpcm[i].ptr;
+
+
+ uint8_t nbb = src_ptr[ (ima_adpcm[i].last_nibble>>1) * (is_stereo?2:1) + i ];
+ nibble = (ima_adpcm[i].last_nibble&1)?(nbb>>4):(nbb&0xF);
+ step=_ima_adpcm_step_table[ima_adpcm[i].step_index];
+
+
+ ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble];
+ if (ima_adpcm[i].step_index<0)
+ ima_adpcm[i].step_index=0;
+ if (ima_adpcm[i].step_index>88)
+ ima_adpcm[i].step_index=88;
+
+ diff = step >> 3 ;
+ if (nibble & 1)
+ diff += step >> 2 ;
+ if (nibble & 2)
+ diff += step >> 1 ;
+ if (nibble & 4)
+ diff += step ;
+ if (nibble & 8)
+ diff = -diff ;
+
+ ima_adpcm[i].predictor+=diff;
+ if (ima_adpcm[i].predictor<-0x8000)
+ ima_adpcm[i].predictor=-0x8000;
+ else if (ima_adpcm[i].predictor>0x7FFF)
+ ima_adpcm[i].predictor=0x7FFF;
+
+
+ /* store loop if there */
+ if (ima_adpcm[i].last_nibble==ima_adpcm[i].loop_pos) {
+
+ ima_adpcm[i].loop_step_index = ima_adpcm[i].step_index;
+ ima_adpcm[i].loop_predictor = ima_adpcm[i].predictor;
+ }
+
+ //printf("%i - %i - pred %i\n",int(ima_adpcm[i].last_nibble),int(nibble),int(ima_adpcm[i].predictor));
+
+ }
+
+ }
+
+ final=ima_adpcm[0].predictor;
+ if (is_stereo) {
+ final_r=ima_adpcm[1].predictor;
+ }
+
+ } else {
+ final=p_src[pos];
+ if (is_stereo)
+ final_r=p_src[pos+1];
+
+ if (sizeof(Depth)==1) { /* conditions will not exist anymore when compiled! */
+ final<<=8;
+ if (is_stereo)
+ final_r<<=8;
+ }
+
+ if (is_stereo) {
+
+ next=p_src[pos+2];
+ next_r=p_src[pos+3];
+ } else {
+ next=p_src[pos+1];
+ }
+
+ if (sizeof(Depth)==1) {
+ next<<=8;
+ if (is_stereo)
+ next_r<<=8;
+ }
+
+ int32_t frac=int64_t(offset&MIX_FRAC_MASK);
+
+ final=final+((next-final)*frac >> MIX_FRAC_BITS);
+ if (is_stereo)
+ final_r=final_r+((next_r-final_r)*frac >> MIX_FRAC_BITS);
+
+ }
+
+
+ if (!is_stereo) {
+ final_r=final; //copy to right channel if stereo
+ }
+
+ p_dst->l=final/32767.0;
+ p_dst->r=final_r/32767.0;
+ p_dst++;
+
+ offset+=increment;
+ }
+}
+
+void AudioStreamPlaybackSample::mix(AudioFrame* p_buffer,float p_rate_scale,int p_frames) {
+
+ if (!base->data || !active) {
+ for(int i=0;i<p_frames;i++) {
+ p_buffer[i]=AudioFrame(0,0);
+ }
+ return;
+ }
+
+ int len = base->data_bytes;
+ switch(base->format) {
+ case AudioStreamSample::FORMAT_8_BITS: len/=1; break;
+ case AudioStreamSample::FORMAT_16_BITS: len/=2; break;
+ case AudioStreamSample::FORMAT_IMA_ADPCM: len*=2; break;
+ }
+
+ if (base->stereo) {
+ len/=2;
+ }
+
+ /* some 64-bit fixed point precaches */
+
+ int64_t loop_begin_fp=((int64_t)len<< 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;
+ int64_t end_limit=(base->loop_mode!=AudioStreamSample::LOOP_DISABLED)?loop_end_fp:length_fp;
+ bool is_stereo=base->stereo;
+
+ int32_t todo=p_frames;
+
+ float base_rate = AudioServer::get_singleton()->get_mix_rate();
+ float srate = base->mix_rate;
+ srate*=p_rate_scale;
+ float fincrement = srate / base_rate;
+ int32_t increment = int32_t(fincrement * MIX_FRAC_LEN);
+ increment*=sign;
+
+
+ //looping
+
+ AudioStreamSample::LoopMode loop_format=base->loop_mode;
+ AudioStreamSample::Format format = base->format;
+
+
+ /* audio data */
+
+ uint8_t *dataptr=(uint8_t*)base->data;
+ const void *data=dataptr+AudioStreamSample::DATA_PAD;
+ AudioFrame *dst_buff=p_buffer;
+
+
+ if (format==AudioStreamSample::FORMAT_IMA_ADPCM) {
+
+ if (loop_format!=AudioStreamSample::LOOP_DISABLED) {
+ ima_adpcm[0].loop_pos=loop_begin_fp>>MIX_FRAC_BITS;
+ ima_adpcm[1].loop_pos=loop_begin_fp>>MIX_FRAC_BITS;
+ loop_format=AudioStreamSample::LOOP_FORWARD;
+ }
+ }
+
+ while (todo>0) {
+
+ int64_t limit=0;
+ int32_t target=0,aux=0;
+
+ /** LOOP CHECKING **/
+
+ if ( increment < 0 ) {
+ /* going backwards */
+
+ if ( loop_format!=AudioStreamSample::LOOP_DISABLED && offset < loop_begin_fp ) {
+ /* loopstart reached */
+ if ( loop_format==AudioStreamSample::LOOP_PING_PONG ) {
+ /* bounce ping pong */
+ offset= loop_begin_fp + ( loop_begin_fp-offset );
+ increment=-increment;
+ sign*=-1;
+ } else {
+ /* go to loop-end */
+ offset=loop_end_fp-(loop_begin_fp-offset);
+ }
+ } else {
+ /* check for sample not reaching begining */
+ if(offset < 0) {
+
+ active=false;
+ break;
+ }
+ }
+ } else {
+ /* going forward */
+ if( loop_format!=AudioStreamSample::LOOP_DISABLED && offset >= loop_end_fp ) {
+ /* loopend reached */
+
+ if ( loop_format==AudioStreamSample::LOOP_PING_PONG ) {
+ /* bounce ping pong */
+ offset=loop_end_fp-(offset-loop_end_fp);
+ increment=-increment;
+ sign*=-1;
+ } else {
+ /* go to loop-begin */
+
+ if (format==AudioStreamSample::FORMAT_IMA_ADPCM) {
+ for(int i=0;i<2;i++) {
+ ima_adpcm[i].step_index=ima_adpcm[i].loop_step_index;
+ ima_adpcm[i].predictor=ima_adpcm[i].loop_predictor;
+ ima_adpcm[i].last_nibble=loop_begin_fp>>MIX_FRAC_BITS;
+ }
+ offset=loop_begin_fp;
+ } else {
+ offset=loop_begin_fp+(offset-loop_end_fp);
+ }
+
+ }
+ } else {
+ /* no loop, check for end of sample */
+ if(offset >= length_fp) {
+
+ active=false;
+ break;
+ }
+ }
+ }
+
+ /** MIXCOUNT COMPUTING **/
+
+ /* next possible limit (looppoints or sample begin/end */
+ limit=(increment < 0) ?begin_limit:end_limit;
+
+ /* compute what is shorter, the todo or the limit? */
+ aux=(limit-offset)/increment+1;
+ target=(aux<todo)?aux:todo; /* mix target is the shorter buffer */
+
+ /* check just in case */
+ if ( target<=0 ) {
+ active=false;
+ break;
+ }
+
+ todo-=target;
+
+ switch(base->format) {
+ case AudioStreamSample::FORMAT_8_BITS: {
+
+ if (is_stereo)
+ do_resample<int8_t,true,false>((int8_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+ else
+ do_resample<int8_t,false,false>((int8_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+ } break;
+ case AudioStreamSample::FORMAT_16_BITS: {
+ if (is_stereo)
+ do_resample<int16_t,true,false>((int16_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+ else
+ do_resample<int16_t,false,false>((int16_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+
+ } break;
+ case AudioStreamSample::FORMAT_IMA_ADPCM: {
+ if (is_stereo)
+ do_resample<int8_t,true,true>((int8_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+ else
+ do_resample<int8_t,false,true>((int8_t*)data,dst_buff,offset,increment,target,ima_adpcm);
+
+ } break;
+ }
+
+ dst_buff+=target;
+
+ }
+
+
+}
+
+float AudioStreamPlaybackSample::get_length() const {
+
+ int len = base->data_bytes;
+ switch(base->format) {
+ case AudioStreamSample::FORMAT_8_BITS: len/=1; break;
+ case AudioStreamSample::FORMAT_16_BITS: len/=2; break;
+ case AudioStreamSample::FORMAT_IMA_ADPCM: len*=2; break;
+ }
+
+ if (base->stereo) {
+ len/=2;
+ }
+
+
+ return float(len)/base->mix_rate;
+}
+
+
+AudioStreamPlaybackSample::AudioStreamPlaybackSample() {
+
+ active=false;
+ offset=0;
+ sign=1;
+}
+
+
+/////////////////////
+
+
+void AudioStreamSample::set_format(Format p_format) {
+
+ format=p_format;
+}
+
+AudioStreamSample::Format AudioStreamSample::get_format() const{
+
+ return format;
+}
+
+void AudioStreamSample::set_loop_mode(LoopMode p_loop_mode){
+
+ loop_mode=p_loop_mode;
+}
+AudioStreamSample::LoopMode AudioStreamSample::get_loop_mode() const{
+
+ return loop_mode;
+}
+
+void AudioStreamSample::set_loop_begin(int p_frame){
+
+ loop_begin=p_frame;
+}
+int AudioStreamSample::get_loop_begin() const{
+
+ return loop_begin;
+}
+
+void AudioStreamSample::set_loop_end(int p_frame){
+
+ loop_end=p_frame;
+}
+int AudioStreamSample::get_loop_end() const{
+
+ return loop_end;
+}
+
+
+void AudioStreamSample::set_mix_rate(int p_hz){
+
+ mix_rate=p_hz;
+}
+int AudioStreamSample::get_mix_rate() const{
+
+ return mix_rate;
+}
+void AudioStreamSample::set_stereo(bool p_enable){
+
+ stereo=p_enable;
+}
+bool AudioStreamSample::is_stereo() const{
+
+ return stereo;
+}
+
+void AudioStreamSample::set_data(const PoolVector<uint8_t>& p_data) {
+
+ AudioServer::get_singleton()->lock();
+ if (data) {
+ AudioServer::get_singleton()->audio_data_free(data);
+ data=NULL;
+ data_bytes=0;
+ }
+
+ int datalen = p_data.size();
+ if (datalen) {
+
+ PoolVector<uint8_t>::Read r = p_data.read();
+ int alloc_len = datalen+DATA_PAD*2;
+ data = AudioServer::get_singleton()->audio_data_alloc(alloc_len); //alloc with some padding for interpolation
+ zeromem(data,alloc_len);
+ uint8_t *dataptr=(uint8_t*)data;
+ copymem(dataptr+DATA_PAD,r.ptr(),datalen);
+ data_bytes=datalen;
+ }
+
+ AudioServer::get_singleton()->unlock();
+
+}
+PoolVector<uint8_t> AudioStreamSample::get_data() const{
+
+ PoolVector<uint8_t> pv;
+
+ if (data) {
+ pv.resize(data_bytes);
+ {
+
+ PoolVector<uint8_t>::Write w =pv.write();
+ copymem(w.ptr(),data,data_bytes);
+ }
+ }
+
+ return pv;
+}
+
+
+Ref<AudioStreamPlayback> AudioStreamSample::instance_playback() {
+
+ Ref<AudioStreamPlaybackSample> sample;
+ sample.instance();
+ sample->base=Ref<AudioStreamSample>(this);
+ return sample;
+}
+
+String AudioStreamSample::get_stream_name() const {
+
+ return "";
+}
+
+void AudioStreamSample::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_format","format"),&AudioStreamSample::set_format);
+ ClassDB::bind_method(D_METHOD("get_format"),&AudioStreamSample::get_format);
+
+ ClassDB::bind_method(D_METHOD("set_loop_mode","loop_mode"),&AudioStreamSample::set_loop_mode);
+ ClassDB::bind_method(D_METHOD("get_loop_mode"),&AudioStreamSample::get_loop_mode);
+
+ ClassDB::bind_method(D_METHOD("set_loop_begin","loop_begin"),&AudioStreamSample::set_loop_begin);
+ ClassDB::bind_method(D_METHOD("get_loop_begin"),&AudioStreamSample::get_loop_begin);
+
+ ClassDB::bind_method(D_METHOD("set_loop_end","loop_end"),&AudioStreamSample::set_loop_end);
+ ClassDB::bind_method(D_METHOD("get_loop_end"),&AudioStreamSample::get_loop_end);
+
+ ClassDB::bind_method(D_METHOD("set_mix_rate","mix_rate"),&AudioStreamSample::set_mix_rate);
+ ClassDB::bind_method(D_METHOD("get_mix_rate"),&AudioStreamSample::get_mix_rate);
+
+ ClassDB::bind_method(D_METHOD("set_stereo","stereo"),&AudioStreamSample::set_stereo);
+ ClassDB::bind_method(D_METHOD("is_stereo"),&AudioStreamSample::is_stereo);
+
+ ClassDB::bind_method(D_METHOD("set_data","data"),&AudioStreamSample::set_data);
+ ClassDB::bind_method(D_METHOD("get_data"),&AudioStreamSample::get_data);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"format",PROPERTY_HINT_ENUM,"8-Bit,16-Bit,IMA-ADPCM"),"set_format","get_format");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"loop_mode",PROPERTY_HINT_ENUM,"Disabled,Forward,Ping-Pong"),"set_loop_mode","get_loop_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"loop_begin"),"set_loop_begin","get_loop_begin");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"loop_end"),"set_loop_end","get_loop_end");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"mix_rate"),"set_mix_rate","get_mix_rate");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"stereo"),"set_stereo","is_stereo");
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"set_data","get_data");
+
+}
+
+AudioStreamSample::AudioStreamSample()
+{
+ format=FORMAT_8_BITS;
+ loop_mode=LOOP_DISABLED;
+ stereo=false;
+ loop_begin=0;
+ loop_end=0;
+ mix_rate=44100;
+ data=NULL;
+ data_bytes=0;
+}
+AudioStreamSample::~AudioStreamSample() {
+
+
+ if (data) {
+ AudioServer::get_singleton()->audio_data_free(data);
+ data=NULL;
+ data_bytes=0;
+ }
+}
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
new file mode 100644
index 0000000000..8c1e74608b
--- /dev/null
+++ b/scene/resources/audio_stream_sample.h
@@ -0,0 +1,128 @@
+#ifndef AUDIOSTREAMSAMPLE_H
+#define AUDIOSTREAMSAMPLE_H
+
+#include "servers/audio/audio_stream.h"
+
+
+class AudioStreamSample;
+
+class AudioStreamPlaybackSample : public AudioStreamPlayback {
+
+ GDCLASS( AudioStreamPlaybackSample, AudioStreamPlayback )
+ enum {
+ MIX_FRAC_BITS=13,
+ MIX_FRAC_LEN=(1<<MIX_FRAC_BITS),
+ MIX_FRAC_MASK=MIX_FRAC_LEN-1,
+ };
+
+ struct IMA_ADPCM_State {
+
+ int16_t step_index;
+ int32_t predictor;
+ /* values at loop point */
+ int16_t loop_step_index;
+ int32_t loop_predictor;
+ int32_t last_nibble;
+ int32_t loop_pos;
+ int32_t window_ofs;
+ const uint8_t *ptr;
+ } ima_adpcm[2];
+
+ int64_t offset;
+ int sign;
+ bool active;
+friend class AudioStreamSample;
+ Ref<AudioStreamSample> base;
+
+ template<class Depth,bool is_stereo,bool is_ima_adpcm>
+ void do_resample(const Depth* p_src, AudioFrame *p_dst,int64_t &offset,int32_t &increment,uint32_t amount,IMA_ADPCM_State *ima_adpcm);
+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_buffer,float p_rate_scale,int p_frames);
+
+ virtual float get_length() const; //if supported, otherwise return 0
+
+
+ AudioStreamPlaybackSample();
+};
+
+class AudioStreamSample : public AudioStream {
+ GDCLASS(AudioStreamSample,AudioStream)
+ RES_BASE_EXTENSION("smp")
+
+public:
+
+ enum Format {
+ FORMAT_8_BITS,
+ FORMAT_16_BITS,
+ FORMAT_IMA_ADPCM
+ };
+
+ enum LoopMode {
+ LOOP_DISABLED,
+ LOOP_FORWARD,
+ LOOP_PING_PONG
+ };
+
+
+private:
+friend class AudioStreamPlaybackSample;
+
+ enum {
+ DATA_PAD=16 //padding for interpolation
+ };
+
+ Format format;
+ LoopMode loop_mode;
+ bool stereo;
+ int loop_begin;
+ int loop_end;
+ int mix_rate;
+ void *data;
+ uint32_t data_bytes;
+protected:
+
+ static void _bind_methods();
+public:
+ void set_format(Format p_format);
+ Format get_format() const;
+
+ void set_loop_mode(LoopMode p_loop_mode);
+ LoopMode get_loop_mode() const;
+
+ void set_loop_begin(int p_frame);
+ int get_loop_begin() const;
+
+ void set_loop_end(int p_frame);
+ int get_loop_end() const;
+
+ void set_mix_rate(int p_hz);
+ int get_mix_rate() const;
+
+ void set_stereo(bool p_enable);
+ bool is_stereo() const;
+
+ void set_data(const PoolVector<uint8_t>& p_data);
+ PoolVector<uint8_t> get_data() const;
+
+
+ virtual Ref<AudioStreamPlayback> instance_playback();
+ virtual String get_stream_name() const;
+
+ AudioStreamSample();
+ ~AudioStreamSample();
+};
+
+VARIANT_ENUM_CAST(AudioStreamSample::Format)
+VARIANT_ENUM_CAST(AudioStreamSample::LoopMode)
+
+#endif // AUDIOSTREAMSample_H
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index d669ab771c..4ceac5af0c 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -177,21 +177,21 @@ Dictionary BitMap::_get_data() const{
void BitMap::_bind_methods() {
- ClassDB::bind_method(_MD("create","size"),&BitMap::create);
- ClassDB::bind_method(_MD("create_from_image_alpha","image"),&BitMap::create_from_image_alpha);
+ 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(_MD("set_bit","pos","bit"),&BitMap::set_bit);
- ClassDB::bind_method(_MD("get_bit","pos"),&BitMap::get_bit);
+ ClassDB::bind_method(D_METHOD("set_bit","pos","bit"),&BitMap::set_bit);
+ ClassDB::bind_method(D_METHOD("get_bit","pos"),&BitMap::get_bit);
- ClassDB::bind_method(_MD("set_bit_rect","p_rect","bit"),&BitMap::set_bit_rect);
- ClassDB::bind_method(_MD("get_true_bit_count"),&BitMap::get_true_bit_count);
+ ClassDB::bind_method(D_METHOD("set_bit_rect","p_rect","bit"),&BitMap::set_bit_rect);
+ ClassDB::bind_method(D_METHOD("get_true_bit_count"),&BitMap::get_true_bit_count);
- ClassDB::bind_method(_MD("get_size"),&BitMap::get_size);
+ ClassDB::bind_method(D_METHOD("get_size"),&BitMap::get_size);
- ClassDB::bind_method(_MD("_set_data"),&BitMap::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&BitMap::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data"),&BitMap::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&BitMap::_get_data);
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_data","_get_data");
}
diff --git a/scene/resources/bounds.cpp b/scene/resources/bounds.cpp
index 03d819451d..26bf6270e9 100644
--- a/scene/resources/bounds.cpp
+++ b/scene/resources/bounds.cpp
@@ -31,10 +31,10 @@
void Bounds::_bind_methods() {
- ClassDB::bind_method( _MD("set_bsp_tree","bsp_tree"),&Bounds::set_bsp_tree);
- ClassDB::bind_method( _MD("get_bsp_tree"),&Bounds::get_bsp_tree );
+ ClassDB::bind_method( D_METHOD("set_bsp_tree","bsp_tree"),&Bounds::set_bsp_tree);
+ ClassDB::bind_method( D_METHOD("get_bsp_tree"),&Bounds::get_bsp_tree );
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "bsp_tree" ), _SCS("set_bsp_tree"), _SCS("get_bsp_tree"));
+ ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "bsp_tree" ), "set_bsp_tree", "get_bsp_tree");
}
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp
index 87585af862..e8eccaceae 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape.cpp
@@ -70,10 +70,10 @@ Vector3 BoxShape::get_extents() const {
void BoxShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_extents","extents"),&BoxShape::set_extents);
- ClassDB::bind_method(_MD("get_extents"),&BoxShape::get_extents);
+ ClassDB::bind_method(D_METHOD("set_extents","extents"),&BoxShape::set_extents);
+ ClassDB::bind_method(D_METHOD("get_extents"),&BoxShape::get_extents);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"), _SCS("set_extents"), _SCS("get_extents") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"), "set_extents", "get_extents") ;
}
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp
index db83a20f38..bd30f009c4 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape.cpp
@@ -42,8 +42,8 @@ Vector<Vector3> CapsuleShape::_gen_debug_mesh_lines() {
Vector3 d(0,0,height*0.5);
for(int i=0;i<360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
@@ -107,13 +107,13 @@ float CapsuleShape::get_height() const {
void CapsuleShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_radius","radius"),&CapsuleShape::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&CapsuleShape::get_radius);
- ClassDB::bind_method(_MD("set_height","height"),&CapsuleShape::set_height);
- ClassDB::bind_method(_MD("get_height"),&CapsuleShape::get_height);
+ ClassDB::bind_method(D_METHOD("set_radius","radius"),&CapsuleShape::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&CapsuleShape::get_radius);
+ ClassDB::bind_method(D_METHOD("set_height","height"),&CapsuleShape::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"),&CapsuleShape::get_height);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_radius"),_SCS("get_radius") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_height"),_SCS("get_height") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), "set_radius","get_radius") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), "set_height","get_height") ;
}
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 27dcff0ce0..523d6d7455 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -89,15 +89,15 @@ Rect2 CapsuleShape2D::get_rect() const {
void CapsuleShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_radius","radius"),&CapsuleShape2D::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&CapsuleShape2D::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius","radius"),&CapsuleShape2D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&CapsuleShape2D::get_radius);
- ClassDB::bind_method(_MD("set_height","height"),&CapsuleShape2D::set_height);
- ClassDB::bind_method(_MD("get_height"),&CapsuleShape2D::get_height);
+ ClassDB::bind_method(D_METHOD("set_height","height"),&CapsuleShape2D::set_height);
+ ClassDB::bind_method(D_METHOD("get_height"),&CapsuleShape2D::get_height);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius"),_SCS("set_radius"),_SCS("get_radius") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"height"),_SCS("set_height"),_SCS("get_height") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius"),"set_radius","get_radius") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"height"),"set_height","get_height") ;
}
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index a82f3f5e2d..cd707b1032 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -51,10 +51,10 @@ real_t CircleShape2D::get_radius() const {
void CircleShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_radius","radius"),&CircleShape2D::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&CircleShape2D::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius","radius"),&CircleShape2D::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&CircleShape2D::get_radius);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.5"),_SCS("set_radius"),_SCS("get_radius") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.5"),"set_radius","get_radius") ;
}
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index 1144ea41f1..b14ba4c8ed 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "color_ramp.h"
+#include "core_string_names.h"
//setter and getter names for property serialization
#define COLOR_RAMP_GET_OFFSETS "get_offsets"
@@ -54,27 +55,27 @@ void ColorRamp::_bind_methods() {
- ClassDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
- ClassDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
+ ClassDB::bind_method(D_METHOD("add_point","offset","color"),&ColorRamp::add_point);
+ ClassDB::bind_method(D_METHOD("remove_point","offset","color"),&ColorRamp::remove_point);
- ClassDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
- ClassDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
+ ClassDB::bind_method(D_METHOD("set_offset","point","offset"),&ColorRamp::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset","point"),&ColorRamp::get_offset);
- ClassDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
- ClassDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
+ ClassDB::bind_method(D_METHOD("set_color","point","color"),&ColorRamp::set_color);
+ ClassDB::bind_method(D_METHOD("get_color","point"),&ColorRamp::get_color);
- ClassDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+ ClassDB::bind_method(D_METHOD("interpolate","offset"),&ColorRamp::get_color_at_offset);
- ClassDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
+ ClassDB::bind_method(D_METHOD("get_point_count"),&ColorRamp::get_points_count);
- ClassDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
- ClassDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
- ClassDB::bind_method(_MD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
- ClassDB::bind_method(_MD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
+ ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"offsets"),_SCS(COLOR_RAMP_SET_OFFSETS),_SCS(COLOR_RAMP_GET_OFFSETS) );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"colors"),_SCS(COLOR_RAMP_SET_COLORS),_SCS(COLOR_RAMP_GET_COLORS) );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"offsets"),COLOR_RAMP_SET_OFFSETS,COLOR_RAMP_GET_OFFSETS) ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"colors"),COLOR_RAMP_SET_COLORS,COLOR_RAMP_GET_COLORS) ;
}
Vector<float> ColorRamp::get_offsets() const {
@@ -104,6 +105,7 @@ void ColorRamp::set_offsets(const Vector<float>& p_offsets) {
points[i].offset = p_offsets[i];
}
is_sorted = false;
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
void ColorRamp::set_colors(const Vector<Color>& p_colors) {
@@ -114,6 +116,7 @@ void ColorRamp::set_colors(const Vector<Color>& p_colors) {
{
points[i].color = p_colors[i];
}
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
Vector<ColorRamp::Point>& ColorRamp::get_points() {
@@ -128,6 +131,7 @@ void ColorRamp::add_point(float p_offset, const Color& p_color) {
is_sorted=false;
points.push_back(p);
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
void ColorRamp::remove_point(int p_index) {
@@ -135,11 +139,13 @@ void ColorRamp::remove_point(int p_index) {
ERR_FAIL_INDEX(p_index,points.size());
ERR_FAIL_COND(points.size()<=2);
points.remove(p_index);
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
points = p_points;
is_sorted = false;
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
void ColorRamp::set_offset(int pos, const float offset) {
@@ -147,6 +153,7 @@ void ColorRamp::set_offset(int pos, const float offset) {
points.resize(pos + 1);
points[pos].offset = offset;
is_sorted = false;
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
float ColorRamp::get_offset(int pos) const {
@@ -162,6 +169,7 @@ void ColorRamp::set_color(int pos, const Color& color) {
is_sorted = false;
}
points[pos].color = color;
+ emit_signal(CoreStringNames::get_singleton()->changed);
}
Color ColorRamp::get_color(int pos) const {
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp
index 5190bba6a5..3945ade215 100644
--- a/scene/resources/concave_polygon_shape.cpp
+++ b/scene/resources/concave_polygon_shape.cpp
@@ -110,8 +110,8 @@ PoolVector<Vector3> ConcavePolygonShape::get_faces() const {
void ConcavePolygonShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_faces","faces"),&ConcavePolygonShape::set_faces);
- ClassDB::bind_method(_MD("get_faces"),&ConcavePolygonShape::get_faces);
+ ClassDB::bind_method(D_METHOD("set_faces","faces"),&ConcavePolygonShape::set_faces);
+ ClassDB::bind_method(D_METHOD("get_faces"),&ConcavePolygonShape::get_faces);
}
ConcavePolygonShape::ConcavePolygonShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) {
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 6866750006..f3dfa8a2b3 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -82,10 +82,10 @@ Rect2 ConcavePolygonShape2D::get_rect() const {
void ConcavePolygonShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_segments","segments"),&ConcavePolygonShape2D::set_segments);
- ClassDB::bind_method(_MD("get_segments"),&ConcavePolygonShape2D::get_segments);
+ ClassDB::bind_method(D_METHOD("set_segments","segments"),&ConcavePolygonShape2D::set_segments);
+ ClassDB::bind_method(D_METHOD("get_segments"),&ConcavePolygonShape2D::get_segments);
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"segments"),_SCS("set_segments"),_SCS("get_segments") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"segments"),"set_segments","get_segments") ;
}
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index ca9897bf97..207419f8cd 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -79,10 +79,10 @@ PoolVector<Vector3> ConvexPolygonShape::get_points() const {
void ConvexPolygonShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape::set_points);
- ClassDB::bind_method(_MD("get_points"),&ConvexPolygonShape::get_points);
+ ClassDB::bind_method(D_METHOD("set_points","points"),&ConvexPolygonShape::set_points);
+ ClassDB::bind_method(D_METHOD("get_points"),&ConvexPolygonShape::get_points);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"points"), _SCS("set_points"), _SCS("get_points") );
+ ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"points"), "set_points", "get_points") ;
}
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 0d3ba238f6..2a4b181611 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -61,13 +61,13 @@ Vector<Vector2> ConvexPolygonShape2D::get_points() const {
void ConvexPolygonShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_point_cloud","point_cloud"),&ConvexPolygonShape2D::set_point_cloud);
- ClassDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape2D::set_points);
- ClassDB::bind_method(_MD("get_points"),&ConvexPolygonShape2D::get_points);
+ ClassDB::bind_method(D_METHOD("set_point_cloud","point_cloud"),&ConvexPolygonShape2D::set_point_cloud);
+ ClassDB::bind_method(D_METHOD("set_points","points"),&ConvexPolygonShape2D::set_points);
+ ClassDB::bind_method(D_METHOD("get_points"),&ConvexPolygonShape2D::get_points);
- ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"points"),_SCS("set_points"),_SCS("get_points") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"points"),"set_points","get_points") ;
}
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index e201cb16ac..9311ab4dd7 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -349,30 +349,30 @@ Vector2Array Curve2D::get_points_pos() const {
void Curve2D::_bind_methods() {
- ClassDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
- ClassDB::bind_method(_MD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()));
- ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
- ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
- ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
- ClassDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
- ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
- ClassDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
- ClassDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
- ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
- ClassDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
+ ClassDB::bind_method(D_METHOD("get_point_count"),&Curve2D::get_point_count);
+ ClassDB::bind_method(D_METHOD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
+ ClassDB::bind_method(D_METHOD("get_point_pos","idx"),&Curve2D::get_point_pos);
+ ClassDB::bind_method(D_METHOD("set_point_in","idx","pos"),&Curve2D::set_point_in);
+ ClassDB::bind_method(D_METHOD("get_point_in","idx"),&Curve2D::get_point_in);
+ ClassDB::bind_method(D_METHOD("set_point_out","idx","pos"),&Curve2D::set_point_out);
+ ClassDB::bind_method(D_METHOD("get_point_out","idx"),&Curve2D::get_point_out);
+ ClassDB::bind_method(D_METHOD("remove_point","idx"),&Curve2D::remove_point);
+ ClassDB::bind_method(D_METHOD("interpolate","idx","t"),&Curve2D::interpolate);
+ ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
- ClassDB::bind_method(_MD("set_points_in"),&Curve2D::set_points_in);
- ClassDB::bind_method(_MD("set_points_out"),&Curve2D::set_points_out);
- ClassDB::bind_method(_MD("set_points_pos"),&Curve2D::set_points_pos);
+ ClassDB::bind_method(D_METHOD("set_points_in"),&Curve2D::set_points_in);
+ ClassDB::bind_method(D_METHOD("set_points_out"),&Curve2D::set_points_out);
+ ClassDB::bind_method(D_METHOD("set_points_pos"),&Curve2D::set_points_pos);
- ClassDB::bind_method(_MD("get_points_in"),&Curve2D::get_points_in);
- ClassDB::bind_method(_MD("get_points_out"),&Curve2D::get_points_out);
- ClassDB::bind_method(_MD("get_points_pos"),&Curve2D::get_points_pos);
+ ClassDB::bind_method(D_METHOD("get_points_in"),&Curve2D::get_points_in);
+ ClassDB::bind_method(D_METHOD("get_points_out"),&Curve2D::get_points_out);
+ ClassDB::bind_method(D_METHOD("get_points_pos"),&Curve2D::get_points_pos);
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_in"), _SCS("set_points_in"),_SCS("get_points_in"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_pos"), _SCS("set_points_pos"),_SCS("get_points_pos"));
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_in"), "set_points_in","get_points_in");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_out"), "set_points_out","get_points_out");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_pos"), "set_points_pos","get_points_pos");
}
@@ -498,7 +498,7 @@ Vector2 Curve2D::interpolatef(real_t p_findex) const {
else if (p_findex>=points.size())
p_findex=points.size();
- return interpolate((int)p_findex,Math::fmod(p_findex,1.0));
+ return interpolate((int)p_findex,Math::fmod(p_findex,(real_t)1.0));
}
@@ -653,7 +653,7 @@ Vector2 Curve2D::interpolate_baked(float p_offset,bool p_cubic) const{
return r[bpc-1];
int idx = Math::floor((double)p_offset/(double)bake_interval);
- float frac = Math::fmod(p_offset,bake_interval);
+ float frac = Math::fmod(p_offset,(float)bake_interval);
if (idx>=bpc-1) {
return r[bpc-1];
@@ -789,35 +789,35 @@ PoolVector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
void Curve2D::_bind_methods() {
- ClassDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
- ClassDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()),DEFVAL(-1));
- ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
- ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
- ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
- ClassDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
- ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
- ClassDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
- ClassDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
- ClassDB::bind_method(_MD("clear_points"),&Curve2D::clear_points);
- ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
- ClassDB::bind_method(_MD("interpolatef","fofs"),&Curve2D::interpolatef);
- //ClassDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
- ClassDB::bind_method(_MD("set_bake_interval","distance"),&Curve2D::set_bake_interval);
- ClassDB::bind_method(_MD("get_bake_interval"),&Curve2D::get_bake_interval);
-
- ClassDB::bind_method(_MD("get_baked_length"),&Curve2D::get_baked_length);
- ClassDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve2D::interpolate_baked,DEFVAL(false));
- ClassDB::bind_method(_MD("get_baked_points"),&Curve2D::get_baked_points);
- ClassDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve2D::tesselate,DEFVAL(5),DEFVAL(4));
-
- ClassDB::bind_method(_MD("_get_data"),&Curve2D::_get_data);
- ClassDB::bind_method(_MD("_set_data"),&Curve2D::_set_data);
-
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
- /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), _SCS("set_points_pos"),_SCS("get_points_pos"));
+ ClassDB::bind_method(D_METHOD("get_point_count"),&Curve2D::get_point_count);
+ ClassDB::bind_method(D_METHOD("add_point","pos","in","out","atpos"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
+ ClassDB::bind_method(D_METHOD("get_point_pos","idx"),&Curve2D::get_point_pos);
+ ClassDB::bind_method(D_METHOD("set_point_in","idx","pos"),&Curve2D::set_point_in);
+ ClassDB::bind_method(D_METHOD("get_point_in","idx"),&Curve2D::get_point_in);
+ ClassDB::bind_method(D_METHOD("set_point_out","idx","pos"),&Curve2D::set_point_out);
+ ClassDB::bind_method(D_METHOD("get_point_out","idx"),&Curve2D::get_point_out);
+ ClassDB::bind_method(D_METHOD("remove_point","idx"),&Curve2D::remove_point);
+ ClassDB::bind_method(D_METHOD("clear_points"),&Curve2D::clear_points);
+ ClassDB::bind_method(D_METHOD("interpolate","idx","t"),&Curve2D::interpolate);
+ ClassDB::bind_method(D_METHOD("interpolatef","fofs"),&Curve2D::interpolatef);
+ //ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
+ ClassDB::bind_method(D_METHOD("set_bake_interval","distance"),&Curve2D::set_bake_interval);
+ ClassDB::bind_method(D_METHOD("get_bake_interval"),&Curve2D::get_bake_interval);
+
+ 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("_get_data"),&Curve2D::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data"),&Curve2D::_set_data);
+
+
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), "set_bake_interval","get_bake_interval");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_data","_get_data");
+ /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), "set_points_out","get_points_out");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), "set_points_pos","get_points_pos");
*/
}
@@ -974,7 +974,7 @@ Vector3 Curve3D::interpolatef(real_t p_findex) const {
else if (p_findex>=points.size())
p_findex=points.size();
- return interpolate((int)p_findex,Math::fmod(p_findex,1.0));
+ return interpolate((int)p_findex,Math::fmod(p_findex,(real_t)1.0));
}
@@ -1329,38 +1329,38 @@ PoolVector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
void Curve3D::_bind_methods() {
- ClassDB::bind_method(_MD("get_point_count"),&Curve3D::get_point_count);
- ClassDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve3D::add_point,DEFVAL(Vector3()),DEFVAL(Vector3()),DEFVAL(-1));
- ClassDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve3D::set_point_pos);
- ClassDB::bind_method(_MD("get_point_pos","idx"),&Curve3D::get_point_pos);
- ClassDB::bind_method(_MD("set_point_tilt","idx","tilt"),&Curve3D::set_point_tilt);
- ClassDB::bind_method(_MD("get_point_tilt","idx"),&Curve3D::get_point_tilt);
- ClassDB::bind_method(_MD("set_point_in","idx","pos"),&Curve3D::set_point_in);
- ClassDB::bind_method(_MD("get_point_in","idx"),&Curve3D::get_point_in);
- ClassDB::bind_method(_MD("set_point_out","idx","pos"),&Curve3D::set_point_out);
- ClassDB::bind_method(_MD("get_point_out","idx"),&Curve3D::get_point_out);
- ClassDB::bind_method(_MD("remove_point","idx"),&Curve3D::remove_point);
- ClassDB::bind_method(_MD("clear_points"),&Curve3D::clear_points);
- ClassDB::bind_method(_MD("interpolate","idx","t"),&Curve3D::interpolate);
- ClassDB::bind_method(_MD("interpolatef","fofs"),&Curve3D::interpolatef);
- //ClassDB::bind_method(_MD("bake","subdivs"),&Curve3D::bake,DEFVAL(10));
- ClassDB::bind_method(_MD("set_bake_interval","distance"),&Curve3D::set_bake_interval);
- ClassDB::bind_method(_MD("get_bake_interval"),&Curve3D::get_bake_interval);
-
- ClassDB::bind_method(_MD("get_baked_length"),&Curve3D::get_baked_length);
- ClassDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve3D::interpolate_baked,DEFVAL(false));
- ClassDB::bind_method(_MD("get_baked_points"),&Curve3D::get_baked_points);
- ClassDB::bind_method(_MD("get_baked_tilts"),&Curve3D::get_baked_tilts);
- ClassDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve3D::tesselate,DEFVAL(5),DEFVAL(4));
-
- ClassDB::bind_method(_MD("_get_data"),&Curve3D::_get_data);
- ClassDB::bind_method(_MD("_set_data"),&Curve3D::_set_data);
-
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
- /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), _SCS("set_points_pos"),_SCS("get_points_pos"));
+ ClassDB::bind_method(D_METHOD("get_point_count"),&Curve3D::get_point_count);
+ ClassDB::bind_method(D_METHOD("add_point","pos","in","out","atpos"),&Curve3D::add_point,DEFVAL(Vector3()),DEFVAL(Vector3()),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("set_point_pos","idx","pos"),&Curve3D::set_point_pos);
+ ClassDB::bind_method(D_METHOD("get_point_pos","idx"),&Curve3D::get_point_pos);
+ ClassDB::bind_method(D_METHOD("set_point_tilt","idx","tilt"),&Curve3D::set_point_tilt);
+ ClassDB::bind_method(D_METHOD("get_point_tilt","idx"),&Curve3D::get_point_tilt);
+ ClassDB::bind_method(D_METHOD("set_point_in","idx","pos"),&Curve3D::set_point_in);
+ ClassDB::bind_method(D_METHOD("get_point_in","idx"),&Curve3D::get_point_in);
+ ClassDB::bind_method(D_METHOD("set_point_out","idx","pos"),&Curve3D::set_point_out);
+ ClassDB::bind_method(D_METHOD("get_point_out","idx"),&Curve3D::get_point_out);
+ ClassDB::bind_method(D_METHOD("remove_point","idx"),&Curve3D::remove_point);
+ ClassDB::bind_method(D_METHOD("clear_points"),&Curve3D::clear_points);
+ ClassDB::bind_method(D_METHOD("interpolate","idx","t"),&Curve3D::interpolate);
+ ClassDB::bind_method(D_METHOD("interpolatef","fofs"),&Curve3D::interpolatef);
+ //ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve3D::bake,DEFVAL(10));
+ ClassDB::bind_method(D_METHOD("set_bake_interval","distance"),&Curve3D::set_bake_interval);
+ ClassDB::bind_method(D_METHOD("get_bake_interval"),&Curve3D::get_bake_interval);
+
+ ClassDB::bind_method(D_METHOD("get_baked_length"),&Curve3D::get_baked_length);
+ 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("_get_data"),&Curve3D::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data"),&Curve3D::_set_data);
+
+
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), "set_bake_interval","get_bake_interval");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_data","_get_data");
+ /*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), "set_points_out","get_points_out");
+ ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), "set_points_pos","get_points_pos");
*/
}
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 3c6e65bf41..dbe0f3e33e 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -125,7 +125,7 @@ static Ref<Texture> make_icon(T p_src) {
static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,const char*lighting_code) {
Ref<Shader> shader = (memnew( Shader(Shader::MODE_CANVAS_ITEM) ));
-// shader->set_code(vertex_code, fragment_code, lighting_code);
+ //shader->set_code(vertex_code, fragment_code, lighting_code);
return shader;
}
@@ -583,24 +583,19 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
// WindowDialog
- Ref<StyleBoxTexture> style_pp_win = sb_expand(make_stylebox( popup_window_png,10,30,10,8),8,26,8,4);
- /*for(int i=0;i<4;i++)
- style_pp_win->set_expand_margin_size((Margin)i,3);
- style_pp_win->set_expand_margin_size(MARGIN_TOP,26);*/
+ Ref<StyleBoxTexture> style_pp_win = sb_expand(make_stylebox(popup_window_png, 10, 26, 10, 8), 8, 24, 8, 6);
+ t->set_stylebox("panel", "WindowDialog", style_pp_win);
+ t->set_constant("titlebar_height", "WindowDialog", 20 * scale);
+ t->set_constant("scaleborder_size", "WindowDialog", 4);
- t->set_stylebox("panel","WindowDialog", style_pp_win );
+ t->set_font("title_font", "WindowDialog", large_font);
+ t->set_color("title_color", "WindowDialog", Color(0, 0, 0));
+ t->set_constant("title_height", "WindowDialog", 18 * scale);
- t->set_icon("close","WindowDialog", make_icon( close_png ) );
- t->set_icon("close_hilite","WindowDialog", make_icon( close_hl_png ) );
-
- t->set_font("title_font","WindowDialog", large_font );
-
- t->set_color("title_color","WindowDialog", Color(0,0,0) );
-
- t->set_constant("close_h_ofs","WindowDialog", 22 *scale);
- t->set_constant("close_v_ofs","WindowDialog", 20 *scale);
- t->set_constant("titlebar_height","WindowDialog", 18 *scale);
- t->set_constant("title_height","WindowDialog", 20 *scale);
+ t->set_icon("close", "WindowDialog", make_icon(close_png));
+ t->set_icon("close_hilite", "WindowDialog", make_icon(close_hl_png));
+ t->set_constant("close_h_ofs", "WindowDialog", 18 * scale);
+ t->set_constant("close_v_ofs", "WindowDialog", 18 * scale);
// File Dialog
@@ -750,6 +745,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_stylebox("tab_fg","TabContainer", sb_expand( make_stylebox( tab_current_png,4,4,4,1,16,4,16,4),2,2,2,2) );
t->set_stylebox("tab_bg","TabContainer", sb_expand( make_stylebox( tab_behind_png,5,5,5,1,16,6,16,4),3,0,3,3) );
+ t->set_stylebox("tab_disabled", "TabContainer", sb_expand(make_stylebox(tab_disabled_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
t->set_stylebox("panel","TabContainer", tc_sb );
t->set_icon("increment","TabContainer",make_icon( scroll_button_right_png));
@@ -763,6 +759,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_color("font_color_fg","TabContainer", control_font_color_hover );
t->set_color("font_color_bg","TabContainer", control_font_color_low );
+ t->set_color("font_color_disabled", "TabContainer", control_font_color_disabled);
t->set_constant("side_margin","TabContainer", 8 *scale);
t->set_constant("top_margin","TabContainer", 24 *scale);
@@ -776,6 +773,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_stylebox("tab_fg","Tabs", sb_expand( make_stylebox( tab_current_png,4,3,4,1,16,3,16,2),2,2,2,2) );
t->set_stylebox("tab_bg","Tabs", sb_expand( make_stylebox( tab_behind_png,5,4,5,1,16,5,16,2),3,3,3,3) );
+ t->set_stylebox("tab_disabled", "Tabs", sb_expand(make_stylebox(tab_disabled_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
t->set_stylebox("panel","Tabs",tc_sb );
t->set_stylebox("button_pressed","Tabs", make_stylebox( button_pressed_png,4,4,4,4) );
t->set_stylebox("button","Tabs", make_stylebox( button_normal_png,4,4,4,4) );
@@ -790,6 +788,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_color("font_color_fg","Tabs", control_font_color_hover );
t->set_color("font_color_bg","Tabs", control_font_color_low );
+ t->set_color("font_color_disabled", "Tabs", control_font_color_disabled);
t->set_constant("top_margin","Tabs", 24 *scale);
t->set_constant("label_valign_fg","Tabs", 0 *scale);
@@ -934,12 +933,12 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_stylebox("focus","VButtonArray", focus );
- // ReferenceFrame
+ // ReferenceRect
Ref<StyleBoxTexture> ttnc = make_stylebox( full_panel_bg_png,8,8,8,8);
ttnc->set_draw_center(false);
- t->set_stylebox("border","ReferenceFrame", make_stylebox( reference_border_png,4,4,4,4) );
+ t->set_stylebox("border","ReferenceRect", make_stylebox( reference_border_png,4,4,4,4) );
t->set_stylebox("panelnc","Panel", ttnc );
t->set_stylebox("panelf","Panel", tc_sb );
@@ -982,7 +981,7 @@ void make_default_theme(bool p_hidpi,Ref<Font> p_font) {
Ref<BitmapFont> default_font;
if (p_font.is_valid()) {
default_font=p_font;
- } if (p_hidpi) {
+ } else if (p_hidpi) {
default_font=make_font2(_hidpi_font_height,_hidpi_font_ascent,_hidpi_font_charcount,&_hidpi_font_charrects[0][0],_hidpi_font_kerning_pair_count,&_hidpi_font_kerning_pairs[0][0],_hidpi_font_img_width,_hidpi_font_img_height,_hidpi_font_img_data);
} else {
default_font=make_font2(_lodpi_font_height,_lodpi_font_ascent,_lodpi_font_charcount,&_lodpi_font_charrects[0][0],_lodpi_font_kerning_pair_count,&_lodpi_font_kerning_pairs[0][0],_lodpi_font_img_width,_lodpi_font_img_height,_lodpi_font_img_data);
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 46fd770a27..394cfaf424 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -45,7 +45,7 @@ static const unsigned char button_normal_png[]={
static const unsigned char button_pressed_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,0x93,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,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x2f,0x37,0x46,0x43,0x4f,0x47,0x44,0x50,0x55,0x52,0x5f,0x55,0x52,0x60,0x3d,0x3a,0x45,0x56,0x52,0x60,0x56,0x52,0x60,0x43,0x40,0x4c,0x42,0x40,0x4b,0x3a,0x38,0x41,0x36,0x34,0x3d,0x44,0x42,0x4e,0x36,0x34,0x3e,0x46,0x42,0x4f,0x38,0x35,0x3f,0x47,0x45,0x50,0x39,0x37,0x40,0x49,0x46,0x53,0x3a,0x38,0x42,0x4a,0x47,0x54,0x3b,0x39,0x43,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x50,0x4d,0x5a,0x3f,0x3d,0x48,0x3f,0x3d,0x47,0x45,0x42,0x4d,0x41,0x3e,0x49,0x40,0x3e,0x48,0x52,0x4e,0x5c,0x51,0x4e,0x5b,0xff,0xff,0xff,0x32,0xd2,0xb4,0xc,0x0,0x0,0x0,0x16,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xef,0xef,0x77,0xef,0xed,0x6b,0x28,0x52,0x7a,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x30,0xae,0xdc,0x2d,0xe4,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,0x0,0x95,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0xdb,0x12,0x42,0x50,0x14,0x6,0xe0,0xb5,0x8f,0xf6,0x11,0xa5,0x24,0x9,0x49,0x22,0xd2,0xfb,0xbf,0x5d,0x9b,0x31,0xfb,0xa2,0xbe,0xcb,0x7f,0x66,0x1d,0x7e,0x0,0x84,0x9,0x65,0xdc,0x61,0x94,0x60,0x4,0x80,0x2,0x21,0x95,0x36,0xd6,0x1a,0xad,0xa4,0x8,0x10,0x60,0x11,0x46,0xe9,0x69,0x95,0x46,0xa1,0xc0,0x40,0x64,0x9c,0x9d,0x37,0x59,0x2c,0x9,0x50,0x95,0x5f,0xbc,0x5c,0x51,0x60,0xba,0xb8,0x7a,0x85,0x66,0xc0,0x4d,0x59,0x79,0xa5,0xe1,0xc0,0x6d,0x7d,0xf3,0x6a,0xbb,0x4,0xcd,0xdd,0x6b,0x96,0xc0,0xb4,0xf,0xaf,0x75,0x23,0x4c,0x77,0x4f,0xaf,0x73,0x4b,0xa9,0xea,0x87,0xd7,0x66,0xe8,0xdd,0x59,0x22,0x77,0xe3,0xf4,0x5e,0x4d,0xe3,0xde,0x3d,0x86,0x45,0x72,0x98,0x3f,0xab,0xf9,0x98,0xb8,0xd7,0xff,0xca,0xfd,0xd6,0xff,0x2,0x86,0xd,0x15,0x51,0x39,0x7d,0xa8,0x8e,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
+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,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,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,0x7,0x1c,0xc,0x14,0x2b,0xf9,0x77,0x52,0x64,0x0,0x0,0x1,0x92,0x49,0x44,0x41,0x54,0x38,0xcb,0x8d,0x93,0x4d,0x4e,0x1b,0x41,0x10,0x85,0xbf,0xea,0xaa,0x1e,0x20,0x83,0xf9,0x9,0x36,0xb2,0x85,0x72,0x84,0x8,0x65,0x11,0xe5,0xc,0x9c,0x80,0x73,0x10,0xee,0xc1,0x41,0x38,0x1,0xab,0xec,0xa3,0x2c,0x2,0x8a,0xe0,0x2,0x51,0xc2,0x48,0x46,0x42,0x64,0xc6,0x91,0x21,0xf4,0x74,0x16,0x2e,0xb0,0x71,0x2,0xf2,0x93,0x9e,0xba,0x16,0xdd,0xaf,0x5e,0xa9,0x5f,0x9,0x60,0x40,0x1,0x2c,0x1,0xcb,0x5e,0x2b,0x10,0x78,0x8a,0x16,0x48,0xc0,0x1d,0x30,0x6,0x6e,0x81,0x3b,0xf3,0x87,0x25,0xb0,0x9,0xac,0x7b,0xbd,0xc,0x88,0x13,0x20,0x3b,0xc7,0xc0,0x8,0xb8,0x1,0xae,0x81,0x91,0xf9,0xe5,0xad,0x77,0xbb,0x1f,0xf6,0x7b,0xdd,0xfe,0x41,0x4a,0x69,0x2d,0x93,0xf9,0x1f,0x4,0x41,0x55,0x7f,0xd,0xaf,0xaa,0xa3,0xaf,0x67,0x9f,0x8f,0x81,0x64,0xde,0xb1,0xbb,0xdd,0x1b,0x7c,0xac,0x9b,0x9b,0xce,0xd9,0xb7,0x2f,0xfc,0xf3,0x5e,0xa6,0xe5,0xee,0xdb,0xf7,0x6b,0xdb,0xbd,0xc1,0x21,0xf0,0x9,0x18,0x5,0x60,0x5,0xd8,0x48,0x6d,0xdb,0x39,0xbf,0x38,0xc5,0x34,0x62,0x36,0x47,0x9d,0xf2,0xfc,0xe2,0x94,0xd4,0xb6,0x1d,0x60,0x3,0x58,0x31,0x20,0x2,0x65,0x40,0x88,0x31,0x92,0xbd,0xbb,0x8,0xe4,0x3c,0x39,0x67,0x91,0x33,0x84,0x89,0xa5,0x12,0x88,0xf,0x3f,0x10,0x45,0x5,0xb3,0xc8,0x73,0x10,0x11,0xb2,0xab,0x8b,0xa,0xde,0xb8,0x30,0x9f,0xb0,0x8,0xa2,0xc4,0x58,0xb0,0x8,0x82,0x28,0xde,0x58,0xcc,0xff,0x5c,0x45,0x64,0x61,0x1,0x99,0xcc,0xa5,0x80,0x4e,0x5,0xc2,0xcb,0x2,0xe2,0x41,0x10,0x40,0xc2,0x53,0x81,0xc,0xa8,0x8a,0x52,0x2c,0xe8,0x40,0x27,0x23,0x28,0x90,0xcd,0xe3,0x79,0x1b,0x34,0x50,0x14,0x4b,0xf0,0x4c,0x88,0x66,0xbd,0x4,0xd,0x78,0x94,0x93,0x79,0x3c,0x9b,0x18,0x63,0x7a,0xbd,0xb9,0xa5,0xcd,0xa8,0x7e,0xb4,0x3a,0x2f,0x15,0x10,0xca,0x72,0x95,0x18,0x8b,0x4,0x34,0xc0,0xd8,0x80,0x1a,0x18,0x56,0xd5,0xcf,0x93,0x41,0x7f,0x67,0xaf,0xb3,0xba,0x1e,0x5e,0x8a,0xb2,0x99,0xb5,0x97,0xd5,0x8f,0x13,0x60,0x8,0xd4,0x2,0x74,0x9d,0x6f,0x80,0xbe,0x2f,0x55,0xe9,0x26,0xc2,0xcc,0x26,0x66,0x5f,0xa4,0x6b,0xa0,0x2,0xbe,0x3,0x57,0xe6,0x56,0x1e,0x66,0x1a,0x2,0xaf,0x3c,0x24,0x36,0x67,0xe0,0x1e,0xf8,0x3,0xfc,0xf6,0x6d,0xac,0x81,0xe6,0x2f,0x7c,0x22,0x6d,0x74,0x25,0xb,0xb3,0xa2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
@@ -458,6 +458,10 @@ static const unsigned char tab_current_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,0x9c,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,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0x3d,0x48,0x5b,0x58,0x66,0x5b,0x57,0x65,0x57,0x54,0x62,0x55,0x53,0x62,0x4a,0x46,0x52,0x46,0x41,0x4e,0x45,0x41,0x4d,0x55,0x52,0x60,0x44,0x41,0x4c,0x53,0x50,0x5e,0x43,0x40,0x4b,0x52,0x4e,0x5d,0x41,0x3e,0x4a,0x4f,0x4d,0x5a,0x3f,0x3d,0x48,0x4e,0x4b,0x59,0x3e,0x3c,0x47,0x4d,0x4a,0x58,0x3d,0x3b,0x46,0x4b,0x49,0x54,0x3c,0x3a,0x44,0x4b,0x47,0x54,0x3b,0x39,0x43,0x3b,0x39,0x42,0x3b,0x38,0x43,0x3b,0x38,0x42,0x3a,0x37,0x41,0x39,0x37,0x41,0x3a,0x38,0x41,0x39,0x36,0x3f,0x38,0x36,0x3f,0x39,0x36,0x40,0x38,0x36,0x40,0x37,0x35,0x3e,0x37,0x34,0x3e,0x36,0x35,0x3d,0x35,0x32,0x3b,0x59,0xdd,0xd3,0xff,0x0,0x0,0x0,0x11,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xa3,0x31,0x6b,0xc2,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x33,0x37,0xd5,0x7c,0x5e,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,0x0,0xa2,0x49,0x44,0x41,0x54,0x18,0xd3,0x45,0xcd,0xd9,0x12,0x82,0x30,0xc,0x40,0xd1,0x0,0x2d,0x4b,0x5b,0x36,0x59,0x44,0x44,0x44,0xa4,0x68,0x59,0x54,0xfc,0xff,0x8f,0x33,0x30,0x4c,0x3d,0x93,0xa7,0x3b,0x93,0x4,0xc0,0x30,0x2d,0x42,0x6d,0x44,0x89,0x65,0x1a,0x0,0x86,0xe3,0x7a,0x8c,0xb,0xdf,0x17,0x9c,0x79,0xae,0x63,0x80,0xe9,0x6,0x61,0x7c,0xd8,0xc4,0x61,0xe0,0x9a,0x60,0x79,0x51,0x92,0x66,0x9b,0x34,0x89,0x3c,0xb,0x8,0xcb,0xb3,0xe3,0x2e,0xcb,0x19,0x1,0xca,0x8b,0x93,0x56,0x70,0xa,0xb6,0x28,0xcf,0x5a,0x29,0x6c,0xb0,0xfd,0xea,0xa2,0x55,0xfe,0x1a,0xea,0xab,0x56,0xaf,0x41,0x34,0x37,0xad,0xc1,0x15,0xca,0xdb,0xbb,0xd6,0xe2,0x51,0xc2,0xba,0x7f,0xe8,0xf0,0x2d,0x6,0x29,0xfb,0x5e,0xca,0xc7,0x53,0xca,0x3d,0xa8,0x61,0x50,0xc3,0xa8,0xc6,0x41,0xed,0x61,0x9a,0xa6,0x19,0xbd,0xe6,0xf7,0x1e,0x3e,0xcb,0x82,0x83,0xbe,0x18,0x7e,0xa1,0xe5,0x17,0x1f,0xcf,0x5d,0x82,0x6b,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 tab_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,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0,0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0xd2,0x49,0x44,0x41,0x54,0x38,0xcb,0xd5,0x90,0x51,0xa,0xc2,0x30,0xc,0x86,0xd3,0x2e,0xdb,0x4,0x1f,0xb6,0x57,0x75,0x77,0xd9,0x1d,0x3c,0x8d,0x47,0xd8,0x69,0xbc,0x81,0xf,0xbb,0xcb,0xf0,0x6d,0xa8,0xa0,0xa0,0x6b,0xd7,0x9a,0x40,0x26,0xa,0xdb,0x98,0x22,0x88,0x81,0xf,0x92,0xf2,0xe7,0x4f,0x13,0x5,0x0,0x48,0x44,0x44,0x4c,0xcc,0x24,0xf,0x8,0xd,0xaf,0xe1,0x88,0x96,0x68,0x88,0x2b,0x71,0xe3,0xbc,0x6b,0x9e,0x13,0x29,0x91,0x48,0xce,0x66,0x4a,0xe0,0xf0,0x2,0x37,0x5d,0x88,0x13,0x71,0x4,0x99,0xce,0xe2,0x34,0xcf,0xf3,0x75,0xb6,0xcc,0xa,0xd3,0x1a,0x18,0x8b,0x30,0x8,0xa1,0xda,0x57,0x9b,0xb2,0x2c,0xb7,0x54,0x5a,0x94,0x6f,0x27,0xab,0xc5,0xaa,0xa8,0xf,0x35,0x58,0x6b,0xc1,0x7b,0xdf,0xdb,0xac,0x94,0x2,0x44,0x4,0xd6,0x52,0xb9,0x23,0xce,0x8f,0x15,0x1a,0xdb,0x80,0x31,0xe3,0xd3,0xd9,0x98,0x35,0xac,0x95,0x55,0x23,0x2d,0x7,0x8b,0x87,0xa6,0xe,0x19,0xc9,0xea,0x1,0xca,0xb5,0x15,0x3f,0x4e,0x35,0x11,0x1d,0x1f,0x58,0x63,0xb7,0xde,0x87,0x6,0x80,0xcf,0x8f,0x6f,0x1a,0xc0,0x77,0xd,0x9c,0x73,0x93,0xd,0x58,0xdb,0x85,0xee,0x73,0xfd,0xcd,0xa,0xff,0x6b,0x70,0x7,0xd6,0xd5,0x90,0x3b,0x10,0xe9,0x51,0x80,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
static const unsigned char tab_menu_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,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x6f,0x49,0x44,0x41,0x54,0x38,0x8d,0x63,0x60,0x18,0x5,0xa3,0x80,0x81,0x81,0x11,0x5d,0xe0,0xc1,0x83,0x7,0xff,0xf1,0x69,0x50,0x50,0x50,0x40,0xd1,0xc3,0x44,0xa9,0xb,0xa8,0x6f,0x0,0x23,0x23,0x63,0x3c,0x3,0x3,0xc3,0x57,0x2c,0x6a,0xbf,0x33,0x32,0x32,0xa6,0x63,0xa8,0xc7,0x66,0xea,0xfd,0xfb,0xf7,0x35,0x18,0x18,0x18,0x56,0x31,0x32,0x32,0xea,0x42,0x85,0x6e,0x30,0x33,0x33,0x87,0xc9,0xca,0xca,0x5e,0x26,0xca,0x0,0x6,0x6,0x6,0x86,0x17,0x2f,0x5e,0x70,0xff,0xfc,0xf9,0x73,0xa,0x3,0x3,0x3,0x3,0x3b,0x3b,0x7b,0x8e,0x84,0x84,0x4,0x36,0x57,0xd,0x2,0x0,0x0,0x67,0xf2,0x14,0xc2,0xc2,0xbe,0xf5,0xb5,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
@@ -540,12 +544,12 @@ static const unsigned char vslider_bg_png[]={
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,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,0x0,0xf8,0x49,0x44,0x41,0x54,0x28,0xcf,0xbd,0x90,0xaf,0x4b,0x43,0x51,0x18,0x86,0x9f,0xf3,0x43,0xcf,0x76,0xae,0xde,0xb9,0xc9,0x1c,0x82,0x86,0xa1,0x16,0x15,0x87,0xc3,0x20,0x68,0x30,0x58,0xb4,0x5a,0x6c,0x62,0x37,0x88,0xff,0x81,0xc5,0xe4,0x5f,0x70,0x8b,0x75,0x45,0xb3,0xc1,0xa6,0x41,0x4,0x19,0xc,0x19,0x18,0x4,0x8d,0xb,0x82,0xdb,0xd8,0x81,0x29,0xf7,0x1e,0x8b,0x6e,0x43,0x30,0xea,0x93,0x5e,0xf8,0x5e,0x5e,0x78,0x3e,0xf8,0x73,0xc4,0x40,0x92,0x18,0x46,0x9,0x18,0xc6,0xd3,0xa1,0x89,0x23,0xee,0x17,0x86,0xc8,0x14,0xa7,0x97,0x57,0x4a,0xdb,0xe1,0xa2,0xc9,0x4b,0xdf,0xac,0x3d,0x9d,0x47,0x15,0x5e,0x89,0x5,0x20,0xb0,0x23,0xc5,0x83,0xc3,0xc2,0xa6,0x99,0xea,0xaa,0xf,0x62,0xc0,0xa0,0x1b,0xf,0x27,0xd1,0x19,0x6d,0x8d,0x66,0x6c,0x75,0x6d,0xf7,0x54,0xcd,0x3a,0x1c,0xc9,0xd7,0x60,0x8c,0x2d,0xcc,0xec,0x70,0x41,0x5b,0x63,0x8e,0xf6,0xe6,0x8f,0xdf,0x82,0x4e,0xef,0x8,0xe0,0xe9,0x92,0x5d,0x22,0x0,0x89,0x48,0x59,0xd4,0xef,0x16,0x8a,0xe4,0xba,0xde,0xaa,0x2e,0x94,0x53,0xb9,0x4,0x8f,0xef,0x29,0xa5,0x71,0x77,0x57,0x15,0x5a,0x8a,0x4,0xf7,0xfc,0x72,0x73,0x39,0xc7,0xf8,0x44,0x90,0x11,0x2,0x24,0x92,0x34,0xba,0xf1,0x18,0xdd,0xdf,0xf2,0xde,0xd7,0xc,0x75,0x7e,0x6b,0x7d,0x63,0x5f,0x4c,0x9a,0x9c,0xfa,0xa1,0xf9,0x8d,0xc4,0x12,0x62,0xd1,0x83,0x8f,0xfa,0x7,0x3e,0x1,0x87,0xd0,0x4a,0x12,0xcf,0xee,0xfb,0xd8,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
+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_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,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,0xec,0x37,0x7,0xf6,0x0,0x0,0x0,0x31,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0xa,0x17,0x22,0x28,0x27,0x1c,0xd,0x5,0x14,0x31,0x65,0xaf,0xdb,0xf0,0xef,0xc1,0x6e,0x16,0xb,0x2c,0x9c,0xe0,0xfc,0xe8,0x4,0x4f,0xdb,0x73,0xf4,0xc,0x7d,0xf7,0x55,0xdc,0x95,0xe0,0xfe,0x13,0x28,0x64,0xc5,0xde,0xf0,0x2,0x1a,0x24,0x77,0x58,0x79,0x88,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,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x7d,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x20,0xf,0x30,0x32,0x31,0xb3,0xb0,0xb2,0xb1,0x73,0x70,0x32,0x41,0xf8,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,0x2,0x82,0x42,0xc2,0x22,0x20,0x11,0x46,0x51,0x31,0x71,0x9,0x49,0x43,0x23,0x63,0x13,0x53,0x29,0x61,0x4e,0x6,0x6,0x69,0x6e,0x19,0x59,0x33,0x73,0xb,0x4b,0x20,0xb0,0x32,0x15,0xe2,0x60,0x60,0x10,0x95,0x93,0xb7,0x6,0x73,0x81,0xc0,0x44,0x90,0x9d,0x81,0x41,0x41,0x51,0xc9,0x6,0x45,0x40,0x5a,0x44,0x59,0xc5,0x16,0x59,0xb,0x3,0xa3,0x82,0x98,0xaa,0x9a,0xba,0x9d,0xbd,0x3,0xd4,0x50,0x90,0xb5,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x30,0x6b,0x41,0x40,0x4f,0x41,0xdf,0x0,0xc9,0x61,0x24,0x2,0x0,0x9d,0x96,0x10,0xf9,0x6,0xb2,0x58,0x28,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
+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.png b/scene/resources/default_theme/vslider_grabber.png
index a61a6a57c9..afc490be45 100644
--- a/scene/resources/default_theme/vslider_grabber.png
+++ b/scene/resources/default_theme/vslider_grabber.png
Binary files differ
diff --git a/scene/resources/default_theme/vslider_grabber_hl.png b/scene/resources/default_theme/vslider_grabber_hl.png
index 548dbbbff8..548972e115 100644
--- a/scene/resources/default_theme/vslider_grabber_hl.png
+++ b/scene/resources/default_theme/vslider_grabber_hl.png
Binary files differ
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 3aadbdbe19..02149f5748 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -84,10 +84,10 @@ void DynamicFontData::set_force_autohinter(bool p_force) {
}
void DynamicFontData::_bind_methods() {
- ClassDB::bind_method(_MD("set_font_path","path"),&DynamicFontData::set_font_path);
- ClassDB::bind_method(_MD("get_font_path"),&DynamicFontData::get_font_path);
+ ClassDB::bind_method(D_METHOD("set_font_path","path"),&DynamicFontData::set_font_path);
+ ClassDB::bind_method(D_METHOD("get_font_path"),&DynamicFontData::get_font_path);
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"font_path",PROPERTY_HINT_FILE,"*.ttf,*.otf"),_SCS("set_font_path"),_SCS("get_font_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"font_path",PROPERTY_HINT_FILE,"*.ttf,*.otf"),"set_font_path","get_font_path");
}
DynamicFontData::DynamicFontData()
@@ -511,7 +511,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ //print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
if (tex_index==-1) {
//could not find texture to fit, create one
@@ -879,37 +879,37 @@ void DynamicFont::_get_property_list( List<PropertyInfo> *p_list) const{
void DynamicFont::_bind_methods() {
- ClassDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ClassDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
+ ClassDB::bind_method(D_METHOD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
+ ClassDB::bind_method(D_METHOD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
- ClassDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ClassDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+ ClassDB::bind_method(D_METHOD("set_size","data"),&DynamicFont::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"),&DynamicFont::get_size);
- ClassDB::bind_method(_MD("set_use_mipmaps","enable"),&DynamicFont::set_use_mipmaps);
- ClassDB::bind_method(_MD("get_use_mipmaps"),&DynamicFont::get_use_mipmaps);
- ClassDB::bind_method(_MD("set_use_filter","enable"),&DynamicFont::set_use_filter);
- ClassDB::bind_method(_MD("get_use_filter"),&DynamicFont::get_use_filter);
- ClassDB::bind_method(_MD("set_spacing","type","value"),&DynamicFont::set_spacing);
- ClassDB::bind_method(_MD("get_spacing","type"),&DynamicFont::get_spacing);
+ ClassDB::bind_method(D_METHOD("set_use_mipmaps","enable"),&DynamicFont::set_use_mipmaps);
+ ClassDB::bind_method(D_METHOD("get_use_mipmaps"),&DynamicFont::get_use_mipmaps);
+ ClassDB::bind_method(D_METHOD("set_use_filter","enable"),&DynamicFont::set_use_filter);
+ ClassDB::bind_method(D_METHOD("get_use_filter"),&DynamicFont::get_use_filter);
+ ClassDB::bind_method(D_METHOD("set_spacing","type","value"),&DynamicFont::set_spacing);
+ ClassDB::bind_method(D_METHOD("get_spacing","type"),&DynamicFont::get_spacing);
- ClassDB::bind_method(_MD("add_fallback","data:DynamicFontData"),&DynamicFont::add_fallback);
- ClassDB::bind_method(_MD("set_fallback","idx","data:DynamicFontData"),&DynamicFont::set_fallback);
- ClassDB::bind_method(_MD("get_fallback:DynamicFontData","idx"),&DynamicFont::get_fallback);
- ClassDB::bind_method(_MD("remove_fallback","idx"),&DynamicFont::remove_fallback);
- ClassDB::bind_method(_MD("get_fallback_count"),&DynamicFont::get_fallback_count);
+ ClassDB::bind_method(D_METHOD("add_fallback","data:DynamicFontData"),&DynamicFont::add_fallback);
+ ClassDB::bind_method(D_METHOD("set_fallback","idx","data:DynamicFontData"),&DynamicFont::set_fallback);
+ ClassDB::bind_method(D_METHOD("get_fallback:DynamicFontData","idx"),&DynamicFont::get_fallback);
+ ClassDB::bind_method(D_METHOD("remove_fallback","idx"),&DynamicFont::remove_fallback);
+ ClassDB::bind_method(D_METHOD("get_fallback_count"),&DynamicFont::get_fallback_count);
ADD_GROUP("Settings","");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"size"),_SCS("set_size"),_SCS("get_size"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_mipmaps"),_SCS("set_use_mipmaps"),_SCS("get_use_mipmaps"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_filter"),_SCS("set_use_filter"),_SCS("get_use_filter"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"size"),"set_size","get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_mipmaps"),"set_use_mipmaps","get_use_mipmaps");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_filter"),"set_use_filter","get_use_filter");
ADD_GROUP("Extra Spacing","extra_spacing");
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_top"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_TOP);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_bottom"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_BOTTOM);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_char"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_CHAR);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_space"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_SPACE);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_top"),"set_spacing","get_spacing",SPACING_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_bottom"),"set_spacing","get_spacing",SPACING_BOTTOM);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_char"),"set_spacing","get_spacing",SPACING_CHAR);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing_space"),"set_spacing","get_spacing",SPACING_SPACE);
ADD_GROUP("Font","");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font_data",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font_data",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),"set_font_data","get_font_data");
BIND_CONSTANT( SPACING_TOP );
BIND_CONSTANT( SPACING_BOTTOM );
@@ -938,7 +938,7 @@ RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_
*r_error=ERR_FILE_CANT_OPEN;
Ref<DynamicFontData> dfont;
- dfont.instance();;
+ dfont.instance();
dfont->set_font_path(p_path);
@@ -961,7 +961,7 @@ bool ResourceFormatLoaderDynamicFont::handles_type(const String& p_type) const {
String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const {
- String el = p_path.extension().to_lower();
+ String el = p_path.get_extension().to_lower();
if (el=="ttf" || el=="otf")
return "DynamicFontData";
return "";
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index a25667d85a..c4a182103f 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -260,7 +260,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ //print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
if (tex_index==-1) {
//could not find texture to fit, create one
@@ -378,14 +378,14 @@ DynamicFontAtSize::~DynamicFontAtSize(){
void DynamicFont::_bind_methods() {
- ClassDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ClassDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
+ ClassDB::bind_method(D_METHOD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
+ ClassDB::bind_method(D_METHOD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
- ClassDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ClassDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+ ClassDB::bind_method(D_METHOD("set_size","data"),&DynamicFont::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"),&DynamicFont::get_size);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),"set_size","get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),"set_font_data","get_font_data");
}
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index ffc0a38fc2..f44b37f6f5 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "environment.h"
#include "texture.h"
-#include "globals.h"
+#include "global_config.h"
#include "servers/visual_server.h"
RID Environment::get_rid() const {
@@ -701,257 +701,257 @@ Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const {
void Environment::_bind_methods() {
- ClassDB::bind_method(_MD("set_background","mode"),&Environment::set_background);
- ClassDB::bind_method(_MD("set_skybox","skybox:CubeMap"),&Environment::set_skybox);
- ClassDB::bind_method(_MD("set_skybox_scale","scale"),&Environment::set_skybox_scale);
- ClassDB::bind_method(_MD("set_bg_color","color"),&Environment::set_bg_color);
- ClassDB::bind_method(_MD("set_bg_energy","energy"),&Environment::set_bg_energy);
- ClassDB::bind_method(_MD("set_canvas_max_layer","layer"),&Environment::set_canvas_max_layer);
- ClassDB::bind_method(_MD("set_ambient_light_color","color"),&Environment::set_ambient_light_color);
- ClassDB::bind_method(_MD("set_ambient_light_energy","energy"),&Environment::set_ambient_light_energy);
- ClassDB::bind_method(_MD("set_ambient_light_skybox_contribution","energy"),&Environment::set_ambient_light_skybox_contribution);
+ ClassDB::bind_method(D_METHOD("set_background","mode"),&Environment::set_background);
+ ClassDB::bind_method(D_METHOD("set_skybox","skybox:CubeMap"),&Environment::set_skybox);
+ ClassDB::bind_method(D_METHOD("set_skybox_scale","scale"),&Environment::set_skybox_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);
+ ClassDB::bind_method(D_METHOD("set_canvas_max_layer","layer"),&Environment::set_canvas_max_layer);
+ ClassDB::bind_method(D_METHOD("set_ambient_light_color","color"),&Environment::set_ambient_light_color);
+ ClassDB::bind_method(D_METHOD("set_ambient_light_energy","energy"),&Environment::set_ambient_light_energy);
+ ClassDB::bind_method(D_METHOD("set_ambient_light_skybox_contribution","energy"),&Environment::set_ambient_light_skybox_contribution);
- ClassDB::bind_method(_MD("get_background"),&Environment::get_background);
- ClassDB::bind_method(_MD("get_skybox:CubeMap"),&Environment::get_skybox);
- ClassDB::bind_method(_MD("get_skybox_scale"),&Environment::get_skybox_scale);
- ClassDB::bind_method(_MD("get_bg_color"),&Environment::get_bg_color);
- ClassDB::bind_method(_MD("get_bg_energy"),&Environment::get_bg_energy);
- ClassDB::bind_method(_MD("get_canvas_max_layer"),&Environment::get_canvas_max_layer);
- ClassDB::bind_method(_MD("get_ambient_light_color"),&Environment::get_ambient_light_color);
- ClassDB::bind_method(_MD("get_ambient_light_energy"),&Environment::get_ambient_light_energy);
- ClassDB::bind_method(_MD("get_ambient_light_skybox_contribution"),&Environment::get_ambient_light_skybox_contribution);
+ ClassDB::bind_method(D_METHOD("get_background"),&Environment::get_background);
+ ClassDB::bind_method(D_METHOD("get_skybox:CubeMap"),&Environment::get_skybox);
+ ClassDB::bind_method(D_METHOD("get_skybox_scale"),&Environment::get_skybox_scale);
+ ClassDB::bind_method(D_METHOD("get_bg_color"),&Environment::get_bg_color);
+ ClassDB::bind_method(D_METHOD("get_bg_energy"),&Environment::get_bg_energy);
+ ClassDB::bind_method(D_METHOD("get_canvas_max_layer"),&Environment::get_canvas_max_layer);
+ ClassDB::bind_method(D_METHOD("get_ambient_light_color"),&Environment::get_ambient_light_color);
+ ClassDB::bind_method(D_METHOD("get_ambient_light_energy"),&Environment::get_ambient_light_energy);
+ ClassDB::bind_method(D_METHOD("get_ambient_light_skybox_contribution"),&Environment::get_ambient_light_skybox_contribution);
ADD_GROUP("Background","background_");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"background_mode",PROPERTY_HINT_ENUM,"Clear Color,Custom Color,Skybox,Canvas,Keep"),_SCS("set_background"),_SCS("get_background") );
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"background_skybox",PROPERTY_HINT_RESOURCE_TYPE,"SkyBox"),_SCS("set_skybox"),_SCS("get_skybox") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_skybox_scale",PROPERTY_HINT_RANGE,"0,32,0.01"),_SCS("set_skybox_scale"),_SCS("get_skybox_scale") );
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"background_color"),_SCS("set_bg_color"),_SCS("get_bg_color") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_bg_energy"),_SCS("get_bg_energy") );
- ADD_PROPERTY(PropertyInfo(Variant::INT,"background_canvas_max_layer",PROPERTY_HINT_RANGE,"-1000,1000,1"),_SCS("set_canvas_max_layer"),_SCS("get_canvas_max_layer") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background_mode",PROPERTY_HINT_ENUM,"Clear Color,Custom Color,Skybox,Canvas,Keep"),"set_background","get_background") ;
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"background_skybox",PROPERTY_HINT_RESOURCE_TYPE,"SkyBox"),"set_skybox","get_skybox") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_skybox_scale",PROPERTY_HINT_RANGE,"0,32,0.01"),"set_skybox_scale","get_skybox_scale") ;
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"background_color"),"set_bg_color","get_bg_color") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_bg_energy","get_bg_energy") ;
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background_canvas_max_layer",PROPERTY_HINT_RANGE,"-1000,1000,1"),"set_canvas_max_layer","get_canvas_max_layer") ;
ADD_GROUP("Ambient Light","ambient_light_");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_light_color"),_SCS("set_ambient_light_color"),_SCS("get_ambient_light_color") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_ambient_light_energy"),_SCS("get_ambient_light_energy") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_skybox_contribution",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_ambient_light_skybox_contribution"),_SCS("get_ambient_light_skybox_contribution") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_light_color"),"set_ambient_light_color","get_ambient_light_color") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_ambient_light_energy","get_ambient_light_energy") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light_skybox_contribution",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_ambient_light_skybox_contribution","get_ambient_light_skybox_contribution") ;
- ClassDB::bind_method(_MD("set_ssr_enabled","enabled"),&Environment::set_ssr_enabled);
- ClassDB::bind_method(_MD("is_ssr_enabled"),&Environment::is_ssr_enabled);
+ ClassDB::bind_method(D_METHOD("set_ssr_enabled","enabled"),&Environment::set_ssr_enabled);
+ ClassDB::bind_method(D_METHOD("is_ssr_enabled"),&Environment::is_ssr_enabled);
- ClassDB::bind_method(_MD("set_ssr_max_steps","max_steps"),&Environment::set_ssr_max_steps);
- ClassDB::bind_method(_MD("get_ssr_max_steps"),&Environment::get_ssr_max_steps);
+ ClassDB::bind_method(D_METHOD("set_ssr_max_steps","max_steps"),&Environment::set_ssr_max_steps);
+ ClassDB::bind_method(D_METHOD("get_ssr_max_steps"),&Environment::get_ssr_max_steps);
- ClassDB::bind_method(_MD("set_ssr_accel","accel"),&Environment::set_ssr_accel);
- ClassDB::bind_method(_MD("get_ssr_accel"),&Environment::get_ssr_accel);
+ ClassDB::bind_method(D_METHOD("set_ssr_accel","accel"),&Environment::set_ssr_accel);
+ ClassDB::bind_method(D_METHOD("get_ssr_accel"),&Environment::get_ssr_accel);
- ClassDB::bind_method(_MD("set_ssr_fade","fade"),&Environment::set_ssr_fade);
- ClassDB::bind_method(_MD("get_ssr_fade"),&Environment::get_ssr_fade);
+ ClassDB::bind_method(D_METHOD("set_ssr_fade","fade"),&Environment::set_ssr_fade);
+ ClassDB::bind_method(D_METHOD("get_ssr_fade"),&Environment::get_ssr_fade);
- ClassDB::bind_method(_MD("set_ssr_depth_tolerance","depth_tolerance"),&Environment::set_ssr_depth_tolerance);
- ClassDB::bind_method(_MD("get_ssr_depth_tolerance"),&Environment::get_ssr_depth_tolerance);
+ ClassDB::bind_method(D_METHOD("set_ssr_depth_tolerance","depth_tolerance"),&Environment::set_ssr_depth_tolerance);
+ ClassDB::bind_method(D_METHOD("get_ssr_depth_tolerance"),&Environment::get_ssr_depth_tolerance);
- ClassDB::bind_method(_MD("set_ssr_smooth","smooth"),&Environment::set_ssr_smooth);
- ClassDB::bind_method(_MD("is_ssr_smooth"),&Environment::is_ssr_smooth);
+ ClassDB::bind_method(D_METHOD("set_ssr_smooth","smooth"),&Environment::set_ssr_smooth);
+ ClassDB::bind_method(D_METHOD("is_ssr_smooth"),&Environment::is_ssr_smooth);
- ClassDB::bind_method(_MD("set_ssr_rough","rough"),&Environment::set_ssr_rough);
- ClassDB::bind_method(_MD("is_ssr_rough"),&Environment::is_ssr_rough);
+ ClassDB::bind_method(D_METHOD("set_ssr_rough","rough"),&Environment::set_ssr_rough);
+ ClassDB::bind_method(D_METHOD("is_ssr_rough"),&Environment::is_ssr_rough);
ADD_GROUP("SS Reflections","ss_reflections_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_enabled"),_SCS("set_ssr_enabled"),_SCS("is_ssr_enabled") );
- ADD_PROPERTY(PropertyInfo(Variant::INT,"ss_reflections_max_steps",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_ssr_max_steps"),_SCS("get_ssr_max_steps") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_accel",PROPERTY_HINT_RANGE,"0,4,0.01"),_SCS("set_ssr_accel"),_SCS("get_ssr_accel") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_fade",PROPERTY_HINT_EXP_EASING),_SCS("set_ssr_fade"),_SCS("get_ssr_fade") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_depth_tolerance",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_ssr_depth_tolerance"),_SCS("get_ssr_depth_tolerance") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_accel_smooth"),_SCS("set_ssr_smooth"),_SCS("is_ssr_smooth") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_roughness"),_SCS("set_ssr_rough"),_SCS("is_ssr_rough") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_enabled"),"set_ssr_enabled","is_ssr_enabled") ;
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"ss_reflections_max_steps",PROPERTY_HINT_RANGE,"1,512,1"),"set_ssr_max_steps","get_ssr_max_steps") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_accel",PROPERTY_HINT_RANGE,"0,4,0.01"),"set_ssr_accel","get_ssr_accel") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_fade",PROPERTY_HINT_EXP_EASING),"set_ssr_fade","get_ssr_fade") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections_depth_tolerance",PROPERTY_HINT_RANGE,"0.1,128,0.1"),"set_ssr_depth_tolerance","get_ssr_depth_tolerance") ;
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_accel_smooth"),"set_ssr_smooth","is_ssr_smooth") ;
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections_roughness"),"set_ssr_rough","is_ssr_rough") ;
- ClassDB::bind_method(_MD("set_ssao_enabled","enabled"),&Environment::set_ssao_enabled);
- ClassDB::bind_method(_MD("is_ssao_enabled"),&Environment::is_ssao_enabled);
+ ClassDB::bind_method(D_METHOD("set_ssao_enabled","enabled"),&Environment::set_ssao_enabled);
+ ClassDB::bind_method(D_METHOD("is_ssao_enabled"),&Environment::is_ssao_enabled);
- ClassDB::bind_method(_MD("set_ssao_radius","radius"),&Environment::set_ssao_radius);
- ClassDB::bind_method(_MD("get_ssao_radius"),&Environment::get_ssao_radius);
+ ClassDB::bind_method(D_METHOD("set_ssao_radius","radius"),&Environment::set_ssao_radius);
+ ClassDB::bind_method(D_METHOD("get_ssao_radius"),&Environment::get_ssao_radius);
- ClassDB::bind_method(_MD("set_ssao_intensity","intensity"),&Environment::set_ssao_intensity);
- ClassDB::bind_method(_MD("get_ssao_intensity"),&Environment::get_ssao_intensity);
+ ClassDB::bind_method(D_METHOD("set_ssao_intensity","intensity"),&Environment::set_ssao_intensity);
+ ClassDB::bind_method(D_METHOD("get_ssao_intensity"),&Environment::get_ssao_intensity);
- ClassDB::bind_method(_MD("set_ssao_radius2","radius"),&Environment::set_ssao_radius2);
- ClassDB::bind_method(_MD("get_ssao_radius2"),&Environment::get_ssao_radius2);
+ ClassDB::bind_method(D_METHOD("set_ssao_radius2","radius"),&Environment::set_ssao_radius2);
+ ClassDB::bind_method(D_METHOD("get_ssao_radius2"),&Environment::get_ssao_radius2);
- ClassDB::bind_method(_MD("set_ssao_intensity2","intensity"),&Environment::set_ssao_intensity2);
- ClassDB::bind_method(_MD("get_ssao_intensity2"),&Environment::get_ssao_intensity2);
+ ClassDB::bind_method(D_METHOD("set_ssao_intensity2","intensity"),&Environment::set_ssao_intensity2);
+ ClassDB::bind_method(D_METHOD("get_ssao_intensity2"),&Environment::get_ssao_intensity2);
- ClassDB::bind_method(_MD("set_ssao_bias","bias"),&Environment::set_ssao_bias);
- ClassDB::bind_method(_MD("get_ssao_bias"),&Environment::get_ssao_bias);
+ ClassDB::bind_method(D_METHOD("set_ssao_bias","bias"),&Environment::set_ssao_bias);
+ ClassDB::bind_method(D_METHOD("get_ssao_bias"),&Environment::get_ssao_bias);
- ClassDB::bind_method(_MD("set_ssao_direct_light_affect","amount"),&Environment::set_ssao_direct_light_affect);
- ClassDB::bind_method(_MD("get_ssao_direct_light_affect"),&Environment::get_ssao_direct_light_affect);
+ ClassDB::bind_method(D_METHOD("set_ssao_direct_light_affect","amount"),&Environment::set_ssao_direct_light_affect);
+ ClassDB::bind_method(D_METHOD("get_ssao_direct_light_affect"),&Environment::get_ssao_direct_light_affect);
- ClassDB::bind_method(_MD("set_ssao_color","color"),&Environment::set_ssao_color);
- ClassDB::bind_method(_MD("get_ssao_color"),&Environment::get_ssao_color);
+ ClassDB::bind_method(D_METHOD("set_ssao_color","color"),&Environment::set_ssao_color);
+ ClassDB::bind_method(D_METHOD("get_ssao_color"),&Environment::get_ssao_color);
- ClassDB::bind_method(_MD("set_ssao_blur","enabled"),&Environment::set_ssao_blur);
- ClassDB::bind_method(_MD("is_ssao_blur_enabled"),&Environment::is_ssao_blur_enabled);
+ ClassDB::bind_method(D_METHOD("set_ssao_blur","enabled"),&Environment::set_ssao_blur);
+ ClassDB::bind_method(D_METHOD("is_ssao_blur_enabled"),&Environment::is_ssao_blur_enabled);
ADD_GROUP("SSAO","ssao_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_enabled"),_SCS("set_ssao_enabled"),_SCS("is_ssao_enabled") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius",PROPERTY_HINT_RANGE,"0.1,16,0.1"),_SCS("set_ssao_radius"),_SCS("get_ssao_radius") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity"),_SCS("get_ssao_intensity") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius2",PROPERTY_HINT_RANGE,"0.0,16,0.1"),_SCS("set_ssao_radius2"),_SCS("get_ssao_radius2") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity2",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity2"),_SCS("get_ssao_intensity2") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_bias",PROPERTY_HINT_RANGE,"0.001,8,0.001"),_SCS("set_ssao_bias"),_SCS("get_ssao_bias") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_light_affect",PROPERTY_HINT_RANGE,"0.00,1,0.01"),_SCS("set_ssao_direct_light_affect"),_SCS("get_ssao_direct_light_affect") );
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ssao_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_ssao_color"),_SCS("get_ssao_color") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_blur"),_SCS("set_ssao_blur"),_SCS("is_ssao_blur_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_enabled"),"set_ssao_enabled","is_ssao_enabled") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius",PROPERTY_HINT_RANGE,"0.1,16,0.1"),"set_ssao_radius","get_ssao_radius") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity",PROPERTY_HINT_RANGE,"0.0,9,0.1"),"set_ssao_intensity","get_ssao_intensity") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_radius2",PROPERTY_HINT_RANGE,"0.0,16,0.1"),"set_ssao_radius2","get_ssao_radius2") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_intensity2",PROPERTY_HINT_RANGE,"0.0,9,0.1"),"set_ssao_intensity2","get_ssao_intensity2") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_bias",PROPERTY_HINT_RANGE,"0.001,8,0.001"),"set_ssao_bias","get_ssao_bias") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ssao_light_affect",PROPERTY_HINT_RANGE,"0.00,1,0.01"),"set_ssao_direct_light_affect","get_ssao_direct_light_affect") ;
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ssao_color",PROPERTY_HINT_COLOR_NO_ALPHA),"set_ssao_color","get_ssao_color") ;
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ssao_blur"),"set_ssao_blur","is_ssao_blur_enabled") ;
- ClassDB::bind_method(_MD("set_dof_blur_far_enabled","enabled"),&Environment::set_dof_blur_far_enabled);
- ClassDB::bind_method(_MD("is_dof_blur_far_enabled"),&Environment::is_dof_blur_far_enabled);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_far_enabled","enabled"),&Environment::set_dof_blur_far_enabled);
+ ClassDB::bind_method(D_METHOD("is_dof_blur_far_enabled"),&Environment::is_dof_blur_far_enabled);
- ClassDB::bind_method(_MD("set_dof_blur_far_distance","intensity"),&Environment::set_dof_blur_far_distance);
- ClassDB::bind_method(_MD("get_dof_blur_far_distance"),&Environment::get_dof_blur_far_distance);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_far_distance","intensity"),&Environment::set_dof_blur_far_distance);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_far_distance"),&Environment::get_dof_blur_far_distance);
- ClassDB::bind_method(_MD("set_dof_blur_far_transition","intensity"),&Environment::set_dof_blur_far_transition);
- ClassDB::bind_method(_MD("get_dof_blur_far_transition"),&Environment::get_dof_blur_far_transition);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_far_transition","intensity"),&Environment::set_dof_blur_far_transition);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_far_transition"),&Environment::get_dof_blur_far_transition);
- ClassDB::bind_method(_MD("set_dof_blur_far_amount","intensity"),&Environment::set_dof_blur_far_amount);
- ClassDB::bind_method(_MD("get_dof_blur_far_amount"),&Environment::get_dof_blur_far_amount);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_far_amount","intensity"),&Environment::set_dof_blur_far_amount);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_far_amount"),&Environment::get_dof_blur_far_amount);
- ClassDB::bind_method(_MD("set_dof_blur_far_quality","intensity"),&Environment::set_dof_blur_far_quality);
- ClassDB::bind_method(_MD("get_dof_blur_far_quality"),&Environment::get_dof_blur_far_quality);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_far_quality","intensity"),&Environment::set_dof_blur_far_quality);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_far_quality"),&Environment::get_dof_blur_far_quality);
- ClassDB::bind_method(_MD("set_dof_blur_near_enabled","enabled"),&Environment::set_dof_blur_near_enabled);
- ClassDB::bind_method(_MD("is_dof_blur_near_enabled"),&Environment::is_dof_blur_near_enabled);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_near_enabled","enabled"),&Environment::set_dof_blur_near_enabled);
+ ClassDB::bind_method(D_METHOD("is_dof_blur_near_enabled"),&Environment::is_dof_blur_near_enabled);
- ClassDB::bind_method(_MD("set_dof_blur_near_distance","intensity"),&Environment::set_dof_blur_near_distance);
- ClassDB::bind_method(_MD("get_dof_blur_near_distance"),&Environment::get_dof_blur_near_distance);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_near_distance","intensity"),&Environment::set_dof_blur_near_distance);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_near_distance"),&Environment::get_dof_blur_near_distance);
- ClassDB::bind_method(_MD("set_dof_blur_near_transition","intensity"),&Environment::set_dof_blur_near_transition);
- ClassDB::bind_method(_MD("get_dof_blur_near_transition"),&Environment::get_dof_blur_near_transition);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_near_transition","intensity"),&Environment::set_dof_blur_near_transition);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_near_transition"),&Environment::get_dof_blur_near_transition);
- ClassDB::bind_method(_MD("set_dof_blur_near_amount","intensity"),&Environment::set_dof_blur_near_amount);
- ClassDB::bind_method(_MD("get_dof_blur_near_amount"),&Environment::get_dof_blur_near_amount);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_near_amount","intensity"),&Environment::set_dof_blur_near_amount);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_near_amount"),&Environment::get_dof_blur_near_amount);
- ClassDB::bind_method(_MD("set_dof_blur_near_quality","level"),&Environment::set_dof_blur_near_quality);
- ClassDB::bind_method(_MD("get_dof_blur_near_quality"),&Environment::get_dof_blur_near_quality);
+ ClassDB::bind_method(D_METHOD("set_dof_blur_near_quality","level"),&Environment::set_dof_blur_near_quality);
+ ClassDB::bind_method(D_METHOD("get_dof_blur_near_quality"),&Environment::get_dof_blur_near_quality);
ADD_GROUP("DOF Far Blur","dof_blur_far_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_far_enabled"),_SCS("set_dof_blur_far_enabled"),_SCS("is_dof_blur_far_enabled") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_distance"),_SCS("get_dof_blur_far_distance") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_transition"),_SCS("get_dof_blur_far_transition") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_far_amount"),_SCS("get_dof_blur_far_amount") );
- ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_far_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_far_quality"),_SCS("get_dof_blur_far_quality") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_far_enabled"),"set_dof_blur_far_enabled","is_dof_blur_far_enabled") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),"set_dof_blur_far_distance","get_dof_blur_far_distance") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),"set_dof_blur_far_transition","get_dof_blur_far_transition") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_dof_blur_far_amount","get_dof_blur_far_amount") ;
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_far_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),"set_dof_blur_far_quality","get_dof_blur_far_quality") ;
ADD_GROUP("DOF Far Near","dof_blur_near_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_near_enabled"),_SCS("set_dof_blur_near_enabled"),_SCS("is_dof_blur_near_enabled") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_distance"),_SCS("get_dof_blur_near_distance") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_transition"),_SCS("get_dof_blur_near_transition") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_near_amount"),_SCS("get_dof_blur_near_amount") );
- ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_near_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_near_quality"),_SCS("get_dof_blur_near_quality") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_near_enabled"),"set_dof_blur_near_enabled","is_dof_blur_near_enabled") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),"set_dof_blur_near_distance","get_dof_blur_near_distance") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),"set_dof_blur_near_transition","get_dof_blur_near_transition") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_dof_blur_near_amount","get_dof_blur_near_amount") ;
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_near_quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),"set_dof_blur_near_quality","get_dof_blur_near_quality") ;
- ClassDB::bind_method(_MD("set_glow_enabled","enabled"),&Environment::set_glow_enabled);
- ClassDB::bind_method(_MD("is_glow_enabled"),&Environment::is_glow_enabled);
+ ClassDB::bind_method(D_METHOD("set_glow_enabled","enabled"),&Environment::set_glow_enabled);
+ ClassDB::bind_method(D_METHOD("is_glow_enabled"),&Environment::is_glow_enabled);
- ClassDB::bind_method(_MD("set_glow_level","idx","enabled"),&Environment::set_glow_level);
- ClassDB::bind_method(_MD("is_glow_level_enabled","idx"),&Environment::is_glow_level_enabled);
+ ClassDB::bind_method(D_METHOD("set_glow_level","idx","enabled"),&Environment::set_glow_level);
+ ClassDB::bind_method(D_METHOD("is_glow_level_enabled","idx"),&Environment::is_glow_level_enabled);
- ClassDB::bind_method(_MD("set_glow_intensity","intensity"),&Environment::set_glow_intensity);
- ClassDB::bind_method(_MD("get_glow_intensity"),&Environment::get_glow_intensity);
+ ClassDB::bind_method(D_METHOD("set_glow_intensity","intensity"),&Environment::set_glow_intensity);
+ ClassDB::bind_method(D_METHOD("get_glow_intensity"),&Environment::get_glow_intensity);
- ClassDB::bind_method(_MD("set_glow_strength","strength"),&Environment::set_glow_strength);
- ClassDB::bind_method(_MD("get_glow_strength"),&Environment::get_glow_strength);
+ ClassDB::bind_method(D_METHOD("set_glow_strength","strength"),&Environment::set_glow_strength);
+ ClassDB::bind_method(D_METHOD("get_glow_strength"),&Environment::get_glow_strength);
- ClassDB::bind_method(_MD("set_glow_bloom","amount"),&Environment::set_glow_bloom);
- ClassDB::bind_method(_MD("get_glow_bloom"),&Environment::get_glow_bloom);
+ ClassDB::bind_method(D_METHOD("set_glow_bloom","amount"),&Environment::set_glow_bloom);
+ ClassDB::bind_method(D_METHOD("get_glow_bloom"),&Environment::get_glow_bloom);
- ClassDB::bind_method(_MD("set_glow_blend_mode","mode"),&Environment::set_glow_blend_mode);
- ClassDB::bind_method(_MD("get_glow_blend_mode"),&Environment::get_glow_blend_mode);
+ 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(_MD("set_glow_hdr_bleed_treshold","treshold"),&Environment::set_glow_hdr_bleed_treshold);
- ClassDB::bind_method(_MD("get_glow_hdr_bleed_treshold"),&Environment::get_glow_hdr_bleed_treshold);
+ 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(_MD("set_glow_hdr_bleed_scale","scale"),&Environment::set_glow_hdr_bleed_scale);
- ClassDB::bind_method(_MD("get_glow_hdr_bleed_scale"),&Environment::get_glow_hdr_bleed_scale);
+ 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);
- ClassDB::bind_method(_MD("set_glow_bicubic_upscale","enabled"),&Environment::set_glow_bicubic_upscale);
- ClassDB::bind_method(_MD("is_glow_bicubic_upscale_enabled"),&Environment::is_glow_bicubic_upscale_enabled);
+ ClassDB::bind_method(D_METHOD("set_glow_bicubic_upscale","enabled"),&Environment::set_glow_bicubic_upscale);
+ ClassDB::bind_method(D_METHOD("is_glow_bicubic_upscale_enabled"),&Environment::is_glow_bicubic_upscale_enabled);
ADD_GROUP("Glow","glow_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow_enabled"),_SCS("set_glow_enabled"),_SCS("is_glow_enabled") );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/1"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),0 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/2"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),1 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/3"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),2 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/4"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),3 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/5"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),4 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/6"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),5 );
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/7"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),6 );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow_enabled"),"set_glow_enabled","is_glow_enabled") ;
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/1"),"set_glow_level","is_glow_level_enabled",0 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/2"),"set_glow_level","is_glow_level_enabled",1 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/3"),"set_glow_level","is_glow_level_enabled",2 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/4"),"set_glow_level","is_glow_level_enabled",3 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/5"),"set_glow_level","is_glow_level_enabled",4 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/6"),"set_glow_level","is_glow_level_enabled",5 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow_levels/7"),"set_glow_level","is_glow_level_enabled",6 );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_intensity",PROPERTY_HINT_RANGE,"0.0,8.0,0.01"),_SCS("set_glow_intensity"),_SCS("get_glow_intensity") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_strength",PROPERTY_HINT_RANGE,"0.0,2.0,0.01"),_SCS("set_glow_strength"),_SCS("get_glow_strength") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_bloom",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_glow_bloom"),_SCS("get_glow_bloom") );
- ADD_PROPERTY(PropertyInfo(Variant::INT,"glow_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,Softlight,Replace"),_SCS("set_glow_blend_mode"),_SCS("get_glow_blend_mode") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_hdr_treshold",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_treshold"),_SCS("get_glow_hdr_bleed_treshold") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_hdr_scale",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_scale"),_SCS("get_glow_hdr_bleed_scale") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow_bicubic_upscale"),_SCS("set_glow_bicubic_upscale"),_SCS("is_glow_bicubic_upscale_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow_intensity",PROPERTY_HINT_RANGE,"0.0,8.0,0.01"),"set_glow_intensity","get_glow_intensity") ;
+ 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_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") ;
- ClassDB::bind_method(_MD("set_tonemapper","mode"),&Environment::set_tonemapper);
- ClassDB::bind_method(_MD("get_tonemapper"),&Environment::get_tonemapper);
+ ClassDB::bind_method(D_METHOD("set_tonemapper","mode"),&Environment::set_tonemapper);
+ ClassDB::bind_method(D_METHOD("get_tonemapper"),&Environment::get_tonemapper);
- ClassDB::bind_method(_MD("set_tonemap_exposure","exposure"),&Environment::set_tonemap_exposure);
- ClassDB::bind_method(_MD("get_tonemap_exposure"),&Environment::get_tonemap_exposure);
+ ClassDB::bind_method(D_METHOD("set_tonemap_exposure","exposure"),&Environment::set_tonemap_exposure);
+ ClassDB::bind_method(D_METHOD("get_tonemap_exposure"),&Environment::get_tonemap_exposure);
- ClassDB::bind_method(_MD("set_tonemap_white","white"),&Environment::set_tonemap_white);
- ClassDB::bind_method(_MD("get_tonemap_white"),&Environment::get_tonemap_white);
+ ClassDB::bind_method(D_METHOD("set_tonemap_white","white"),&Environment::set_tonemap_white);
+ ClassDB::bind_method(D_METHOD("get_tonemap_white"),&Environment::get_tonemap_white);
- ClassDB::bind_method(_MD("set_tonemap_auto_exposure","auto_exposure"),&Environment::set_tonemap_auto_exposure);
- ClassDB::bind_method(_MD("get_tonemap_auto_exposure"),&Environment::get_tonemap_auto_exposure);
+ ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure","auto_exposure"),&Environment::set_tonemap_auto_exposure);
+ ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure"),&Environment::get_tonemap_auto_exposure);
- ClassDB::bind_method(_MD("set_tonemap_auto_exposure_max","exposure_max"),&Environment::set_tonemap_auto_exposure_max);
- ClassDB::bind_method(_MD("get_tonemap_auto_exposure_max"),&Environment::get_tonemap_auto_exposure_max);
+ ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_max","exposure_max"),&Environment::set_tonemap_auto_exposure_max);
+ ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_max"),&Environment::get_tonemap_auto_exposure_max);
- ClassDB::bind_method(_MD("set_tonemap_auto_exposure_min","exposure_min"),&Environment::set_tonemap_auto_exposure_min);
- ClassDB::bind_method(_MD("get_tonemap_auto_exposure_min"),&Environment::get_tonemap_auto_exposure_min);
+ ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_min","exposure_min"),&Environment::set_tonemap_auto_exposure_min);
+ ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_min"),&Environment::get_tonemap_auto_exposure_min);
- ClassDB::bind_method(_MD("set_tonemap_auto_exposure_speed","exposure_speed"),&Environment::set_tonemap_auto_exposure_speed);
- ClassDB::bind_method(_MD("get_tonemap_auto_exposure_speed"),&Environment::get_tonemap_auto_exposure_speed);
+ ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_speed","exposure_speed"),&Environment::set_tonemap_auto_exposure_speed);
+ ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_speed"),&Environment::get_tonemap_auto_exposure_speed);
- ClassDB::bind_method(_MD("set_tonemap_auto_exposure_grey","exposure_grey"),&Environment::set_tonemap_auto_exposure_grey);
- ClassDB::bind_method(_MD("get_tonemap_auto_exposure_grey"),&Environment::get_tonemap_auto_exposure_grey);
+ ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_grey","exposure_grey"),&Environment::set_tonemap_auto_exposure_grey);
+ ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_grey"),&Environment::get_tonemap_auto_exposure_grey);
ADD_GROUP("Tonemap","tonemap_");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap_mode",PROPERTY_HINT_ENUM,"Linear,Reindhart,Filmic,Aces"),_SCS("set_tonemapper"),_SCS("get_tonemapper") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_exposure",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_exposure"),_SCS("get_tonemap_exposure") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_white",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_white"),_SCS("get_tonemap_white") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap_mode",PROPERTY_HINT_ENUM,"Linear,Reindhart,Filmic,Aces"),"set_tonemapper","get_tonemapper") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_exposure",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_tonemap_exposure","get_tonemap_exposure") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap_white",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_tonemap_white","get_tonemap_white") ;
ADD_GROUP("Auto Exposure","auto_exposure_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"auto_expoure_enabled"),_SCS("set_tonemap_auto_exposure"),_SCS("get_tonemap_auto_exposure") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_grey"),_SCS("get_tonemap_auto_exposure_grey") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_min_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_min"),_SCS("get_tonemap_auto_exposure_min") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_max_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_max"),_SCS("get_tonemap_auto_exposure_max") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_speed",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_speed"),_SCS("get_tonemap_auto_exposure_speed") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"auto_expoure_enabled"),"set_tonemap_auto_exposure","get_tonemap_auto_exposure") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_tonemap_auto_exposure_grey","get_tonemap_auto_exposure_grey") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_min_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_tonemap_auto_exposure_min","get_tonemap_auto_exposure_min") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_max_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_tonemap_auto_exposure_max","get_tonemap_auto_exposure_max") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_expoure_speed",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_tonemap_auto_exposure_speed","get_tonemap_auto_exposure_speed") ;
- ClassDB::bind_method(_MD("set_adjustment_enable","enabled"),&Environment::set_adjustment_enable);
- ClassDB::bind_method(_MD("is_adjustment_enabled"),&Environment::is_adjustment_enabled);
+ ClassDB::bind_method(D_METHOD("set_adjustment_enable","enabled"),&Environment::set_adjustment_enable);
+ ClassDB::bind_method(D_METHOD("is_adjustment_enabled"),&Environment::is_adjustment_enabled);
- ClassDB::bind_method(_MD("set_adjustment_brightness","brightness"),&Environment::set_adjustment_brightness);
- ClassDB::bind_method(_MD("get_adjustment_brightness"),&Environment::get_adjustment_brightness);
+ ClassDB::bind_method(D_METHOD("set_adjustment_brightness","brightness"),&Environment::set_adjustment_brightness);
+ ClassDB::bind_method(D_METHOD("get_adjustment_brightness"),&Environment::get_adjustment_brightness);
- ClassDB::bind_method(_MD("set_adjustment_contrast","contrast"),&Environment::set_adjustment_contrast);
- ClassDB::bind_method(_MD("get_adjustment_contrast"),&Environment::get_adjustment_contrast);
+ ClassDB::bind_method(D_METHOD("set_adjustment_contrast","contrast"),&Environment::set_adjustment_contrast);
+ ClassDB::bind_method(D_METHOD("get_adjustment_contrast"),&Environment::get_adjustment_contrast);
- ClassDB::bind_method(_MD("set_adjustment_saturation","saturation"),&Environment::set_adjustment_saturation);
- ClassDB::bind_method(_MD("get_adjustment_saturation"),&Environment::get_adjustment_saturation);
+ 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(_MD("set_adjustment_color_correction","color_correction"),&Environment::set_adjustment_color_correction);
- ClassDB::bind_method(_MD("get_adjustment_color_correction"),&Environment::get_adjustment_color_correction);
+ 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);
ADD_GROUP("Adjustments","adjustment_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"adjustment_enabled"),_SCS("set_adjustment_enable"),_SCS("is_adjustment_enabled") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_brightness"),_SCS("get_adjustment_brightness") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_contrast"),_SCS("get_adjustment_contrast") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_saturation"),_SCS("get_adjustment_saturation") );
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"adjustment_color_correction",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_adjustment_color_correction"),_SCS("get_adjustment_color_correction") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"adjustment_enabled"),"set_adjustment_enable","is_adjustment_enabled") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),"set_adjustment_brightness","get_adjustment_brightness") ;
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment_contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),"set_adjustment_contrast","get_adjustment_contrast") ;
+ 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/skybox/irradiance_cube_resolution",256);
diff --git a/scene/resources/event_stream.cpp b/scene/resources/event_stream.cpp
deleted file mode 100644
index 521f305327..0000000000
--- a/scene/resources/event_stream.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*************************************************************************/
-/* event_stream.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "event_stream.h"
-
-
-Error EventStreamPlayback::play() {
- if (stream.is_valid())
- stop();
-
- Error err = _play();
- if (err)
- return err;
-
-
- playing=true;
- AudioServer::get_singleton()->stream_set_active(stream,true);
-
- return OK;
-}
-
-void EventStreamPlayback::stop(){
-
- if (!playing)
- return;
-
- AudioServer::get_singleton()->stream_set_active(stream,false);
- _stop();
- playing=false;
-
-
-}
-bool EventStreamPlayback::is_playing() const{
-
- return playing;
-}
-
-
-EventStreamPlayback::EventStreamPlayback() {
-
- playing=false;
- estream.playback=this;
- stream=AudioServer::get_singleton()->event_stream_create(&estream);
-
-}
-
-EventStreamPlayback::~EventStreamPlayback() {
-
- AudioServer::get_singleton()->free(stream);
-
-}
-
-
-
-EventStream::EventStream()
-{
-
-
-}
-
diff --git a/scene/resources/event_stream.h b/scene/resources/event_stream.h
deleted file mode 100644
index 40af78fcce..0000000000
--- a/scene/resources/event_stream.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************/
-/* event_stream.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 EVENT_STREAM_H
-#define EVENT_STREAM_H
-
-#include "resource.h"
-#include "servers/audio_server.h"
-
-class EventStreamPlayback : public Reference {
-
- GDCLASS(EventStreamPlayback,Reference);
-
- class InternalEventStream : public AudioServer::EventStream {
- public:
- AudioMixer *_get_mixer(){ return get_mixer(); }
- EventStreamPlayback *playback;
- virtual void update(uint64_t p_usec) {
-
- playback->_update(get_mixer(),p_usec);
- }
-
-
- virtual ~InternalEventStream() {}
- };
-
-
- InternalEventStream estream;
-
- RID stream;
- bool playing;
-
-
-protected:
-
- virtual AudioMixer* _get_mixer() { return estream._get_mixer(); }
- virtual Error _play()=0;
- virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec)=0;
- virtual void _stop()=0;
-public:
-
- virtual Error play();
- virtual void stop();
- virtual bool is_playing() const;
-
- virtual void set_paused(bool p_paused)=0;
- virtual bool is_paused() const=0;
-
- virtual void set_loop(bool p_loop)=0;
- virtual bool is_loop_enabled() const=0;
-
- virtual int get_loop_count() const=0;
-
- virtual float get_pos() const=0;
- virtual void seek_pos(float p_time)=0;
-
- virtual void set_volume(float p_vol)=0;
- virtual float get_volume() const=0;
-
- virtual void set_pitch_scale(float p_pitch_scale)=0;
- virtual float get_pitch_scale() const=0;
-
- virtual void set_tempo_scale(float p_tempo_scale)=0;
- virtual float get_tempo_scale() const=0;
-
- virtual void set_channel_volume(int p_channel,float p_volume)=0;
- virtual float get_channel_volume(int p_channel) const=0;
-
- virtual float get_last_note_time(int p_channel) const=0;
- EventStreamPlayback();
- ~EventStreamPlayback();
-
-};
-
-class EventStream : public Resource {
-
- GDCLASS(EventStream,Resource);
- OBJ_SAVE_TYPE( EventStream ); //children are all saved as EventStream, so they can be exchanged
-
-public:
-
- virtual Ref<EventStreamPlayback> instance_playback()=0;
-
- virtual String get_stream_name() const=0;
- virtual float get_length() const=0;
- virtual int get_channel_count() const=0;
-
-
-
- EventStream();
-};
-
-#endif // EVENT_STREAM_H
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 3373478336..d94e046b98 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -78,14 +78,14 @@ void Font::update_changes() {
void Font::_bind_methods() {
- ClassDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ClassDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
- ClassDB::bind_method(_MD("get_descent"),&Font::get_descent);
- ClassDB::bind_method(_MD("get_height"),&Font::get_height);
- ClassDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
- ClassDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
- ClassDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
- ClassDB::bind_method(_MD("update_changes"),&Font::update_changes);
+ ClassDB::bind_method(D_METHOD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("get_ascent"),&Font::get_ascent);
+ ClassDB::bind_method(D_METHOD("get_descent"),&Font::get_descent);
+ ClassDB::bind_method(D_METHOD("get_height"),&Font::get_height);
+ ClassDB::bind_method(D_METHOD("is_distance_field_hint"),&Font::is_distance_field_hint);
+ ClassDB::bind_method(D_METHOD("get_string_size","string"),&Font::get_string_size);
+ ClassDB::bind_method(D_METHOD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
+ ClassDB::bind_method(D_METHOD("update_changes"),&Font::update_changes);
}
@@ -252,8 +252,10 @@ Error BitmapFont::create_from_fnt(const String& p_string) {
if (keys.has("face"))
set_name(keys["face"]);
- //if (keys.has("size"))
- // font->set_height(keys["size"].to_int());
+ /*
+ if (keys.has("size"))
+ font->set_height(keys["size"].to_int());
+ */
} else if (type=="common") {
@@ -564,48 +566,48 @@ Size2 BitmapFont::get_char_size(CharType p_char,CharType p_next) const {
void BitmapFont::_bind_methods() {
- ClassDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
- ClassDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);
+ ClassDB::bind_method(D_METHOD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
+ ClassDB::bind_method(D_METHOD("set_height","px"),&BitmapFont::set_height);
- ClassDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);
+ ClassDB::bind_method(D_METHOD("set_ascent","px"),&BitmapFont::set_ascent);
- ClassDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
- ClassDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
+ ClassDB::bind_method(D_METHOD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
+ ClassDB::bind_method(D_METHOD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
- ClassDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
- ClassDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("add_texture","texture:Texture"),&BitmapFont::add_texture);
+ ClassDB::bind_method(D_METHOD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
- ClassDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
- ClassDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);
+ ClassDB::bind_method(D_METHOD("get_texture_count"),&BitmapFont::get_texture_count);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture","idx"),&BitmapFont::get_texture);
- ClassDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
- ClassDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
+ ClassDB::bind_method(D_METHOD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
- ClassDB::bind_method(_MD("clear"),&BitmapFont::clear);
+ ClassDB::bind_method(D_METHOD("clear"),&BitmapFont::clear);
- ClassDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
- ClassDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);
+ ClassDB::bind_method(D_METHOD("_set_chars"),&BitmapFont::_set_chars);
+ ClassDB::bind_method(D_METHOD("_get_chars"),&BitmapFont::_get_chars);
- ClassDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
- ClassDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);
+ ClassDB::bind_method(D_METHOD("_set_kernings"),&BitmapFont::_set_kernings);
+ ClassDB::bind_method(D_METHOD("_get_kernings"),&BitmapFont::_get_kernings);
- ClassDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
- ClassDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);
+ ClassDB::bind_method(D_METHOD("_set_textures"),&BitmapFont::_set_textures);
+ ClassDB::bind_method(D_METHOD("_get_textures"),&BitmapFont::_get_textures);
- ClassDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
- ClassDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);
+ ClassDB::bind_method(D_METHOD("set_fallback","fallback"),&BitmapFont::set_fallback);
+ ClassDB::bind_method(D_METHOD("get_fallback"),&BitmapFont::get_fallback);
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") );
- ADD_PROPERTY( PropertyInfo( Variant::POOL_INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
- ADD_PROPERTY( PropertyInfo( Variant::POOL_INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_kernings"), _SCS("_get_kernings") );
+ 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") ;
+ ADD_PROPERTY( PropertyInfo( Variant::POOL_INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), "_set_kernings", "_get_kernings") ;
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"BitmapFont" ), _SCS("set_fallback"), _SCS("get_fallback") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), "set_height", "get_height") ;
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), "set_ascent", "get_ascent") ;
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), "set_distance_field_hint", "is_distance_field_hint") ;
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"BitmapFont" ), "set_fallback", "get_fallback") ;
}
diff --git a/scene/resources/gibberish_stream.cpp b/scene/resources/gibberish_stream.cpp
index 3a6a6df7ea..fdc5bf01e8 100644
--- a/scene/resources/gibberish_stream.cpp
+++ b/scene/resources/gibberish_stream.cpp
@@ -305,22 +305,22 @@ float AudioStreamGibberish::get_pitch_random_scale() const {
void AudioStreamGibberish::_bind_methods() {
- ClassDB::bind_method(_MD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
- ClassDB::bind_method(_MD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
+ ClassDB::bind_method(D_METHOD("set_phonemes","phonemes"),&AudioStreamGibberish::set_phonemes);
+ ClassDB::bind_method(D_METHOD("get_phonemes"),&AudioStreamGibberish::get_phonemes);
- ClassDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
- ClassDB::bind_method(_MD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
+ ClassDB::bind_method(D_METHOD("set_pitch_scale","pitch_scale"),&AudioStreamGibberish::set_pitch_scale);
+ ClassDB::bind_method(D_METHOD("get_pitch_scale"),&AudioStreamGibberish::get_pitch_scale);
- ClassDB::bind_method(_MD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
- ClassDB::bind_method(_MD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
+ ClassDB::bind_method(D_METHOD("set_pitch_random_scale","pitch_random_scale"),&AudioStreamGibberish::set_pitch_random_scale);
+ ClassDB::bind_method(D_METHOD("get_pitch_random_scale"),&AudioStreamGibberish::get_pitch_random_scale);
- ClassDB::bind_method(_MD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
- ClassDB::bind_method(_MD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
+ ClassDB::bind_method(D_METHOD("set_xfade_time","sec"),&AudioStreamGibberish::set_xfade_time);
+ ClassDB::bind_method(D_METHOD("get_xfade_time"),&AudioStreamGibberish::get_xfade_time);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_phonemes"),_SCS("get_phonemes"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_pitch_scale"),_SCS("get_pitch_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_random_scale",PROPERTY_HINT_RANGE,"0,64,0.01"),_SCS("set_pitch_random_scale"),_SCS("get_pitch_random_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"xfade_sec",PROPERTY_HINT_RANGE,"0.001,0.5,0.001"),_SCS("set_xfade_time"),_SCS("get_xfade_time"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"phonemes",PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),"set_phonemes","get_phonemes");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),"set_pitch_scale","get_pitch_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"pitch_random_scale",PROPERTY_HINT_RANGE,"0,64,0.01"),"set_pitch_random_scale","get_pitch_random_scale");
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"xfade_sec",PROPERTY_HINT_RANGE,"0.001,0.5,0.001"),"set_xfade_time","get_xfade_time");
}
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 112ecaae2f..3780c466a5 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -339,7 +339,7 @@ void FixedSpatialMaterial::_update_shader() {
code+="\tROUGHNESS = specular_tex.a * roughness;\n";
} else {
code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
- code+="\tSPECULAR = vec3(metalness * specular_tex.r);\n";
+ code+="\tSPECULAR = vec3(ALBEDO.rgb * metalness * specular_tex.r);\n";
code+="\tROUGHNESS = specular_tex.a * roughness;\n";
}
@@ -732,7 +732,7 @@ Ref<Texture> FixedSpatialMaterial::get_texture(TextureParam p_param) const {
void FixedSpatialMaterial::_validate_feature(const String& text, Feature feature,PropertyInfo& property) const {
- if (property.name.begins_with(text) && property.name!=text+"/enabled" && !features[feature]) {
+ if (property.name.begins_with(text) && property.name!=text+"_enabled" && !features[feature]) {
property.usage=0;
}
@@ -831,193 +831,193 @@ Vector2 FixedSpatialMaterial::get_uv2_offset() const{
void FixedSpatialMaterial::_bind_methods() {
- ClassDB::bind_method(_MD("set_albedo","albedo"),&FixedSpatialMaterial::set_albedo);
- ClassDB::bind_method(_MD("get_albedo"),&FixedSpatialMaterial::get_albedo);
+ ClassDB::bind_method(D_METHOD("set_albedo","albedo"),&FixedSpatialMaterial::set_albedo);
+ ClassDB::bind_method(D_METHOD("get_albedo"),&FixedSpatialMaterial::get_albedo);
- ClassDB::bind_method(_MD("set_specular_mode","specular_mode"),&FixedSpatialMaterial::set_specular_mode);
- ClassDB::bind_method(_MD("get_specular_mode"),&FixedSpatialMaterial::get_specular_mode);
+ ClassDB::bind_method(D_METHOD("set_specular_mode","specular_mode"),&FixedSpatialMaterial::set_specular_mode);
+ ClassDB::bind_method(D_METHOD("get_specular_mode"),&FixedSpatialMaterial::get_specular_mode);
- ClassDB::bind_method(_MD("set_specular","specular"),&FixedSpatialMaterial::set_specular);
- ClassDB::bind_method(_MD("get_specular"),&FixedSpatialMaterial::get_specular);
+ ClassDB::bind_method(D_METHOD("set_specular","specular"),&FixedSpatialMaterial::set_specular);
+ ClassDB::bind_method(D_METHOD("get_specular"),&FixedSpatialMaterial::get_specular);
- ClassDB::bind_method(_MD("set_metalness","metalness"),&FixedSpatialMaterial::set_metalness);
- ClassDB::bind_method(_MD("get_metalness"),&FixedSpatialMaterial::get_metalness);
+ ClassDB::bind_method(D_METHOD("set_metalness","metalness"),&FixedSpatialMaterial::set_metalness);
+ ClassDB::bind_method(D_METHOD("get_metalness"),&FixedSpatialMaterial::get_metalness);
- ClassDB::bind_method(_MD("set_roughness","roughness"),&FixedSpatialMaterial::set_roughness);
- ClassDB::bind_method(_MD("get_roughness"),&FixedSpatialMaterial::get_roughness);
+ ClassDB::bind_method(D_METHOD("set_roughness","roughness"),&FixedSpatialMaterial::set_roughness);
+ ClassDB::bind_method(D_METHOD("get_roughness"),&FixedSpatialMaterial::get_roughness);
- ClassDB::bind_method(_MD("set_emission","emission"),&FixedSpatialMaterial::set_emission);
- ClassDB::bind_method(_MD("get_emission"),&FixedSpatialMaterial::get_emission);
+ ClassDB::bind_method(D_METHOD("set_emission","emission"),&FixedSpatialMaterial::set_emission);
+ ClassDB::bind_method(D_METHOD("get_emission"),&FixedSpatialMaterial::get_emission);
- ClassDB::bind_method(_MD("set_emission_energy","emission_energy"),&FixedSpatialMaterial::set_emission_energy);
- ClassDB::bind_method(_MD("get_emission_energy"),&FixedSpatialMaterial::get_emission_energy);
+ ClassDB::bind_method(D_METHOD("set_emission_energy","emission_energy"),&FixedSpatialMaterial::set_emission_energy);
+ ClassDB::bind_method(D_METHOD("get_emission_energy"),&FixedSpatialMaterial::get_emission_energy);
- ClassDB::bind_method(_MD("set_normal_scale","normal_scale"),&FixedSpatialMaterial::set_normal_scale);
- ClassDB::bind_method(_MD("get_normal_scale"),&FixedSpatialMaterial::get_normal_scale);
+ ClassDB::bind_method(D_METHOD("set_normal_scale","normal_scale"),&FixedSpatialMaterial::set_normal_scale);
+ ClassDB::bind_method(D_METHOD("get_normal_scale"),&FixedSpatialMaterial::get_normal_scale);
- ClassDB::bind_method(_MD("set_rim","rim"),&FixedSpatialMaterial::set_rim);
- ClassDB::bind_method(_MD("get_rim"),&FixedSpatialMaterial::get_rim);
+ ClassDB::bind_method(D_METHOD("set_rim","rim"),&FixedSpatialMaterial::set_rim);
+ ClassDB::bind_method(D_METHOD("get_rim"),&FixedSpatialMaterial::get_rim);
- ClassDB::bind_method(_MD("set_rim_tint","rim_tint"),&FixedSpatialMaterial::set_rim_tint);
- ClassDB::bind_method(_MD("get_rim_tint"),&FixedSpatialMaterial::get_rim_tint);
+ ClassDB::bind_method(D_METHOD("set_rim_tint","rim_tint"),&FixedSpatialMaterial::set_rim_tint);
+ ClassDB::bind_method(D_METHOD("get_rim_tint"),&FixedSpatialMaterial::get_rim_tint);
- ClassDB::bind_method(_MD("set_clearcoat","clearcoat"),&FixedSpatialMaterial::set_clearcoat);
- ClassDB::bind_method(_MD("get_clearcoat"),&FixedSpatialMaterial::get_clearcoat);
+ ClassDB::bind_method(D_METHOD("set_clearcoat","clearcoat"),&FixedSpatialMaterial::set_clearcoat);
+ ClassDB::bind_method(D_METHOD("get_clearcoat"),&FixedSpatialMaterial::get_clearcoat);
- ClassDB::bind_method(_MD("set_clearcoat_gloss","clearcoat_gloss"),&FixedSpatialMaterial::set_clearcoat_gloss);
- ClassDB::bind_method(_MD("get_clearcoat_gloss"),&FixedSpatialMaterial::get_clearcoat_gloss);
+ ClassDB::bind_method(D_METHOD("set_clearcoat_gloss","clearcoat_gloss"),&FixedSpatialMaterial::set_clearcoat_gloss);
+ ClassDB::bind_method(D_METHOD("get_clearcoat_gloss"),&FixedSpatialMaterial::get_clearcoat_gloss);
- ClassDB::bind_method(_MD("set_anisotropy","anisotropy"),&FixedSpatialMaterial::set_anisotropy);
- ClassDB::bind_method(_MD("get_anisotropy"),&FixedSpatialMaterial::get_anisotropy);
+ ClassDB::bind_method(D_METHOD("set_anisotropy","anisotropy"),&FixedSpatialMaterial::set_anisotropy);
+ ClassDB::bind_method(D_METHOD("get_anisotropy"),&FixedSpatialMaterial::get_anisotropy);
- ClassDB::bind_method(_MD("set_height_scale","height_scale"),&FixedSpatialMaterial::set_height_scale);
- ClassDB::bind_method(_MD("get_height_scale"),&FixedSpatialMaterial::get_height_scale);
+ ClassDB::bind_method(D_METHOD("set_height_scale","height_scale"),&FixedSpatialMaterial::set_height_scale);
+ ClassDB::bind_method(D_METHOD("get_height_scale"),&FixedSpatialMaterial::get_height_scale);
- ClassDB::bind_method(_MD("set_subsurface_scattering_strength","strength"),&FixedSpatialMaterial::set_subsurface_scattering_strength);
- ClassDB::bind_method(_MD("get_subsurface_scattering_strength"),&FixedSpatialMaterial::get_subsurface_scattering_strength);
+ ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength","strength"),&FixedSpatialMaterial::set_subsurface_scattering_strength);
+ ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"),&FixedSpatialMaterial::get_subsurface_scattering_strength);
- ClassDB::bind_method(_MD("set_refraction","refraction"),&FixedSpatialMaterial::set_refraction);
- ClassDB::bind_method(_MD("get_refraction"),&FixedSpatialMaterial::get_refraction);
+ ClassDB::bind_method(D_METHOD("set_refraction","refraction"),&FixedSpatialMaterial::set_refraction);
+ ClassDB::bind_method(D_METHOD("get_refraction"),&FixedSpatialMaterial::get_refraction);
- ClassDB::bind_method(_MD("set_refraction_roughness","refraction_roughness"),&FixedSpatialMaterial::set_refraction_roughness);
- ClassDB::bind_method(_MD("get_refraction_roughness"),&FixedSpatialMaterial::get_refraction_roughness);
+ ClassDB::bind_method(D_METHOD("set_refraction_roughness","refraction_roughness"),&FixedSpatialMaterial::set_refraction_roughness);
+ ClassDB::bind_method(D_METHOD("get_refraction_roughness"),&FixedSpatialMaterial::get_refraction_roughness);
- ClassDB::bind_method(_MD("set_line_width","line_width"),&FixedSpatialMaterial::set_line_width);
- ClassDB::bind_method(_MD("get_line_width"),&FixedSpatialMaterial::get_line_width);
+ ClassDB::bind_method(D_METHOD("set_line_width","line_width"),&FixedSpatialMaterial::set_line_width);
+ ClassDB::bind_method(D_METHOD("get_line_width"),&FixedSpatialMaterial::get_line_width);
- ClassDB::bind_method(_MD("set_point_size","point_size"),&FixedSpatialMaterial::set_point_size);
- ClassDB::bind_method(_MD("get_point_size"),&FixedSpatialMaterial::get_point_size);
+ ClassDB::bind_method(D_METHOD("set_point_size","point_size"),&FixedSpatialMaterial::set_point_size);
+ ClassDB::bind_method(D_METHOD("get_point_size"),&FixedSpatialMaterial::get_point_size);
- ClassDB::bind_method(_MD("set_detail_uv","detail_uv"),&FixedSpatialMaterial::set_detail_uv);
- ClassDB::bind_method(_MD("get_detail_uv"),&FixedSpatialMaterial::get_detail_uv);
+ ClassDB::bind_method(D_METHOD("set_detail_uv","detail_uv"),&FixedSpatialMaterial::set_detail_uv);
+ ClassDB::bind_method(D_METHOD("get_detail_uv"),&FixedSpatialMaterial::get_detail_uv);
- ClassDB::bind_method(_MD("set_blend_mode","blend_mode"),&FixedSpatialMaterial::set_blend_mode);
- ClassDB::bind_method(_MD("get_blend_mode"),&FixedSpatialMaterial::get_blend_mode);
+ ClassDB::bind_method(D_METHOD("set_blend_mode","blend_mode"),&FixedSpatialMaterial::set_blend_mode);
+ ClassDB::bind_method(D_METHOD("get_blend_mode"),&FixedSpatialMaterial::get_blend_mode);
- ClassDB::bind_method(_MD("set_depth_draw_mode","depth_draw_mode"),&FixedSpatialMaterial::set_depth_draw_mode);
- ClassDB::bind_method(_MD("get_depth_draw_mode"),&FixedSpatialMaterial::get_depth_draw_mode);
+ ClassDB::bind_method(D_METHOD("set_depth_draw_mode","depth_draw_mode"),&FixedSpatialMaterial::set_depth_draw_mode);
+ ClassDB::bind_method(D_METHOD("get_depth_draw_mode"),&FixedSpatialMaterial::get_depth_draw_mode);
- ClassDB::bind_method(_MD("set_cull_mode","cull_mode"),&FixedSpatialMaterial::set_cull_mode);
- ClassDB::bind_method(_MD("get_cull_mode"),&FixedSpatialMaterial::get_cull_mode);
+ ClassDB::bind_method(D_METHOD("set_cull_mode","cull_mode"),&FixedSpatialMaterial::set_cull_mode);
+ ClassDB::bind_method(D_METHOD("get_cull_mode"),&FixedSpatialMaterial::get_cull_mode);
- ClassDB::bind_method(_MD("set_diffuse_mode","diffuse_mode"),&FixedSpatialMaterial::set_diffuse_mode);
- ClassDB::bind_method(_MD("get_diffuse_mode"),&FixedSpatialMaterial::get_diffuse_mode);
+ ClassDB::bind_method(D_METHOD("set_diffuse_mode","diffuse_mode"),&FixedSpatialMaterial::set_diffuse_mode);
+ ClassDB::bind_method(D_METHOD("get_diffuse_mode"),&FixedSpatialMaterial::get_diffuse_mode);
- ClassDB::bind_method(_MD("set_flag","flag","enable"),&FixedSpatialMaterial::set_flag);
- ClassDB::bind_method(_MD("get_flag"),&FixedSpatialMaterial::get_flag);
+ ClassDB::bind_method(D_METHOD("set_flag","flag","enable"),&FixedSpatialMaterial::set_flag);
+ ClassDB::bind_method(D_METHOD("get_flag"),&FixedSpatialMaterial::get_flag);
- ClassDB::bind_method(_MD("set_feature","feature","enable"),&FixedSpatialMaterial::set_feature);
- ClassDB::bind_method(_MD("get_feature","feature"),&FixedSpatialMaterial::get_feature);
+ ClassDB::bind_method(D_METHOD("set_feature","feature","enable"),&FixedSpatialMaterial::set_feature);
+ ClassDB::bind_method(D_METHOD("get_feature","feature"),&FixedSpatialMaterial::get_feature);
- ClassDB::bind_method(_MD("set_texture","param:Texture","texture"),&FixedSpatialMaterial::set_texture);
- ClassDB::bind_method(_MD("get_texture:Texture","param:Texture"),&FixedSpatialMaterial::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","param:Texture","texture"),&FixedSpatialMaterial::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture","param:Texture"),&FixedSpatialMaterial::get_texture);
- ClassDB::bind_method(_MD("set_detail_blend_mode","detail_blend_mode"),&FixedSpatialMaterial::set_detail_blend_mode);
- ClassDB::bind_method(_MD("get_detail_blend_mode"),&FixedSpatialMaterial::get_detail_blend_mode);
+ ClassDB::bind_method(D_METHOD("set_detail_blend_mode","detail_blend_mode"),&FixedSpatialMaterial::set_detail_blend_mode);
+ ClassDB::bind_method(D_METHOD("get_detail_blend_mode"),&FixedSpatialMaterial::get_detail_blend_mode);
- ClassDB::bind_method(_MD("set_uv1_scale","scale"),&FixedSpatialMaterial::set_uv1_scale);
- ClassDB::bind_method(_MD("get_uv1_scale"),&FixedSpatialMaterial::get_uv1_scale);
+ ClassDB::bind_method(D_METHOD("set_uv1_scale","scale"),&FixedSpatialMaterial::set_uv1_scale);
+ ClassDB::bind_method(D_METHOD("get_uv1_scale"),&FixedSpatialMaterial::get_uv1_scale);
- ClassDB::bind_method(_MD("set_uv1_offset","offset"),&FixedSpatialMaterial::set_uv1_offset);
- ClassDB::bind_method(_MD("get_uv1_offset"),&FixedSpatialMaterial::get_uv1_offset);
+ ClassDB::bind_method(D_METHOD("set_uv1_offset","offset"),&FixedSpatialMaterial::set_uv1_offset);
+ ClassDB::bind_method(D_METHOD("get_uv1_offset"),&FixedSpatialMaterial::get_uv1_offset);
- ClassDB::bind_method(_MD("set_uv2_scale","scale"),&FixedSpatialMaterial::set_uv2_scale);
- ClassDB::bind_method(_MD("get_uv2_scale"),&FixedSpatialMaterial::get_uv2_scale);
+ ClassDB::bind_method(D_METHOD("set_uv2_scale","scale"),&FixedSpatialMaterial::set_uv2_scale);
+ ClassDB::bind_method(D_METHOD("get_uv2_scale"),&FixedSpatialMaterial::get_uv2_scale);
- ClassDB::bind_method(_MD("set_uv2_offset","offset"),&FixedSpatialMaterial::set_uv2_offset);
- ClassDB::bind_method(_MD("get_uv2_offset"),&FixedSpatialMaterial::get_uv2_offset);
+ ClassDB::bind_method(D_METHOD("set_uv2_offset","offset"),&FixedSpatialMaterial::set_uv2_offset);
+ ClassDB::bind_method(D_METHOD("get_uv2_offset"),&FixedSpatialMaterial::get_uv2_offset);
ADD_GROUP("Flags","flags_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_transparent"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_TRANSPARENT);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_unshaded"),_SCS("set_flag"),_SCS("get_flag"),FLAG_UNSHADED);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_on_top"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ONTOP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags_use_point_size"),_SCS("set_flag"),_SCS("get_flag"),FLAG_USE_POINT_SIZE);
+ 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_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_GROUP("Vertex Color","vertex_color");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_use_as_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_is_srgb"),_SCS("set_flag"),_SCS("get_flag"),FLAG_SRGB_VERTEX_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_use_as_albedo"),"set_flag","get_flag",FLAG_ALBEDO_FROM_VERTEX_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color_is_srgb"),"set_flag","get_flag",FLAG_SRGB_VERTEX_COLOR);
ADD_GROUP("Parameters","params_");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"params_diffuse_mode",PROPERTY_HINT_ENUM,"Labert,Lambert Wrap,Oren Nayar,Burley"),_SCS("set_diffuse_mode"),_SCS("get_diffuse_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"params_blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_blend_mode"),_SCS("get_blend_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"params_cull_mode",PROPERTY_HINT_ENUM,"Back,Front,Disabled"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"params_depth_draw_mode",PROPERTY_HINT_ENUM,"Opaque Only,Always,Never,Opaque Pre-Pass"),_SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"params_line_width",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_line_width"),_SCS("get_line_width"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"params_point_size",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_point_size"),_SCS("get_point_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params_diffuse_mode",PROPERTY_HINT_ENUM,"Labert,Lambert Wrap,Oren Nayar,Burley"),"set_diffuse_mode","get_diffuse_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_GROUP("Albedo","albedo_");
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"albedo_color"),_SCS("set_albedo"),_SCS("get_albedo"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"albedo_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_ALBEDO);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"albedo_color"),"set_albedo","get_albedo");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"albedo_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_ALBEDO);
ADD_GROUP("Specular","specular_");
- ADD_PROPERTY(PropertyInfo(Variant::INT,"specular_mode",PROPERTY_HINT_ENUM,"Metallic,Specular"),_SCS("set_specular_mode"),_SCS("get_specular_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"specular_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_specular"),_SCS("get_specular"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_metalness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_metalness"),_SCS("get_metalness"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_roughness"),_SCS("get_roughness"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"specular_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SPECULAR);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"specular_mode",PROPERTY_HINT_ENUM,"Metallic,Specular"),"set_specular_mode","get_specular_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"specular_color",PROPERTY_HINT_COLOR_NO_ALPHA),"set_specular","get_specular");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_metalness",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_metalness","get_metalness");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_roughness","get_roughness");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"specular_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_SPECULAR);
ADD_GROUP("Emission","emission_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"emission_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_EMISSION);
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"emission_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_emission"),_SCS("get_emission"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"emission_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_emission_energy"),_SCS("get_emission_energy"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"emission_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_EMISSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"emission_enabled"),"set_feature","get_feature",FEATURE_EMISSION);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"emission_color",PROPERTY_HINT_COLOR_NO_ALPHA),"set_emission","get_emission");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"emission_energy",PROPERTY_HINT_RANGE,"0,16,0.01"),"set_emission_energy","get_emission_energy");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"emission_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_EMISSION);
ADD_GROUP("NormapMap","normal_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"normal_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_NORMAL_MAPPING);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"normal_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_normal_scale"),_SCS("get_normal_scale"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"normal_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_NORMAL);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"normal_enabled"),"set_feature","get_feature",FEATURE_NORMAL_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"normal_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),"set_normal_scale","get_normal_scale");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"normal_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_NORMAL);
ADD_GROUP("Rim","rim_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"rim_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_RIM);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim"),_SCS("get_rim"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_tint",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim_tint"),_SCS("get_rim_tint"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"rim_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_RIM);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"rim_enabled"),"set_feature","get_feature",FEATURE_RIM);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_rim","get_rim");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim_tint",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_rim_tint","get_rim_tint");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"rim_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_RIM);
ADD_GROUP("Clearcoat","clearcoat_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"clearcoat_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_CLEARCOAT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat"),_SCS("get_clearcoat"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_gloss",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat_gloss"),_SCS("get_clearcoat_gloss"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"clearcoat_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_CLEARCOAT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"clearcoat_enabled"),"set_feature","get_feature",FEATURE_CLEARCOAT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_amount",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_clearcoat","get_clearcoat");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat_gloss",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_clearcoat_gloss","get_clearcoat_gloss");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"clearcoat_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_CLEARCOAT);
ADD_GROUP("Anisotropy","anisotropy_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"anisotropy_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_ANISOTROPY);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"anisotropy_anisotropy",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_anisotropy"),_SCS("get_anisotropy"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"anisotropy_flowmap",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_FLOWMAP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"anisotropy_enabled"),"set_feature","get_feature",FEATURE_ANISOTROPY);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"anisotropy_anisotropy",PROPERTY_HINT_RANGE,"0,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"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_AMBIENT_OCCLUSION);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"ao_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_AMBIENT_OCCLUSION);
+ 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_GROUP("Height","height_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"height_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_HEIGHT_MAPPING);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"height_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_height_scale"),_SCS("get_height_scale"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"height_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_HEIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"height_enabled"),"set_feature","get_feature",FEATURE_HEIGHT_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"height_scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),"set_height_scale","get_height_scale");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"height_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_HEIGHT);
ADD_GROUP("Subsurf Scatter","subsurf_scatter_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"subsurf_scatter_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_SUBSURACE_SCATTERING);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"subsurf_scatter_strength",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_subsurface_scattering_strength"),_SCS("get_subsurface_scattering_strength"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"subsurf_scatter_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SUBSURFACE_SCATTERING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"subsurf_scatter_enabled"),"set_feature","get_feature",FEATURE_SUBSURACE_SCATTERING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"subsurf_scatter_strength",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_subsurface_scattering_strength","get_subsurface_scattering_strength");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"subsurf_scatter_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_SUBSURFACE_SCATTERING);
ADD_GROUP("Refraction","refraction_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"refraction_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_REFRACTION);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_displacement",PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_refraction"),_SCS("get_refraction"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_refraction_roughness"),_SCS("get_refraction_roughness"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"refraction_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_REFRACTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"refraction_enabled"),"set_feature","get_feature",FEATURE_REFRACTION);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_displacement",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_refraction","get_refraction");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction_roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_refraction_roughness","get_refraction_roughness");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"refraction_texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_REFRACTION);
ADD_GROUP("Detail","detail_");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"detail_enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_DETAIL);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_mask",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_MASK);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_detail_blend_mode"),_SCS("get_detail_blend_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_uv_layer",PROPERTY_HINT_ENUM,"UV1,UV2"),_SCS("set_detail_uv"),_SCS("get_detail_uv"));
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_albedo",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_ALBEDO);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_NORMAL);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"detail_enabled"),"set_feature","get_feature",FEATURE_DETAIL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_mask",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_DETAIL_MASK);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),"set_detail_blend_mode","get_detail_blend_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail_uv_layer",PROPERTY_HINT_ENUM,"UV1,UV2"),"set_detail_uv","get_detail_uv");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail_albedo",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),"set_texture","get_texture",TEXTURE_DETAIL_ALBEDO);
+ 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"),_SCS("set_uv1_scale"),_SCS("get_uv1_scale"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv1_offset"),_SCS("set_uv1_offset"),_SCS("get_uv1_offset"));
+ 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_GROUP("UV2","uv2_");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2_scale"),_SCS("set_uv2_scale"),_SCS("get_uv2_scale"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2_offset"),_SCS("set_uv2_offset"),_SCS("get_uv2_offset"));
+ 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");
BIND_CONSTANT( TEXTURE_ALBEDO );
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 99911eddeb..9990a6e796 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -128,8 +128,8 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (d.has("arrays")) {
//old format
- ERR_FAIL_COND_V(!d.has("blend_shape_arrays"),false);
- add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["blend_shape_arrays"]);
+ ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
+ add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]);
} else if (d.has("array_data")) {
@@ -1019,31 +1019,31 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
void Mesh::_bind_methods() {
- ClassDB::bind_method(_MD("add_blend_shape","name"),&Mesh::add_blend_shape);
- ClassDB::bind_method(_MD("get_blend_shape_count"),&Mesh::get_blend_shape_count);
- ClassDB::bind_method(_MD("get_blend_shape_name","index"),&Mesh::get_blend_shape_name);
- ClassDB::bind_method(_MD("clear_blend_shapes"),&Mesh::clear_blend_shapes);
- ClassDB::bind_method(_MD("set_blend_shape_mode","mode"),&Mesh::set_blend_shape_mode);
- ClassDB::bind_method(_MD("get_blend_shape_mode"),&Mesh::get_blend_shape_mode);
-
- ClassDB::bind_method(_MD("add_surface_from_arrays","primitive","arrays","blend_shapes","compress_flags"),&Mesh::add_surface_from_arrays,DEFVAL(Array()),DEFVAL(ARRAY_COMPRESS_DEFAULT));
- ClassDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
- ClassDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
- ClassDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
- ClassDB::bind_method(_MD("surface_get_array_index_len","surf_idx"),&Mesh::surface_get_array_index_len);
- ClassDB::bind_method(_MD("surface_get_format","surf_idx"),&Mesh::surface_get_format);
- ClassDB::bind_method(_MD("surface_get_primitive_type","surf_idx"),&Mesh::surface_get_primitive_type);
- ClassDB::bind_method(_MD("surface_set_material","surf_idx","material:Material"),&Mesh::surface_set_material);
- ClassDB::bind_method(_MD("surface_get_material:Material","surf_idx"),&Mesh::surface_get_material);
- ClassDB::bind_method(_MD("surface_set_name","surf_idx","name"),&Mesh::surface_set_name);
- ClassDB::bind_method(_MD("surface_get_name","surf_idx"),&Mesh::surface_get_name);
- ClassDB::bind_method(_MD("center_geometry"),&Mesh::center_geometry);
- ClassDB::set_method_flags(get_class_static(),_SCS("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("regen_normalmaps"),&Mesh::regen_normalmaps);
- ClassDB::set_method_flags(get_class_static(),_SCS("regen_normalmaps"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
-
- ClassDB::bind_method(_MD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb);
- ClassDB::bind_method(_MD("get_custom_aabb"),&Mesh::get_custom_aabb);
+ ClassDB::bind_method(D_METHOD("add_blend_shape","name"),&Mesh::add_blend_shape);
+ ClassDB::bind_method(D_METHOD("get_blend_shape_count"),&Mesh::get_blend_shape_count);
+ ClassDB::bind_method(D_METHOD("get_blend_shape_name","index"),&Mesh::get_blend_shape_name);
+ ClassDB::bind_method(D_METHOD("clear_blend_shapes"),&Mesh::clear_blend_shapes);
+ ClassDB::bind_method(D_METHOD("set_blend_shape_mode","mode"),&Mesh::set_blend_shape_mode);
+ ClassDB::bind_method(D_METHOD("get_blend_shape_mode"),&Mesh::get_blend_shape_mode);
+
+ ClassDB::bind_method(D_METHOD("add_surface_from_arrays","primitive","arrays","blend_shapes","compress_flags"),&Mesh::add_surface_from_arrays,DEFVAL(Array()),DEFVAL(ARRAY_COMPRESS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("get_surface_count"),&Mesh::get_surface_count);
+ ClassDB::bind_method(D_METHOD("surface_remove","surf_idx"),&Mesh::surface_remove);
+ ClassDB::bind_method(D_METHOD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
+ ClassDB::bind_method(D_METHOD("surface_get_array_index_len","surf_idx"),&Mesh::surface_get_array_index_len);
+ ClassDB::bind_method(D_METHOD("surface_get_format","surf_idx"),&Mesh::surface_get_format);
+ ClassDB::bind_method(D_METHOD("surface_get_primitive_type","surf_idx"),&Mesh::surface_get_primitive_type);
+ ClassDB::bind_method(D_METHOD("surface_set_material","surf_idx","material:Material"),&Mesh::surface_set_material);
+ ClassDB::bind_method(D_METHOD("surface_get_material:Material","surf_idx"),&Mesh::surface_get_material);
+ ClassDB::bind_method(D_METHOD("surface_set_name","surf_idx","name"),&Mesh::surface_set_name);
+ ClassDB::bind_method(D_METHOD("surface_get_name","surf_idx"),&Mesh::surface_get_name);
+ ClassDB::bind_method(D_METHOD("center_geometry"),&Mesh::center_geometry);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("regen_normalmaps"),&Mesh::regen_normalmaps);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("regen_normalmaps"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+
+ ClassDB::bind_method(D_METHOD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb);
+ ClassDB::bind_method(D_METHOD("get_custom_aabb"),&Mesh::get_custom_aabb);
BIND_CONSTANT( NO_INDEX_ARRAY );
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index ec699ee8e3..abe335aa5b 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -565,62 +565,62 @@ void MeshDataTool::set_material(const Ref<Material> &p_material) {
void MeshDataTool::_bind_methods() {
- ClassDB::bind_method(_MD("clear"),&MeshDataTool::clear);
- ClassDB::bind_method(_MD("create_from_surface","mesh","surface"),&MeshDataTool::create_from_surface);
- ClassDB::bind_method(_MD("commit_to_surface","mesh"),&MeshDataTool::commit_to_surface);
+ 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(_MD("get_format"),&MeshDataTool::get_format);
+ ClassDB::bind_method(D_METHOD("get_format"),&MeshDataTool::get_format);
- ClassDB::bind_method(_MD("get_vertex_count"),&MeshDataTool::get_vertex_count);
- ClassDB::bind_method(_MD("get_edge_count"),&MeshDataTool::get_edge_count);
- ClassDB::bind_method(_MD("get_face_count"),&MeshDataTool::get_face_count);
+ ClassDB::bind_method(D_METHOD("get_vertex_count"),&MeshDataTool::get_vertex_count);
+ ClassDB::bind_method(D_METHOD("get_edge_count"),&MeshDataTool::get_edge_count);
+ ClassDB::bind_method(D_METHOD("get_face_count"),&MeshDataTool::get_face_count);
- ClassDB::bind_method(_MD("set_vertex","idx","vertex"),&MeshDataTool::set_vertex);
- ClassDB::bind_method(_MD("get_vertex","idx"),&MeshDataTool::get_vertex);
+ ClassDB::bind_method(D_METHOD("set_vertex","idx","vertex"),&MeshDataTool::set_vertex);
+ ClassDB::bind_method(D_METHOD("get_vertex","idx"),&MeshDataTool::get_vertex);
- ClassDB::bind_method(_MD("set_vertex_normal","idx","normal"),&MeshDataTool::set_vertex_normal);
- ClassDB::bind_method(_MD("get_vertex_normal","idx"),&MeshDataTool::get_vertex_normal);
+ ClassDB::bind_method(D_METHOD("set_vertex_normal","idx","normal"),&MeshDataTool::set_vertex_normal);
+ ClassDB::bind_method(D_METHOD("get_vertex_normal","idx"),&MeshDataTool::get_vertex_normal);
- ClassDB::bind_method(_MD("set_vertex_tangent","idx","tangent"),&MeshDataTool::set_vertex_tangent);
- ClassDB::bind_method(_MD("get_vertex_tangent","idx"),&MeshDataTool::get_vertex_tangent);
+ ClassDB::bind_method(D_METHOD("set_vertex_tangent","idx","tangent"),&MeshDataTool::set_vertex_tangent);
+ ClassDB::bind_method(D_METHOD("get_vertex_tangent","idx"),&MeshDataTool::get_vertex_tangent);
- ClassDB::bind_method(_MD("set_vertex_uv","idx","uv"),&MeshDataTool::set_vertex_uv);
- ClassDB::bind_method(_MD("get_vertex_uv","idx"),&MeshDataTool::get_vertex_uv);
+ ClassDB::bind_method(D_METHOD("set_vertex_uv","idx","uv"),&MeshDataTool::set_vertex_uv);
+ ClassDB::bind_method(D_METHOD("get_vertex_uv","idx"),&MeshDataTool::get_vertex_uv);
- ClassDB::bind_method(_MD("set_vertex_uv2","idx","uv2"),&MeshDataTool::set_vertex_uv2);
- ClassDB::bind_method(_MD("get_vertex_uv2","idx"),&MeshDataTool::get_vertex_uv2);
+ ClassDB::bind_method(D_METHOD("set_vertex_uv2","idx","uv2"),&MeshDataTool::set_vertex_uv2);
+ ClassDB::bind_method(D_METHOD("get_vertex_uv2","idx"),&MeshDataTool::get_vertex_uv2);
- ClassDB::bind_method(_MD("set_vertex_color","idx","color"),&MeshDataTool::set_vertex_color);
- ClassDB::bind_method(_MD("get_vertex_color","idx"),&MeshDataTool::get_vertex_color);
+ ClassDB::bind_method(D_METHOD("set_vertex_color","idx","color"),&MeshDataTool::set_vertex_color);
+ ClassDB::bind_method(D_METHOD("get_vertex_color","idx"),&MeshDataTool::get_vertex_color);
- ClassDB::bind_method(_MD("set_vertex_bones","idx","bones"),&MeshDataTool::set_vertex_bones);
- ClassDB::bind_method(_MD("get_vertex_bones","idx"),&MeshDataTool::get_vertex_bones);
+ ClassDB::bind_method(D_METHOD("set_vertex_bones","idx","bones"),&MeshDataTool::set_vertex_bones);
+ ClassDB::bind_method(D_METHOD("get_vertex_bones","idx"),&MeshDataTool::get_vertex_bones);
- ClassDB::bind_method(_MD("set_vertex_weights","idx","weights"),&MeshDataTool::set_vertex_weights);
- ClassDB::bind_method(_MD("get_vertex_weights","idx"),&MeshDataTool::get_vertex_weights);
+ ClassDB::bind_method(D_METHOD("set_vertex_weights","idx","weights"),&MeshDataTool::set_vertex_weights);
+ ClassDB::bind_method(D_METHOD("get_vertex_weights","idx"),&MeshDataTool::get_vertex_weights);
- ClassDB::bind_method(_MD("set_vertex_meta","idx","meta"),&MeshDataTool::set_vertex_meta);
- ClassDB::bind_method(_MD("get_vertex_meta","idx"),&MeshDataTool::get_vertex_meta);
+ 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(_MD("get_vertex_edges","idx"),&MeshDataTool::get_vertex_edges);
- ClassDB::bind_method(_MD("get_vertex_faces","idx"),&MeshDataTool::get_vertex_faces);
+ 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);
- ClassDB::bind_method(_MD("get_edge_vertex","idx","vertex"),&MeshDataTool::get_edge_vertex);
- ClassDB::bind_method(_MD("get_edge_faces","idx","faces"),&MeshDataTool::get_edge_faces);
+ ClassDB::bind_method(D_METHOD("get_edge_vertex","idx","vertex"),&MeshDataTool::get_edge_vertex);
+ ClassDB::bind_method(D_METHOD("get_edge_faces","idx","faces"),&MeshDataTool::get_edge_faces);
- ClassDB::bind_method(_MD("set_edge_meta","idx","meta"),&MeshDataTool::set_edge_meta);
- ClassDB::bind_method(_MD("get_edge_meta","idx"),&MeshDataTool::get_edge_meta);
+ 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(_MD("get_face_vertex","idx","vertex"),&MeshDataTool::get_face_vertex);
- ClassDB::bind_method(_MD("get_face_edge","idx","edge"),&MeshDataTool::get_face_edge);
+ 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(_MD("set_face_meta","idx","meta"),&MeshDataTool::set_face_meta);
- ClassDB::bind_method(_MD("get_face_meta","idx"),&MeshDataTool::get_face_meta);
+ 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(_MD("get_face_normal","idx"),&MeshDataTool::get_face_normal);
+ ClassDB::bind_method(D_METHOD("get_face_normal","idx"),&MeshDataTool::get_face_normal);
- ClassDB::bind_method(_MD("set_material","material:Material"),&MeshDataTool::set_material);
- ClassDB::bind_method(_MD("get_material","material"),&MeshDataTool::get_material);
+ ClassDB::bind_method(D_METHOD("set_material","material:Material"),&MeshDataTool::set_material);
+ ClassDB::bind_method(D_METHOD("get_material","material"),&MeshDataTool::get_material);
}
MeshDataTool::MeshDataTool(){
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index cc357c4d9b..becbf39dad 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -244,19 +244,19 @@ int MeshLibrary::get_last_unused_item_id() const {
void MeshLibrary::_bind_methods() {
- ClassDB::bind_method(_MD("create_item","id"),&MeshLibrary::create_item);
- ClassDB::bind_method(_MD("set_item_name","id","name"),&MeshLibrary::set_item_name);
- ClassDB::bind_method(_MD("set_item_mesh","id","mesh:Mesh"),&MeshLibrary::set_item_mesh);
- ClassDB::bind_method(_MD("set_item_navmesh","id","navmesh:NavigationMesh"),&MeshLibrary::set_item_navmesh);
- ClassDB::bind_method(_MD("set_item_shape","id","shape:Shape"),&MeshLibrary::set_item_shape);
- ClassDB::bind_method(_MD("get_item_name","id"),&MeshLibrary::get_item_name);
- ClassDB::bind_method(_MD("get_item_mesh:Mesh","id"),&MeshLibrary::get_item_mesh);
- ClassDB::bind_method(_MD("get_item_navmesh:NavigationMesh","id"),&MeshLibrary::get_item_navmesh);
- ClassDB::bind_method(_MD("get_item_shape:Shape","id"),&MeshLibrary::get_item_shape);
- ClassDB::bind_method(_MD("remove_item","id"),&MeshLibrary::remove_item);
- ClassDB::bind_method(_MD("clear"),&MeshLibrary::clear);
- ClassDB::bind_method(_MD("get_item_list"),&MeshLibrary::get_item_list);
- ClassDB::bind_method(_MD("get_last_unused_item_id"),&MeshLibrary::get_last_unused_item_id);
+ ClassDB::bind_method(D_METHOD("create_item","id"),&MeshLibrary::create_item);
+ ClassDB::bind_method(D_METHOD("set_item_name","id","name"),&MeshLibrary::set_item_name);
+ ClassDB::bind_method(D_METHOD("set_item_mesh","id","mesh:Mesh"),&MeshLibrary::set_item_mesh);
+ ClassDB::bind_method(D_METHOD("set_item_navmesh","id","navmesh:NavigationMesh"),&MeshLibrary::set_item_navmesh);
+ ClassDB::bind_method(D_METHOD("set_item_shape","id","shape:Shape"),&MeshLibrary::set_item_shape);
+ ClassDB::bind_method(D_METHOD("get_item_name","id"),&MeshLibrary::get_item_name);
+ ClassDB::bind_method(D_METHOD("get_item_mesh:Mesh","id"),&MeshLibrary::get_item_mesh);
+ ClassDB::bind_method(D_METHOD("get_item_navmesh:NavigationMesh","id"),&MeshLibrary::get_item_navmesh);
+ ClassDB::bind_method(D_METHOD("get_item_shape:Shape","id"),&MeshLibrary::get_item_shape);
+ ClassDB::bind_method(D_METHOD("remove_item","id"),&MeshLibrary::remove_item);
+ ClassDB::bind_method(D_METHOD("clear"),&MeshLibrary::clear);
+ ClassDB::bind_method(D_METHOD("get_item_list"),&MeshLibrary::get_item_list);
+ ClassDB::bind_method(D_METHOD("get_last_unused_item_id"),&MeshLibrary::get_last_unused_item_id);
}
MeshLibrary::MeshLibrary() {
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 75df4a4e60..69ef3f18a6 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -211,34 +211,34 @@ MultiMesh::TransformFormat MultiMesh::get_transform_format() const{
void MultiMesh::_bind_methods() {
- ClassDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
- ClassDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
- ClassDB::bind_method(_MD("set_color_format","format"),&MultiMesh::set_color_format);
- ClassDB::bind_method(_MD("get_color_format"),&MultiMesh::get_color_format);
- ClassDB::bind_method(_MD("set_transform_format","format"),&MultiMesh::set_transform_format);
- ClassDB::bind_method(_MD("get_transform_format"),&MultiMesh::get_transform_format);
-
- ClassDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
- ClassDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
- ClassDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
- ClassDB::bind_method(_MD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
- ClassDB::bind_method(_MD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
- ClassDB::bind_method(_MD("get_instance_color","instance"),&MultiMesh::get_instance_color);
- ClassDB::bind_method(_MD("get_aabb"),&MultiMesh::get_aabb);
-
-
- ClassDB::bind_method(_MD("_set_transform_array"),&MultiMesh::_set_transform_array);
- ClassDB::bind_method(_MD("_get_transform_array"),&MultiMesh::_get_transform_array);
- ClassDB::bind_method(_MD("_set_color_array"),&MultiMesh::_set_color_array);
- ClassDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
-
-
- ADD_PROPERTY(PropertyInfo(Variant::INT,"color_format",PROPERTY_HINT_ENUM,"None,Byte,Float"), _SCS("set_color_format"), _SCS("get_color_format"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"transform_format",PROPERTY_HINT_ENUM,"2D,3D"), _SCS("set_transform_format"), _SCS("get_transform_format"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
- ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+ ClassDB::bind_method(D_METHOD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
+ ClassDB::bind_method(D_METHOD("get_mesh:Mesh"),&MultiMesh::get_mesh);
+ ClassDB::bind_method(D_METHOD("set_color_format","format"),&MultiMesh::set_color_format);
+ ClassDB::bind_method(D_METHOD("get_color_format"),&MultiMesh::get_color_format);
+ ClassDB::bind_method(D_METHOD("set_transform_format","format"),&MultiMesh::set_transform_format);
+ ClassDB::bind_method(D_METHOD("get_transform_format"),&MultiMesh::get_transform_format);
+
+ ClassDB::bind_method(D_METHOD("set_instance_count","count"),&MultiMesh::set_instance_count);
+ ClassDB::bind_method(D_METHOD("get_instance_count"),&MultiMesh::get_instance_count);
+ ClassDB::bind_method(D_METHOD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
+ ClassDB::bind_method(D_METHOD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
+ ClassDB::bind_method(D_METHOD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
+ ClassDB::bind_method(D_METHOD("get_instance_color","instance"),&MultiMesh::get_instance_color);
+ ClassDB::bind_method(D_METHOD("get_aabb"),&MultiMesh::get_aabb);
+
+
+ ClassDB::bind_method(D_METHOD("_set_transform_array"),&MultiMesh::_set_transform_array);
+ ClassDB::bind_method(D_METHOD("_get_transform_array"),&MultiMesh::_get_transform_array);
+ ClassDB::bind_method(D_METHOD("_set_color_array"),&MultiMesh::_set_color_array);
+ ClassDB::bind_method(D_METHOD("_get_color_array"),&MultiMesh::_get_color_array);
+
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"color_format",PROPERTY_HINT_ENUM,"None,Byte,Float"), "set_color_format", "get_color_format");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"transform_format",PROPERTY_HINT_ENUM,"2D,3D"), "set_transform_format", "get_transform_format");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), "set_instance_count", "get_instance_count");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), "set_mesh", "get_mesh");
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_transform_array", "_get_transform_array");
+ ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_color_array", "_get_color_array");
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 625cc6a596..5e3347687a 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "packed_scene.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/resource_loader.h"
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
@@ -177,6 +177,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
node = obj->cast_to<Node>();
+ } else {
+ print_line("wtf class is disabled for: "+itos(n.type));
+ print_line("name: "+String(snames[n.type]));
}
@@ -196,6 +199,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL );
ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL );
+
if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) {
//work around to avoid old script variables from disappearing, should be the proper fix to:
//https://github.com/godotengine/godot/issues/2958
@@ -332,7 +336,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
//remove nodes that could not be added, likely as a result that
while(stray_instances.size()) {
memdelete(stray_instances.front()->get());
- stray_instances.pop_front();;
+ stray_instances.pop_front();
}
for(int i=0;i<editable_instances.size();i++) {
@@ -357,7 +361,7 @@ static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map)
return idx;
}
-static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
+static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map) {
if (variant_map.has(p_variant))
return variant_map[p_variant];
@@ -367,7 +371,7 @@ static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,Variant
return idx;
}
-Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
+Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
// this function handles all the work related to properly packing scenes, be it
@@ -529,9 +533,11 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one());
-// if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
-// continue;
-// }
+ /*
+ if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
+ continue;
+ }
+ */
@@ -614,8 +620,10 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
if (!gi.persistent)
continue;
-// if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
-// continue; //group was instanced, don't add here
+ /*
+ if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
+ continue; //group was instanced, don't add here
+ */
bool skip=false;
for (List<PackState>::Element *F=pack_state_stack.front();F;F=F->next()) {
@@ -739,7 +747,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
}
-Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
+Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
if (p_node!=p_owner && p_node->get_owner() && p_node->get_owner()!=p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
return OK;
@@ -944,7 +952,7 @@ Error SceneState::pack(Node *p_scene) {
Node *scene = p_scene;
Map<StringName,int> name_map;
- HashMap<Variant,int,VariantHasher> variant_map;
+ HashMap<Variant,int,VariantHasher,VariantComparator> variant_map;
Map<Node*,int> node_map;
Map<Node*,int> nodepath_map;
@@ -1166,7 +1174,7 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
ERR_FAIL_COND( !d.has("nodes"));
ERR_FAIL_COND( !d.has("conn_count"));
ERR_FAIL_COND( !d.has("conns"));
-// ERR_FAIL_COND( !d.has("path"));
+ //ERR_FAIL_COND( !d.has("path"));
int version=1;
if (d.has("version"))
@@ -1277,7 +1285,7 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
editable_instances[i]=ei[i];
}
-// path=d["path"];
+ //path=d["path"];
}
@@ -1362,7 +1370,7 @@ Dictionary SceneState::get_bundled_scene() const {
d["version"]=PACK_VERSION;
-// d["path"]=path;
+ //d["path"]=path;
return d;
@@ -1712,25 +1720,25 @@ void SceneState::_bind_methods() {
//unbuild API
- ClassDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count);
- ClassDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type);
- ClassDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name);
- ClassDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
- ClassDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
- ClassDB::bind_method(_MD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder);
- ClassDB::bind_method(_MD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder);
- ClassDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
- ClassDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups);
- ClassDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count);
- ClassDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name);
- ClassDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value);
- ClassDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count);
- ClassDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source);
- ClassDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal);
- ClassDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target);
- ClassDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method);
- ClassDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags);
- ClassDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds);
+ ClassDB::bind_method(D_METHOD("get_node_count"),&SceneState::get_node_count);
+ ClassDB::bind_method(D_METHOD("get_node_type","idx"),&SceneState::get_node_type);
+ ClassDB::bind_method(D_METHOD("get_node_name","idx"),&SceneState::get_node_name);
+ ClassDB::bind_method(D_METHOD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
+ ClassDB::bind_method(D_METHOD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder);
+ ClassDB::bind_method(D_METHOD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder);
+ ClassDB::bind_method(D_METHOD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
+ 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_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);
+ ClassDB::bind_method(D_METHOD("get_connection_target","idx"),&SceneState::get_connection_target);
+ ClassDB::bind_method(D_METHOD("get_connection_method","idx"),&SceneState::get_connection_method);
+ ClassDB::bind_method(D_METHOD("get_connection_flags","idx"),&SceneState::get_connection_flags);
+ ClassDB::bind_method(D_METHOD("get_connection_binds","idx"),&SceneState::get_connection_binds);
BIND_CONSTANT( GEN_EDIT_STATE_DISABLED );
BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE );
@@ -1833,14 +1841,14 @@ void PackedScene::set_path(const String& p_path,bool p_take_over) {
void PackedScene::_bind_methods() {
- ClassDB::bind_method(_MD("pack","path:Node"),&PackedScene::pack);
- ClassDB::bind_method(_MD("instance:Node","edit_state"),&PackedScene::instance,DEFVAL(false));
- ClassDB::bind_method(_MD("can_instance"),&PackedScene::can_instance);
- ClassDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
- ClassDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
- ClassDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state);
+ ClassDB::bind_method(D_METHOD("pack","path:Node"),&PackedScene::pack);
+ ClassDB::bind_method(D_METHOD("instance:Node","edit_state"),&PackedScene::instance,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("can_instance"),&PackedScene::can_instance);
+ ClassDB::bind_method(D_METHOD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
+ ClassDB::bind_method(D_METHOD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
+ ClassDB::bind_method(D_METHOD("get_state:SceneState"),&PackedScene::get_state);
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
+ ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),"_set_bundled_scene","_get_bundled_scene");
BIND_CONSTANT( GEN_EDIT_STATE_DISABLED );
BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE );
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index 381b356b1e..4a3841abe9 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -91,8 +91,8 @@ class SceneState : public Reference {
Vector<ConnectionData> connections;
- Error _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
- Error _parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
+ Error _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
+ Error _parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
String path;
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp
index 1814eea66c..f1bb6d60c0 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/plane_shape.cpp
@@ -80,10 +80,10 @@ Plane PlaneShape::get_plane() const {
void PlaneShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_plane","plane"),&PlaneShape::set_plane);
- ClassDB::bind_method(_MD("get_plane"),&PlaneShape::get_plane);
+ ClassDB::bind_method(D_METHOD("set_plane","plane"),&PlaneShape::set_plane);
+ ClassDB::bind_method(D_METHOD("get_plane"),&PlaneShape::get_plane);
- ADD_PROPERTY( PropertyInfo(Variant::PLANE,"plane"), _SCS("set_plane"), _SCS("get_plane") );
+ ADD_PROPERTY( PropertyInfo(Variant::PLANE,"plane"), "set_plane", "get_plane") ;
}
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 2156487407..6dac8a9779 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -419,7 +419,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
path.push_back(points[at].pos);
} while (at!=aidx);
- path.invert();;
+ path.invert();
}
for(int i=0;i<points.size()-2;i++) {
@@ -618,19 +618,19 @@ float PolygonPathFinder::get_point_penalty(int p_point) const {
void PolygonPathFinder::_bind_methods() {
- ClassDB::bind_method(_MD("setup","points","connections"),&PolygonPathFinder::setup);
- ClassDB::bind_method(_MD("find_path","from","to"),&PolygonPathFinder::find_path);
- ClassDB::bind_method(_MD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
- ClassDB::bind_method(_MD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
- ClassDB::bind_method(_MD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
- ClassDB::bind_method(_MD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
- ClassDB::bind_method(_MD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
+ ClassDB::bind_method(D_METHOD("setup","points","connections"),&PolygonPathFinder::setup);
+ ClassDB::bind_method(D_METHOD("find_path","from","to"),&PolygonPathFinder::find_path);
+ ClassDB::bind_method(D_METHOD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
+ ClassDB::bind_method(D_METHOD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
+ ClassDB::bind_method(D_METHOD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
+ ClassDB::bind_method(D_METHOD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
+ ClassDB::bind_method(D_METHOD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
- ClassDB::bind_method(_MD("get_bounds"),&PolygonPathFinder::get_bounds);
- ClassDB::bind_method(_MD("_set_data"),&PolygonPathFinder::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&PolygonPathFinder::_get_data);
+ ClassDB::bind_method(D_METHOD("get_bounds"),&PolygonPathFinder::get_bounds);
+ ClassDB::bind_method(D_METHOD("_set_data"),&PolygonPathFinder::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&PolygonPathFinder::_get_data);
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),"_set_data","_get_data");
}
diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp
index 226062bed3..52ce736925 100644
--- a/scene/resources/ray_shape.cpp
+++ b/scene/resources/ray_shape.cpp
@@ -60,10 +60,10 @@ float RayShape::get_length() const {
void RayShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_length","length"),&RayShape::set_length);
- ClassDB::bind_method(_MD("get_length"),&RayShape::get_length);
+ ClassDB::bind_method(D_METHOD("set_length","length"),&RayShape::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"),&RayShape::get_length);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"length",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_length"), _SCS("get_length") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"length",PROPERTY_HINT_RANGE,"0,4096,0.01"), "set_length", "get_length") ;
}
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index 3272125b33..1161843a2b 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -64,12 +64,12 @@ Rect2 RectangleShape2D::get_rect() const {
void RectangleShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_extents","extents"),&RectangleShape2D::set_extents);
- ClassDB::bind_method(_MD("get_extents"),&RectangleShape2D::get_extents);
+ ClassDB::bind_method(D_METHOD("set_extents","extents"),&RectangleShape2D::set_extents);
+ ClassDB::bind_method(D_METHOD("get_extents"),&RectangleShape2D::get_extents);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),_SCS("set_extents"),_SCS("get_extents") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),"set_extents","get_extents") ;
}
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index 069127f291..e677f92c31 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -52,11 +52,11 @@ PoolVector<Face3> RoomBounds::get_geometry_hint() const {
void RoomBounds::_bind_methods() {
- ClassDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
- ClassDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
+ ClassDB::bind_method(D_METHOD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
+ ClassDB::bind_method(D_METHOD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
- ADD_PROPERTY( PropertyInfo( Variant::POOL_VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
+ //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), "set_bounds","get_bounds") ;
+ ADD_PROPERTY( PropertyInfo( Variant::POOL_VECTOR3_ARRAY, "geometry_hint"),"set_geometry_hint","get_geometry_hint") ;
}
diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp
deleted file mode 100644
index e07e4d3767..0000000000
--- a/scene/resources/sample.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*************************************************************************/
-/* sample.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "sample.h"
-
-
-void Sample::_set_data(const Dictionary& p_data) {
-
- ERR_FAIL_COND(!p_data.has("packing"));
- String packing = p_data["packing"];
-
- if (packing=="raw") {
-
- ERR_FAIL_COND( !p_data.has("stereo"));
- ERR_FAIL_COND( !p_data.has("format"));
- ERR_FAIL_COND( !p_data.has("length"));
- bool stereo=p_data["stereo"];
- int length=p_data["length"];
- Format fmt;
- String fmtstr=p_data["format"];
- if (fmtstr=="pcm8")
- fmt=FORMAT_PCM8;
- else if (fmtstr=="pcm16")
- fmt=FORMAT_PCM16;
- else if (fmtstr=="ima_adpcm")
- fmt=FORMAT_IMA_ADPCM;
- else {
- ERR_EXPLAIN("Invalid format for sample: "+fmtstr);
- ERR_FAIL();
- }
-
- ERR_FAIL_COND(!p_data.has("data"));
-
- create(fmt,stereo,length);
- set_data(p_data["data"]);
- } else {
-
- ERR_EXPLAIN("Invalid packing for sample data: "+packing);
- ERR_FAIL();
- }
-}
-
-Dictionary Sample::_get_data() const {
-
- Dictionary d;
- switch(get_format()) {
-
- case FORMAT_PCM8: d["format"]="pcm8"; break;
- case FORMAT_PCM16: d["format"]="pcm16"; break;
- case FORMAT_IMA_ADPCM: d["format"]="ima_adpcm"; break;
- }
-
- d["stereo"]=is_stereo();
- d["length"]=get_length();
- d["packing"]="raw";
- d["data"]=get_data();
- return d;
-
-}
-
-void Sample::create(Format p_format, bool p_stereo, int p_length) {
-
- if (p_length<1)
- return;
-
- if (sample.is_valid())
- AudioServer::get_singleton()->free(sample);
-
-
- mix_rate=44100;
- stereo=p_stereo;
- length=p_length;
- format=p_format;
- loop_format=LOOP_NONE;
- loop_begin=0;
- loop_end=0;
-
- sample=AudioServer::get_singleton()->sample_create((AudioServer::SampleFormat)p_format,p_stereo,p_length);
-}
-
-
-Sample::Format Sample::get_format() const {
-
- return format;
-}
-bool Sample::is_stereo() const {
-
-
- return stereo;
-}
-int Sample::get_length() const {
-
-
- return length;
-}
-
-void Sample::set_data(const PoolVector<uint8_t>& p_buffer) {
-
- if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_data(sample,p_buffer);
-
-}
-PoolVector<uint8_t> Sample::get_data() const {
-
- if (sample.is_valid())
- return AudioServer::get_singleton()->sample_get_data(sample);
-
- return PoolVector<uint8_t>();
-
-}
-
-void Sample::set_mix_rate(int p_rate) {
-
- mix_rate=p_rate;
- if (sample.is_valid())
- return AudioServer::get_singleton()->sample_set_mix_rate(sample,mix_rate);
-
-}
-int Sample::get_mix_rate() const {
-
- return mix_rate;
-}
-
-void Sample::set_loop_format(LoopFormat p_format) {
-
- if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_format(sample,(AudioServer::SampleLoopFormat)p_format);
- loop_format=p_format;
-}
-
-Sample::LoopFormat Sample::get_loop_format() const {
-
- return loop_format;
-}
-
-void Sample::set_loop_begin(int p_pos) {
-
- if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_begin(sample,p_pos);
- loop_begin=p_pos;
-
-}
-int Sample::get_loop_begin() const {
-
- return loop_begin;
-}
-
-void Sample::set_loop_end(int p_pos) {
-
- if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_end(sample,p_pos);
- loop_end=p_pos;
-}
-
-int Sample::get_loop_end() const {
-
- return loop_end;
-}
-
-RID Sample::get_rid() const {
-
- return sample;
-}
-
-
-
-void Sample::_bind_methods(){
-
-
- ClassDB::bind_method(_MD("create","format","stereo","length"),&Sample::create);
- ClassDB::bind_method(_MD("get_format"),&Sample::get_format);
- ClassDB::bind_method(_MD("is_stereo"),&Sample::is_stereo);
- ClassDB::bind_method(_MD("get_length"),&Sample::get_length);
- ClassDB::bind_method(_MD("set_data","data"),&Sample::set_data);
- ClassDB::bind_method(_MD("get_data"),&Sample::get_data);
- ClassDB::bind_method(_MD("set_mix_rate","hz"),&Sample::set_mix_rate);
- ClassDB::bind_method(_MD("get_mix_rate"),&Sample::get_mix_rate);
- ClassDB::bind_method(_MD("set_loop_format","format"),&Sample::set_loop_format);
- ClassDB::bind_method(_MD("get_loop_format"),&Sample::get_loop_format);
- ClassDB::bind_method(_MD("set_loop_begin","pos"),&Sample::set_loop_begin);
- ClassDB::bind_method(_MD("get_loop_begin"),&Sample::get_loop_begin);
- ClassDB::bind_method(_MD("set_loop_end","pos"),&Sample::set_loop_end);
- ClassDB::bind_method(_MD("get_loop_end"),&Sample::get_loop_end);
-
- ClassDB::bind_method(_MD("_set_data"),&Sample::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&Sample::_get_data);
-
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "stereo"), _SCS(""), _SCS("is_stereo") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "length",PROPERTY_HINT_RANGE,"0,999999999"), _SCS(""), _SCS("get_length") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "mix_rate", PROPERTY_HINT_RANGE,"1,192000,1" ), _SCS("set_mix_rate"), _SCS("get_mix_rate") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_format", PROPERTY_HINT_ENUM,"None,Forward,PingPong" ), _SCS("set_loop_format"), _SCS("get_loop_format") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_begin", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_begin"), _SCS("get_loop_begin") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_end", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_end"), _SCS("get_loop_end") );
-
- BIND_CONSTANT( FORMAT_PCM8 );
- BIND_CONSTANT( FORMAT_PCM16 );
- BIND_CONSTANT( FORMAT_IMA_ADPCM );
-
- BIND_CONSTANT( LOOP_NONE );
- BIND_CONSTANT( LOOP_FORWARD );
- BIND_CONSTANT( LOOP_PING_PONG );
-
-}
-
-Sample::Sample() {
-
- format=FORMAT_PCM8;
- length=0;
- stereo=false;
-
- loop_format=LOOP_NONE;
- loop_begin=0;
- loop_end=0;
- mix_rate=44100;
-
-}
-
-Sample::~Sample() {
-
- if (sample.is_valid())
- AudioServer::get_singleton()->free(sample);
-}
diff --git a/scene/resources/sample.h b/scene/resources/sample.h
deleted file mode 100644
index be2cf67954..0000000000
--- a/scene/resources/sample.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*************************************************************************/
-/* sample.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SAMPLE_H
-#define SAMPLE_H
-
-#include "servers/audio_server.h"
-#include "resource.h"
-
-class Sample : public Resource {
-
- GDCLASS(Sample, Resource );
- RES_BASE_EXTENSION("smp");
-public:
-
- enum Format {
-
- FORMAT_PCM8,
- FORMAT_PCM16,
- FORMAT_IMA_ADPCM
- };
-
- enum LoopFormat {
- LOOP_NONE,
- LOOP_FORWARD,
- LOOP_PING_PONG // not supported in every platform
-
- };
-
-private:
-
- Format format;
- int length;
- bool stereo;
-
- LoopFormat loop_format;
- int loop_begin;
- int loop_end;
- int mix_rate;
-
- RID sample;
-
-
- void _set_data(const Dictionary& p_data);
- Dictionary _get_data() const;
-
-protected:
-
- static void _bind_methods();
-
-public:
-
-
- void create(Format p_format, bool p_stereo, int p_length);
-
- Format get_format() const;
- bool is_stereo() const;
- int get_length() const;
-
- void set_data(const PoolVector<uint8_t>& p_buffer);
- PoolVector<uint8_t> get_data() const;
-
- void set_mix_rate(int p_rate);
- int get_mix_rate() const;
-
- void set_loop_format(LoopFormat p_format);
- LoopFormat get_loop_format() const;
-
- void set_loop_begin(int p_pos);
- int get_loop_begin() const;
-
- void set_loop_end(int p_pos);
- int get_loop_end() const;
-
- virtual RID get_rid() const;
- Sample();
- ~Sample();
-};
-
-VARIANT_ENUM_CAST( Sample::Format );
-VARIANT_ENUM_CAST( Sample::LoopFormat );
-
-#endif // SAMPLE_H
diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp
deleted file mode 100644
index 44895df8fa..0000000000
--- a/scene/resources/sample_library.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*************************************************************************/
-/* sample_library.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "sample_library.h"
-
-
-bool SampleLibrary::_set(const StringName& p_name, const Variant& p_value) {
-
-
- if (String(p_name).begins_with("samples/")) {
-
- String name=String(p_name).get_slicec('/',1);
- if (p_value.get_type()==Variant::NIL)
- sample_map.erase(name);
- else {
- SampleData sd;
-
- if (p_value.get_type()==Variant::OBJECT)
- sd.sample=p_value;
- else if (p_value.get_type()==Variant::DICTIONARY) {
-
- Dictionary d = p_value;
- ERR_FAIL_COND_V(!d.has("sample"),false);
- ERR_FAIL_COND_V(!d.has("pitch"),false);
- ERR_FAIL_COND_V(!d.has("db"),false);
- sd.sample=d["sample"];
- sd.pitch_scale=d["pitch"];
- sd.db=d["db"];
- }
-
- sample_map[name]=sd;
- }
-
- return true;
- }
-
- return false;
-}
-
-bool SampleLibrary::_get(const StringName& p_name,Variant &r_ret) const {
-
- if (String(p_name).begins_with("samples/")) {
-
- String name=String(p_name).get_slicec('/',1);
- if(sample_map.has(name)) {
- Dictionary d;
- d["sample"]=sample_map[name].sample;
- d["pitch"]=sample_map[name].pitch_scale;
- d["db"]=sample_map[name].db;
- r_ret=d;
- } else {
- return false;
- }
-
- return true;
- }
-
- return false;
-
-
-}
-
-void SampleLibrary::add_sample(const StringName& p_name, const Ref<Sample>& p_sample) {
-
- ERR_FAIL_COND(p_sample.is_null());
-
- SampleData sd;
- sd.sample=p_sample;
- sample_map[p_name]=sd;
-}
-
-Ref<Sample> SampleLibrary::get_sample(const StringName& p_name) const {
-
- ERR_FAIL_COND_V(!sample_map.has(p_name),Ref<Sample>());
-
- return sample_map[p_name].sample;
-}
-
-void SampleLibrary::remove_sample(const StringName& p_name) {
-
- sample_map.erase(p_name);
-}
-
-void SampleLibrary::get_sample_list(List<StringName> *p_samples) const {
-
- for(const Map<StringName,SampleData >::Element *E=sample_map.front();E;E=E->next()) {
-
- p_samples->push_back(E->key());
- }
-
-}
-
-bool SampleLibrary::has_sample(const StringName& p_name) const {
-
- return sample_map.has(p_name);
-}
-
-void SampleLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
-
-
- List<PropertyInfo> tpl;
- for(Map<StringName,SampleData>::Element *E=sample_map.front();E;E=E->next()) {
-
- tpl.push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
- }
-
- tpl.sort();
- //sort so order is kept
- for(List<PropertyInfo>::Element *E=tpl.front();E;E=E->next()) {
- p_list->push_back(E->get());
- }
-}
-
-StringName SampleLibrary::get_sample_idx(int p_idx) const {
-
- int idx=0;
- for (Map<StringName, SampleData >::Element *E=sample_map.front();E;E=E->next()) {
-
- if (p_idx==idx)
- return E->key();
- idx++;
- }
-
- return "";
-}
-
-void SampleLibrary::sample_set_volume_db(const StringName& p_name, float p_db) {
-
- ERR_FAIL_COND( !sample_map.has(p_name) );
- sample_map[p_name].db=p_db;
-
-}
-
-float SampleLibrary::sample_get_volume_db(const StringName& p_name) const{
-
- ERR_FAIL_COND_V( !sample_map.has(p_name),0 );
-
- return sample_map[p_name].db;
-}
-
-void SampleLibrary::sample_set_pitch_scale(const StringName& p_name, float p_pitch){
-
- ERR_FAIL_COND( !sample_map.has(p_name) );
-
- sample_map[p_name].pitch_scale=p_pitch;
-}
-
-float SampleLibrary::sample_get_pitch_scale(const StringName& p_name) const{
-
- ERR_FAIL_COND_V( !sample_map.has(p_name),0 );
-
- return sample_map[p_name].pitch_scale;
-}
-
-Array SampleLibrary::_get_sample_list() const {
-
- List<StringName> snames;
- get_sample_list(&snames);
-
- snames.sort_custom<StringName::AlphCompare>();
-
- Array ret;
- for (List<StringName>::Element *E=snames.front();E;E=E->next()) {
- ret.push_back(E->get());
- }
-
- return ret;
-}
-
-void SampleLibrary::_bind_methods() {
-
- ClassDB::bind_method(_MD("add_sample","name","sample:Sample"),&SampleLibrary::add_sample );
- ClassDB::bind_method(_MD("get_sample:Sample","name"),&SampleLibrary::get_sample );
- ClassDB::bind_method(_MD("has_sample","name"),&SampleLibrary::has_sample );
- ClassDB::bind_method(_MD("remove_sample","name"),&SampleLibrary::remove_sample );
-
- ClassDB::bind_method(_MD("get_sample_list"),&SampleLibrary::_get_sample_list );
-
- ClassDB::bind_method(_MD("sample_set_volume_db","name","db"),&SampleLibrary::sample_set_volume_db );
- ClassDB::bind_method(_MD("sample_get_volume_db","name"),&SampleLibrary::sample_get_volume_db );
-
- ClassDB::bind_method(_MD("sample_set_pitch_scale","name","pitch"),&SampleLibrary::sample_set_pitch_scale );
- ClassDB::bind_method(_MD("sample_get_pitch_scale","name"),&SampleLibrary::sample_get_pitch_scale );
-
-
-}
-
-SampleLibrary::SampleLibrary()
-{
-}
diff --git a/scene/resources/sample_library.h b/scene/resources/sample_library.h
deleted file mode 100644
index d09eea64c5..0000000000
--- a/scene/resources/sample_library.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*************************************************************************/
-/* sample_library.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SAMPLE_LIBRARY_H
-#define SAMPLE_LIBRARY_H
-
-#include "resource.h"
-#include "scene/resources/sample.h"
-#include "map.h"
-
-class SampleLibrary : public Resource {
-
- GDCLASS(SampleLibrary,Resource);
-
- struct SampleData {
-
- Ref<Sample> sample;
- float db;
- float pitch_scale;
-
- SampleData() { db=0; pitch_scale=1; }
- };
-
- Map<StringName,SampleData > sample_map;
-
- Array _get_sample_list() const;
-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;
-
- static void _bind_methods();
-
-public:
-
-
-
- void add_sample(const StringName& p_name, const Ref<Sample>& p_sample);
- bool has_sample(const StringName& p_name) const;
- void sample_set_volume_db(const StringName& p_name, float p_db);
- float sample_get_volume_db(const StringName& p_name) const;
- void sample_set_pitch_scale(const StringName& p_name, float p_pitch);
- float sample_get_pitch_scale(const StringName& p_name) const;
- Ref<Sample> get_sample(const StringName& p_name) const;
- void get_sample_list(List<StringName> *p_samples) const;
- void remove_sample(const StringName& p_name);
- StringName get_sample_idx(int p_idx) const;
-
- SampleLibrary();
-};
-
-#endif // SAMPLE_LIBRARY_H
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index fa56f63465..3a254836a2 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -28,11 +28,12 @@
/*************************************************************************/
#include "scene_format_text.h"
-#include "globals.h"
+#include "global_config.h"
#include "version.h"
#include "os/dir_access.h"
-#define FORMAT_VERSION 1
+//version 2: changed names for basis, rect3, poolvectors, etc.
+#define FORMAT_VERSION 2
#include "version.h"
#include "os/dir_access.h"
@@ -397,7 +398,7 @@ Error ResourceInteractiveLoaderText::poll() {
int type=-1;
int name=-1;
int instance=-1;
-// int base_scene=-1;
+ //int base_scene=-1;
if (next_tag.fields.has("name")) {
name=packed_scene->get_state()->add_name(next_tag.fields["name"]);
@@ -950,7 +951,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
ria->local_path=GlobalConfig::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( GlobalConfig::get_singleton()->localize_path(p_path) );
ria->open(f);
return ria;
@@ -984,7 +985,7 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const{
- String ext=p_path.extension().to_lower();
+ String ext=p_path.get_extension().to_lower();
if (ext=="tscn")
return "PackedScene";
else if (ext!="tres")
@@ -1001,7 +1002,7 @@ 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->res_path=ria->local_path;
-// ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
+ //ria->set_local_path( GlobalConfig::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
return r;
}
@@ -1018,7 +1019,7 @@ void ResourceFormatLoaderText::get_dependencies(const String& p_path,List<String
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
ria->local_path=GlobalConfig::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( GlobalConfig::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f,p_dependencies,p_add_types);
@@ -1035,7 +1036,7 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path,const M
Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
ria->local_path=GlobalConfig::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( GlobalConfig::get_singleton()->localize_path(p_path) );
return ria->rename_dependencies(f,p_path,p_map);
}
@@ -1158,7 +1159,7 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b
static String _valprop(const String& p_name) {
if (p_name.find("\"")!=-1 || p_name.find("=")!=-1 || p_name.find(" ")!=-1)
- return "\""+p_name.c_escape()+"\"";
+ return "\""+p_name.c_escape_multiline()+"\"";
return p_name;
}
@@ -1208,10 +1209,12 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
if (packed_scene.is_null())
title+="type=\""+p_resource->get_class()+"\" ";
int load_steps=saved_resources.size()+external_resources.size();
- //if (packed_scene.is_valid()) {
- // load_steps+=packed_scene->get_node_count();
- //}
+ /*
+ if (packed_scene.is_valid()) {
+ load_steps+=packed_scene->get_node_count();
+ }
//no, better to not use load steps from nodes, no point to that
+ */
if (load_steps>1) {
title+="load_steps="+itos(load_steps)+" ";
@@ -1299,7 +1302,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
List<PropertyInfo> property_list;
res->get_property_list(&property_list);
-// property_list.sort();
+ //property_list.sort();
for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
@@ -1358,13 +1361,11 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
}
if (groups.size()) {
- String sgroups=" groups=[ ";
+ String sgroups=" groups=[\n";
for(int j=0;j<groups.size();j++) {
- if (j>0)
- sgroups+=", ";
- sgroups+="\""+groups[j].operator String().c_escape()+"\"";
+ sgroups+="\""+String(groups[j]).c_escape()+"\",\n";
}
- sgroups+=" ]";
+ sgroups+="]";
header+=sgroups;
}
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index 58660fa639..ce18f6a702 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -58,7 +58,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
bool ignore_resource_parsing;
-// Map<String,String> remaps;
+ //Map<String,String> remaps;
Map<int,ExtResource> ext_resources;
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index 71d5a8efa8..fbe1efe5d1 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -82,15 +82,15 @@ Rect2 SegmentShape2D::get_rect() const{
void SegmentShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a);
- ClassDB::bind_method(_MD("get_a"),&SegmentShape2D::get_a);
+ ClassDB::bind_method(D_METHOD("set_a","a"),&SegmentShape2D::set_a);
+ ClassDB::bind_method(D_METHOD("get_a"),&SegmentShape2D::get_a);
- ClassDB::bind_method(_MD("set_b","b"),&SegmentShape2D::set_b);
- ClassDB::bind_method(_MD("get_b"),&SegmentShape2D::get_b);
+ ClassDB::bind_method(D_METHOD("set_b","b"),&SegmentShape2D::set_b);
+ ClassDB::bind_method(D_METHOD("get_b"),&SegmentShape2D::get_b);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),_SCS("set_a"),_SCS("get_a") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"b"),_SCS("set_b"),_SCS("get_b") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),"set_a","get_a") ;
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"b"),"set_b","get_b") ;
}
@@ -145,10 +145,10 @@ Rect2 RayShape2D::get_rect() const {
void RayShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length);
- ClassDB::bind_method(_MD("get_length"),&RayShape2D::get_length);
+ ClassDB::bind_method(D_METHOD("set_length","length"),&RayShape2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"),&RayShape2D::get_length);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),_SCS("set_length"),_SCS("get_length") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),"set_length","get_length") ;
}
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 6afbf32c35..375a9a1cb0 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -116,20 +116,20 @@ bool Shader::has_param(const StringName& p_param) const {
void Shader::_bind_methods() {
- ClassDB::bind_method(_MD("get_mode"),&Shader::get_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&Shader::get_mode);
- ClassDB::bind_method(_MD("set_code","code"),&Shader::set_code);
- ClassDB::bind_method(_MD("get_code"),&Shader::get_code);
+ ClassDB::bind_method(D_METHOD("set_code","code"),&Shader::set_code);
+ ClassDB::bind_method(D_METHOD("get_code"),&Shader::get_code);
- ClassDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
- ClassDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
+ ClassDB::bind_method(D_METHOD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
+ ClassDB::bind_method(D_METHOD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
- ClassDB::bind_method(_MD("has_param","name"),&Shader::has_param);
+ ClassDB::bind_method(D_METHOD("has_param","name"),&Shader::has_param);
- //ClassDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
+ //ClassDB::bind_method(D_METHOD("get_param_list"),&Shader::get_fragment_code);
- ADD_PROPERTY( PropertyInfo(Variant::STRING, "code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("set_code"), _SCS("get_code") );
+ ADD_PROPERTY( PropertyInfo(Variant::STRING, "code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "set_code", "get_code") ;
BIND_CONSTANT( MODE_SPATIAL);
BIND_CONSTANT( MODE_CANVAS_ITEM );
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 37b019e369..c21feb0bf5 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -165,108 +165,108 @@ int ShaderGraph::node_count(ShaderType p_which, int p_type)
void ShaderGraph::_bind_methods() {
- ClassDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
+ ClassDB::bind_method(D_METHOD("_update_shader"),&ShaderGraph::_update_shader);
- ClassDB::bind_method(_MD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add);
- ClassDB::bind_method(_MD("node_remove","shader_type","id"),&ShaderGraph::node_remove);
- ClassDB::bind_method(_MD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos);
- ClassDB::bind_method(_MD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos);
+ ClassDB::bind_method(D_METHOD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add);
+ ClassDB::bind_method(D_METHOD("node_remove","shader_type","id"),&ShaderGraph::node_remove);
+ ClassDB::bind_method(D_METHOD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos);
+ ClassDB::bind_method(D_METHOD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos);
- ClassDB::bind_method(_MD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type);
+ ClassDB::bind_method(D_METHOD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type);
- ClassDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
+ ClassDB::bind_method(D_METHOD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
- ClassDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
- ClassDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
+ ClassDB::bind_method(D_METHOD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
+ ClassDB::bind_method(D_METHOD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
- ClassDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
- ClassDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_get_value);
+ ClassDB::bind_method(D_METHOD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
+ ClassDB::bind_method(D_METHOD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_get_value);
- ClassDB::bind_method(_MD("vec_const_node_set_value","shader_type","id","value"),&ShaderGraph::vec_const_node_set_value);
- ClassDB::bind_method(_MD("vec_const_node_get_value","shader_type","id"),&ShaderGraph::vec_const_node_get_value);
+ ClassDB::bind_method(D_METHOD("vec_const_node_set_value","shader_type","id","value"),&ShaderGraph::vec_const_node_set_value);
+ ClassDB::bind_method(D_METHOD("vec_const_node_get_value","shader_type","id"),&ShaderGraph::vec_const_node_get_value);
- ClassDB::bind_method(_MD("rgb_const_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_const_node_set_value);
- ClassDB::bind_method(_MD("rgb_const_node_get_value","shader_type","id"),&ShaderGraph::rgb_const_node_get_value);
+ ClassDB::bind_method(D_METHOD("rgb_const_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_const_node_set_value);
+ ClassDB::bind_method(D_METHOD("rgb_const_node_get_value","shader_type","id"),&ShaderGraph::rgb_const_node_get_value);
- ClassDB::bind_method(_MD("xform_const_node_set_value","shader_type","id","value"),&ShaderGraph::xform_const_node_set_value);
- ClassDB::bind_method(_MD("xform_const_node_get_value","shader_type","id"),&ShaderGraph::xform_const_node_get_value);
+ ClassDB::bind_method(D_METHOD("xform_const_node_set_value","shader_type","id","value"),&ShaderGraph::xform_const_node_set_value);
+ ClassDB::bind_method(D_METHOD("xform_const_node_get_value","shader_type","id"),&ShaderGraph::xform_const_node_get_value);
-// void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
+ //void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
- ClassDB::bind_method(_MD("texture_node_set_filter_size","shader_type","id","filter_size"),&ShaderGraph::texture_node_set_filter_size);
- ClassDB::bind_method(_MD("texture_node_get_filter_size","shader_type","id"),&ShaderGraph::texture_node_get_filter_size);
+ ClassDB::bind_method(D_METHOD("texture_node_set_filter_size","shader_type","id","filter_size"),&ShaderGraph::texture_node_set_filter_size);
+ ClassDB::bind_method(D_METHOD("texture_node_get_filter_size","shader_type","id"),&ShaderGraph::texture_node_get_filter_size);
- ClassDB::bind_method(_MD("texture_node_set_filter_strength","shader_type","id","filter_strength"),&ShaderGraph::texture_node_set_filter_strength);
- ClassDB::bind_method(_MD("texture_node_get_filter_strength","shader_type","id"),&ShaderGraph::texture_node_get_filter_strength);
+ ClassDB::bind_method(D_METHOD("texture_node_set_filter_strength","shader_type","id","filter_strength"),&ShaderGraph::texture_node_set_filter_strength);
+ ClassDB::bind_method(D_METHOD("texture_node_get_filter_strength","shader_type","id"),&ShaderGraph::texture_node_get_filter_strength);
- ClassDB::bind_method(_MD("scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::scalar_op_node_set_op);
- ClassDB::bind_method(_MD("scalar_op_node_get_op","shader_type","id"),&ShaderGraph::scalar_op_node_get_op);
+ ClassDB::bind_method(D_METHOD("scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::scalar_op_node_set_op);
+ ClassDB::bind_method(D_METHOD("scalar_op_node_get_op","shader_type","id"),&ShaderGraph::scalar_op_node_get_op);
- ClassDB::bind_method(_MD("vec_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_op_node_set_op);
- ClassDB::bind_method(_MD("vec_op_node_get_op","shader_type","id"),&ShaderGraph::vec_op_node_get_op);
+ ClassDB::bind_method(D_METHOD("vec_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_op_node_set_op);
+ ClassDB::bind_method(D_METHOD("vec_op_node_get_op","shader_type","id"),&ShaderGraph::vec_op_node_get_op);
- ClassDB::bind_method(_MD("vec_scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_scalar_op_node_set_op);
- ClassDB::bind_method(_MD("vec_scalar_op_node_get_op","shader_type","id"),&ShaderGraph::vec_scalar_op_node_get_op);
+ ClassDB::bind_method(D_METHOD("vec_scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_scalar_op_node_set_op);
+ ClassDB::bind_method(D_METHOD("vec_scalar_op_node_get_op","shader_type","id"),&ShaderGraph::vec_scalar_op_node_get_op);
- ClassDB::bind_method(_MD("rgb_op_node_set_op","shader_type","id","op"),&ShaderGraph::rgb_op_node_set_op);
- ClassDB::bind_method(_MD("rgb_op_node_get_op","shader_type","id"),&ShaderGraph::rgb_op_node_get_op);
+ ClassDB::bind_method(D_METHOD("rgb_op_node_set_op","shader_type","id","op"),&ShaderGraph::rgb_op_node_set_op);
+ ClassDB::bind_method(D_METHOD("rgb_op_node_get_op","shader_type","id"),&ShaderGraph::rgb_op_node_get_op);
- ClassDB::bind_method(_MD("xform_vec_mult_node_set_no_translation","shader_type","id","disable"),&ShaderGraph::xform_vec_mult_node_set_no_translation);
- ClassDB::bind_method(_MD("xform_vec_mult_node_get_no_translation","shader_type","id"),&ShaderGraph::xform_vec_mult_node_get_no_translation);
+ ClassDB::bind_method(D_METHOD("xform_vec_mult_node_set_no_translation","shader_type","id","disable"),&ShaderGraph::xform_vec_mult_node_set_no_translation);
+ ClassDB::bind_method(D_METHOD("xform_vec_mult_node_get_no_translation","shader_type","id"),&ShaderGraph::xform_vec_mult_node_get_no_translation);
- ClassDB::bind_method(_MD("scalar_func_node_set_function","shader_type","id","func"),&ShaderGraph::scalar_func_node_set_function);
- ClassDB::bind_method(_MD("scalar_func_node_get_function","shader_type","id"),&ShaderGraph::scalar_func_node_get_function);
+ ClassDB::bind_method(D_METHOD("scalar_func_node_set_function","shader_type","id","func"),&ShaderGraph::scalar_func_node_set_function);
+ ClassDB::bind_method(D_METHOD("scalar_func_node_get_function","shader_type","id"),&ShaderGraph::scalar_func_node_get_function);
- ClassDB::bind_method(_MD("vec_func_node_set_function","shader_type","id","func"),&ShaderGraph::vec_func_node_set_function);
- ClassDB::bind_method(_MD("vec_func_node_get_function","shader_type","id"),&ShaderGraph::vec_func_node_get_function);
+ ClassDB::bind_method(D_METHOD("vec_func_node_set_function","shader_type","id","func"),&ShaderGraph::vec_func_node_set_function);
+ ClassDB::bind_method(D_METHOD("vec_func_node_get_function","shader_type","id"),&ShaderGraph::vec_func_node_get_function);
- ClassDB::bind_method(_MD("input_node_set_name","shader_type","id","name"),&ShaderGraph::input_node_set_name);
- ClassDB::bind_method(_MD("input_node_get_name","shader_type","id"),&ShaderGraph::input_node_get_name);
+ ClassDB::bind_method(D_METHOD("input_node_set_name","shader_type","id","name"),&ShaderGraph::input_node_set_name);
+ ClassDB::bind_method(D_METHOD("input_node_get_name","shader_type","id"),&ShaderGraph::input_node_get_name);
- ClassDB::bind_method(_MD("scalar_input_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_input_node_set_value);
- ClassDB::bind_method(_MD("scalar_input_node_get_value","shader_type","id"),&ShaderGraph::scalar_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("scalar_input_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("scalar_input_node_get_value","shader_type","id"),&ShaderGraph::scalar_input_node_get_value);
- ClassDB::bind_method(_MD("vec_input_node_set_value","shader_type","id","value"),&ShaderGraph::vec_input_node_set_value);
- ClassDB::bind_method(_MD("vec_input_node_get_value","shader_type","id"),&ShaderGraph::vec_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("vec_input_node_set_value","shader_type","id","value"),&ShaderGraph::vec_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("vec_input_node_get_value","shader_type","id"),&ShaderGraph::vec_input_node_get_value);
- ClassDB::bind_method(_MD("rgb_input_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_input_node_set_value);
- ClassDB::bind_method(_MD("rgb_input_node_get_value","shader_type","id"),&ShaderGraph::rgb_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("rgb_input_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("rgb_input_node_get_value","shader_type","id"),&ShaderGraph::rgb_input_node_get_value);
- ClassDB::bind_method(_MD("xform_input_node_set_value","shader_type","id","value"),&ShaderGraph::xform_input_node_set_value);
- ClassDB::bind_method(_MD("xform_input_node_get_value","shader_type","id"),&ShaderGraph::xform_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("xform_input_node_set_value","shader_type","id","value"),&ShaderGraph::xform_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("xform_input_node_get_value","shader_type","id"),&ShaderGraph::xform_input_node_get_value);
- ClassDB::bind_method(_MD("texture_input_node_set_value","shader_type","id","value:Texture"),&ShaderGraph::texture_input_node_set_value);
- ClassDB::bind_method(_MD("texture_input_node_get_value:Texture","shader_type","id"),&ShaderGraph::texture_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("texture_input_node_set_value","shader_type","id","value:Texture"),&ShaderGraph::texture_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("texture_input_node_get_value:Texture","shader_type","id"),&ShaderGraph::texture_input_node_get_value);
- ClassDB::bind_method(_MD("cubemap_input_node_set_value","shader_type","id","value:CubeMap"),&ShaderGraph::cubemap_input_node_set_value);
- ClassDB::bind_method(_MD("cubemap_input_node_get_value:CubeMap","shader_type","id"),&ShaderGraph::cubemap_input_node_get_value);
+ ClassDB::bind_method(D_METHOD("cubemap_input_node_set_value","shader_type","id","value:CubeMap"),&ShaderGraph::cubemap_input_node_set_value);
+ ClassDB::bind_method(D_METHOD("cubemap_input_node_get_value:CubeMap","shader_type","id"),&ShaderGraph::cubemap_input_node_get_value);
- ClassDB::bind_method(_MD("comment_node_set_text","shader_type","id","text"),&ShaderGraph::comment_node_set_text);
- ClassDB::bind_method(_MD("comment_node_get_text","shader_type","id"),&ShaderGraph::comment_node_get_text);
+ ClassDB::bind_method(D_METHOD("comment_node_set_text","shader_type","id","text"),&ShaderGraph::comment_node_set_text);
+ ClassDB::bind_method(D_METHOD("comment_node_get_text","shader_type","id"),&ShaderGraph::comment_node_get_text);
- ClassDB::bind_method(_MD("color_ramp_node_set_ramp","shader_type","id","colors","offsets"),&ShaderGraph::color_ramp_node_set_ramp);
- ClassDB::bind_method(_MD("color_ramp_node_get_colors","shader_type","id"),&ShaderGraph::color_ramp_node_get_colors);
- ClassDB::bind_method(_MD("color_ramp_node_get_offsets","shader_type","id"),&ShaderGraph::color_ramp_node_get_offsets);
+ ClassDB::bind_method(D_METHOD("color_ramp_node_set_ramp","shader_type","id","colors","offsets"),&ShaderGraph::color_ramp_node_set_ramp);
+ ClassDB::bind_method(D_METHOD("color_ramp_node_get_colors","shader_type","id"),&ShaderGraph::color_ramp_node_get_colors);
+ ClassDB::bind_method(D_METHOD("color_ramp_node_get_offsets","shader_type","id"),&ShaderGraph::color_ramp_node_get_offsets);
- ClassDB::bind_method(_MD("curve_map_node_set_points","shader_type","id","points"),&ShaderGraph::curve_map_node_set_points);
- ClassDB::bind_method(_MD("curve_map_node_get_points","shader_type","id"),&ShaderGraph::curve_map_node_get_points);
+ ClassDB::bind_method(D_METHOD("curve_map_node_set_points","shader_type","id","points"),&ShaderGraph::curve_map_node_set_points);
+ ClassDB::bind_method(D_METHOD("curve_map_node_get_points","shader_type","id"),&ShaderGraph::curve_map_node_get_points);
- ClassDB::bind_method(_MD("connect_node:Error","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::connect_node);
- ClassDB::bind_method(_MD("is_node_connected","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::is_node_connected);
- ClassDB::bind_method(_MD("disconnect_node","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::disconnect_node);
- ClassDB::bind_method(_MD("get_node_connections","shader_type"),&ShaderGraph::_get_connections);
+ ClassDB::bind_method(D_METHOD("connect_node:Error","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::connect_node);
+ ClassDB::bind_method(D_METHOD("is_node_connected","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::is_node_connected);
+ ClassDB::bind_method(D_METHOD("disconnect_node","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::disconnect_node);
+ ClassDB::bind_method(D_METHOD("get_node_connections","shader_type"),&ShaderGraph::_get_connections);
- ClassDB::bind_method(_MD("clear","shader_type"),&ShaderGraph::clear);
+ ClassDB::bind_method(D_METHOD("clear","shader_type"),&ShaderGraph::clear);
- ClassDB::bind_method(_MD("node_set_state","shader_type","id","state"),&ShaderGraph::node_set_state);
- ClassDB::bind_method(_MD("node_get_state:Variant","shader_type","id"),&ShaderGraph::node_get_state);
+ ClassDB::bind_method(D_METHOD("node_set_state","shader_type","id","state"),&ShaderGraph::node_set_state);
+ ClassDB::bind_method(D_METHOD("node_get_state:Variant","shader_type","id"),&ShaderGraph::node_get_state);
- ClassDB::bind_method(_MD("_set_data"),&ShaderGraph::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&ShaderGraph::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data"),&ShaderGraph::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&ShaderGraph::_get_data);
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_data","_get_data");
//void get_connections(ShaderType p_which,List<Connection> *p_connections) const;
@@ -399,21 +399,21 @@ void ShaderGraph::_bind_methods() {
#if 0
- ClassDB::bind_method(_MD("node_add"),&ShaderGraph::node_add );
- ClassDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove );
- ClassDB::bind_method(_MD("node_set_param"),&ShaderGraph::node_set_param );
- ClassDB::bind_method(_MD("node_set_pos"),&ShaderGraph::node_set_pos );
+ ClassDB::bind_method(D_METHOD("node_add"),&ShaderGraph::node_add );
+ ClassDB::bind_method(D_METHOD("node_remove"),&ShaderGraph::node_remove );
+ ClassDB::bind_method(D_METHOD("node_set_param"),&ShaderGraph::node_set_param );
+ ClassDB::bind_method(D_METHOD("node_set_pos"),&ShaderGraph::node_set_pos );
- ClassDB::bind_method(_MD("node_get_pos"),&ShaderGraph::node_get_pos );
- ClassDB::bind_method(_MD("node_get_param"),&ShaderGraph::node_get_param);
- ClassDB::bind_method(_MD("node_get_type"),&ShaderGraph::node_get_type);
+ ClassDB::bind_method(D_METHOD("node_get_pos"),&ShaderGraph::node_get_pos );
+ ClassDB::bind_method(D_METHOD("node_get_param"),&ShaderGraph::node_get_param);
+ ClassDB::bind_method(D_METHOD("node_get_type"),&ShaderGraph::node_get_type);
- ClassDB::bind_method(_MD("connect"),&ShaderGraph::connect );
- ClassDB::bind_method(_MD("disconnect"),&ShaderGraph::disconnect );
+ ClassDB::bind_method(D_METHOD("connect"),&ShaderGraph::connect );
+ ClassDB::bind_method(D_METHOD("disconnect"),&ShaderGraph::disconnect );
- ClassDB::bind_method(_MD("get_connections"),&ShaderGraph::_get_connections_helper );
+ ClassDB::bind_method(D_METHOD("get_connections"),&ShaderGraph::_get_connections_helper );
- ClassDB::bind_method(_MD("clear"),&ShaderGraph::clear );
+ ClassDB::bind_method(D_METHOD("clear"),&ShaderGraph::clear );
BIND_CONSTANT( NODE_IN ); ///< param 0: name
BIND_CONSTANT( NODE_OUT ); ///< param 0: name
@@ -1993,8 +1993,7 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
/* compose the basis and geometry matrices */
- static const float CR_basis[4][4] =
- {
+ static const float CR_basis[4][4] = {
{ -0.5, 1.5, -1.5, 0.5 },
{ 1.0, -2.5, 2.0, -0.5 },
{ -0.5, 0.0, 0.5, 0.0 },
@@ -2161,7 +2160,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
case SCALAR_OP_ATAN2: optxt = "atan2("+p_inputs[0]+","+p_inputs[1]+");"; break;
}
- code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";;
+ code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";
}break;
case NODE_VEC_OP: {
@@ -2364,7 +2363,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
code+="\t"+OUTVAR(p_node->id,0)+"=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n";
code+="}\n";
} else if (func==VEC_FUNC_HSV2RGB) {
- code += OUTNAME(p_node->id,0)+";\n";;
+ code += OUTNAME(p_node->id,0)+";\n";
code+="{\n";
code+="\tvec3 c = "+p_inputs[0]+";\n";
code+="\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n";
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index b5a886b4b9..ec1568e218 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -104,14 +104,14 @@ Variant Shape2D::collide_and_get_contacts(const Transform2D& p_local_xform, con
void Shape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
- ClassDB::bind_method(_MD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
- ClassDB::bind_method(_MD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
- ClassDB::bind_method(_MD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
- ClassDB::bind_method(_MD("collide_and_get_contacts:Variant","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
- ClassDB::bind_method(_MD("collide_with_motion_and_get_contacts:Variant","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion_and_get_contacts);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_solver_bias",PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_custom_solver_bias"),_SCS("get_custom_solver_bias"));
+ ClassDB::bind_method(D_METHOD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
+ ClassDB::bind_method(D_METHOD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
+ ClassDB::bind_method(D_METHOD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
+ ClassDB::bind_method(D_METHOD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
+ ClassDB::bind_method(D_METHOD("collide_and_get_contacts:Variant","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
+ ClassDB::bind_method(D_METHOD("collide_with_motion_and_get_contacts:Variant","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion_and_get_contacts);
+
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_solver_bias",PROPERTY_HINT_RANGE,"0,1,0.001"),"set_custom_solver_bias","get_custom_solver_bias");
}
diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp
index b2270d00c0..64e50e62c8 100644
--- a/scene/resources/shape_line_2d.cpp
+++ b/scene/resources/shape_line_2d.cpp
@@ -90,14 +90,14 @@ Rect2 LineShape2D::get_rect() const{
void LineShape2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_normal","normal"),&LineShape2D::set_normal);
- ClassDB::bind_method(_MD("get_normal"),&LineShape2D::get_normal);
+ ClassDB::bind_method(D_METHOD("set_normal","normal"),&LineShape2D::set_normal);
+ ClassDB::bind_method(D_METHOD("get_normal"),&LineShape2D::get_normal);
- ClassDB::bind_method(_MD("set_d","d"),&LineShape2D::set_d);
- ClassDB::bind_method(_MD("get_d"),&LineShape2D::get_d);
+ ClassDB::bind_method(D_METHOD("set_d","d"),&LineShape2D::set_d);
+ ClassDB::bind_method(D_METHOD("get_d"),&LineShape2D::get_d);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"normal"),_SCS("set_normal"),_SCS("get_normal") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"d"),_SCS("set_d"),_SCS("get_d") );
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"normal"),"set_normal","get_normal") ;
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"d"),"set_d","get_d") ;
}
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 2a4fbfa8d4..fddf3070b1 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -16,10 +16,10 @@ SkyBox::RadianceSize SkyBox::get_radiance_size() const {
void SkyBox::_bind_methods() {
- ClassDB::bind_method(_MD("set_radiance_size","size"),&SkyBox::set_radiance_size);
- ClassDB::bind_method(_MD("get_radiance_size"),&SkyBox::get_radiance_size);
+ ClassDB::bind_method(D_METHOD("set_radiance_size","size"),&SkyBox::set_radiance_size);
+ ClassDB::bind_method(D_METHOD("get_radiance_size"),&SkyBox::get_radiance_size);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"radiance_size",PROPERTY_HINT_ENUM,"256,512,1024,2048"),_SCS("set_radiance_size"),_SCS("get_radiance_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"radiance_size",PROPERTY_HINT_ENUM,"256,512,1024,2048"),"set_radiance_size","get_radiance_size");
BIND_CONSTANT( RADIANCE_SIZE_256 );
@@ -113,8 +113,8 @@ RID ImageSkyBox::get_rid() const {
void ImageSkyBox::_bind_methods() {
- ClassDB::bind_method(_MD("set_image_path","image","path"),&ImageSkyBox::set_image_path);
- ClassDB::bind_method(_MD("get_image_path","image"),&ImageSkyBox::get_image_path);
+ ClassDB::bind_method(D_METHOD("set_image_path","image","path"),&ImageSkyBox::set_image_path);
+ ClassDB::bind_method(D_METHOD("get_image_path","image"),&ImageSkyBox::get_image_path);
List<String> extensions;
ImageLoader::get_recognized_extensions(&extensions);
@@ -127,12 +127,12 @@ void ImageSkyBox::_bind_methods() {
}
ADD_GROUP("Image Path","image_path_");
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_X);
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_X);
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Y);
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Z);
- ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_x",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_NEGATIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_x",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_POSITIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_y",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_NEGATIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_y",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_POSITIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_negative_z",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_NEGATIVE_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path_positive_z",PROPERTY_HINT_FILE,hints),"set_image_path","get_image_path",IMAGE_PATH_POSITIVE_Z);
BIND_CONSTANT( IMAGE_PATH_NEGATIVE_X );
BIND_CONSTANT( IMAGE_PATH_POSITIVE_X );
diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp
index 3f0d2824ce..f1fe9629dd 100644
--- a/scene/resources/space_2d.cpp
+++ b/scene/resources/space_2d.cpp
@@ -48,10 +48,10 @@ bool Space2D::is_active() const {
void Space2D::_bind_methods() {
- ClassDB::bind_method(_MD("set_active","active"),&Space2D::set_active);
- ClassDB::bind_method(_MD("is_active"),&Space2D::is_active);
+ ClassDB::bind_method(D_METHOD("set_active","active"),&Space2D::set_active);
+ ClassDB::bind_method(D_METHOD("is_active"),&Space2D::is_active);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"active"),_SCS("set_active"),_SCS("is_active") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"active"),"set_active","is_active") ;
}
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp
index bcfb164b4c..3029625928 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape.cpp
@@ -37,8 +37,8 @@ Vector<Vector3> SphereShape::_gen_debug_mesh_lines() {
for(int i=0;i<=360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
@@ -75,10 +75,10 @@ float SphereShape::get_radius() const {
void SphereShape::_bind_methods() {
- ClassDB::bind_method(_MD("set_radius","radius"),&SphereShape::set_radius);
- ClassDB::bind_method(_MD("get_radius"),&SphereShape::get_radius);
+ ClassDB::bind_method(D_METHOD("set_radius","radius"),&SphereShape::set_radius);
+ ClassDB::bind_method(D_METHOD("get_radius"),&SphereShape::get_radius);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_radius"), _SCS("get_radius"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0,4096,0.01"), "set_radius", "get_radius");
}
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 066062f302..34a4202942 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -70,26 +70,26 @@ Size2 StyleBox::get_center_size() const {
void StyleBox::_bind_methods() {
- ClassDB::bind_method(_MD("test_mask","point","rect"),&StyleBox::test_mask);
+ ClassDB::bind_method(D_METHOD("test_mask","point","rect"),&StyleBox::test_mask);
- ClassDB::bind_method(_MD("set_default_margin","margin","offset"),&StyleBox::set_default_margin);
- ClassDB::bind_method(_MD("get_default_margin","margin"),&StyleBox::get_default_margin);
+ ClassDB::bind_method(D_METHOD("set_default_margin","margin","offset"),&StyleBox::set_default_margin);
+ ClassDB::bind_method(D_METHOD("get_default_margin","margin"),&StyleBox::get_default_margin);
-// ClassDB::bind_method(_MD("set_default_margin"),&StyleBox::set_default_margin);
-// ClassDB::bind_method(_MD("get_default_margin"),&StyleBox::get_default_margin);
+ //ClassDB::bind_method(D_METHOD("set_default_margin"),&StyleBox::set_default_margin);
+ //ClassDB::bind_method(D_METHOD("get_default_margin"),&StyleBox::get_default_margin);
- ClassDB::bind_method(_MD("get_margin","margin"),&StyleBox::get_margin);
- ClassDB::bind_method(_MD("get_minimum_size"),&StyleBox::get_minimum_size);
- ClassDB::bind_method(_MD("get_center_size"),&StyleBox::get_center_size);
- ClassDB::bind_method(_MD("get_offset"),&StyleBox::get_offset);
+ ClassDB::bind_method(D_METHOD("get_margin","margin"),&StyleBox::get_margin);
+ ClassDB::bind_method(D_METHOD("get_minimum_size"),&StyleBox::get_minimum_size);
+ ClassDB::bind_method(D_METHOD("get_center_size"),&StyleBox::get_center_size);
+ ClassDB::bind_method(D_METHOD("get_offset"),&StyleBox::get_offset);
- ClassDB::bind_method(_MD("draw","canvas_item","rect"),&StyleBox::draw);
+ ClassDB::bind_method(D_METHOD("draw","canvas_item","rect"),&StyleBox::draw);
ADD_GROUP("Content Margin","content_margin_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_left", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_right", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_top", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_bottom", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_BOTTOM );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_left", PROPERTY_HINT_RANGE,"-1,2048,1" ), "set_default_margin","get_default_margin", MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_right", PROPERTY_HINT_RANGE,"-1,2048,1" ), "set_default_margin","get_default_margin", MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_top", PROPERTY_HINT_RANGE,"-1,2048,1" ), "set_default_margin","get_default_margin", MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin_bottom", PROPERTY_HINT_RANGE,"-1,2048,1" ), "set_default_margin","get_default_margin", MARGIN_BOTTOM );
}
@@ -209,42 +209,42 @@ Color StyleBoxTexture::get_modulate() const {
void StyleBoxTexture::_bind_methods() {
- ClassDB::bind_method(_MD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
- ClassDB::bind_method(_MD("get_texture:Texture"),&StyleBoxTexture::get_texture);
+ ClassDB::bind_method(D_METHOD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture:Texture"),&StyleBoxTexture::get_texture);
- ClassDB::bind_method(_MD("set_margin_size","margin","size"),&StyleBoxTexture::set_margin_size);
- ClassDB::bind_method(_MD("get_margin_size","margin"),&StyleBoxTexture::get_margin_size);
+ ClassDB::bind_method(D_METHOD("set_margin_size","margin","size"),&StyleBoxTexture::set_margin_size);
+ ClassDB::bind_method(D_METHOD("get_margin_size","margin"),&StyleBoxTexture::get_margin_size);
- ClassDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxTexture::set_expand_margin_size);
- ClassDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxTexture::get_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_size","margin","size"),&StyleBoxTexture::set_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("get_expand_margin_size","margin"),&StyleBoxTexture::get_expand_margin_size);
- ClassDB::bind_method(_MD("set_region_rect","region"),&StyleBoxTexture::set_region_rect);
- ClassDB::bind_method(_MD("get_region_rect"),&StyleBoxTexture::get_region_rect);
+ ClassDB::bind_method(D_METHOD("set_region_rect","region"),&StyleBoxTexture::set_region_rect);
+ ClassDB::bind_method(D_METHOD("get_region_rect"),&StyleBoxTexture::get_region_rect);
- ClassDB::bind_method(_MD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
- ClassDB::bind_method(_MD("get_draw_center"),&StyleBoxTexture::get_draw_center);
+ ClassDB::bind_method(D_METHOD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
+ ClassDB::bind_method(D_METHOD("get_draw_center"),&StyleBoxTexture::get_draw_center);
- ClassDB::bind_method(_MD("set_modulate","color"),&StyleBoxTexture::set_modulate);
- ClassDB::bind_method(_MD("get_modulate"),&StyleBoxTexture::get_modulate);
+ ClassDB::bind_method(D_METHOD("set_modulate","color"),&StyleBoxTexture::set_modulate);
+ ClassDB::bind_method(D_METHOD("get_modulate"),&StyleBoxTexture::get_modulate);
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), "set_texture","get_texture") ;
+ ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), "set_region_rect","get_region_rect");
ADD_GROUP("Margin","margin_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_BOTTOM );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_margin_size","get_margin_size", MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_margin_size","get_margin_size", MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_margin_size","get_margin_size", MARGIN_TOP);
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_margin_size","get_margin_size", MARGIN_BOTTOM );
ADD_GROUP("Expand Margin","expand_margin_");
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_expand_margin_size","get_expand_margin_size", MARGIN_LEFT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_expand_margin_size","get_expand_margin_size", MARGIN_RIGHT );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_expand_margin_size","get_expand_margin_size", MARGIN_TOP );
+ ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), "set_expand_margin_size","get_expand_margin_size", MARGIN_BOTTOM );
ADD_GROUP("Modulate","modulate_");
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate_color" ), _SCS("set_modulate"),_SCS("get_modulate"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_center" ) , _SCS("set_draw_center"),_SCS("get_draw_center"));
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate_color" ), "set_modulate","get_modulate");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_center" ) , "set_draw_center","get_draw_center");
}
@@ -390,25 +390,25 @@ float StyleBoxFlat::get_style_margin(Margin p_margin) const {
}
void StyleBoxFlat::_bind_methods() {
- ClassDB::bind_method(_MD("set_bg_color","color"),&StyleBoxFlat::set_bg_color);
- ClassDB::bind_method(_MD("get_bg_color"),&StyleBoxFlat::get_bg_color);
- ClassDB::bind_method(_MD("set_light_color","color"),&StyleBoxFlat::set_light_color);
- ClassDB::bind_method(_MD("get_light_color"),&StyleBoxFlat::get_light_color);
- ClassDB::bind_method(_MD("set_dark_color","color"),&StyleBoxFlat::set_dark_color);
- ClassDB::bind_method(_MD("get_dark_color"),&StyleBoxFlat::get_dark_color);
- ClassDB::bind_method(_MD("set_border_size","size"),&StyleBoxFlat::set_border_size);
- ClassDB::bind_method(_MD("get_border_size"),&StyleBoxFlat::get_border_size);
- ClassDB::bind_method(_MD("set_border_blend","blend"),&StyleBoxFlat::set_border_blend);
- ClassDB::bind_method(_MD("get_border_blend"),&StyleBoxFlat::get_border_blend);
- ClassDB::bind_method(_MD("set_draw_center","size"),&StyleBoxFlat::set_draw_center);
- ClassDB::bind_method(_MD("get_draw_center"),&StyleBoxFlat::get_draw_center);
-
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "bg_color"), _SCS("set_bg_color"),_SCS("get_bg_color") );
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color"),_SCS("set_light_color"),_SCS("get_light_color"));
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "dark_color"),_SCS("set_dark_color"),_SCS("get_dark_color"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "border_size",PROPERTY_HINT_RANGE,"0,4096"),_SCS("set_border_size"),_SCS("get_border_size"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "border_blend"),_SCS("set_border_blend"),_SCS("get_border_blend"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_bg"),_SCS("set_draw_center"),_SCS("get_draw_center"));
+ ClassDB::bind_method(D_METHOD("set_bg_color","color"),&StyleBoxFlat::set_bg_color);
+ ClassDB::bind_method(D_METHOD("get_bg_color"),&StyleBoxFlat::get_bg_color);
+ ClassDB::bind_method(D_METHOD("set_light_color","color"),&StyleBoxFlat::set_light_color);
+ ClassDB::bind_method(D_METHOD("get_light_color"),&StyleBoxFlat::get_light_color);
+ ClassDB::bind_method(D_METHOD("set_dark_color","color"),&StyleBoxFlat::set_dark_color);
+ ClassDB::bind_method(D_METHOD("get_dark_color"),&StyleBoxFlat::get_dark_color);
+ ClassDB::bind_method(D_METHOD("set_border_size","size"),&StyleBoxFlat::set_border_size);
+ ClassDB::bind_method(D_METHOD("get_border_size"),&StyleBoxFlat::get_border_size);
+ ClassDB::bind_method(D_METHOD("set_border_blend","blend"),&StyleBoxFlat::set_border_blend);
+ ClassDB::bind_method(D_METHOD("get_border_blend"),&StyleBoxFlat::get_border_blend);
+ ClassDB::bind_method(D_METHOD("set_draw_center","size"),&StyleBoxFlat::set_draw_center);
+ ClassDB::bind_method(D_METHOD("get_draw_center"),&StyleBoxFlat::get_draw_center);
+
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "bg_color"), "set_bg_color","get_bg_color") ;
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color"),"set_light_color","get_light_color");
+ ADD_PROPERTY( PropertyInfo( Variant::COLOR, "dark_color"),"set_dark_color","get_dark_color");
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "border_size",PROPERTY_HINT_RANGE,"0,4096"),"set_border_size","get_border_size");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "border_blend"),"set_border_blend","get_border_blend");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_bg"),"set_draw_center","get_draw_center");
}
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index cc13c0ff11..cf07f1658b 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -650,9 +650,11 @@ void SurfaceTool::append_from(const Ref<Mesh>& p_existing, int p_surface,const T
for(List<int>::Element *E=nindices.front();E;E=E->next()) {
int dst_index = E->get()+vfrom;
- //if (dst_index <0 || dst_index>=vertex_array.size()) {
- // print_line("invalid index!");
- //}
+ /*
+ if (dst_index <0 || dst_index>=vertex_array.size()) {
+ print_line("invalid index!");
+ }
+ */
index_array.push_back(dst_index);
}
if (index_array.size()%3)
@@ -850,7 +852,7 @@ void SurfaceTool::clear() {
begun=false;
primitive=Mesh::PRIMITIVE_LINES;
format=0;
- last_bones.clear();;
+ last_bones.clear();
last_weights.clear();
index_array.clear();
vertex_array.clear();
@@ -860,25 +862,25 @@ void SurfaceTool::clear() {
void SurfaceTool::_bind_methods() {
- ClassDB::bind_method(_MD("begin","primitive"),&SurfaceTool::begin);
- ClassDB::bind_method(_MD("add_vertex","vertex"),&SurfaceTool::add_vertex);
- ClassDB::bind_method(_MD("add_color","color"),&SurfaceTool::add_color);
- ClassDB::bind_method(_MD("add_normal","normal"),&SurfaceTool::add_normal);
- ClassDB::bind_method(_MD("add_tangent","tangent"),&SurfaceTool::add_tangent);
- ClassDB::bind_method(_MD("add_uv","uv"),&SurfaceTool::add_uv);
- ClassDB::bind_method(_MD("add_uv2","uv2"),&SurfaceTool::add_uv2);
- ClassDB::bind_method(_MD("add_bones","bones"),&SurfaceTool::add_bones);
- ClassDB::bind_method(_MD("add_weights","weights"),&SurfaceTool::add_weights);
- ClassDB::bind_method(_MD("add_smooth_group","smooth"),&SurfaceTool::add_smooth_group);
- ClassDB::bind_method(_MD("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(_MD("set_material","material:Material"),&SurfaceTool::set_material);
- ClassDB::bind_method(_MD("index"),&SurfaceTool::index);
- ClassDB::bind_method(_MD("deindex"),&SurfaceTool::deindex);
- ///ClassDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals);
- ClassDB::bind_method(_MD("generate_normals"),&SurfaceTool::generate_normals);
- ClassDB::bind_method(_MD("add_index", "index"), &SurfaceTool::add_index);
- ClassDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("clear"),&SurfaceTool::clear);
+ 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);
+ ClassDB::bind_method(D_METHOD("add_tangent","tangent"),&SurfaceTool::add_tangent);
+ ClassDB::bind_method(D_METHOD("add_uv","uv"),&SurfaceTool::add_uv);
+ ClassDB::bind_method(D_METHOD("add_uv2","uv2"),&SurfaceTool::add_uv2);
+ 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("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("clear"),&SurfaceTool::clear);
}
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 462341a751..62feb7b37c 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -63,16 +63,15 @@ bool Texture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2
void Texture::_bind_methods() {
- ClassDB::bind_method(_MD("get_width"),&Texture::get_width);
- ClassDB::bind_method(_MD("get_height"),&Texture::get_height);
- ClassDB::bind_method(_MD("get_size"),&Texture::get_size);
- ClassDB::bind_method(_MD("get_rid"),&Texture::get_rid);
- ClassDB::bind_method(_MD("has_alpha"),&Texture::has_alpha);
- ClassDB::bind_method(_MD("set_flags","flags"),&Texture::set_flags);
- ClassDB::bind_method(_MD("get_flags"),&Texture::get_flags);
- ClassDB::bind_method(_MD("draw","canvas_item","pos","modulate","transpose"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ClassDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate","transpose"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ClassDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate","transpose"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_width"),&Texture::get_width);
+ ClassDB::bind_method(D_METHOD("get_height"),&Texture::get_height);
+ ClassDB::bind_method(D_METHOD("get_size"),&Texture::get_size);
+ ClassDB::bind_method(D_METHOD("has_alpha"),&Texture::has_alpha);
+ ClassDB::bind_method(D_METHOD("set_flags","flags"),&Texture::set_flags);
+ ClassDB::bind_method(D_METHOD("get_flags"),&Texture::get_flags);
+ ClassDB::bind_method(D_METHOD("draw","canvas_item","pos","modulate","transpose"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_rect","canvas_item","rect","tile","modulate","transpose"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_rect_region","canvas_item","rect","src_rect","modulate","transpose"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
BIND_CONSTANT( FLAG_MIPMAPS );
BIND_CONSTANT( FLAG_REPEAT );
@@ -407,27 +406,27 @@ void ImageTexture::_set_data(Dictionary p_data) {
void ImageTexture::_bind_methods() {
- ClassDB::bind_method(_MD("create","width","height","format","flags"),&ImageTexture::create,DEFVAL(FLAGS_DEFAULT));
- ClassDB::bind_method(_MD("create_from_image","image","flags"),&ImageTexture::create_from_image,DEFVAL(FLAGS_DEFAULT));
- ClassDB::bind_method(_MD("get_format"),&ImageTexture::get_format);
- ClassDB::bind_method(_MD("load","path"),&ImageTexture::load);
- ClassDB::bind_method(_MD("set_data","image"),&ImageTexture::set_data);
- ClassDB::bind_method(_MD("get_data","cube_side"),&ImageTexture::get_data);
- ClassDB::bind_method(_MD("set_storage","mode"),&ImageTexture::set_storage);
- ClassDB::bind_method(_MD("get_storage"),&ImageTexture::get_storage);
- ClassDB::bind_method(_MD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
- ClassDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
- ClassDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
- ClassDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
- ClassDB::bind_method(_MD("normal_to_xy"),&ImageTexture::normal_to_xy);
- ClassDB::bind_method(_MD("shrink_x2_and_keep_size"),&ImageTexture::shrink_x2_and_keep_size);
-
- ClassDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
- ClassDB::set_method_flags(get_class_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::set_method_flags(get_class_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::set_method_flags(get_class_static(),_SCS("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::set_method_flags(get_class_static(),_SCS("shrink_x2_and_keep_size"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ClassDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
+ ClassDB::bind_method(D_METHOD("create","width","height","format","flags"),&ImageTexture::create,DEFVAL(FLAGS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("create_from_image","image","flags"),&ImageTexture::create_from_image,DEFVAL(FLAGS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("get_format"),&ImageTexture::get_format);
+ ClassDB::bind_method(D_METHOD("load","path"),&ImageTexture::load);
+ ClassDB::bind_method(D_METHOD("set_data","image"),&ImageTexture::set_data);
+ ClassDB::bind_method(D_METHOD("get_data","cube_side"),&ImageTexture::get_data);
+ ClassDB::bind_method(D_METHOD("set_storage","mode"),&ImageTexture::set_storage);
+ ClassDB::bind_method(D_METHOD("get_storage"),&ImageTexture::get_storage);
+ ClassDB::bind_method(D_METHOD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
+ ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
+ ClassDB::bind_method(D_METHOD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
+ ClassDB::bind_method(D_METHOD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
+ ClassDB::bind_method(D_METHOD("normal_to_xy"),&ImageTexture::normal_to_xy);
+ ClassDB::bind_method(D_METHOD("shrink_x2_and_keep_size"),&ImageTexture::shrink_x2_and_keep_size);
+
+ ClassDB::bind_method(D_METHOD("set_size_override","size"),&ImageTexture::set_size_override);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::set_method_flags(get_class_static(),_scs_create("shrink_x2_and_keep_size"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("_reload_hook","rid"),&ImageTexture::_reload_hook);
BIND_CONSTANT( STORAGE_RAW );
@@ -454,6 +453,390 @@ ImageTexture::~ImageTexture() {
VisualServer::get_singleton()->free( texture );
}
+//////////////////////////////////////////
+
+
+void StreamTexture::_requested_3d(void* p_ud) {
+
+ StreamTexture *st = (StreamTexture *)p_ud;
+ Ref<StreamTexture> stex(st);
+ ERR_FAIL_COND(!request_3d_callback);
+ request_3d_callback(stex);
+}
+
+void StreamTexture::_requested_srgb(void* p_ud) {
+
+ StreamTexture *st = (StreamTexture *)p_ud;
+ Ref<StreamTexture> stex(st);
+ ERR_FAIL_COND(!request_srgb_callback);
+ request_srgb_callback(stex);
+
+}
+
+StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback=NULL;
+StreamTexture::TextureFormatRequestCallback StreamTexture::request_srgb_callback=NULL;
+
+
+uint32_t StreamTexture::get_flags() const {
+
+ return flags;
+}
+Image::Format StreamTexture::get_format() const {
+
+ return format;
+}
+
+
+Error StreamTexture::_load_data(const String& p_path,int &tw,int &th,int& flags,Image& image,int p_size_limit) {
+
+
+ FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
+ ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
+
+ uint8_t header[4];
+ f->get_buffer(header,4);
+ if (header[0]!='G' || header[1]!='D' || header[2]!='S' || header[3]!='T') {
+ memdelete(f);
+ ERR_FAIL_COND_V(header[0]!='G' || header[1]!='D' || header[2]!='S' || header[3]!='T',ERR_FILE_CORRUPT);
+ }
+
+ tw = f->get_32();
+ th = f->get_32();
+ flags= f->get_32(); //texture flags!
+ uint32_t df = f->get_32(); //data format
+
+ print_line("width: "+itos(tw));
+ print_line("height: "+itos(th));
+ print_line("flags: "+itos(flags));
+ print_line("df: "+itos(df));
+
+
+ if (request_3d_callback && df&FORMAT_BIT_DETECT_3D) {
+ print_line("request detect 3D at "+p_path);
+ VS::get_singleton()->texture_set_detect_3d_callback(texture,_requested_3d,this);
+ } else {
+ print_line("not requesting detect 3D at "+p_path);
+ VS::get_singleton()->texture_set_detect_3d_callback(texture,NULL,NULL);
+ }
+
+ if (request_srgb_callback && df&FORMAT_BIT_DETECT_SRGB) {
+ print_line("request detect srgb at "+p_path);
+ VS::get_singleton()->texture_set_detect_srgb_callback(texture,_requested_srgb,this);
+ } else {
+ VS::get_singleton()->texture_set_detect_srgb_callback(texture,NULL,NULL);
+ print_line("not requesting detect srgb at "+p_path);
+ }
+
+ if (!(df&FORMAT_BIT_STREAM)) {
+ p_size_limit=0;
+ }
+
+
+ if (df&FORMAT_BIT_LOSSLESS || df&FORMAT_BIT_LOSSY) {
+ //look for a PNG or WEBP file inside
+
+ int sw=tw;
+ int sh=th;
+
+ uint32_t mipmaps = f->get_32();
+ uint32_t size = f->get_32();
+
+ print_line("mipmaps: "+itos(mipmaps));
+
+ while(mipmaps>1 && p_size_limit>0 && (sw>p_size_limit || sh>p_size_limit)) {
+
+ f->seek(f->get_pos()+size);
+ mipmaps = f->get_32();
+ size = f->get_32();
+
+ sw=MAX(sw>>1,1);
+ sh=MAX(sh>>1,1);
+ mipmaps--;
+ }
+
+ //mipmaps need to be read independently, they will be later combined
+ Vector<Image> mipmap_images;
+ int total_size=0;
+
+ for(int i=0;i<mipmaps;i++) {
+
+ if (i>0) {
+ size = f->get_32();
+ }
+
+ PoolVector<uint8_t> pv;
+ pv.resize(size);
+ {
+ PoolVector<uint8_t>::Write w = pv.write();
+ f->get_buffer(w.ptr(),size);
+ }
+
+ Image img;
+ if (df&FORMAT_BIT_LOSSLESS) {
+ img = Image::lossless_unpacker(pv);
+ } else {
+ img = Image::lossy_unpacker(pv);
+ }
+
+ if (img.empty()) {
+ memdelete(f);
+ ERR_FAIL_COND_V(img.empty(),ERR_FILE_CORRUPT);
+ }
+ total_size+=img.get_data().size();
+
+ mipmap_images.push_back(img);
+ }
+
+ print_line("mipmap read total: "+itos(mipmap_images.size()));
+
+
+ memdelete(f); //no longer needed
+
+ if (mipmap_images.size()==1) {
+
+ image=mipmap_images[0];
+ return OK;
+
+ } else {
+ PoolVector<uint8_t> img_data;
+ img_data.resize(total_size);
+
+ {
+ PoolVector<uint8_t>::Write w=img_data.write();
+
+ int ofs=0;
+ for(int i=0;i<mipmap_images.size();i++) {
+
+ PoolVector<uint8_t> id = mipmap_images[i].get_data();
+ int len = id.size();
+ PoolVector<uint8_t>::Read r = id.read();
+ copymem(&w[ofs],r.ptr(),len);
+ ofs+=len;
+ }
+ }
+
+ image = Image(sw,sh,true,mipmap_images[0].get_format(),img_data);
+ return OK;
+ }
+
+ } else {
+
+ //look for regular format
+ Image::Format format = (Image::Format)(df&FORMAT_MASK_IMAGE_FORMAT);
+ bool mipmaps = df&FORMAT_BIT_HAS_MIPMAPS;
+
+ if (!mipmaps) {
+ int size = Image::get_image_data_size(tw,th,format,0);
+
+ PoolVector<uint8_t> img_data;
+ img_data.resize(size);
+
+ {
+ PoolVector<uint8_t>::Write w=img_data.write();
+ f->get_buffer(w.ptr(),size);
+ }
+
+ memdelete(f);
+
+ image = Image(tw,th,false,format,img_data);
+ return OK;
+ } else {
+
+ int sw=tw;
+ int sh=th;
+
+ int mipmaps = Image::get_image_required_mipmaps(tw,th,format);
+ int total_size = Image::get_image_data_size(tw,th,format,mipmaps);
+ int idx=0;
+ int ofs=0;
+
+
+ while(mipmaps>1 && p_size_limit>0 && (sw>p_size_limit || sh>p_size_limit)) {
+
+ sw=MAX(sw>>1,1);
+ sh=MAX(sh>>1,1);
+ mipmaps--;
+ idx++;
+ }
+
+ if (idx>0) {
+ ofs=Image::get_image_data_size(tw,th,format,idx-1);
+ }
+
+ if (total_size - ofs <=0) {
+ memdelete(f);
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
+ }
+
+ f->seek(f->get_pos()+ofs);
+
+
+ PoolVector<uint8_t> img_data;
+ img_data.resize(total_size - ofs);
+
+ {
+ PoolVector<uint8_t>::Write w=img_data.write();
+ int bytes = f->get_buffer(w.ptr(),total_size - ofs);
+ print_line("requested read: "+itos(total_size - ofs)+" but got: "+itos(bytes));
+
+ memdelete(f);
+
+ if (bytes != total_size - ofs) {
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
+ }
+ }
+
+ image = Image(sw,sh,true,format,img_data);
+
+ return OK;
+ }
+ }
+
+ return ERR_BUG; //unreachable
+}
+
+Error StreamTexture::load(const String& p_path) {
+
+
+ int lw,lh,lflags;
+ Image image;
+ Error err = _load_data(p_path,lw,lh,lflags,image);
+ if (err)
+ return err;
+
+ VS::get_singleton()->texture_allocate(texture,image.get_width(),image.get_height(),image.get_format(),lflags);
+ VS::get_singleton()->texture_set_data(texture,image);
+
+ w=lw;
+ h=lh;
+ flags=lflags;
+ path_to_file=p_path;
+ format=image.get_format();
+
+ return OK;
+}
+String StreamTexture::get_load_path() const {
+
+ return path_to_file;
+}
+
+int StreamTexture::get_width() const {
+
+ return w;
+}
+int StreamTexture::get_height() const {
+
+ return h;
+}
+RID StreamTexture::get_rid() const {
+
+ return texture;
+}
+
+
+void StreamTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
+
+ if ((w|h)==0)
+ return;
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, Size2(w,h)),texture,false,p_modulate,p_transpose);
+
+}
+void StreamTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
+
+ if ((w|h)==0)
+ return;
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,texture,p_tile,p_modulate,p_transpose);
+
+}
+void StreamTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const{
+
+ if ((w|h)==0)
+ return;
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,texture,p_src_rect,p_modulate,p_transpose);
+}
+
+bool StreamTexture::has_alpha() const {
+
+ return false;
+}
+
+Image StreamTexture::get_data() const {
+
+ return VS::get_singleton()->texture_get_data(texture);
+}
+
+void StreamTexture::set_flags(uint32_t p_flags){
+
+}
+
+void StreamTexture::reload_from_file() {
+
+#ifdef TOOLS_ENABLED
+ String ipath = get_import_path();
+ if (ipath.is_resource_file() && ipath!=path_to_file) {
+ path_to_file=ipath;
+ }
+#endif
+ load(path_to_file);
+}
+
+void StreamTexture::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("load","path"),&StreamTexture::load);
+ ClassDB::bind_method(D_METHOD("get_load_path"),&StreamTexture::get_load_path);
+
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"load_path",PROPERTY_HINT_FILE,"*.stex"),"load","get_load_path");
+}
+
+
+StreamTexture::StreamTexture() {
+
+ format=Image::FORMAT_MAX;
+ flags=0;
+ w=0;
+ h=0;
+
+ texture = VS::get_singleton()->texture_create();
+}
+
+StreamTexture::~StreamTexture() {
+
+ VS::get_singleton()->free(texture);
+}
+
+
+
+RES ResourceFormatLoaderStreamTexture::load(const String &p_path,const String& p_original_path,Error *r_error) {
+
+ Ref<StreamTexture> st;
+ st.instance();
+ Error err = st->load(p_path);
+ if (r_error)
+ *r_error=err;
+ if (err!=OK)
+ return RES();
+
+ return st;
+}
+
+void ResourceFormatLoaderStreamTexture::get_recognized_extensions(List<String> *p_extensions) const{
+
+ p_extensions->push_back("stex");
+}
+bool ResourceFormatLoaderStreamTexture::handles_type(const String& p_type) const{
+ return p_type=="StreamTexture";
+
+}
+String ResourceFormatLoaderStreamTexture::get_resource_type(const String &p_path) const{
+
+ if (p_path.get_extension().to_lower()=="stex")
+ return "StreamTexture";
+ return "";
+}
+
+
+
+
//////////////////////////////////////////
@@ -549,20 +932,20 @@ Rect2 AtlasTexture::get_margin() const {
void AtlasTexture::_bind_methods() {
- ClassDB::bind_method(_MD("set_atlas","atlas:Texture"),&AtlasTexture::set_atlas);
- ClassDB::bind_method(_MD("get_atlas:Texture"),&AtlasTexture::get_atlas);
+ ClassDB::bind_method(D_METHOD("set_atlas","atlas:Texture"),&AtlasTexture::set_atlas);
+ ClassDB::bind_method(D_METHOD("get_atlas:Texture"),&AtlasTexture::get_atlas);
- ClassDB::bind_method(_MD("set_region","region"),&AtlasTexture::set_region);
- ClassDB::bind_method(_MD("get_region"),&AtlasTexture::get_region);
+ ClassDB::bind_method(D_METHOD("set_region","region"),&AtlasTexture::set_region);
+ ClassDB::bind_method(D_METHOD("get_region"),&AtlasTexture::get_region);
- ClassDB::bind_method(_MD("set_margin","margin"),&AtlasTexture::set_margin);
- ClassDB::bind_method(_MD("get_margin"),&AtlasTexture::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin","margin"),&AtlasTexture::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"),&AtlasTexture::get_margin);
ADD_SIGNAL(MethodInfo("atlas_changed"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_atlas"),_SCS("get_atlas") );
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region"), _SCS("set_region"),_SCS("get_region") );
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "margin"), _SCS("set_margin"),_SCS("get_margin") );
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), "set_atlas","get_atlas") ;
+ ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region"), "set_region","get_region") ;
+ ADD_PROPERTY( PropertyInfo( Variant::RECT2, "margin"), "set_margin","get_margin") ;
}
@@ -804,20 +1187,20 @@ Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const{
void LargeTexture::_bind_methods() {
- ClassDB::bind_method(_MD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
- ClassDB::bind_method(_MD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
- ClassDB::bind_method(_MD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
- ClassDB::bind_method(_MD("set_size","size"),&LargeTexture::set_size);
- ClassDB::bind_method(_MD("clear"),&LargeTexture::clear);
+ ClassDB::bind_method(D_METHOD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
+ ClassDB::bind_method(D_METHOD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
+ ClassDB::bind_method(D_METHOD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
+ ClassDB::bind_method(D_METHOD("set_size","size"),&LargeTexture::set_size);
+ ClassDB::bind_method(D_METHOD("clear"),&LargeTexture::clear);
- ClassDB::bind_method(_MD("get_piece_count"),&LargeTexture::get_piece_count);
- ClassDB::bind_method(_MD("get_piece_offset","idx"),&LargeTexture::get_piece_offset);
- ClassDB::bind_method(_MD("get_piece_texture:Texture","idx"),&LargeTexture::get_piece_texture);
+ ClassDB::bind_method(D_METHOD("get_piece_count"),&LargeTexture::get_piece_count);
+ ClassDB::bind_method(D_METHOD("get_piece_offset","idx"),&LargeTexture::get_piece_offset);
+ ClassDB::bind_method(D_METHOD("get_piece_texture:Texture","idx"),&LargeTexture::get_piece_texture);
- ClassDB::bind_method(_MD("_set_data","data"),&LargeTexture::_set_data);
- ClassDB::bind_method(_MD("_get_data"),&LargeTexture::_get_data);
+ ClassDB::bind_method(D_METHOD("_set_data","data"),&LargeTexture::_set_data);
+ ClassDB::bind_method(D_METHOD("_get_data"),&LargeTexture::_get_data);
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data") );
+ ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), "_set_data","_get_data") ;
}
@@ -1048,18 +1431,18 @@ void CubeMap::_get_property_list( List<PropertyInfo> *p_list) const {
void CubeMap::_bind_methods() {
- ClassDB::bind_method(_MD("get_width"),&CubeMap::get_width);
- ClassDB::bind_method(_MD("get_height"),&CubeMap::get_height);
- ClassDB::bind_method(_MD("get_rid"),&CubeMap::get_rid);
- ClassDB::bind_method(_MD("set_flags","flags"),&CubeMap::set_flags);
- ClassDB::bind_method(_MD("get_flags"),&CubeMap::get_flags);
-
- ClassDB::bind_method(_MD("set_side","side","image"),&CubeMap::set_side);
- ClassDB::bind_method(_MD("get_side","side"),&CubeMap::get_side);
- ClassDB::bind_method(_MD("set_storage","mode"),&CubeMap::set_storage);
- ClassDB::bind_method(_MD("get_storage"),&CubeMap::get_storage);
- ClassDB::bind_method(_MD("set_lossy_storage_quality","quality"),&CubeMap::set_lossy_storage_quality);
- ClassDB::bind_method(_MD("get_lossy_storage_quality"),&CubeMap::get_lossy_storage_quality);
+ ClassDB::bind_method(D_METHOD("get_width"),&CubeMap::get_width);
+ ClassDB::bind_method(D_METHOD("get_height"),&CubeMap::get_height);
+ //ClassDB::bind_method(D_METHOD("get_rid"),&CubeMap::get_rid);
+ 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_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);
+ ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"),&CubeMap::get_lossy_storage_quality);
BIND_CONSTANT( STORAGE_RAW );
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index aac3514af3..cae77ad5cf 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -31,6 +31,7 @@
#include "resource.h"
#include "servers/visual_server.h"
+#include "io/resource_loader.h"
#include "math_2d.h"
/**
@@ -75,7 +76,7 @@ public:
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
-
+ virtual Image get_data() const { return Image(); }
Texture();
};
@@ -160,6 +161,88 @@ public:
};
+
+class StreamTexture : public Texture {
+
+ GDCLASS( StreamTexture, Texture );
+public:
+ enum DataFormat {
+ DATA_FORMAT_IMAGE,
+ DATA_FORMAT_LOSSLESS,
+ DATA_FORMAT_LOSSY
+ };
+
+ enum FormatBits {
+ FORMAT_MASK_IMAGE_FORMAT=(1<<20)-1,
+ FORMAT_BIT_LOSSLESS=1<<20,
+ FORMAT_BIT_LOSSY=1<<21,
+ FORMAT_BIT_STREAM=1<<22,
+ FORMAT_BIT_HAS_MIPMAPS=1<<23,
+ FORMAT_BIT_DETECT_3D=1<<24,
+ FORMAT_BIT_DETECT_SRGB=1<<25,
+ };
+
+private:
+
+ Error _load_data(const String &p_path, int &tw, int &th, int& flags, Image& image, int p_size_limit=0);
+ String path_to_file;
+ RID texture;
+ Image::Format format;
+ uint32_t flags;
+ int w,h;
+
+ virtual void reload_from_file();
+
+ static void _requested_3d(void* p_ud);
+ static void _requested_srgb(void* p_ud);
+
+protected:
+
+ static void _bind_methods();
+
+public:
+
+
+ typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture>&);
+
+ static TextureFormatRequestCallback request_3d_callback;
+ static TextureFormatRequestCallback request_srgb_callback;
+
+ uint32_t get_flags() const;
+ Image::Format get_format() const;
+ Error load(const String& p_path);
+ String get_load_path() const;
+
+ int get_width() const;
+ int get_height() const;
+ virtual RID get_rid() const;
+
+ virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
+ virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
+ virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
+
+ virtual bool has_alpha() const;
+ virtual void set_flags(uint32_t p_flags);
+
+ virtual Image get_data() const;
+
+ StreamTexture();
+ ~StreamTexture();
+
+};
+
+
+class ResourceFormatLoaderStreamTexture : 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;
+
+};
+
+
+
VARIANT_ENUM_CAST( ImageTexture::Storage );
class AtlasTexture : public Texture {
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 2e3afbf057..10ad38d498 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -233,7 +233,7 @@ void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) {
}
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -267,7 +267,7 @@ void Theme::set_default_font( const Ref<Font>& p_font ) {
void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref<Texture>& p_icon) {
-// ERR_FAIL_COND(p_icon.is_null());
+ //ERR_FAIL_COND(p_icon.is_null());
bool new_value=!icon_map.has(p_type) || !icon_map[p_type].has(p_name);
@@ -275,7 +275,7 @@ void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref
if (new_value) {
_change_notify();
- emit_changed();;
+ emit_changed();
}
}
Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) const {
@@ -301,7 +301,7 @@ void Theme::clear_icon(const StringName& p_name,const StringName& p_type) {
icon_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -326,7 +326,7 @@ void Theme::set_shader(const StringName &p_name,const StringName &p_type,const R
if (new_value) {
_change_notify();
- emit_changed();;
+ emit_changed();
}
}
@@ -348,7 +348,7 @@ void Theme::clear_shader(const StringName &p_name, const StringName &p_type) {
shader_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) const {
@@ -367,7 +367,7 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list)
void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const Ref<StyleBox>& p_style) {
-// ERR_FAIL_COND(p_style.is_null());
+ //ERR_FAIL_COND(p_style.is_null());
bool new_value=!style_map.has(p_type) || !style_map[p_type].has(p_name);
@@ -375,7 +375,7 @@ void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const
if (new_value)
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -403,7 +403,7 @@ void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) {
style_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -430,7 +430,7 @@ void Theme::get_stylebox_types(List<StringName> *p_list) const {
void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref<Font>& p_font) {
-// ERR_FAIL_COND(p_font.is_null());
+ //ERR_FAIL_COND(p_font.is_null());
bool new_value=!font_map.has(p_type) || !font_map[p_type].has(p_name);
@@ -447,7 +447,7 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref
if (new_value) {
_change_notify();
- emit_changed();;
+ emit_changed();
}
}
Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) const {
@@ -477,7 +477,7 @@ void Theme::clear_font(const StringName& p_name,const StringName& p_type) {
font_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -503,7 +503,7 @@ void Theme::set_color(const StringName& p_name,const StringName& p_type,const Co
if (new_value) {
_change_notify();
- emit_changed();;
+ emit_changed();
}
}
@@ -531,7 +531,7 @@ void Theme::clear_color(const StringName& p_name,const StringName& p_type) {
color_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -556,7 +556,7 @@ void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p
if (new_value) {
_change_notify();
- emit_changed();;
+ emit_changed();
}
}
@@ -582,7 +582,7 @@ void Theme::clear_constant(const StringName& p_name,const StringName& p_type) {
constant_map[p_type].erase(p_name);
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -611,7 +611,7 @@ void Theme::copy_default_theme() {
color_map=default_theme->color_map;
constant_map=default_theme->constant_map;
_change_notify();
- emit_changed();;
+ emit_changed();
}
@@ -664,50 +664,50 @@ void Theme::get_type_list(List<StringName> *p_list) const {
void Theme::_bind_methods() {
- ClassDB::bind_method(_MD("set_icon","name","type","texture:Texture"),&Theme::set_icon);
- ClassDB::bind_method(_MD("get_icon:Texture","name","type"),&Theme::get_icon);
- ClassDB::bind_method(_MD("has_icon","name","type"),&Theme::has_icon);
- ClassDB::bind_method(_MD("clear_icon","name","type"),&Theme::clear_icon);
- ClassDB::bind_method(_MD("get_icon_list","type"),&Theme::_get_icon_list);
+ ClassDB::bind_method(D_METHOD("set_icon","name","type","texture:Texture"),&Theme::set_icon);
+ ClassDB::bind_method(D_METHOD("get_icon:Texture","name","type"),&Theme::get_icon);
+ ClassDB::bind_method(D_METHOD("has_icon","name","type"),&Theme::has_icon);
+ ClassDB::bind_method(D_METHOD("clear_icon","name","type"),&Theme::clear_icon);
+ ClassDB::bind_method(D_METHOD("get_icon_list","type"),&Theme::_get_icon_list);
- ClassDB::bind_method(_MD("set_stylebox","name","type","texture:StyleBox"),&Theme::set_stylebox);
- ClassDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Theme::get_stylebox);
- ClassDB::bind_method(_MD("has_stylebox","name","type"),&Theme::has_stylebox);
- ClassDB::bind_method(_MD("clear_stylebox","name","type"),&Theme::clear_stylebox);
- ClassDB::bind_method(_MD("get_stylebox_list","type"),&Theme::_get_stylebox_list);
- ClassDB::bind_method(_MD("get_stylebox_types"),&Theme::_get_stylebox_types);
+ ClassDB::bind_method(D_METHOD("set_stylebox","name","type","texture:StyleBox"),&Theme::set_stylebox);
+ ClassDB::bind_method(D_METHOD("get_stylebox:StyleBox","name","type"),&Theme::get_stylebox);
+ ClassDB::bind_method(D_METHOD("has_stylebox","name","type"),&Theme::has_stylebox);
+ ClassDB::bind_method(D_METHOD("clear_stylebox","name","type"),&Theme::clear_stylebox);
+ ClassDB::bind_method(D_METHOD("get_stylebox_list","type"),&Theme::_get_stylebox_list);
+ ClassDB::bind_method(D_METHOD("get_stylebox_types"),&Theme::_get_stylebox_types);
- ClassDB::bind_method(_MD("set_font","name","type","font:Font"),&Theme::set_font);
- ClassDB::bind_method(_MD("get_font:Font","name","type"),&Theme::get_font);
- ClassDB::bind_method(_MD("has_font","name","type"),&Theme::has_font);
- ClassDB::bind_method(_MD("clear_font","name","type"),&Theme::clear_font);
- ClassDB::bind_method(_MD("get_font_list","type"),&Theme::_get_font_list);
+ ClassDB::bind_method(D_METHOD("set_font","name","type","font:Font"),&Theme::set_font);
+ ClassDB::bind_method(D_METHOD("get_font:Font","name","type"),&Theme::get_font);
+ ClassDB::bind_method(D_METHOD("has_font","name","type"),&Theme::has_font);
+ ClassDB::bind_method(D_METHOD("clear_font","name","type"),&Theme::clear_font);
+ ClassDB::bind_method(D_METHOD("get_font_list","type"),&Theme::_get_font_list);
- ClassDB::bind_method(_MD("set_color","name","type","color"),&Theme::set_color);
- ClassDB::bind_method(_MD("get_color","name","type"),&Theme::get_color);
- ClassDB::bind_method(_MD("has_color","name","type"),&Theme::has_color);
- ClassDB::bind_method(_MD("clear_color","name","type"),&Theme::clear_color);
- ClassDB::bind_method(_MD("get_color_list","type"),&Theme::_get_color_list);
+ ClassDB::bind_method(D_METHOD("set_color","name","type","color"),&Theme::set_color);
+ ClassDB::bind_method(D_METHOD("get_color","name","type"),&Theme::get_color);
+ ClassDB::bind_method(D_METHOD("has_color","name","type"),&Theme::has_color);
+ ClassDB::bind_method(D_METHOD("clear_color","name","type"),&Theme::clear_color);
+ ClassDB::bind_method(D_METHOD("get_color_list","type"),&Theme::_get_color_list);
- ClassDB::bind_method(_MD("set_constant","name","type","constant"),&Theme::set_constant);
- ClassDB::bind_method(_MD("get_constant","name","type"),&Theme::get_constant);
- ClassDB::bind_method(_MD("has_constant","name","type"),&Theme::has_constant);
- ClassDB::bind_method(_MD("clear_constant","name","type"),&Theme::clear_constant);
- ClassDB::bind_method(_MD("get_constant_list","type"),&Theme::_get_constant_list);
+ ClassDB::bind_method(D_METHOD("set_constant","name","type","constant"),&Theme::set_constant);
+ ClassDB::bind_method(D_METHOD("get_constant","name","type"),&Theme::get_constant);
+ ClassDB::bind_method(D_METHOD("has_constant","name","type"),&Theme::has_constant);
+ 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(_MD("set_default_font","font"),&Theme::set_default_theme_font);
- ClassDB::bind_method(_MD("get_default_font"),&Theme::get_default_theme_font);
+ 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(_MD("get_type_list","type"),&Theme::_get_type_list);
+ ClassDB::bind_method(D_METHOD("get_type_list","type"),&Theme::_get_type_list);
- ClassDB::bind_method(_MD("_emit_theme_changed"),&Theme::_emit_theme_changed);
+ ClassDB::bind_method(D_METHOD("_emit_theme_changed"),&Theme::_emit_theme_changed);
ClassDB::bind_method("copy_default_theme",&Theme::copy_default_theme);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"default_font",PROPERTY_HINT_RESOURCE_TYPE,"Font"),_SCS("set_default_font"),_SCS("get_default_font"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"default_font",PROPERTY_HINT_RESOURCE_TYPE,"Font"),"set_default_font","get_default_font");
}
@@ -999,7 +999,7 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
ERR_FAIL_V(RES());
}
-// int margin = params[i+ccodes+1].to_int();
+ //int margin = params[i+ccodes+1].to_int();
//sbflat->set_margin_size(Margin(i),margin);
}
} else if (params.size()!=ccodes+1) {
@@ -1147,7 +1147,7 @@ bool ResourceFormatLoaderTheme::handles_type(const String& p_type) const {
String ResourceFormatLoaderTheme::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="theme")
+ if (p_path.get_extension().to_lower()=="theme")
return "Theme";
return "";
}
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 1811dee384..e12d8057d8 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -48,6 +48,8 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) {
tile_set_texture_offset(id,p_value);
else if (what=="material")
tile_set_material(id,p_value);
+ else if (what=="modulate")
+ tile_set_modulate(id,p_value);
else if (what=="shape_offset")
tile_set_shape_offset(id,p_value);
else if (what=="region")
@@ -91,6 +93,8 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{
r_ret=tile_get_texture_offset(id);
else if (what=="material")
r_ret=tile_get_material(id);
+ else if (what=="modulate")
+ r_ret=tile_get_modulate(id);
else if (what=="shape_offset")
r_ret=tile_get_shape_offset(id);
else if (what=="region")
@@ -124,6 +128,7 @@ void TileSet::_get_property_list( List<PropertyInfo> *p_list) const{
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"material",PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemMaterial"));
+ p_list->push_back(PropertyInfo(Variant::COLOR,pre+"modulate"));
p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region"));
p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"occluder_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"));
@@ -175,6 +180,20 @@ Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const{
}
+void TileSet::tile_set_modulate(int p_id,const Color &p_modulate) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].modulate=p_modulate;
+ emit_changed();
+
+}
+
+Color TileSet::tile_get_modulate(int p_id) const{
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Color(1,1,1));
+ return tile_map[p_id].modulate;
+}
+
void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -407,37 +426,37 @@ void TileSet::clear() {
void TileSet::_bind_methods() {
- ClassDB::bind_method(_MD("create_tile","id"),&TileSet::create_tile);
- ClassDB::bind_method(_MD("tile_set_name","id","name"),&TileSet::tile_set_name);
- ClassDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
- ClassDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
- ClassDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
- ClassDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
- ClassDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
- ClassDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
- ClassDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
- ClassDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
- ClassDB::bind_method(_MD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
- ClassDB::bind_method(_MD("tile_set_region","id","region"),&TileSet::tile_set_region);
- ClassDB::bind_method(_MD("tile_get_region","id"),&TileSet::tile_get_region);
- ClassDB::bind_method(_MD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
- ClassDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
- ClassDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes);
- ClassDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes);
- ClassDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
- ClassDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
- ClassDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
- ClassDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
- ClassDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
- ClassDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
- ClassDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
- ClassDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
-
- ClassDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile);
- ClassDB::bind_method(_MD("clear"),&TileSet::clear);
- ClassDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
- ClassDB::bind_method(_MD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
- ClassDB::bind_method(_MD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
+ ClassDB::bind_method(D_METHOD("create_tile","id"),&TileSet::create_tile);
+ ClassDB::bind_method(D_METHOD("tile_set_name","id","name"),&TileSet::tile_set_name);
+ ClassDB::bind_method(D_METHOD("tile_get_name","id"),&TileSet::tile_get_name);
+ ClassDB::bind_method(D_METHOD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
+ ClassDB::bind_method(D_METHOD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
+ ClassDB::bind_method(D_METHOD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
+ ClassDB::bind_method(D_METHOD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
+ ClassDB::bind_method(D_METHOD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
+ ClassDB::bind_method(D_METHOD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
+ ClassDB::bind_method(D_METHOD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
+ ClassDB::bind_method(D_METHOD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
+ ClassDB::bind_method(D_METHOD("tile_set_region","id","region"),&TileSet::tile_set_region);
+ ClassDB::bind_method(D_METHOD("tile_get_region","id"),&TileSet::tile_get_region);
+ ClassDB::bind_method(D_METHOD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
+ ClassDB::bind_method(D_METHOD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
+ 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);
+ ClassDB::bind_method(D_METHOD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
+ ClassDB::bind_method(D_METHOD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
+ ClassDB::bind_method(D_METHOD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
+ ClassDB::bind_method(D_METHOD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
+ ClassDB::bind_method(D_METHOD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
+ ClassDB::bind_method(D_METHOD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
+ ClassDB::bind_method(D_METHOD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
+
+ ClassDB::bind_method(D_METHOD("remove_tile","id"),&TileSet::remove_tile);
+ ClassDB::bind_method(D_METHOD("clear"),&TileSet::clear);
+ ClassDB::bind_method(D_METHOD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
+ ClassDB::bind_method(D_METHOD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
+ ClassDB::bind_method(D_METHOD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index ce40e5ebe3..b80889fc6f 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -52,6 +52,10 @@ class TileSet : public Resource {
Vector2 navigation_polygon_offset;
Ref<NavigationPolygon> navigation_polygon;
Ref<CanvasItemMaterial> material;
+ Color modulate;
+
+ // Default modulate for back-compat
+ explicit Data() : modulate(1,1,1) {}
};
Map<int,Data> tile_map;
@@ -94,6 +98,9 @@ public:
void tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material);
Ref<CanvasItemMaterial> tile_get_material(int p_id) const;
+ void tile_set_modulate(int p_id,const Color &p_color);
+ Color tile_get_modulate(int p_id) const;
+
void tile_set_occluder_offset(int p_id,const Vector2& p_offset);
Vector2 tile_get_occluder_offset(int p_id) const;
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index 3f7261c312..f9233d950c 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -287,10 +287,6 @@ RID World::get_scenario() const{
return scenario;
}
-RID World::get_sound_space() const{
-
- return sound_space;
-}
void World::set_environment(const Ref<Environment>& p_environment) {
@@ -314,13 +310,12 @@ PhysicsDirectSpaceState *World::get_direct_space_state() {
void World::_bind_methods() {
- ClassDB::bind_method(_MD("get_space"),&World::get_space);
- ClassDB::bind_method(_MD("get_scenario"),&World::get_scenario);
- ClassDB::bind_method(_MD("get_sound_space"),&World::get_sound_space);
- ClassDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment);
- ClassDB::bind_method(_MD("get_environment:Environment"),&World::get_environment);
- ClassDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
+ ClassDB::bind_method(D_METHOD("get_space"),&World::get_space);
+ ClassDB::bind_method(D_METHOD("get_scenario"),&World::get_scenario);
+ ClassDB::bind_method(D_METHOD("set_environment","env:Environment"),&World::set_environment);
+ ClassDB::bind_method(D_METHOD("get_environment:Environment"),&World::get_environment);
+ ClassDB::bind_method(D_METHOD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),"set_environment","get_environment");
}
@@ -329,7 +324,6 @@ World::World() {
space = PhysicsServer::get_singleton()->space_create();
scenario = VisualServer::get_singleton()->scenario_create();
- sound_space = SpatialSoundServer::get_singleton()->space_create();
PhysicsServer::get_singleton()->space_set_active(space,true);
PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/3d/default_gravity",9.8));
@@ -348,7 +342,6 @@ World::~World() {
PhysicsServer::get_singleton()->free(space);
VisualServer::get_singleton()->free(scenario);
- SpatialSoundServer::get_singleton()->free(sound_space);
#ifndef _3D_DISABLED
memdelete( indexer );
diff --git a/scene/resources/world.h b/scene/resources/world.h
index bea07882d7..1ad60f3405 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -32,7 +32,6 @@
#include "resource.h"
#include "servers/physics_server.h"
#include "servers/visual_server.h"
-#include "servers/spatial_sound_server.h"
#include "scene/resources/environment.h"
class SpatialIndexer;
@@ -45,7 +44,6 @@ class World : public Resource {
private:
RID space;
RID scenario;
- RID sound_space;
SpatialIndexer* indexer;
Ref<Environment> environment;
@@ -71,7 +69,6 @@ public:
RID get_space() const;
RID get_scenario() const;
- RID get_sound_space() const;
void set_environment(const Ref<Environment>& p_environment);
Ref<Environment> get_environment() const;
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 98c5ae3bb9..6b745d5d35 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -29,12 +29,12 @@
#include "world_2d.h"
#include "servers/visual_server.h"
#include "servers/physics_2d_server.h"
-#include "servers/spatial_sound_2d_server.h"
-#include "globals.h"
+//#include "servers/spatial_sound_2d_server.h"
+#include "global_config.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/main/viewport.h"
#include "scene/2d/camera_2d.h"
-#include "globals.h"
+#include "global_config.h"
struct SpatialIndexer2D {
@@ -382,11 +382,11 @@ RID World2D::get_sound_space() {
void World2D::_bind_methods() {
- ClassDB::bind_method(_MD("get_canvas"),&World2D::get_canvas);
- ClassDB::bind_method(_MD("get_space"),&World2D::get_space);
- ClassDB::bind_method(_MD("get_sound_space"),&World2D::get_sound_space);
+ ClassDB::bind_method(D_METHOD("get_canvas"),&World2D::get_canvas);
+ ClassDB::bind_method(D_METHOD("get_space"),&World2D::get_space);
+ ClassDB::bind_method(D_METHOD("get_sound_space"),&World2D::get_sound_space);
- ClassDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
+ ClassDB::bind_method(D_METHOD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
}
@@ -400,18 +400,11 @@ World2D::World2D() {
canvas = VisualServer::get_singleton()->canvas_create();
space = Physics2DServer::get_singleton()->space_create();
- sound_space = SpatialSound2DServer::get_singleton()->space_create();
//set space2D to be more friendly with pixels than meters, by adjusting some constants
Physics2DServer::get_singleton()->space_set_active(space,true);
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/2d/default_gravity",98));
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics/2d/default_gravity_vector",Vector2(0,1)));
- // TODO: Remove this deprecation warning and compatibility code for 2.2 or 3.0
- if (GlobalConfig::get_singleton()->get("physics/2d/default_density") && !GlobalConfig::get_singleton()->get("physics/2d/default_linear_damp")) {
- WARN_PRINT("Deprecated parameter 'physics/2d/default_density'. It was renamed to 'physics/2d/default_linear_damp', adjusting your project settings accordingly (make sure to adjust scripts that potentially rely on 'physics/2d/default_density'.");
- GlobalConfig::get_singleton()->set("physics/2d/default_linear_damp", GlobalConfig::get_singleton()->get("physics/2d/default_density"));
- GlobalConfig::get_singleton()->save();
- }
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics/2d/default_linear_damp",0.1));
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics/2d/default_angular_damp",1));
indexer = memnew( SpatialIndexer2D );
@@ -423,6 +416,5 @@ World2D::~World2D() {
VisualServer::get_singleton()->free(canvas);
Physics2DServer::get_singleton()->free(space);
- SpatialSound2DServer::get_singleton()->free(sound_space);
memdelete(indexer);
}
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index a9110b3bd9..c02880e9ed 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -31,7 +31,7 @@
#include "resource.h"
#include "servers/physics_2d_server.h"
-#include "globals.h"
+#include "global_config.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index ffa35a93d8..d3a913680b 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -51,6 +51,7 @@ SceneStringNames::SceneStringNames() {
sleeping_state_changed=StaticCString::create("sleeping_state_changed");
finished=StaticCString::create("finished");
+ emission_finished=StaticCString::create("emission_finished");
animation_finished=StaticCString::create("animation_finished");
animation_changed=StaticCString::create("animation_changed");
animation_started=StaticCString::create("animation_started");
@@ -115,6 +116,7 @@ SceneStringNames::SceneStringNames() {
_area_enter_tree = StaticCString::create("_area_enter_tree");
_area_exit_tree = StaticCString::create("_area_exit_tree");
+ _input = StaticCString::create("_input");
_input_event=StaticCString::create("_input_event");
gui_input=StaticCString::create("gui_input");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 125d391294..624a9147d5 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -80,6 +80,7 @@ public:
StringName sort_children;
StringName finished;
+ StringName emission_finished;
StringName animation_finished;
StringName animation_changed;
StringName animation_started;
diff --git a/servers/audio/SCsub b/servers/audio/SCsub
index ccc76e823f..afaffcfe93 100644
--- a/servers/audio/SCsub
+++ b/servers/audio/SCsub
@@ -5,3 +5,5 @@ Import('env')
env.add_source_files(env.servers_sources, "*.cpp")
Export('env')
+
+SConscript("effects/SCsub")
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index 6fe14b0fcb..6c12957851 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "audio_driver_dummy.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/os.h"
@@ -43,7 +43,7 @@ Error AudioDriverDummy::init() {
mix_rate = 44100;
- output_format = OUTPUT_STEREO;
+ speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency",25);
@@ -97,16 +97,18 @@ int AudioDriverDummy::get_mix_rate() const {
return mix_rate;
};
-AudioDriverSW::OutputFormat AudioDriverDummy::get_output_format() const {
+AudioDriver::SpeakerMode AudioDriverDummy::get_speaker_mode() const {
- return output_format;
+ return speaker_mode;
};
+
void AudioDriverDummy::lock() {
if (!thread || !mutex)
return;
mutex->lock();
};
+
void AudioDriverDummy::unlock() {
if (!thread || !mutex)
diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h
index c91a0db43a..78ec41ea09 100644
--- a/servers/audio/audio_driver_dummy.h
+++ b/servers/audio/audio_driver_dummy.h
@@ -29,13 +29,13 @@
#ifndef AUDIO_DRIVER_DUMMY_H
#define AUDIO_DRIVER_DUMMY_H
-#include "servers/audio/audio_server_sw.h"
+#include "servers/audio_server.h"
#include "core/os/thread.h"
#include "core/os/mutex.h"
-class AudioDriverDummy : public AudioDriverSW {
+class AudioDriverDummy : public AudioDriver {
Thread* thread;
Mutex* mutex;
@@ -46,7 +46,7 @@ class AudioDriverDummy : public AudioDriverSW {
int buffer_size;
unsigned int mix_rate;
- OutputFormat output_format;
+ SpeakerMode speaker_mode;
int channels;
@@ -64,7 +64,7 @@ public:
virtual Error init();
virtual void start();
virtual int get_mix_rate() const;
- virtual OutputFormat get_output_format() const;
+ virtual SpeakerMode get_speaker_mode() const;
virtual void lock();
virtual void unlock();
virtual void finish();
diff --git a/servers/audio/audio_effect.cpp b/servers/audio/audio_effect.cpp
new file mode 100644
index 0000000000..372c0cbc13
--- /dev/null
+++ b/servers/audio/audio_effect.cpp
@@ -0,0 +1,6 @@
+#include "audio_effect.h"
+
+AudioEffect::AudioEffect()
+{
+
+}
diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h
new file mode 100644
index 0000000000..02eb258f99
--- /dev/null
+++ b/servers/audio/audio_effect.h
@@ -0,0 +1,26 @@
+#ifndef AUDIOEFFECT_H
+#define AUDIOEFFECT_H
+
+#include "audio_frame.h"
+#include "resource.h"
+
+
+class AudioEffectInstance : public Reference {
+ GDCLASS(AudioEffectInstance,Reference)
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count)=0;
+
+};
+
+
+class AudioEffect : public Resource {
+ GDCLASS(AudioEffect,Resource)
+public:
+
+ virtual Ref<AudioEffectInstance> instance()=0;
+ AudioEffect();
+};
+
+#endif // AUDIOEFFECT_H
diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp
index cdfe1a29f0..e97eb75d04 100644
--- a/servers/audio/audio_filter_sw.cpp
+++ b/servers/audio/audio_filter_sw.cpp
@@ -142,9 +142,9 @@ void AudioFilterSW::prepare_coefficients(Coeffs *p_coeffs) {
//this one is extra tricky
double hicutoff=resonance;
double centercutoff = (cutoff+resonance)/2.0;
- double bandwidth=(Math::log(centercutoff)-Math::log(hicutoff))/Math::log(2);
+ double bandwidth=(Math::log(centercutoff)-Math::log(hicutoff))/Math::log((double)2);
omega=2.0*Math_PI*centercutoff/sampling_rate;
- alpha = Math::sin(omega)*Math::sinh( Math::log(2)/2 * bandwidth * omega/Math::sin(omega) );
+ alpha = Math::sin(omega)*Math::sinh( Math::log((double)2)/2 * bandwidth * omega/Math::sin(omega) );
a0=1+alpha;
p_coeffs->b0 = alpha;
diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h
index 0f3e2410fd..b711944ca8 100644
--- a/servers/audio/audio_filter_sw.h
+++ b/servers/audio/audio_filter_sw.h
@@ -65,7 +65,7 @@ public:
void set_filter(AudioFilterSW * p_filter);
void process(float *p_samples,int p_amount, int p_stride=1);
void update_coeffs();
- inline void process_one(float& p_sample);
+ _ALWAYS_INLINE_ void process_one(float& p_sample);
Processor();
};
diff --git a/servers/audio/audio_mixer_sw.cpp b/servers/audio/audio_mixer_sw.cpp
deleted file mode 100644
index faed6905ea..0000000000
--- a/servers/audio/audio_mixer_sw.cpp
+++ /dev/null
@@ -1,1222 +0,0 @@
-/*************************************************************************/
-/* audio_mixer_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "audio_mixer_sw.h"
-#include "print_string.h"
-#include "os/os.h"
-//TODO implement FAST_AUDIO macro
-
-#ifdef FAST_AUDIO
-#define NO_REVERB
-#endif
-
-template<class Depth,bool is_stereo,bool is_ima_adpcm,bool use_filter,bool use_fx,AudioMixerSW::InterpolationType type,AudioMixerSW::MixChannels mix_mode>
-void AudioMixerSW::do_resample(const Depth* p_src, int32_t *p_dst, ResamplerState *p_state) {
-
- // this function will be compiled branchless by any decent compiler
-
- int32_t final,final_r,next,next_r;
- int32_t *reverb_dst = p_state->reverb_buffer;
- while (p_state->amount--) {
-
- int32_t pos=p_state->pos >> MIX_FRAC_BITS;
- if (is_stereo && !is_ima_adpcm)
- pos<<=1;
-
- if (is_ima_adpcm) {
-
- int sample_pos = pos + p_state->ima_adpcm[0].window_ofs;
-
- while(sample_pos>p_state->ima_adpcm[0].last_nibble) {
-
-
- static const int16_t _ima_adpcm_step_table[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
- };
-
- static const int8_t _ima_adpcm_index_table[16] = {
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8
- };
-
- for(int i=0;i<(is_stereo?2:1);i++) {
-
-
- int16_t nibble,diff,step;
-
- p_state->ima_adpcm[i].last_nibble++;
- const uint8_t *src_ptr=p_state->ima_adpcm[i].ptr;
-
-
- uint8_t nbb = src_ptr[ (p_state->ima_adpcm[i].last_nibble>>1) * (is_stereo?2:1) + i ];
- nibble = (p_state->ima_adpcm[i].last_nibble&1)?(nbb>>4):(nbb&0xF);
- step=_ima_adpcm_step_table[p_state->ima_adpcm[i].step_index];
-
-
- p_state->ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble];
- if (p_state->ima_adpcm[i].step_index<0)
- p_state->ima_adpcm[i].step_index=0;
- if (p_state->ima_adpcm[i].step_index>88)
- p_state->ima_adpcm[i].step_index=88;
-
- diff = step >> 3 ;
- if (nibble & 1)
- diff += step >> 2 ;
- if (nibble & 2)
- diff += step >> 1 ;
- if (nibble & 4)
- diff += step ;
- if (nibble & 8)
- diff = -diff ;
-
- p_state->ima_adpcm[i].predictor+=diff;
- if (p_state->ima_adpcm[i].predictor<-0x8000)
- p_state->ima_adpcm[i].predictor=-0x8000;
- else if (p_state->ima_adpcm[i].predictor>0x7FFF)
- p_state->ima_adpcm[i].predictor=0x7FFF;
-
-
- /* store loop if there */
- if (p_state->ima_adpcm[i].last_nibble==p_state->ima_adpcm[i].loop_pos) {
-
- p_state->ima_adpcm[i].loop_step_index = p_state->ima_adpcm[i].step_index;
- p_state->ima_adpcm[i].loop_predictor = p_state->ima_adpcm[i].predictor;
- }
-
- //printf("%i - %i - pred %i\n",int(p_state->ima_adpcm[i].last_nibble),int(nibble),int(p_state->ima_adpcm[i].predictor));
-
- }
-
- }
-
- final=p_state->ima_adpcm[0].predictor;
- if (is_stereo) {
- final_r=p_state->ima_adpcm[1].predictor;
- }
-
- } else {
- final=p_src[pos];
- if (is_stereo)
- final_r=p_src[pos+1];
-
- if (sizeof(Depth)==1) { /* conditions will not exist anymore when compiled! */
- final<<=8;
- if (is_stereo)
- final_r<<=8;
- }
-
- if (type==INTERPOLATION_LINEAR) {
-
- if (is_stereo) {
-
- next=p_src[pos+2];
- next_r=p_src[pos+3];
- } else {
- next=p_src[pos+1];
- }
-
- if (sizeof(Depth)==1) {
- next<<=8;
- if (is_stereo)
- next_r<<=8;
- }
-
- int32_t frac=int32_t(p_state->pos&MIX_FRAC_MASK);
-
- final=final+((next-final)*frac >> MIX_FRAC_BITS);
- if (is_stereo)
- final_r=final_r+((next_r-final_r)*frac >> MIX_FRAC_BITS);
- }
- }
-
- if (use_filter) {
-
- Channel::Mix::Filter *f = p_state->filter_l;
- float finalf=final;
- float pre = finalf;
- finalf = ((finalf*p_state->coefs.b0) + (f->hb[0]*p_state->coefs.b1) + (f->hb[1]*p_state->coefs.b2) + (f->ha[0]*p_state->coefs.a1) + (f->ha[1]*p_state->coefs.a2)
- );
-
- f->ha[1]=f->ha[0];
- f->hb[1]=f->hb[0];
- f->hb[0]=pre;
- f->ha[0]=finalf;
-
- final=Math::fast_ftoi(finalf);
-
- if (is_stereo) {
-
- f = p_state->filter_r;
- finalf=final_r;
- pre = finalf;
- finalf = ((finalf*p_state->coefs.b0) + (f->hb[0]*p_state->coefs.b1) + (f->hb[1]*p_state->coefs.b2) + (f->ha[0]*p_state->coefs.a1) + (f->ha[1]*p_state->coefs.a2)
- );
- f->ha[1]=f->ha[0];
- f->hb[1]=f->hb[0];
- f->hb[0]=pre;
- f->ha[0]=finalf;
-
- final_r=Math::fast_ftoi(finalf);
-
- }
-
- p_state->coefs.b0+=p_state->coefs_inc.b0;
- p_state->coefs.b1+=p_state->coefs_inc.b1;
- p_state->coefs.b2+=p_state->coefs_inc.b2;
- p_state->coefs.a1+=p_state->coefs_inc.a1;
- p_state->coefs.a2+=p_state->coefs_inc.a2;
- }
-
- if (!is_stereo) {
- final_r=final; //copy to right channel if stereo
- }
-
- //convert back to 24 bits and mix to buffers
-
- if (mix_mode==MIX_STEREO) {
- *p_dst++ +=(final*(p_state->vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *p_dst++ +=(final_r*(p_state->vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
-
- p_state->vol[0]+=p_state->vol_inc[0];
- p_state->vol[1]+=p_state->vol_inc[1];
-
- if (use_fx) {
- *reverb_dst++ +=(final*(p_state->reverb_vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *reverb_dst++ +=(final_r*(p_state->reverb_vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- p_state->reverb_vol[0]+=p_state->reverb_vol_inc[0];
- p_state->reverb_vol[1]+=p_state->reverb_vol_inc[1];
- }
-
-
- } else if (mix_mode==MIX_QUAD) {
-
- *p_dst++ +=(final*(p_state->vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *p_dst++ +=(final_r*(p_state->vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
-
- *p_dst++ +=(final*(p_state->vol[2]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *p_dst++ +=(final_r*(p_state->vol[3]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
-
- p_state->vol[0]+=p_state->vol_inc[0];
- p_state->vol[1]+=p_state->vol_inc[1];
- p_state->vol[2]+=p_state->vol_inc[2];
- p_state->vol[3]+=p_state->vol_inc[3];
-
- if (use_fx) {
- *reverb_dst++ +=(final*(p_state->reverb_vol[0]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *reverb_dst++ +=(final_r*(p_state->reverb_vol[1]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *reverb_dst++ +=(final*(p_state->reverb_vol[2]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- *reverb_dst++ +=(final_r*(p_state->reverb_vol[3]>>MIX_VOLRAMP_FRAC_BITS))>>MIX_VOL_MOVE_TO_24;
- p_state->reverb_vol[0]+=p_state->reverb_vol_inc[0];
- p_state->reverb_vol[1]+=p_state->reverb_vol_inc[1];
- p_state->reverb_vol[2]+=p_state->reverb_vol_inc[2];
- p_state->reverb_vol[3]+=p_state->reverb_vol_inc[3];
- }
- }
-
- p_state->pos+=p_state->increment;
- }
-}
-
-
-void AudioMixerSW::mix_channel(Channel& c) {
-
-
- if (!sample_manager->is_sample(c.sample)) {
- // sample is gone!
- c.active=false;
- return;
- }
-
-
- /* some 64-bit fixed point precaches */
-
- int64_t loop_begin_fp=((int64_t)sample_manager->sample_get_loop_begin(c.sample) << MIX_FRAC_BITS);
- int64_t loop_end_fp=((int64_t)sample_manager->sample_get_loop_end(c.sample) << MIX_FRAC_BITS);
- int64_t length_fp=((int64_t)sample_manager->sample_get_length(c.sample) << MIX_FRAC_BITS);
- int64_t begin_limit=(sample_manager->sample_get_loop_format(c.sample)!=AS::SAMPLE_LOOP_NONE)?loop_begin_fp:0;
- int64_t end_limit=(sample_manager->sample_get_loop_format(c.sample)!=AS::SAMPLE_LOOP_NONE)?loop_end_fp:length_fp;
- bool is_stereo=sample_manager->sample_is_stereo(c.sample);
-
- int32_t todo=mix_chunk_size;
-// int mixed=0;
- bool use_filter=false;
-
- ResamplerState rstate;
-
- /* compute voume ramps, increment, etc */
-
-
-
- for(int i=0;i<mix_channels;i++) {
- c.mix.old_vol[i]=c.mix.vol[i];
- c.mix.old_reverb_vol[i]=c.mix.reverb_vol[i];
- c.mix.old_chorus_vol[i]=c.mix.chorus_vol[i];
- }
-
- float vol = c.vol*channel_nrg;
-
- float reverb_vol = c.reverb_send*channel_nrg;
- float chorus_vol = c.chorus_send*channel_nrg;
-
- if (mix_channels==2) {
- //stereo pan
- float pan = c.pan * 0.5 + 0.5;
- float panv[2]={
- (1.0 - pan)*(1<<MIX_VOL_FRAC_BITS),
- (pan)*(1<<MIX_VOL_FRAC_BITS)
- };
-
- for(int i=0;i<2;i++) {
-
- c.mix.vol[i]=Math::fast_ftoi(vol*panv[i]);
- c.mix.reverb_vol[i]=Math::fast_ftoi(reverb_vol*panv[i]);
- c.mix.chorus_vol[i]=Math::fast_ftoi(chorus_vol*panv[i]);
- }
-
- } else {
- //qudra pan
- float panx = c.pan * 0.5 + 0.5;
- float pany = c.depth * 0.5 + 0.5;
- // with this model every speaker plays at 0.25 energy at the center.. i'm not sure if it's correct but it seems to be balanced
- float panv[4]={
- (1.0-pany)*(1.0-panx)*(1<<MIX_VOL_FRAC_BITS),
- (1.0-pany)*( panx)*(1<<MIX_VOL_FRAC_BITS),
- ( pany)*(1.0-panx)*(1<<MIX_VOL_FRAC_BITS),
- ( pany)*( panx)*(1<<MIX_VOL_FRAC_BITS)
- };
-
- for(int i=0;i<4;i++) {
-
- c.mix.vol[i]=Math::fast_ftoi(vol*panv[i]);
- c.mix.reverb_vol[i]=Math::fast_ftoi(reverb_vol*panv[i]);
- c.mix.chorus_vol[i]=Math::fast_ftoi(chorus_vol*panv[i]);
- }
-
- }
-
- if (c.first_mix) { // avoid ramp up
-
- for(int i=0;i<mix_channels;i++) {
- c.mix.old_vol[i]=c.mix.vol[i];
- c.mix.old_reverb_vol[i]=c.mix.reverb_vol[i];
- c.mix.old_chorus_vol[i]=c.mix.chorus_vol[i];
- }
-
- c.first_mix=false;
- }
-
-
-
- Channel::Filter::Coefs filter_coefs;
- Channel::Filter::Coefs filter_inc;
-
- if (c.filter.type!=AudioMixer::FILTER_NONE) {
-
- filter_coefs=c.filter.old_coefs;
- filter_inc.b0=(c.filter.coefs.b0-filter_coefs.b0)/(1<<mix_chunk_bits);
- filter_inc.b1=(c.filter.coefs.b1-filter_coefs.b1)/(1<<mix_chunk_bits);
- filter_inc.b2=(c.filter.coefs.b2-filter_coefs.b2)/(1<<mix_chunk_bits);
- filter_inc.a1=(c.filter.coefs.a1-filter_coefs.a1)/(1<<mix_chunk_bits);
- filter_inc.a2=(c.filter.coefs.a2-filter_coefs.a2)/(1<<mix_chunk_bits);
- use_filter=true;
- }
-
- if (c.mix.increment>0)
- c.mix.increment=((int64_t)c.speed<<MIX_FRAC_BITS)/mix_rate;
- else
- c.mix.increment=-((int64_t)c.speed<<MIX_FRAC_BITS)/mix_rate;
-
- //volume ramp
-
-
- for(int i=0;i<mix_channels;i++) {
- rstate.vol_inc[i]=((c.mix.vol[i]-c.mix.old_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits;
- rstate.vol[i]=c.mix.old_vol[i]<<MIX_VOLRAMP_FRAC_BITS;
- rstate.reverb_vol_inc[i]=((c.mix.reverb_vol[i]-c.mix.old_reverb_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits;
- rstate.reverb_vol[i]=c.mix.old_reverb_vol[i]<<MIX_VOLRAMP_FRAC_BITS;
- rstate.chorus_vol_inc[i]=((c.mix.chorus_vol[i]-c.mix.old_chorus_vol[i])<<MIX_VOLRAMP_FRAC_BITS)>>mix_chunk_bits;
- rstate.chorus_vol[i]=c.mix.old_chorus_vol[i]<<MIX_VOLRAMP_FRAC_BITS;
- }
-
-
- //looping
-
- AS::SampleLoopFormat loop_format=sample_manager->sample_get_loop_format(c.sample);
- AS::SampleFormat format=sample_manager->sample_get_format(c.sample);
-
- bool use_fx=false;
-
- if (fx_enabled) {
-
- for(int i=0;i<mix_channels;i++) {
- if (c.mix.old_reverb_vol[i] || c.mix.reverb_vol[i] || c.mix.old_chorus_vol[i] || c.mix.chorus_vol[i] ) {
- use_fx=true;
- break;
- }
- }
- }
-
- /* audio data */
-
- const void *data=sample_manager->sample_get_data_ptr(c.sample);
- int32_t *dst_buff=mix_buffer;
-
-#ifndef NO_REVERB
- rstate.reverb_buffer=reverb_state[c.reverb_room].buffer;
-#endif
-
- /* @TODO validar loops al registrar? */
-
- rstate.coefs=filter_coefs;
- rstate.coefs_inc=filter_inc;
- rstate.filter_l=&c.mix.filter_l;
- rstate.filter_r=&c.mix.filter_r;
-
- if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) {
-
- rstate.ima_adpcm=c.mix.ima_adpcm;
- if (loop_format!=AS::SAMPLE_LOOP_NONE) {
- c.mix.ima_adpcm[0].loop_pos=loop_begin_fp>>MIX_FRAC_BITS;
- c.mix.ima_adpcm[1].loop_pos=loop_begin_fp>>MIX_FRAC_BITS;
- loop_format=AS::SAMPLE_LOOP_FORWARD;
- }
- }
-
- while (todo>0) {
-
- int64_t limit=0;
- int32_t target=0,aux=0;
-
- /** LOOP CHECKING **/
-
- if ( c.mix.increment < 0 ) {
- /* going backwards */
-
- if ( loop_format!=AS::SAMPLE_LOOP_NONE && c.mix.offset < loop_begin_fp ) {
- /* loopstart reached */
- if ( loop_format==AS::SAMPLE_LOOP_PING_PONG ) {
- /* bounce ping pong */
- c.mix.offset= loop_begin_fp + ( loop_begin_fp-c.mix.offset );
- c.mix.increment=-c.mix.increment;
- } else {
- /* go to loop-end */
- c.mix.offset=loop_end_fp-(loop_begin_fp-c.mix.offset);
- }
- } else {
- /* check for sample not reaching begining */
- if(c.mix.offset < 0) {
-
- c.active=false;
- break;
- }
- }
- } else {
- /* going forward */
- if( loop_format!=AS::SAMPLE_LOOP_NONE && c.mix.offset >= loop_end_fp ) {
- /* loopend reached */
-
- if ( loop_format==AS::SAMPLE_LOOP_PING_PONG ) {
- /* bounce ping pong */
- c.mix.offset=loop_end_fp-(c.mix.offset-loop_end_fp);
- c.mix.increment=-c.mix.increment;
- } else {
- /* go to loop-begin */
-
- if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) {
- for(int i=0;i<2;i++) {
- c.mix.ima_adpcm[i].step_index=c.mix.ima_adpcm[i].loop_step_index;
- c.mix.ima_adpcm[i].predictor=c.mix.ima_adpcm[i].loop_predictor;
- c.mix.ima_adpcm[i].last_nibble=loop_begin_fp>>MIX_FRAC_BITS;
- }
- c.mix.offset=loop_begin_fp;
- } else {
- c.mix.offset=loop_begin_fp+(c.mix.offset-loop_end_fp);
- }
-
- }
- } else {
- /* no loop, check for end of sample */
- if(c.mix.offset >= length_fp) {
-
- c.active=false;
- break;
- }
- }
- }
-
- /** MIXCOUNT COMPUTING **/
-
- /* next possible limit (looppoints or sample begin/end */
- limit=(c.mix.increment < 0) ?begin_limit:end_limit;
-
- /* compute what is shorter, the todo or the limit? */
- aux=(limit-c.mix.offset)/c.mix.increment+1;
- target=(aux<todo)?aux:todo; /* mix target is the shorter buffer */
-
- /* check just in case */
- if ( target<=0 ) {
- c.active=false;
- break;
- }
-
- todo-=target;
-
- int32_t offset=c.mix.offset&mix_chunk_mask; /* strip integer */
- c.mix.offset-=offset;
-
- rstate.increment=c.mix.increment;
- rstate.amount=target;
- rstate.pos=offset;
-
-/* Macros to call the resample function for all possibilities, creating a dedicated-non branchy function call for each thanks to template magic*/
-
-#define CALL_RESAMPLE_FUNC( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- do_resample<m_depth,m_stereo,m_ima_adpcm, m_use_filter,m_use_fx,m_interp, m_mode>(\
- src_ptr,\
- dst_buff,&rstate);
-
-
-#define CALL_RESAMPLE_INTERP( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- if(m_interp==INTERPOLATION_RAW) {\
- CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_RAW,m_mode);\
- } else if(m_interp==INTERPOLATION_LINEAR) {\
- CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_LINEAR,m_mode);\
- } else if(m_interp==INTERPOLATION_CUBIC) {\
- CALL_RESAMPLE_FUNC(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,INTERPOLATION_CUBIC,m_mode);\
- }\
-
-#define CALL_RESAMPLE_FX( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- if(m_use_fx) {\
- CALL_RESAMPLE_INTERP(m_depth,m_stereo, m_ima_adpcm,m_use_filter,true,m_interp, m_mode);\
- } else {\
- CALL_RESAMPLE_INTERP(m_depth,m_stereo, m_ima_adpcm,m_use_filter,false,m_interp, m_mode);\
- }\
-
-
-#define CALL_RESAMPLE_FILTER( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- if(m_use_filter) {\
- CALL_RESAMPLE_FX(m_depth,m_stereo, m_ima_adpcm,true,m_use_fx,m_interp, m_mode);\
- } else {\
- CALL_RESAMPLE_FX(m_depth,m_stereo, m_ima_adpcm,false,m_use_fx,m_interp, m_mode);\
- }\
-
-#define CALL_RESAMPLE_STEREO( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- if(m_stereo) {\
- CALL_RESAMPLE_FILTER(m_depth,true,m_ima_adpcm, m_use_filter,m_use_fx,m_interp, m_mode);\
- } else {\
- CALL_RESAMPLE_FILTER(m_depth,false,m_ima_adpcm,m_use_filter,m_use_fx,m_interp, m_mode);\
- }\
-
-#define CALL_RESAMPLE_MODE( m_depth, m_stereo, m_ima_adpcm, m_use_filter, m_use_fx, m_interp, m_mode)\
- if(m_mode==MIX_STEREO) {\
- CALL_RESAMPLE_STEREO(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,m_interp, MIX_STEREO);\
- } else {\
- CALL_RESAMPLE_STEREO(m_depth,m_stereo, m_ima_adpcm,m_use_filter,m_use_fx,m_interp, MIX_QUAD);\
- }\
-
-
-
-
- if (format==AS::SAMPLE_FORMAT_PCM8) {
-
- int8_t *src_ptr = &((int8_t*)data)[(c.mix.offset >> MIX_FRAC_BITS)<<(is_stereo?1:0) ];
- CALL_RESAMPLE_MODE(int8_t,is_stereo,false,use_filter,use_fx,interpolation_type,mix_channels);
-
- } else if (format==AS::SAMPLE_FORMAT_PCM16) {
- int16_t *src_ptr = &((int16_t*)data)[(c.mix.offset >> MIX_FRAC_BITS)<<(is_stereo?1:0) ];
- CALL_RESAMPLE_MODE(int16_t,is_stereo,false,use_filter,use_fx,interpolation_type,mix_channels);
-
- } else if (format==AS::SAMPLE_FORMAT_IMA_ADPCM) {
- for(int i=0;i<2;i++) {
- c.mix.ima_adpcm[i].window_ofs=c.mix.offset>>MIX_FRAC_BITS;
- c.mix.ima_adpcm[i].ptr=(const uint8_t*)data;
- }
- int8_t *src_ptr = NULL;
- CALL_RESAMPLE_MODE(int8_t,is_stereo,true,use_filter,use_fx,interpolation_type,mix_channels);
-
- }
-
- c.mix.offset+=rstate.pos;
- dst_buff+=target*mix_channels;
- rstate.reverb_buffer+=target*mix_channels;
- }
-
- c.filter.old_coefs=c.filter.coefs;
-}
-
-void AudioMixerSW::mix_chunk() {
-
- ERR_FAIL_COND(mix_chunk_left);
-
- inside_mix=true;
-
- // emit tick in usecs
- for (int i=0;i<mix_chunk_size*mix_channels;i++) {
-
- mix_buffer[i]=0;
- }
-#ifndef NO_REVERB
- for(int i=0;i<max_reverbs;i++)
- reverb_state[i].used_in_chunk=false;
-#endif
-
-
- audio_mixer_chunk_call(mix_chunk_size);
-
- int ac=0;
- for (int i=0;i<MAX_CHANNELS;i++) {
-
- if (!channels[i].active)
- continue;
- ac++;
-
- /* process volume */
- Channel&c=channels[i];
-#ifndef NO_REVERB
- bool has_reverb = c.reverb_send>CMP_EPSILON && fx_enabled;
- if (has_reverb || c.had_prev_reverb) {
-
- if (!reverb_state[c.reverb_room].used_in_chunk) {
- //zero the room
- int32_t *buff = reverb_state[c.reverb_room].buffer;
- int len = mix_chunk_size*mix_channels;
- for (int j=0;j<len;j++) {
-
- buff[j]=0; // buffer in use, clear it for appending
- }
- reverb_state[c.reverb_room].used_in_chunk=true;
- }
- }
-#else
- bool has_reverb = false;
-#endif
- bool has_chorus = c.chorus_send>CMP_EPSILON && fx_enabled;
-
-
- mix_channel(c);
-
- c.had_prev_reverb=has_reverb;
- c.had_prev_chorus=has_chorus;
-
- }
-
- //process reverb
-#ifndef NO_REVERB
- if (fx_enabled) {
-
-
- for(int i=0;i<max_reverbs;i++) {
-
- if (!reverb_state[i].enabled && !reverb_state[i].used_in_chunk)
- continue; //this reverb is not in use
-
- int32_t *src=NULL;
-
- if (reverb_state[i].used_in_chunk)
- src=reverb_state[i].buffer;
- else
- src=zero_buffer;
-
- bool in_use=false;
-
- int passes=mix_channels/2;
-
- for(int j=0;j<passes;j++) {
-
- if (reverb_state[i].reverb[j].process((int*)&src[j*2],(int*)&mix_buffer[j*2],mix_chunk_size,passes))
- in_use=true;
- }
-
- if (in_use) {
- reverb_state[i].enabled=true;
- reverb_state[i].frames_idle=0;
- //copy data over
-
- } else {
- reverb_state[i].frames_idle+=mix_chunk_size;
- if (false) { // go idle because too many frames passed
- //disable this reverb, as nothing important happened on it
- reverb_state[i].enabled=false;
- reverb_state[i].frames_idle=0;
- }
- }
-
- }
- }
-#endif
- mix_chunk_left=mix_chunk_size;
- inside_mix=false;
-}
-
-int AudioMixerSW::mix(int32_t *p_buffer,int p_frames) {
-
- int todo=p_frames;
- int mixes=0;
-
- while(todo) {
-
-
- if (!mix_chunk_left) {
-
- if (step_callback)
- step_callback(step_udata);
- mix_chunk();
- mixes++;
- }
-
- int to_mix=MIN(mix_chunk_left,todo);
- int from=mix_chunk_size-mix_chunk_left;
-
- for (int i=0;i<to_mix*2;i++) {
-
- (*p_buffer++)=mix_buffer[from*2+i];
- }
-
- mix_chunk_left-=to_mix;
- todo-=to_mix;
- }
-
- return mixes;
-}
-
-uint64_t AudioMixerSW::get_step_usecs() const {
-
- double mct = (1<<mix_chunk_bits)/double(mix_rate);
- return mct*1000000.0;
-}
-
-int AudioMixerSW::_get_channel(ChannelID p_channel) const {
-
- if (p_channel<0) {
- return -1;
- }
-
- int idx=p_channel%MAX_CHANNELS;
- int check=p_channel/MAX_CHANNELS;
- ERR_FAIL_INDEX_V(idx,MAX_CHANNELS,-1);
- if (channels[idx].check!=check) {
- return -1;
- }
- if (!channels[idx].active) {
- return -1;
- }
-
- return idx;
-}
-
-AudioMixer::ChannelID AudioMixerSW::channel_alloc(RID p_sample) {
-
- ERR_FAIL_COND_V( !sample_manager->is_sample(p_sample), INVALID_CHANNEL );
-
-
- int index=-1;
- for (int i=0;i<MAX_CHANNELS;i++) {
-
- if (!channels[i].active) {
- index=i;
- break;
- }
- }
-
- if (index==-1)
- return INVALID_CHANNEL;
-
- Channel &c=channels[index];
-
- // init variables
- c.sample=p_sample;
- c.vol=1;
- c.pan=0;
- c.depth=0;
- c.height=0;
- c.chorus_send=0;
- c.reverb_send=0;
- c.reverb_room=REVERB_HALL;
- c.positional=false;
- c.filter.type=FILTER_NONE;
- c.speed=sample_manager->sample_get_mix_rate(p_sample);
- c.active=true;
- c.check=channel_id_count++;
- c.first_mix=true;
-
- // init mix variables
-
- c.mix.offset=0;
- c.mix.increment=1;
- //zero everything when this errors
- for(int i=0;i<4;i++) {
- c.mix.vol[i]=0;
- c.mix.reverb_vol[i]=0;
- c.mix.chorus_vol[i]=0;
-
- c.mix.old_vol[i]=0;
- c.mix.old_reverb_vol[i]=0;
- c.mix.old_chorus_vol[i]=0;
- }
-
- c.had_prev_chorus=false;
- c.had_prev_reverb=false;
- c.had_prev_vol=false;
-
-
- if (sample_manager->sample_get_format(c.sample)==AudioServer::SAMPLE_FORMAT_IMA_ADPCM) {
-
- for(int i=0;i<2;i++) {
- c.mix.ima_adpcm[i].step_index=0;
- c.mix.ima_adpcm[i].predictor=0;
- c.mix.ima_adpcm[i].loop_step_index=0;
- c.mix.ima_adpcm[i].loop_predictor=0;
- c.mix.ima_adpcm[i].last_nibble=-1;
- c.mix.ima_adpcm[i].loop_pos=0x7FFFFFFF;
- c.mix.ima_adpcm[i].window_ofs=0;
- c.mix.ima_adpcm[i].ptr=NULL;
- }
- }
-
- ChannelID ret_id = index+c.check*MAX_CHANNELS;
-
- return ret_id;
-
-}
-
-void AudioMixerSW::channel_set_volume(ChannelID p_channel, float p_gain) {
-
- if (p_gain>3) // avoid gain going too high
- p_gain=3;
- if (p_gain<0)
- p_gain=0;
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
- Channel &c = channels[chan];
-
- //Math::exp( p_db * 0.11512925464970228420089957273422 );
- c.vol=p_gain;
-
-}
-
-void AudioMixerSW::channel_set_pan(ChannelID p_channel, float p_pan, float p_depth,float p_height) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
- Channel &c = channels[chan];
-
- c.pan=p_pan;
- c.depth=p_depth;
- c.height=p_height;
-
-}
-void AudioMixerSW::channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c = channels[chan];
-
- if (c.filter.type==p_type && c.filter.cutoff==p_cutoff && c.filter.resonance==p_resonance && c.filter.gain==p_gain)
- return; //bye
-
-
- bool type_changed = p_type!=c.filter.type;
-
- c.filter.type=p_type;
- c.filter.cutoff=p_cutoff;
- c.filter.resonance=p_resonance;
- c.filter.gain=p_gain;
-
-
- AudioFilterSW filter;
- switch(p_type) {
- case FILTER_NONE: {
-
- return; //do nothing else
- } break;
- case FILTER_LOWPASS: {
- filter.set_mode(AudioFilterSW::LOWPASS);
- } break;
- case FILTER_BANDPASS: {
- filter.set_mode(AudioFilterSW::BANDPASS);
- } break;
- case FILTER_HIPASS: {
- filter.set_mode(AudioFilterSW::HIGHPASS);
- } break;
- case FILTER_NOTCH: {
- filter.set_mode(AudioFilterSW::NOTCH);
- } break;
- case FILTER_PEAK: {
- filter.set_mode(AudioFilterSW::PEAK);
- } break;
- case FILTER_BANDLIMIT: {
- filter.set_mode(AudioFilterSW::BANDLIMIT);
- } break;
- case FILTER_LOW_SHELF: {
- filter.set_mode(AudioFilterSW::LOWSHELF);
- } break;
- case FILTER_HIGH_SHELF: {
- filter.set_mode(AudioFilterSW::HIGHSHELF);
- } break;
- }
-
- filter.set_cutoff(p_cutoff);
- filter.set_resonance(p_resonance);
- filter.set_gain(p_gain);
- filter.set_sampling_rate(mix_rate);
- filter.set_stages(1);
-
- AudioFilterSW::Coeffs coefs;
- filter.prepare_coefficients(&coefs);
-
- if (!type_changed)
- c.filter.old_coefs=c.filter.coefs;
-
- c.filter.coefs.b0=coefs.b0;
- c.filter.coefs.b1=coefs.b1;
- c.filter.coefs.b2=coefs.b2;
- c.filter.coefs.a1=coefs.a1;
- c.filter.coefs.a2=coefs.a2;
-
-
- if (type_changed) {
- //type changed reset filter
- c.filter.old_coefs=c.filter.coefs;
- c.mix.filter_l.ha[0]=0;
- c.mix.filter_l.ha[1]=0;
- c.mix.filter_l.hb[0]=0;
- c.mix.filter_l.hb[1]=0;
- c.mix.filter_r.ha[0]=0;
- c.mix.filter_r.ha[1]=0;
- c.mix.filter_r.hb[0]=0;
- c.mix.filter_r.hb[1]=0;
- }
-
-
-}
-void AudioMixerSW::channel_set_chorus(ChannelID p_channel, float p_chorus ) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c = channels[chan];
- c.chorus_send=p_chorus;
-
-}
-void AudioMixerSW::channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb) {
-
- ERR_FAIL_INDEX(p_room_type,MAX_REVERBS);
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c = channels[chan];
- c.reverb_room=p_room_type;
- c.reverb_send=p_reverb;
-
-}
-
-void AudioMixerSW::channel_set_mix_rate(ChannelID p_channel, int p_mix_rate) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c = channels[chan];
- c.speed=p_mix_rate;
-
-}
-void AudioMixerSW::channel_set_positional(ChannelID p_channel, bool p_positional) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c = channels[chan];
- c.positional=p_positional;
-}
-
-float AudioMixerSW::channel_get_volume(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- //Math::log( c.vol ) * 8.6858896380650365530225783783321;
- return c.vol;
-}
-
-float AudioMixerSW::channel_get_pan(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.pan;
-}
-float AudioMixerSW::channel_get_pan_depth(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.depth;
-}
-float AudioMixerSW::channel_get_pan_height(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.height;
-
-}
-AudioMixer::FilterType AudioMixerSW::channel_get_filter_type(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return FILTER_NONE;
-
- const Channel &c = channels[chan];
- return c.filter.type;
-}
-float AudioMixerSW::channel_get_filter_cutoff(ChannelID p_channel) const {
-
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.filter.cutoff;
-
-}
-float AudioMixerSW::channel_get_filter_resonance(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.filter.resonance;
-
-}
-
-float AudioMixerSW::channel_get_filter_gain(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.filter.gain;
-}
-
-
-float AudioMixerSW::channel_get_chorus(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.chorus_send;
-
-}
-AudioMixer::ReverbRoomType AudioMixerSW::channel_get_reverb_type(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return REVERB_HALL;
-
- const Channel &c = channels[chan];
- return c.reverb_room;
-
-}
-float AudioMixerSW::channel_get_reverb(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.reverb_send;
-}
-
-int AudioMixerSW::channel_get_mix_rate(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return 0;
-
- const Channel &c = channels[chan];
- return c.speed;
-}
-bool AudioMixerSW::channel_is_positional(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return false;
-
- const Channel &c = channels[chan];
- return c.positional;
-}
-
-bool AudioMixerSW::channel_is_valid(ChannelID p_channel) const {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return false;
- return channels[chan].active;
-}
-
-
-void AudioMixerSW::channel_free(ChannelID p_channel) {
-
- int chan = _get_channel(p_channel);
- if (chan<0 || chan >=MAX_CHANNELS)
- return;
-
- Channel &c=channels[chan];
-
- if (!c.active)
- return;
-
- bool has_vol=false;
-
- for(int i=0;i<mix_channels;i++) {
-
- if (c.mix.vol[i])
- has_vol=true;
- if (c.mix.reverb_vol[i])
- has_vol=true;
- if (c.mix.chorus_vol[i])
- has_vol=true;
- }
- if (c.active && has_vol && inside_mix) {
- // drive voice to zero, and run a chunk, the VRAMP will fade it good
- c.vol=0;
- c.reverb_send=0;
- c.chorus_send=0;
- mix_channel(c);
- }
- /* @TODO RAMP DOWN ON STOP */
- c.active=false;
-}
-
-
-
-AudioMixerSW::AudioMixerSW(SampleManagerSW *p_sample_manager,int p_desired_latency_ms,int p_mix_rate,MixChannels p_mix_channels,bool p_use_fx,InterpolationType p_interp,MixStepCallback p_step_callback,void *p_step_udata) {
-
- if (OS::get_singleton()->is_stdout_verbose()) {
- print_line("AudioServerSW Params: ");
- print_line(" -mix chans: "+itos(p_mix_channels));
- print_line(" -mix rate: "+itos(p_mix_rate));
- print_line(" -latency: "+itos(p_desired_latency_ms));
- print_line(" -fx: "+itos(p_use_fx));
- print_line(" -interp: "+itos(p_interp));
- }
- sample_manager=p_sample_manager;
- mix_channels=p_mix_channels;
- mix_rate=p_mix_rate;
- step_callback=p_step_callback;
- step_udata=p_step_udata;
-
-
- mix_chunk_bits=nearest_shift( p_desired_latency_ms * p_mix_rate / 1000 );
-
- mix_chunk_size=(1<<mix_chunk_bits);
- mix_chunk_mask=mix_chunk_size-1;
- mix_buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels);
-#ifndef NO_REVERB
- zero_buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels);
- for(int i=0;i<mix_chunk_size*mix_channels;i++)
- zero_buffer[i]=0; //zero buffer is zero...
-
- max_reverbs=MAX_REVERBS;
- int reverberators=mix_channels/2;
-
- reverb_state = memnew_arr(ReverbState,max_reverbs);
- for(int i=0;i<max_reverbs;i++) {
- reverb_state[i].enabled=false;
- reverb_state[i].reverb = memnew_arr(ReverbSW,reverberators);
- reverb_state[i].buffer = memnew_arr(int32_t,mix_chunk_size*mix_channels);
- reverb_state[i].frames_idle=0;
- for(int j=0;j<reverberators;j++) {
- static ReverbSW::ReverbMode modes[MAX_REVERBS]={ReverbSW::REVERB_MODE_STUDIO_SMALL,ReverbSW::REVERB_MODE_STUDIO_MEDIUM,ReverbSW::REVERB_MODE_STUDIO_LARGE,ReverbSW::REVERB_MODE_HALL};
- reverb_state[i].reverb[j].set_mix_rate(p_mix_rate);
- reverb_state[i].reverb[j].set_mode(modes[i]);
- }
-
- }
- fx_enabled=p_use_fx;
-#else
- fx_enabled=false;
-#endif
- mix_chunk_left=0;
-
- interpolation_type=p_interp;
- channel_id_count=1;
- inside_mix=false;
- channel_nrg=1.0;
-
-}
-
-void AudioMixerSW::set_mixer_volume(float p_volume) {
-
- channel_nrg=p_volume;
-}
-
-AudioMixerSW::~AudioMixerSW() {
-
- memdelete_arr(mix_buffer);
-
-#ifndef NO_REVERB
- memdelete_arr(zero_buffer);
- for(int i=0;i<max_reverbs;i++) {
- memdelete_arr(reverb_state[i].reverb);
- memdelete_arr(reverb_state[i].buffer);
- }
- memdelete_arr(reverb_state);
-#endif
-
-
-}
diff --git a/servers/audio/audio_mixer_sw.h b/servers/audio/audio_mixer_sw.h
deleted file mode 100644
index 952cad4cfa..0000000000
--- a/servers/audio/audio_mixer_sw.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*************************************************************************/
-/* audio_mixer_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 AUDIO_MIXER_SW_H
-#define AUDIO_MIXER_SW_H
-
-#include "servers/audio_server.h"
-#include "servers/audio/sample_manager_sw.h"
-#include "servers/audio/audio_filter_sw.h"
-#include "servers/audio/reverb_sw.h"
-
-class AudioMixerSW : public AudioMixer {
-public:
-
- enum InterpolationType {
-
- INTERPOLATION_RAW,
- INTERPOLATION_LINEAR,
- INTERPOLATION_CUBIC
- };
-
- enum MixChannels {
-
- MIX_STEREO=2,
- MIX_QUAD=4
- };
-
- typedef void (*MixStepCallback)(void*);
-
-private:
- SampleManagerSW *sample_manager;
-
- enum {
-
- MAX_CHANNELS=64,
- // fixed point defs
-
- MIX_FRAC_BITS=13,
- MIX_FRAC_LEN=(1<<MIX_FRAC_BITS),
- MIX_FRAC_MASK=MIX_FRAC_LEN-1,
- MIX_VOL_FRAC_BITS=12,
- MIX_VOLRAMP_FRAC_BITS=16,
- MIX_VOLRAMP_FRAC_LEN=(1<<MIX_VOLRAMP_FRAC_BITS),
- MIX_VOLRAMP_FRAC_MASK=MIX_VOLRAMP_FRAC_LEN-1,
- MIX_FILTER_FRAC_BITS=16,
- MIX_FILTER_RAMP_FRAC_BITS=8,
- MIX_VOL_MOVE_TO_24=4
- };
-
-
- struct Channel {
-
- RID sample;
- struct Mix {
- int64_t offset;
- int32_t increment;
-
- int32_t vol[4];
- int32_t reverb_vol[4];
- int32_t chorus_vol[4];
-
- int32_t old_vol[4];
- int32_t old_reverb_vol[4];
- int32_t old_chorus_vol[4];
-
-
- struct Filter { //history (stereo)
- float ha[2],hb[2];
- } filter_l,filter_r;
-
- struct IMA_ADPCM_State {
-
- int16_t step_index;
- int32_t predictor;
- /* values at loop point */
- int16_t loop_step_index;
- int32_t loop_predictor;
- int32_t last_nibble;
- int32_t loop_pos;
- int32_t window_ofs;
- const uint8_t *ptr;
- } ima_adpcm[2];
-
- } mix;
-
- float vol;
- float pan;
- float depth;
- float height;
-
- float chorus_send;
- ReverbRoomType reverb_room;
- float reverb_send;
- int speed;
- int check;
- bool positional;
-
- bool had_prev_reverb;
- bool had_prev_chorus;
- bool had_prev_vol;
-
- struct Filter {
-
- bool dirty;
-
- FilterType type;
- float cutoff;
- float resonance;
- float gain;
-
- struct Coefs {
-
- float a1,a2,b0,b1,b2; // fixed point coefficients
- } coefs,old_coefs;
-
- } filter;
-
- bool first_mix;
- bool active;
- Channel() { active=false; check=-1; first_mix=false; filter.dirty=true; filter.type=FILTER_NONE; filter.cutoff=8000; filter.resonance=0; filter.gain=0; }
- };
-
- Channel channels[MAX_CHANNELS];
-
- uint32_t mix_rate;
- bool fx_enabled;
- InterpolationType interpolation_type;
-
- int mix_chunk_bits;
- int mix_chunk_size;
- int mix_chunk_mask;
-
- int32_t *mix_buffer;
- int32_t *zero_buffer; // fx feed when no input was mixed
-
- struct ResamplerState {
-
- uint32_t amount;
- int32_t increment;
-
-
- int32_t pos;
-
-
- int32_t vol[4];
- int32_t reverb_vol[4];
- int32_t chorus_vol[4];
-
- int32_t vol_inc[4];
- int32_t reverb_vol_inc[4];
- int32_t chorus_vol_inc[4];
-
-
-
- Channel::Mix::Filter *filter_l;
- Channel::Mix::Filter *filter_r;
- Channel::Filter::Coefs coefs;
- Channel::Filter::Coefs coefs_inc;
-
- Channel::Mix::IMA_ADPCM_State *ima_adpcm;
-
- int32_t *reverb_buffer;
- };
-
-
-
- template<class Depth,bool is_stereo,bool use_filter,bool is_ima_adpcm,bool use_fx,InterpolationType type,MixChannels>
- _FORCE_INLINE_ void do_resample(const Depth* p_src, int32_t *p_dst, ResamplerState *p_state);
-
- MixChannels mix_channels;
-
- void mix_channel(Channel& p_channel);
- int mix_chunk_left;
- void mix_chunk();
-
- float channel_nrg;
- int channel_id_count;
- bool inside_mix;
- MixStepCallback step_callback;
- void *step_udata;
- _FORCE_INLINE_ int _get_channel(ChannelID p_channel) const;
-
- int max_reverbs;
- struct ReverbState {
-
- bool used_in_chunk;
- bool enabled;
- ReverbSW *reverb;
- int frames_idle;
- int32_t *buffer; //reverb is sent here
- ReverbState() { enabled=false; frames_idle=0; used_in_chunk=false; }
- };
-
- ReverbState *reverb_state;
-
-
-public:
-
-
- virtual ChannelID channel_alloc(RID p_sample);
-
- virtual void channel_set_volume(ChannelID p_channel, float p_gain);
- virtual void channel_set_pan(ChannelID p_channel, float p_pan, float p_depth=0,float height=0); //pan and depth go from -1 to 1
- virtual void channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=1.0);
- virtual void channel_set_chorus(ChannelID p_channel, float p_chorus );
- virtual void channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb);
- virtual void channel_set_mix_rate(ChannelID p_channel, int p_mix_rate);
- virtual void channel_set_positional(ChannelID p_channel, bool p_positional);
-
- virtual float channel_get_volume(ChannelID p_channel) const;
- virtual float channel_get_pan(ChannelID p_channel) const; //pan and depth go from -1 to 1
- virtual float channel_get_pan_depth(ChannelID p_channel) const; //pan and depth go from -1 to 1
- virtual float channel_get_pan_height(ChannelID p_channel) const; //pan and depth go from -1 to 1
- virtual FilterType channel_get_filter_type(ChannelID p_channel) const;
- virtual float channel_get_filter_cutoff(ChannelID p_channel) const;
- virtual float channel_get_filter_resonance(ChannelID p_channel) const;
- virtual float channel_get_filter_gain(ChannelID p_channel) const;
-
- virtual float channel_get_chorus(ChannelID p_channel) const;
- virtual ReverbRoomType channel_get_reverb_type(ChannelID p_channel) const;
- virtual float channel_get_reverb(ChannelID p_channel) const;
-
- virtual int channel_get_mix_rate(ChannelID p_channel) const;
- virtual bool channel_is_positional(ChannelID p_channel) const;
-
- virtual bool channel_is_valid(ChannelID p_channel) const;
-
- virtual void channel_free(ChannelID p_channel);
-
- int mix(int32_t *p_buffer,int p_frames); //return amount of mixsteps
- uint64_t get_step_usecs() const;
-
- virtual void set_mixer_volume(float p_volume);
-
- AudioMixerSW(SampleManagerSW *p_sample_manager,int p_desired_latency_ms,int p_mix_rate,MixChannels p_mix_channels,bool p_use_fx=true,InterpolationType p_interp=INTERPOLATION_LINEAR,MixStepCallback p_step_callback=NULL,void *p_callback_udata=NULL);
- ~AudioMixerSW();
-};
-
-#endif // AUDIO_MIXER_SW_H
diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp
deleted file mode 100644
index f508a130b4..0000000000
--- a/servers/audio/audio_server_sw.cpp
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*************************************************************************/
-/* audio_server_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "audio_server_sw.h"
-#include "globals.h"
-#include "os/os.h"
-
-struct _AudioDriverLock {
-
- _AudioDriverLock() { if (AudioDriverSW::get_singleton()) AudioDriverSW::get_singleton()->lock(); }
- ~_AudioDriverLock() { if (AudioDriverSW::get_singleton()) AudioDriverSW::get_singleton()->unlock(); }
-
-};
-
-#define AUDIO_LOCK _AudioDriverLock _adlock;
-
-AudioMixer *AudioServerSW::get_mixer() {
-
- return mixer;
-}
-
-/* CALLBACKS */
-
-void AudioServerSW::audio_mixer_chunk_callback(int p_frames) {
-/*
- for(List<Stream*>::Element *E=event_streams.front();E;E=E->next()) {
-
- if (E->get()->active)
- E->get()->audio_stream->mix(NULL,p_frames);
- }
-*/
-}
-
-void AudioServerSW::_mixer_callback(void *p_udata) {
-
- AudioServerSW *self = (AudioServerSW*)p_udata;
- for(List<Stream*>::Element *E=self->active_audio_streams.front();E;E=E->next()) {
-
- if (!E->get()->active)
- continue;
-
- EventStream *es=E->get()->event_stream;
- if (!es)
- continue;
-
- es->update(self->mixer_step_usecs);
- }
-
-}
-
-void AudioServerSW::driver_process_chunk(int p_frames,int32_t *p_buffer) {
-
-
-
- int samples=p_frames*internal_buffer_channels;
-
- for(int i=0;i<samples;i++) {
- internal_buffer[i]=0;
- }
-
- while(voice_rb.commands_left()) {
-
- VoiceRBSW::Command cmd = voice_rb.pop_command();
-
- if (cmd.type==VoiceRBSW::Command::CMD_CHANGE_ALL_FX_VOLUMES) {
-
- SelfList<Voice>*al = active_list.first();
- while(al) {
-
- Voice *v=al->self();
- if (v->channel!=AudioMixer::INVALID_CHANNEL) {
- mixer->channel_set_volume(v->channel,v->volume*fx_volume_scale);
- }
- al=al->next();
- }
-
- continue;
- }
- if (!voice_owner.owns(cmd.voice))
- continue;
-
-
- Voice *v = voice_owner.get(cmd.voice);
-
- switch(cmd.type) {
- case VoiceRBSW::Command::CMD_NONE: {
-
-
- } break;
- case VoiceRBSW::Command::CMD_PLAY: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_free(v->channel);
-
- RID sample = cmd.play.sample;
- if (!sample_manager->is_sample(sample))
- continue;
-
- v->channel=mixer->channel_alloc(sample);
- v->volume=1.0;
- mixer->channel_set_volume(v->channel,fx_volume_scale);
- if (v->channel==AudioMixer::INVALID_CHANNEL) {
-#ifdef AUDIO_DEBUG
- WARN_PRINT("AUDIO: all channels used, failed to allocate voice");
-#endif
- v->active=false;
- break; // no voices left?
- }
-
- v->active=true; // this kind of ensures it works
- if (!v->active_item.in_list())
- active_list.add(&v->active_item);
-
- } break;
- case VoiceRBSW::Command::CMD_STOP: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL) {
- mixer->channel_free(v->channel);
- if (v->active_item.in_list()) {
- active_list.remove(&v->active_item);
- }
- }
- v->active=false;
- } break;
- case VoiceRBSW::Command::CMD_SET_VOLUME: {
-
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL) {
- v->volume=cmd.volume.volume;
- mixer->channel_set_volume(v->channel,cmd.volume.volume*fx_volume_scale);
- }
-
- } break;
- case VoiceRBSW::Command::CMD_SET_PAN: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_pan(v->channel,cmd.pan.pan,cmd.pan.depth,cmd.pan.height);
-
- } break;
- case VoiceRBSW::Command::CMD_SET_FILTER: {
-
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_filter(v->channel,(AudioMixer::FilterType)cmd.filter.type,cmd.filter.cutoff,cmd.filter.resonance,cmd.filter.gain);
- } break;
- case VoiceRBSW::Command::CMD_SET_CHORUS: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_chorus(v->channel,cmd.chorus.send);
-
- } break;
- case VoiceRBSW::Command::CMD_SET_REVERB: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_reverb(v->channel,(AudioMixer::ReverbRoomType)cmd.reverb.room,cmd.reverb.send);
-
- } break;
- case VoiceRBSW::Command::CMD_SET_MIX_RATE: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_mix_rate(v->channel,cmd.mix_rate.mix_rate);
-
- } break;
- case VoiceRBSW::Command::CMD_SET_POSITIONAL: {
-
- if (v->channel!=AudioMixer::INVALID_CHANNEL)
- mixer->channel_set_positional(v->channel,cmd.positional.positional);
-
- } break;
- default: {}
-
- }
- }
-
- mixer->mix(internal_buffer,p_frames);
- //uint64_t stepsize=mixer->get_step_usecs();
-
-
- for(List<Stream*>::Element *E=active_audio_streams.front();E;E=E->next()) {
-
- ERR_CONTINUE(!E->get()->active); // bug?
-
-
- AudioStream *as=E->get()->audio_stream;
- if (!as)
- continue;
-
- int channels=as->get_channel_count();
- if (channels==0)
- continue; // does not want mix
- if (!as->mix(stream_buffer,p_frames))
- continue; //nothing was mixed!!
-
- int32_t stream_vol_scale=(stream_volume*stream_volume_scale*E->get()->volume_scale)*(1<<STREAM_SCALE_BITS);
-
-#define STRSCALE(m_val) (((m_val>>STREAM_SCALE_BITS)*stream_vol_scale)>>8)
- switch(internal_buffer_channels) {
-
- case 2: {
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<p_frames;i++) {
-
- internal_buffer[(i<<1)+0]+=STRSCALE(stream_buffer[i]);
- internal_buffer[(i<<1)+1]+=STRSCALE(stream_buffer[i]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<p_frames*2;i++) {
-
- internal_buffer[i]+=STRSCALE(stream_buffer[i]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<p_frames;i++) {
-
- internal_buffer[(i<<2)+0]+=STRSCALE((stream_buffer[(i<<2)+0]+stream_buffer[(i<<2)+2])>>1);
- internal_buffer[(i<<2)+1]+=STRSCALE((stream_buffer[(i<<2)+1]+stream_buffer[(i<<2)+3])>>1);
- }
- } break;
-
- } break;
-
- } break;
- case 4: {
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<p_frames;i++) {
-
- internal_buffer[(i<<2)+0]+=STRSCALE(stream_buffer[i]);
- internal_buffer[(i<<2)+1]+=STRSCALE(stream_buffer[i]);
- internal_buffer[(i<<2)+2]+=STRSCALE(stream_buffer[i]);
- internal_buffer[(i<<2)+3]+=STRSCALE(stream_buffer[i]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<p_frames*2;i++) {
-
- internal_buffer[(i<<2)+0]+=STRSCALE(stream_buffer[(i<<1)+0]);
- internal_buffer[(i<<2)+1]+=STRSCALE(stream_buffer[(i<<1)+1]);
- internal_buffer[(i<<2)+2]+=STRSCALE(stream_buffer[(i<<1)+0]);
- internal_buffer[(i<<2)+3]+=STRSCALE(stream_buffer[(i<<1)+1]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<p_frames*4;i++) {
- internal_buffer[i]+=STRSCALE(stream_buffer[i]);
- }
- } break;
-
- } break;
-
- } break;
- case 6: {
-
-
- } break;
- }
-
-#undef STRSCALE
- }
-
- SelfList<Voice> *activeE=active_list.first();
- while(activeE) {
-
- SelfList<Voice> *activeN=activeE->next();
- if (activeE->self()->channel==AudioMixer::INVALID_CHANNEL || !mixer->channel_is_valid(activeE->self()->channel)) {
-
- active_list.remove(activeE);
- activeE->self()->active=false;
-
- }
- activeE=activeN;
- }
-
- uint32_t peak=0;
- for(int i=0;i<samples;i++) {
- //clamp to (1<<24) using branchless code
- int32_t in = internal_buffer[i];
-#ifdef DEBUG_ENABLED
- {
- int mask = (in >> (32 - 1));
- uint32_t p = (in + mask) ^ mask;
- if (p>peak)
- peak=p;
- }
-#endif
- int32_t lo = -0x800000, hi=0x7FFFFF;
- lo-=in;
- hi-=in;
- in += (lo & ((lo < 0) - 1)) + (hi & ((hi > 0) - 1));
- p_buffer[i]=in<<8;
- }
-
- if (peak>max_peak)
- max_peak=peak;
-}
-
-void AudioServerSW::driver_process(int p_frames,int32_t *p_buffer) {
-
-
- _output_delay=p_frames/double(AudioDriverSW::get_singleton()->get_mix_rate());
- //process in chunks to make sure to never process more than INTERNAL_BUFFER_SIZE
- int todo=p_frames;
- while(todo) {
-
- int tomix=MIN(todo,INTERNAL_BUFFER_SIZE);
- driver_process_chunk(tomix,p_buffer);
- p_buffer+=tomix;
- todo-=tomix;
- }
-
-
-}
-
-/* SAMPLE API */
-
-RID AudioServerSW::sample_create(SampleFormat p_format, bool p_stereo, int p_length) {
-
- AUDIO_LOCK
-
- return sample_manager->sample_create(p_format,p_stereo,p_length);
-}
-
-void AudioServerSW::sample_set_description(RID p_sample, const String& p_description) {
-
- AUDIO_LOCK
- sample_manager->sample_set_description(p_sample,p_description);
-}
-String AudioServerSW::sample_get_description(RID p_sample) const {
-
- AUDIO_LOCK
- return sample_manager->sample_get_description(p_sample);
-}
-
-AS::SampleFormat AudioServerSW::sample_get_format(RID p_sample) const {
- //AUDIO_LOCK
- return sample_manager->sample_get_format(p_sample);
-}
-bool AudioServerSW::sample_is_stereo(RID p_sample) const {
- //AUDIO_LOCK
- return sample_manager->sample_is_stereo(p_sample);
-}
-int AudioServerSW::sample_get_length(RID p_sample) const {
- ///AUDIO_LOCK
- return sample_manager->sample_get_length(p_sample);
-}
-
-const void* AudioServerSW::sample_get_data_ptr(RID p_sample) const {
- ///AUDIO_LOCK
- return sample_manager->sample_get_data_ptr(p_sample);
-}
-
-void AudioServerSW::sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer) {
- AUDIO_LOCK
- sample_manager->sample_set_data(p_sample,p_buffer);
-}
-PoolVector<uint8_t> AudioServerSW::sample_get_data(RID p_sample) const {
- AUDIO_LOCK
- return sample_manager->sample_get_data(p_sample);
-}
-
-void AudioServerSW::sample_set_mix_rate(RID p_sample,int p_rate) {
- AUDIO_LOCK
- sample_manager->sample_set_mix_rate(p_sample,p_rate);
-}
-int AudioServerSW::sample_get_mix_rate(RID p_sample) const {
- AUDIO_LOCK
- return sample_manager->sample_get_mix_rate(p_sample);
-}
-
-void AudioServerSW::sample_set_loop_format(RID p_sample,SampleLoopFormat p_format) {
- AUDIO_LOCK
- sample_manager->sample_set_loop_format(p_sample,p_format);
-}
-AS::SampleLoopFormat AudioServerSW::sample_get_loop_format(RID p_sample) const {
- AUDIO_LOCK
- return sample_manager->sample_get_loop_format(p_sample);
-}
-
-void AudioServerSW::sample_set_loop_begin(RID p_sample,int p_pos) {
- AUDIO_LOCK
- sample_manager->sample_set_loop_begin(p_sample,p_pos);
-}
-int AudioServerSW::sample_get_loop_begin(RID p_sample) const {
- AUDIO_LOCK
- return sample_manager->sample_get_loop_begin(p_sample);
-}
-
-void AudioServerSW::sample_set_loop_end(RID p_sample,int p_pos) {
- AUDIO_LOCK
- sample_manager->sample_set_loop_end(p_sample,p_pos);
-}
-int AudioServerSW::sample_get_loop_end(RID p_sample) const {
- AUDIO_LOCK
- return sample_manager->sample_get_loop_end(p_sample);
-}
-
-/* VOICE API */
-
-RID AudioServerSW::voice_create() {
-
- Voice * v = memnew( Voice );
- v->channel=AudioMixer::INVALID_CHANNEL;
-
- AUDIO_LOCK
- return voice_owner.make_rid(v);
-
-}
-void AudioServerSW::voice_play(RID p_voice, RID p_sample) {
-
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND(!v);
- v->active=true; // force actvive (will be disabled later i gues..)
-
- //stop old, start new
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_PLAY;
- cmd.voice=p_voice;
- cmd.play.sample=p_sample;
- voice_rb.push_command(cmd);
-
-}
-
-void AudioServerSW::voice_set_volume(RID p_voice, float p_volume) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_VOLUME;
- cmd.voice=p_voice;
- cmd.volume.volume=p_volume;
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_pan(RID p_voice, float p_pan, float p_depth,float p_height) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_PAN;
- cmd.voice=p_voice;
- cmd.pan.pan=p_pan;
- cmd.pan.depth=p_depth;
- cmd.pan.height=p_height;
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance,float p_gain) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_FILTER;
- cmd.voice=p_voice;
- cmd.filter.type=p_type;
- cmd.filter.cutoff=p_cutoff;
- cmd.filter.resonance=p_resonance;
- cmd.filter.gain=p_gain;
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_chorus(RID p_voice, float p_chorus ) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_CHORUS;
- cmd.voice=p_voice;
- cmd.chorus.send=p_chorus;
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_REVERB;
- cmd.voice=p_voice;
- cmd.reverb.room=p_room_type;
- cmd.reverb.send=p_reverb;
-
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_mix_rate(RID p_voice, int p_mix_rate) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_MIX_RATE;
- cmd.voice=p_voice;
- cmd.mix_rate.mix_rate=p_mix_rate;
- voice_rb.push_command(cmd);
-
-}
-void AudioServerSW::voice_set_positional(RID p_voice, bool p_positional) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_SET_POSITIONAL;
- cmd.voice=p_voice;
- cmd.positional.positional=p_positional;
- voice_rb.push_command(cmd);
-
-}
-
-float AudioServerSW::voice_get_volume(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_volume( v->channel );
-
-}
-float AudioServerSW::voice_get_pan(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_pan( v->channel );
-
-}
-float AudioServerSW::voice_get_pan_depth(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_pan_depth( v->channel );
-
-}
-float AudioServerSW::voice_get_pan_height(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_pan_height( v->channel );
-
-}
-AS::FilterType AudioServerSW::voice_get_filter_type(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, AS::FILTER_NONE);
-
- return (AS::FilterType)mixer->channel_get_filter_type(v->channel);
-
-}
-float AudioServerSW::voice_get_filter_cutoff(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_filter_cutoff( v->channel );
-
-}
-float AudioServerSW::voice_get_filter_resonance(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_filter_resonance( v->channel );
-
-}
-float AudioServerSW::voice_get_chorus(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_chorus( v->channel );
-
-}
-AS::ReverbRoomType AudioServerSW::voice_get_reverb_type(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, REVERB_SMALL);
-
- return (AS::ReverbRoomType)mixer->channel_get_reverb_type( v->channel );
-
-}
-float AudioServerSW::voice_get_reverb(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_reverb( v->channel );
-
-}
-
-int AudioServerSW::voice_get_mix_rate(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_get_mix_rate( v->channel );
-
-}
-bool AudioServerSW::voice_is_positional(RID p_voice) const {
-
- AUDIO_LOCK
- Voice *v = voice_owner.get( p_voice );
- ERR_FAIL_COND_V(!v, 0);
-
- return mixer->channel_is_positional( v->channel );
-
-}
-
-void AudioServerSW::voice_stop(RID p_voice) {
-
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_STOP;
- cmd.voice=p_voice;
- voice_rb.push_command(cmd);
-
- //return mixer->channel_free( v->channel );
-
-}
-
-bool AudioServerSW::voice_is_active(RID p_voice) const {
-
- Voice *v = voice_owner.get(p_voice);
- ERR_FAIL_COND_V(!v,false);
- return v->active;
-
-}
-
-/* STREAM API */
-
-RID AudioServerSW::audio_stream_create(AudioStream *p_stream) {
-
- AUDIO_LOCK
- Stream *s = memnew(Stream);
- s->audio_stream=p_stream;
- s->event_stream=NULL;
- s->active=false;
- s->E=NULL;
- s->volume_scale=1.0;
- p_stream->set_mix_rate(AudioDriverSW::get_singleton()->get_mix_rate());
-
- return stream_owner.make_rid(s);
-}
-
-RID AudioServerSW::event_stream_create(EventStream *p_stream) {
-
- AUDIO_LOCK
- Stream *s = memnew(Stream);
- s->audio_stream=NULL;
- s->event_stream=p_stream;
- s->active=false;
- s->E=NULL;
- s->volume_scale=1.0;
- //p_stream->set_mix_rate(AudioDriverSW::get_singleton()->get_mix_rate());
-
- return stream_owner.make_rid(s);
-
-
-}
-
-
-void AudioServerSW::stream_set_active(RID p_stream, bool p_active) {
-
-
- Stream *s = stream_owner.get(p_stream);
- ERR_FAIL_COND(!s);
- _THREAD_SAFE_METHOD_
-
- if (s->active==p_active)
- return;
- AUDIO_LOCK;
- s->active=p_active;
- if (p_active)
- s->E=active_audio_streams.push_back(s);
- else {
- active_audio_streams.erase(s->E);
- s->E=NULL;
- }
-
-
-}
-
-bool AudioServerSW::stream_is_active(RID p_stream) const {
-
- Stream *s = stream_owner.get(p_stream);
- ERR_FAIL_COND_V(!s,false);
- return s->active;
-}
-
-void AudioServerSW::stream_set_volume_scale(RID p_stream, float p_scale) {
-
- Stream *s = stream_owner.get(p_stream);
- ERR_FAIL_COND(!s);
- s->volume_scale=p_scale;
-
-}
-
-float AudioServerSW::stream_set_volume_scale(RID p_stream) const {
-
- Stream *s = stream_owner.get(p_stream);
- ERR_FAIL_COND_V(!s,0);
- return s->volume_scale;
-
-}
-
-
-void AudioServerSW::free(RID p_id) {
-
- if(voice_owner.owns(p_id)) {
-
- Voice *v = voice_owner.get(p_id);
- AUDIO_LOCK
- mixer->channel_free( v->channel );
- voice_owner.free(p_id);
- memdelete(v);
-
- } else if (stream_owner.owns(p_id)) {
-
-
- Stream *s=stream_owner.get(p_id);
-
- if (s->active) {
- stream_set_active(p_id,false);
- }
-
- memdelete(s);
- stream_owner.free(p_id);
-
- } else if (sample_manager->is_sample(p_id)) {
-
- AUDIO_LOCK
- sample_manager->free(p_id);
- }
-
-}
-
-void AudioServerSW::_thread_func(void *self) {
-
- Thread::set_name("AudioServerSW");
-
- AudioServerSW *as=(AudioServerSW *)self;
-
- while (!as->exit_update_thread) {
- as->_update_streams(true);
- OS::get_singleton()->delay_usec(5000);
- }
-
-}
-
-void AudioServerSW::init() {
-
- int latency = GLOBAL_DEF("audio/mixer_latency",10);
- internal_buffer_channels=2; // read from driver
- internal_buffer = memnew_arr(int32_t,INTERNAL_BUFFER_SIZE*internal_buffer_channels);
- stream_buffer = memnew_arr(int32_t,INTERNAL_BUFFER_SIZE*4); //max 4 channels
- AudioMixerSW::MixChannels mix_chans = AudioMixerSW::MIX_STEREO;
-
- switch(AudioDriverSW::get_singleton()->get_output_format()) {
-
- case AudioDriverSW::OUTPUT_MONO:
- case AudioDriverSW::OUTPUT_STEREO:
- mix_chans=AudioMixerSW::MIX_STEREO;
- break;
- case AudioDriverSW::OUTPUT_QUAD:
- case AudioDriverSW::OUTPUT_5_1:
- mix_chans=AudioMixerSW::MIX_QUAD;
- break;
- }
-
- mixer = memnew( AudioMixerSW( sample_manager, latency, AudioDriverSW::get_singleton()->get_mix_rate(),mix_chans,mixer_use_fx,mixer_interp,_mixer_callback,this ) );
- mixer_step_usecs=mixer->get_step_usecs();
-
- _output_delay=0;
-
- stream_volume=0.3;
- // start the audio driver
- if (AudioDriverSW::get_singleton())
- AudioDriverSW::get_singleton()->start();
-
-#ifndef NO_THREADS
- exit_update_thread=false;
- thread = Thread::create(_thread_func,this);
-#endif
-
-}
-
-void AudioServerSW::finish() {
-
-#ifndef NO_THREADS
- exit_update_thread=true;
- Thread::wait_to_finish(thread);
- memdelete(thread);
-#endif
-
- if (AudioDriverSW::get_singleton())
- AudioDriverSW::get_singleton()->finish();
-
- memdelete_arr(internal_buffer);
- memdelete_arr(stream_buffer);
- memdelete(mixer);
-
-}
-
-void AudioServerSW::_update_streams(bool p_thread) {
-
- _THREAD_SAFE_METHOD_
- for(List<Stream*>::Element *E=active_audio_streams.front();E;) { //stream might be removed durnig this callback
-
- List<Stream*>::Element *N=E->next();
-
- if (E->get()->audio_stream && p_thread == E->get()->audio_stream->can_update_mt())
- E->get()->audio_stream->update();
-
- E=N;
- }
-
-}
-
-void AudioServerSW::update() {
-
- _update_streams(false);
-#ifdef NO_THREADS
-
- _update_streams(true);
-#endif
-}
-
-
-void AudioServerSW::lock() {
-
- AudioDriverSW::get_singleton()->lock();
-}
-
-void AudioServerSW::unlock() {
- AudioDriverSW::get_singleton()->unlock();
-
-}
-
-int AudioServerSW::get_default_mix_rate() const {
-
- return AudioDriverSW::get_singleton()->get_mix_rate();
-}
-int AudioServerSW::get_default_channel_count() const {
- return internal_buffer_channels;
-}
-
-void AudioServerSW::set_mixer_params(AudioMixerSW::InterpolationType p_interp, bool p_use_fx) {
-
- mixer_interp=p_interp;
- mixer_use_fx=p_use_fx;
-}
-
-void AudioServerSW::set_stream_global_volume_scale(float p_volume) {
-
- stream_volume_scale=p_volume;
-}
-
-float AudioServerSW::get_stream_global_volume_scale() const {
-
- return stream_volume_scale;
-
-
-}
-
-void AudioServerSW::set_fx_global_volume_scale(float p_volume) {
-
- fx_volume_scale=p_volume;
- //mixer->set_mixer_volume(fx_volume_scale);
- VoiceRBSW::Command cmd;
- cmd.type=VoiceRBSW::Command::CMD_CHANGE_ALL_FX_VOLUMES;
- cmd.voice=RID();
- cmd.volume.volume=p_volume;
- voice_rb.push_command(cmd);
-
-}
-
-
-float AudioServerSW::get_fx_global_volume_scale() const {
-
- return fx_volume_scale;
-}
-
-void AudioServerSW::set_event_voice_global_volume_scale(float p_volume) {
-
- event_voice_volume_scale=p_volume;
- //mixer->set_mixer_volume(event_voice_volume_scale);
-}
-
-
-float AudioServerSW::get_event_voice_global_volume_scale() const {
-
- return event_voice_volume_scale;
-}
-
-double AudioServerSW::get_output_delay() const {
-
- return _output_delay+AudioDriverSW::get_singleton()->get_latency();
-}
-
-double AudioServerSW::get_mix_time() const {
-
- return AudioDriverSW::get_singleton()->get_mix_time();
-}
-
-uint32_t AudioServerSW::read_output_peak() const {
-
- uint32_t val = max_peak;
- uint32_t *p = (uint32_t*)&max_peak;
- *p=0;
- return val;
-}
-
-AudioServerSW::AudioServerSW(SampleManagerSW *p_sample_manager) {
-
- sample_manager=p_sample_manager;
- String interp = GLOBAL_DEF("audio/mixer_interp","linear");
- GlobalConfig::get_singleton()->set_custom_property_info("audio/mixer_interp",PropertyInfo(Variant::STRING,"audio/mixer_interp",PROPERTY_HINT_ENUM,"raw,linear,cubic"));
- if (interp=="raw")
- mixer_interp=AudioMixerSW::INTERPOLATION_RAW;
- else if (interp=="cubic")
- mixer_interp=AudioMixerSW::INTERPOLATION_CUBIC;
- else
- mixer_interp=AudioMixerSW::INTERPOLATION_LINEAR;
- mixer_use_fx = GLOBAL_DEF("audio/use_chorus_reverb",true);
- stream_volume_scale=GLOBAL_DEF("audio/stream_volume_scale",1.0);
- fx_volume_scale=GLOBAL_DEF("audio/fx_volume_scale",1.0);
- event_voice_volume_scale=GLOBAL_DEF("audio/event_voice_volume_scale",0.5);
- max_peak=0;
-
-
-}
-
-AudioServerSW::~AudioServerSW() {
-
-}
-
-
-AudioDriverSW *AudioDriverSW::singleton=NULL;
-AudioDriverSW *AudioDriverSW::get_singleton() {
-
- return singleton;
-}
-
-void AudioDriverSW::set_singleton() {
-
- singleton=this;
-}
-
-void AudioDriverSW::audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time) {
-
- AudioServerSW * audio_server = static_cast<AudioServerSW*>(AudioServer::get_singleton());
- if (p_update_mix_time)
- update_mix_time(p_frames);
- audio_server->driver_process(p_frames,p_buffer);
-}
-
-void AudioDriverSW::update_mix_time(int p_frames) {
-
- _mix_amount+=p_frames;
- _last_mix_time=OS::get_singleton()->get_ticks_usec();
-}
-
-double AudioDriverSW::get_mix_time() const {
-
- double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
- total+=_mix_amount/(double)get_mix_rate();
- return total;
-
-}
-
-
-AudioDriverSW::AudioDriverSW() {
-
- _last_mix_time=0;
- _mix_amount=0;
-}
-
-
-AudioDriverSW *AudioDriverManagerSW::drivers[MAX_DRIVERS];
-int AudioDriverManagerSW::driver_count=0;
-
-
-
-void AudioDriverManagerSW::add_driver(AudioDriverSW *p_driver) {
-
- ERR_FAIL_COND(driver_count>=MAX_DRIVERS);
- drivers[driver_count++]=p_driver;
-}
-
-int AudioDriverManagerSW::get_driver_count() {
-
- return driver_count;
-}
-AudioDriverSW *AudioDriverManagerSW::get_driver(int p_driver) {
-
- ERR_FAIL_INDEX_V(p_driver,driver_count,NULL);
- return drivers[p_driver];
-}
-
diff --git a/servers/audio/audio_server_sw.h b/servers/audio/audio_server_sw.h
deleted file mode 100644
index 52b45351c3..0000000000
--- a/servers/audio/audio_server_sw.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/*************************************************************************/
-/* audio_server_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 AUDIO_SERVER_SW_H
-#define AUDIO_SERVER_SW_H
-
-#include "servers/audio_server.h"
-#include "servers/audio/audio_mixer_sw.h"
-#include "servers/audio/voice_rb_sw.h"
-#include "self_list.h"
-#include "os/thread_safe.h"
-#include "os/thread.h"
-class AudioServerSW : public AudioServer {
-
- GDCLASS( AudioServerSW, AudioServer );
-
- _THREAD_SAFE_CLASS_
-
- enum {
- INTERNAL_BUFFER_SIZE=4096,
- STREAM_SCALE_BITS=12
-
- };
-
- SampleManagerSW *sample_manager;
- AudioMixerSW *mixer;
-
- virtual AudioMixer *get_mixer();
- virtual void audio_mixer_chunk_callback(int p_frames);
-
- struct Voice : public RID_Data {
-
- float volume;
- volatile bool active;
- SelfList<Voice> active_item;
- AudioMixer::ChannelID channel;
-
-
- Voice () : active_item(this) { channel=AudioMixer::INVALID_CHANNEL; active=false;}
- };
-
- mutable RID_Owner<Voice> voice_owner;
- SelfList<Voice>::List active_list;
-
- struct Stream : public RID_Data {
- bool active;
- List<Stream*>::Element *E;
- AudioStream *audio_stream;
- EventStream *event_stream;
- float volume_scale;
- };
-
- List<Stream*> active_audio_streams;
-
- //List<Stream*> event_streams;
-
- int32_t * internal_buffer;
- int internal_buffer_channels;
- int32_t * stream_buffer;
-
- mutable RID_Owner<Stream> stream_owner;
-
- float stream_volume;
- float stream_volume_scale;
- float fx_volume_scale;
- float event_voice_volume_scale;
- float peak_left,peak_right;
- uint32_t max_peak;
-
- double _output_delay;
-
- VoiceRBSW voice_rb;
-
- bool exit_update_thread;
- Thread *thread;
- static void _thread_func(void *self);
-
- void _update_streams(bool p_thread);
- void driver_process_chunk(int p_frames,int32_t *p_buffer);
-
- AudioMixerSW::InterpolationType mixer_interp;
- bool mixer_use_fx;
- uint64_t mixer_step_usecs;
-
- static void _mixer_callback(void *p_udata);
-friend class AudioDriverSW;
- void driver_process(int p_frames,int32_t *p_buffer);
-public:
-
-
- /* SAMPLE API */
-
- virtual RID sample_create(SampleFormat p_format, bool p_stereo, int p_length);
-
- virtual void sample_set_description(RID p_sample, const String& p_description);
- virtual String sample_get_description(RID p_sample) const;
-
- virtual SampleFormat sample_get_format(RID p_sample) const;
- virtual bool sample_is_stereo(RID p_sample) const;
- virtual int sample_get_length(RID p_sample) const;
- const void* sample_get_data_ptr(RID p_sample) const;
-
- virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer);
- virtual PoolVector<uint8_t> sample_get_data(RID p_sample) const;
-
- virtual void sample_set_mix_rate(RID p_sample,int p_rate);
- virtual int sample_get_mix_rate(RID p_sample) const;
-
- virtual void sample_set_loop_format(RID p_sample,SampleLoopFormat p_format);
- virtual SampleLoopFormat sample_get_loop_format(RID p_sample) const;
-
- virtual void sample_set_loop_begin(RID p_sample,int p_pos);
- virtual int sample_get_loop_begin(RID p_sample) const;
-
- virtual void sample_set_loop_end(RID p_sample,int p_pos);
- virtual int sample_get_loop_end(RID p_sample) const;
-
- /* VOICE API */
-
- virtual RID voice_create();
-
- virtual void voice_play(RID p_voice, RID p_sample);
-
- virtual void voice_set_volume(RID p_voice, float p_volume);
- virtual void voice_set_pan(RID p_voice, float p_pan, float p_depth=0,float height=0); //pan and depth go from -1 to 1
- virtual void voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance,float p_gain=0);
- virtual void voice_set_chorus(RID p_voice, float p_chorus );
- virtual void voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb);
- virtual void voice_set_mix_rate(RID p_voice, int p_mix_rate);
- virtual void voice_set_positional(RID p_voice, bool p_positional);
-
- virtual float voice_get_volume(RID p_voice) const;
- virtual float voice_get_pan(RID p_voice) const; //pan and depth go from -1 to 1
- virtual float voice_get_pan_depth(RID p_voice) const; //pan and depth go from -1 to 1
- virtual float voice_get_pan_height(RID p_voice) const; //pan and depth go from -1 to 1
- virtual FilterType voice_get_filter_type(RID p_voice) const;
- virtual float voice_get_filter_cutoff(RID p_voice) const;
- virtual float voice_get_filter_resonance(RID p_voice) const;
- virtual float voice_get_chorus(RID p_voice) const;
- virtual ReverbRoomType voice_get_reverb_type(RID p_voice) const;
- virtual float voice_get_reverb(RID p_voice) const;
-
- virtual int voice_get_mix_rate(RID p_voice) const;
- virtual bool voice_is_positional(RID p_voice) const;
-
- virtual void voice_stop(RID p_voice);
- virtual bool voice_is_active(RID p_voice) const;
-
- /* STREAM API */
-
- virtual RID audio_stream_create(AudioStream *p_stream);
- virtual RID event_stream_create(EventStream *p_stream);
-
- virtual void stream_set_active(RID p_stream, bool p_active);
- virtual bool stream_is_active(RID p_stream) const;
-
- virtual void stream_set_volume_scale(RID p_stream, float p_scale);
- virtual float stream_set_volume_scale(RID p_stream) const;
-
- virtual void free(RID p_id);
-
- virtual void init();
- virtual void finish();
- virtual void update();
-
- virtual void lock();
- virtual void unlock();
- virtual int get_default_channel_count() const;
- virtual int get_default_mix_rate() const;
-
- void set_mixer_params(AudioMixerSW::InterpolationType p_interp, bool p_use_fx);
-
- virtual void set_stream_global_volume_scale(float p_volume);
- virtual void set_fx_global_volume_scale(float p_volume);
- virtual void set_event_voice_global_volume_scale(float p_volume);
-
-
- virtual float get_stream_global_volume_scale() const;
- virtual float get_fx_global_volume_scale() const;
- virtual float get_event_voice_global_volume_scale() const;
-
- virtual uint32_t read_output_peak() const;
-
- virtual double get_mix_time() const; //useful for video -> audio sync
-
- virtual double get_output_delay() const;
-
-
- AudioServerSW(SampleManagerSW *p_sample_manager);
- ~AudioServerSW();
-
-};
-
-
-class AudioDriverSW {
-
-
- static AudioDriverSW *singleton;
- uint64_t _last_mix_time;
- uint64_t _mix_amount;
-
-
-protected:
-
- void audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time=true);
- void update_mix_time(int p_frames);
-
-public:
-
-
- double get_mix_time() const; //useful for video -> audio sync
-
- enum OutputFormat {
-
- OUTPUT_MONO,
- OUTPUT_STEREO,
- OUTPUT_QUAD,
- OUTPUT_5_1
- };
-
- static AudioDriverSW *get_singleton();
- void set_singleton();
-
- virtual const char* get_name() const=0;
-
- virtual Error init()=0;
- virtual void start()=0;
- virtual int get_mix_rate() const =0;
- virtual OutputFormat get_output_format() const=0;
- virtual void lock()=0;
- virtual void unlock()=0;
- virtual void finish()=0;
-
- virtual float get_latency() { return 0; }
-
-
-
-
- AudioDriverSW();
- virtual ~AudioDriverSW() {};
-};
-
-
-
-class AudioDriverManagerSW {
-
- enum {
-
- MAX_DRIVERS=10
- };
-
- static AudioDriverSW *drivers[MAX_DRIVERS];
- static int driver_count;
-public:
-
- static void add_driver(AudioDriverSW *p_driver);
- static int get_driver_count();
- static AudioDriverSW *get_driver(int p_driver);
-};
-
-#endif // AUDIO_SERVER_SW_H
diff --git a/scene/resources/audio_stream.cpp b/servers/audio/audio_stream.cpp
index 7c269de007..f4214838a1 100644
--- a/scene/resources/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -31,31 +31,56 @@
//////////////////////////////
-void AudioStreamPlayback::_bind_methods() {
- ClassDB::bind_method(_MD("play","from_pos_sec"),&AudioStreamPlayback::play,DEFVAL(0));
- ClassDB::bind_method(_MD("stop"),&AudioStreamPlayback::stop);
- ClassDB::bind_method(_MD("is_playing"),&AudioStreamPlayback::is_playing);
+void AudioStreamPlaybackResampled::_begin_resample() {
- ClassDB::bind_method(_MD("set_loop","enabled"),&AudioStreamPlayback::set_loop);
- ClassDB::bind_method(_MD("has_loop"),&AudioStreamPlayback::has_loop);
+ //clear cubic interpolation history
+ internal_buffer[0]=AudioFrame(0.0,0.0);
+ internal_buffer[1]=AudioFrame(0.0,0.0);
+ internal_buffer[2]=AudioFrame(0.0,0.0);
+ internal_buffer[3]=AudioFrame(0.0,0.0);
+ //mix buffer
+ _mix_internal(internal_buffer+4,INTERNAL_BUFFER_LEN);
+ mix_offset=0;
+}
- ClassDB::bind_method(_MD("get_loop_count"),&AudioStreamPlayback::get_loop_count);
+void AudioStreamPlaybackResampled::mix(AudioFrame* p_buffer,float p_rate_scale,int p_frames) {
- ClassDB::bind_method(_MD("seek_pos","pos"),&AudioStreamPlayback::seek_pos);
- ClassDB::bind_method(_MD("get_pos"),&AudioStreamPlayback::get_pos);
+ float target_rate = AudioServer::get_singleton()->get_mix_rate() * p_rate_scale;
- ClassDB::bind_method(_MD("get_length"),&AudioStreamPlayback::get_length);
- ClassDB::bind_method(_MD("get_channels"),&AudioStreamPlayback::get_channels);
- ClassDB::bind_method(_MD("get_mix_rate"),&AudioStreamPlayback::get_mix_rate);
- ClassDB::bind_method(_MD("get_minimum_buffer_size"),&AudioStreamPlayback::get_minimum_buffer_size);
+ uint64_t mix_increment = uint64_t((get_stream_sampling_rate() / double(target_rate)) * double( FP_LEN ));
+ for(int i=0;i<p_frames;i++) {
-}
-void AudioStream::_bind_methods() {
+ uint32_t idx = CUBIC_INTERP_HISTORY + uint32_t(mix_offset >> FP_BITS);
+ //standard cubic interpolation (great quality/performance ratio)
+ //this used to be moved to a LUT for greater performance, but nowadays CPU speed is generally faster than memory.
+ float mu = (mix_offset&FP_MASK)/float(FP_LEN);
+ AudioFrame y0 = internal_buffer[idx-3];
+ AudioFrame y1 = internal_buffer[idx-2];
+ AudioFrame y2 = internal_buffer[idx-1];
+ AudioFrame y3 = internal_buffer[idx-0];
+ float mu2 = mu*mu;
+ AudioFrame a0 = y3 - y2 - y0 + y1;
+ AudioFrame a1 = y0 - y1 - a0;
+ AudioFrame a2 = y2 - y0;
+ AudioFrame a3 = y1;
-}
+ p_buffer[i] = (a0*mu*mu2 + a1*mu2 + a2*mu + a3);
+ mix_offset+=mix_increment;
+
+ while ( (mix_offset >> FP_BITS) >= INTERNAL_BUFFER_LEN ) {
+
+ internal_buffer[0]=internal_buffer[INTERNAL_BUFFER_LEN+0];
+ internal_buffer[1]=internal_buffer[INTERNAL_BUFFER_LEN+1];
+ internal_buffer[2]=internal_buffer[INTERNAL_BUFFER_LEN+2];
+ internal_buffer[3]=internal_buffer[INTERNAL_BUFFER_LEN+3];
+ _mix_internal(internal_buffer+4,INTERNAL_BUFFER_LEN);
+ mix_offset-=(INTERNAL_BUFFER_LEN<<FP_BITS);
+ }
+ }
+}
diff --git a/scene/resources/audio_stream.h b/servers/audio/audio_stream.h
index b79707cd32..d08fedb084 100644
--- a/scene/resources/audio_stream.h
+++ b/servers/audio/audio_stream.h
@@ -34,47 +34,65 @@
class AudioStreamPlayback : public Reference {
- GDCLASS( AudioStreamPlayback, Reference );
-protected:
- static void _bind_methods();
-public:
+ GDCLASS( AudioStreamPlayback, Reference )
+public:
- virtual void play(float p_from_pos=0)=0;
+ virtual void start(float p_from_pos=0.0)=0;
virtual void stop()=0;
virtual bool is_playing() const=0;
- virtual void set_loop(bool p_enable)=0;
- virtual bool has_loop() const=0;
-
- virtual void set_loop_restart_time(float p_time)=0;
-
- virtual int get_loop_count() const=0;
+ virtual int get_loop_count() const=0; //times it looped
virtual float get_pos() const=0;
virtual void seek_pos(float p_time)=0;
- virtual int mix(int16_t* p_bufer,int p_frames)=0;
+ virtual void mix(AudioFrame* p_bufer,float p_rate_scale,int p_frames)=0;
- virtual float get_length() const=0;
- virtual String get_stream_name() const=0;
+ virtual float get_length() const=0; //if supported, otherwise return 0
- virtual int get_channels() const=0;
- virtual int get_mix_rate() const=0;
- virtual int get_minimum_buffer_size() const=0;
};
-class AudioStream : public Resource {
+class AudioStreamPlaybackResampled : public AudioStreamPlayback {
+
+ GDCLASS( AudioStreamPlaybackResampled, AudioStreamPlayback )
+
+
+
+ enum {
+ FP_BITS=16, //fixed point used for resampling
+ FP_LEN=(1<<FP_BITS),
+ FP_MASK=FP_LEN-1,
+ INTERNAL_BUFFER_LEN=256,
+ CUBIC_INTERP_HISTORY=4
+ };
- GDCLASS( AudioStream, Resource );
- OBJ_SAVE_TYPE( AudioStream ); //children are all saved as AudioStream, so they can be exchanged
+ AudioFrame internal_buffer[INTERNAL_BUFFER_LEN+CUBIC_INTERP_HISTORY];
+ uint64_t mix_offset;
protected:
- static void _bind_methods();
+ void _begin_resample();
+ virtual void _mix_internal(AudioFrame* p_bufer,int p_frames)=0;
+ virtual float get_stream_sampling_rate()=0;
+
+public:
+
+ virtual void mix(AudioFrame* p_bufer,float p_rate_scale,int p_frames);
+
+ AudioStreamPlaybackResampled() { mix_offset=0; }
+};
+
+class AudioStream : public Resource {
+
+ GDCLASS( AudioStream, Resource )
+ OBJ_SAVE_TYPE( AudioStream ) //children are all saved as AudioStream, so they can be exchanged
+
+
public:
virtual Ref<AudioStreamPlayback> instance_playback()=0;
+ virtual String get_stream_name() const=0;
};
diff --git a/servers/spatial_sound/SCsub b/servers/audio/effects/SCsub
index ccc76e823f..ccc76e823f 100644
--- a/servers/spatial_sound/SCsub
+++ b/servers/audio/effects/SCsub
diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp
new file mode 100644
index 0000000000..fde33dfe63
--- /dev/null
+++ b/servers/audio/effects/audio_effect_amplify.cpp
@@ -0,0 +1,50 @@
+#include "audio_effect_amplify.h"
+
+
+void AudioEffectAmplifyInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+ //multiply volume interpolating to avoid clicks if this changes
+ float volume_db = base->volume_db;
+ float vol = Math::db2linear(mix_volume_db);
+ float vol_inc = (Math::db2linear(volume_db) - vol)/float(p_frame_count);
+
+ for(int i=0;i<p_frame_count;i++) {
+ p_dst_frames[i]=p_src_frames[i]*vol;
+ vol+=vol_inc;
+ }
+ //set volume for next mix
+ mix_volume_db = volume_db;
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectAmplify::instance() {
+ Ref<AudioEffectAmplifyInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectAmplify>(this);
+ ins->mix_volume_db=volume_db;
+ return ins;
+}
+
+void AudioEffectAmplify::set_volume_db(float p_volume) {
+ volume_db=p_volume;
+}
+
+float AudioEffectAmplify::get_volume_db() const {
+
+ return volume_db;
+}
+
+void AudioEffectAmplify::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_volume_db","volume"),&AudioEffectAmplify::set_volume_db);
+ ClassDB::bind_method(D_METHOD("get_volume_db"),&AudioEffectAmplify::get_volume_db);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"volume_db",PROPERTY_HINT_RANGE,"-80,24,0.01"),"set_volume_db","get_volume_db");
+}
+
+AudioEffectAmplify::AudioEffectAmplify()
+{
+ volume_db=0;
+}
diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h
new file mode 100644
index 0000000000..921054e2cd
--- /dev/null
+++ b/servers/audio/effects/audio_effect_amplify.h
@@ -0,0 +1,40 @@
+#ifndef AUDIOEFFECTAMPLIFY_H
+#define AUDIOEFFECTAMPLIFY_H
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectAmplify;
+
+class AudioEffectAmplifyInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectAmplifyInstance,AudioEffectInstance)
+friend class AudioEffectAmplify;
+ Ref<AudioEffectAmplify> base;
+
+ float mix_volume_db;
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectAmplify : public AudioEffect {
+ GDCLASS(AudioEffectAmplify,AudioEffect)
+
+friend class AudioEffectAmplifyInstance;
+ float volume_db;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+ void set_volume_db(float p_volume);
+ float get_volume_db() const;
+
+ AudioEffectAmplify();
+};
+
+#endif // AUDIOEFFECTAMPLIFY_H
diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp
new file mode 100644
index 0000000000..b33aabf24b
--- /dev/null
+++ b/servers/audio/effects/audio_effect_chorus.cpp
@@ -0,0 +1,365 @@
+#include "audio_effect_chorus.h"
+#include "servers/audio_server.h"
+#include "math_funcs.h"
+
+void AudioEffectChorusInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ int todo = p_frame_count;
+
+ while(todo) {
+
+ int to_mix = MIN(todo,256); //can't mix too much
+
+ _process_chunk(p_src_frames,p_dst_frames,to_mix);
+
+ p_src_frames+=to_mix;
+ p_dst_frames+=to_mix;
+
+ todo-=to_mix;
+ }
+}
+
+void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+ //fill ringbuffer
+ for(int i=0;i<p_frame_count;i++) {
+ audio_buffer[(buffer_pos+i)&buffer_mask]=p_src_frames[i];
+ p_dst_frames[i]=p_src_frames[i]*base->dry;
+ }
+
+ float mix_rate = AudioServer::get_singleton()->get_mix_rate();
+
+ /* process voices */
+ for (int vc=0;vc<base->voice_count;vc++) {
+
+ AudioEffectChorus::Voice &v=base->voice[vc];
+
+
+ double time_to_mix=(float)p_frame_count/mix_rate;
+ double cycles_to_mix=time_to_mix*v.rate;
+
+ unsigned int local_rb_pos=buffer_pos;
+ AudioFrame *dst_buff=p_dst_frames;
+ AudioFrame *rb_buff=audio_buffer.ptr();
+
+ double delay_msec=v.delay;
+ unsigned int delay_frames=Math::fast_ftoi((delay_msec/1000.0)*mix_rate);
+ float max_depth_frames=(v.depth/1000.0)*mix_rate;
+
+ uint64_t local_cycles=cycles[vc];
+ uint64_t increment=llrint(cycles_to_mix/(double)p_frame_count*(double)(1<<AudioEffectChorus::CYCLES_FRAC));
+
+ //check the LFO doesnt read ahead of the write pos
+ if ((((int)max_depth_frames)+10)>delay_frames) { //10 as some threshold to avoid precision stuff
+ delay_frames+=(int)max_depth_frames-delay_frames;
+ delay_frames+=10; //threshold to avoid precision stuff
+
+ }
+
+
+
+ //low pass filter
+ if (v.cutoff==0)
+ continue;
+ float auxlp=expf(-2.0*Math_PI*v.cutoff/mix_rate);
+ float c1=1.0-auxlp;
+ float c2=auxlp;
+ AudioFrame h=filter_h[vc];
+ if (v.cutoff>=AudioEffectChorus::MS_CUTOFF_MAX) {
+ c1=1.0; c2=0.0;
+ }
+
+ //vol modifier
+
+ AudioFrame vol_modifier=AudioFrame(base->wet,base->wet) * Math::db2linear(v.level);
+ vol_modifier.l*=CLAMP( 1.0 - v.pan, 0, 1);
+ vol_modifier.r*=CLAMP( 1.0 + v.pan, 0, 1);
+
+
+
+ for (int i=0;i<p_frame_count;i++) {
+
+ /** COMPUTE WAVEFORM **/
+
+ float phase=(float)(local_cycles&AudioEffectChorus::CYCLES_MASK)/(float)(1<<AudioEffectChorus::CYCLES_FRAC);
+
+ float wave_delay=sinf(phase*2.0*Math_PI)*max_depth_frames;
+
+ int wave_delay_frames=lrint(floor(wave_delay));
+ float wave_delay_frac=wave_delay-(float)wave_delay_frames;
+
+ /** COMPUTE RINGBUFFER POS**/
+
+ unsigned int rb_source=local_rb_pos;
+ rb_source-=delay_frames;
+
+ rb_source-=wave_delay_frames;
+
+ /** READ FROM RINGBUFFER, LINEARLY INTERPOLATE */
+
+ AudioFrame val=rb_buff[rb_source&buffer_mask];
+ AudioFrame val_next=rb_buff[(rb_source-1)&buffer_mask];
+
+ val+=(val_next-val)*wave_delay_frac;
+
+ val=val*c1+h*c2;
+ h=val;
+
+ /** MIX VALUE TO OUTPUT **/
+
+ dst_buff[i]+=val*vol_modifier;
+
+ local_cycles+=increment;
+ local_rb_pos++;
+
+ }
+
+ filter_h[vc]=h;
+ cycles[vc]+=Math::fast_ftoi(cycles_to_mix*(double)(1<<AudioEffectChorus::CYCLES_FRAC));
+ }
+
+ buffer_pos+=p_frame_count;
+}
+
+
+Ref<AudioEffectInstance> AudioEffectChorus::instance() {
+
+ Ref<AudioEffectChorusInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectChorus>(this);
+ for(int i=0;i<4;i++) {
+ ins->filter_h[i]=AudioFrame(0,0);
+ ins->cycles[i]=0;
+ }
+
+ float ring_buffer_max_size=AudioEffectChorus::MAX_DELAY_MS+AudioEffectChorus::MAX_DEPTH_MS+AudioEffectChorus::MAX_WIDTH_MS;
+
+ ring_buffer_max_size*=2; //just to avoid complications
+ ring_buffer_max_size/=1000.0;//convert to seconds
+ ring_buffer_max_size*=AudioServer::get_singleton()->get_mix_rate();
+
+ int ringbuff_size=ring_buffer_max_size;
+
+ int bits=0;
+
+ while(ringbuff_size>0) {
+ bits++;
+ ringbuff_size/=2;
+ }
+
+ ringbuff_size=1<<bits;
+ ins->buffer_mask=ringbuff_size-1;
+ ins->buffer_pos=0;
+ ins->audio_buffer.resize(ringbuff_size);
+ for(int i=0;i<ringbuff_size;i++) {
+ ins->audio_buffer[i]=AudioFrame(0,0);
+ }
+
+ return ins;
+}
+
+void AudioEffectChorus::set_voice_count(int p_voices) {
+
+ ERR_FAIL_COND(p_voices<1 || p_voices>=MAX_VOICES);
+ voice_count=p_voices;
+ _change_notify();
+}
+
+
+int AudioEffectChorus::get_voice_count() const{
+
+ return voice_count;
+}
+
+void AudioEffectChorus::set_voice_delay_ms(int p_voice,float p_delay_ms){
+
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].delay=p_delay_ms;
+
+}
+float AudioEffectChorus::get_voice_delay_ms(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+ return voice[p_voice].delay;
+}
+
+void AudioEffectChorus::set_voice_rate_hz(int p_voice,float p_rate_hz){
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].rate=p_rate_hz;
+}
+float AudioEffectChorus::get_voice_rate_hz(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+
+ return voice[p_voice].rate;
+}
+
+void AudioEffectChorus::set_voice_depth_ms(int p_voice,float p_depth_ms){
+
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].depth=p_depth_ms;
+}
+float AudioEffectChorus::get_voice_depth_ms(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+
+ return voice[p_voice].depth;
+}
+
+void AudioEffectChorus::set_voice_level_db(int p_voice,float p_level_db){
+
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].level=p_level_db;
+}
+float AudioEffectChorus::get_voice_level_db(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+
+ return voice[p_voice].level;
+}
+
+
+void AudioEffectChorus::set_voice_cutoff_hz(int p_voice,float p_cutoff_hz){
+
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].cutoff=p_cutoff_hz;
+}
+float AudioEffectChorus::get_voice_cutoff_hz(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+
+ return voice[p_voice].cutoff;
+}
+
+void AudioEffectChorus::set_voice_pan(int p_voice,float p_pan){
+
+ ERR_FAIL_INDEX(p_voice,MAX_VOICES);
+
+ voice[p_voice].pan=p_pan;
+}
+float AudioEffectChorus::get_voice_pan(int p_voice) const{
+
+ ERR_FAIL_INDEX_V(p_voice,MAX_VOICES,0);
+
+ return voice[p_voice].pan;
+}
+
+
+void AudioEffectChorus::set_wet(float amount){
+
+
+ wet=amount;
+}
+float AudioEffectChorus::get_wet() const{
+
+ return wet;
+}
+
+void AudioEffectChorus::set_dry(float amount){
+
+ dry=amount;
+
+}
+float AudioEffectChorus::get_dry() const{
+
+ return dry;
+}
+
+void AudioEffectChorus::_validate_property(PropertyInfo& property) const {
+
+ if (property.name.begins_with("voice/")) {
+ int voice_idx = property.name.get_slice("/",1).to_int();
+ if (voice_idx>voice_count) {
+ property.usage=0;
+ }
+ }
+}
+
+
+void AudioEffectChorus::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_voice_count","voices"),&AudioEffectChorus::set_voice_count);
+ ClassDB::bind_method(D_METHOD("get_voice_count"),&AudioEffectChorus::get_voice_count);
+
+
+ ClassDB::bind_method(D_METHOD("set_voice_delay_ms","voice_idx","delay_ms"),&AudioEffectChorus::set_voice_delay_ms);
+ ClassDB::bind_method(D_METHOD("get_voice_delay_ms","voice_idx"),&AudioEffectChorus::get_voice_delay_ms);
+
+ ClassDB::bind_method(D_METHOD("set_voice_rate_hz","voice_idx","rate_hz"),&AudioEffectChorus::set_voice_rate_hz);
+ ClassDB::bind_method(D_METHOD("get_voice_rate_hz","voice_idx"),&AudioEffectChorus::get_voice_rate_hz);
+
+ ClassDB::bind_method(D_METHOD("set_voice_depth_ms","voice_idx","depth_ms"),&AudioEffectChorus::set_voice_depth_ms);
+ ClassDB::bind_method(D_METHOD("get_voice_depth_ms","voice_idx"),&AudioEffectChorus::get_voice_depth_ms);
+
+ ClassDB::bind_method(D_METHOD("set_voice_level_db","voice_idx","level_db"),&AudioEffectChorus::set_voice_level_db);
+ ClassDB::bind_method(D_METHOD("get_voice_level_db","voice_idx"),&AudioEffectChorus::get_voice_level_db);
+
+ ClassDB::bind_method(D_METHOD("set_voice_cutoff_hz","voice_idx","cutoff_hz"),&AudioEffectChorus::set_voice_cutoff_hz);
+ ClassDB::bind_method(D_METHOD("get_voice_cutoff_hz","voice_idx"),&AudioEffectChorus::get_voice_cutoff_hz);
+
+ ClassDB::bind_method(D_METHOD("set_voice_pan","voice_idx","pan"),&AudioEffectChorus::set_voice_pan);
+ ClassDB::bind_method(D_METHOD("get_voice_pan","voice_idx"),&AudioEffectChorus::get_voice_pan);
+
+ ClassDB::bind_method(D_METHOD("set_wet","amount"),&AudioEffectChorus::set_wet);
+ ClassDB::bind_method(D_METHOD("get_wet"),&AudioEffectChorus::get_wet);
+
+ ClassDB::bind_method(D_METHOD("set_dry","amount"),&AudioEffectChorus::set_dry);
+ ClassDB::bind_method(D_METHOD("get_dry"),&AudioEffectChorus::get_dry);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"voice_count",PROPERTY_HINT_RANGE,"1,4,1"),"set_voice_count","get_voice_count");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dry",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_dry","get_dry");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wet",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_wet","get_wet");
+
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/delay_ms",PROPERTY_HINT_RANGE,"0,50,0.01"),"set_voice_delay_ms","get_voice_delay_ms",0);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/rate_hz",PROPERTY_HINT_RANGE,"0.1,20,0.1"),"set_voice_rate_hz","get_voice_rate_hz",0);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/depth_ms",PROPERTY_HINT_RANGE,"0,20,0.01"),"set_voice_depth_ms","get_voice_depth_ms",0);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/level_db",PROPERTY_HINT_RANGE,"-60,24,0.1"),"set_voice_level_db","get_voice_level_db",0);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/cutoff_hz",PROPERTY_HINT_RANGE,"1,16000,1"),"set_voice_cutoff_hz","get_voice_cutoff_hz",0);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/1/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_voice_pan","get_voice_pan",0);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/delay_ms",PROPERTY_HINT_RANGE,"0,50,0.01"),"set_voice_delay_ms","get_voice_delay_ms",1);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/rate_hz",PROPERTY_HINT_RANGE,"0.1,20,0.1"),"set_voice_rate_hz","get_voice_rate_hz",1);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/depth_ms",PROPERTY_HINT_RANGE,"0,20,0.01"),"set_voice_depth_ms","get_voice_depth_ms",1);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/level_db",PROPERTY_HINT_RANGE,"-60,24,0.1"),"set_voice_level_db","get_voice_level_db",1);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/cutoff_hz",PROPERTY_HINT_RANGE,"1,16000,1"),"set_voice_cutoff_hz","get_voice_cutoff_hz",1);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/2/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_voice_pan","get_voice_pan",1);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/delay_ms",PROPERTY_HINT_RANGE,"0,50,0.01"),"set_voice_delay_ms","get_voice_delay_ms",2);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/rate_hz",PROPERTY_HINT_RANGE,"0.1,20,0.1"),"set_voice_rate_hz","get_voice_rate_hz",2);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/depth_ms",PROPERTY_HINT_RANGE,"0,20,0.01"),"set_voice_depth_ms","get_voice_depth_ms",2);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/level_db",PROPERTY_HINT_RANGE,"-60,24,0.1"),"set_voice_level_db","get_voice_level_db",2);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/cutoff_hz",PROPERTY_HINT_RANGE,"1,16000,1"),"set_voice_cutoff_hz","get_voice_cutoff_hz",2);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/3/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_voice_pan","get_voice_pan",2);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/delay_ms",PROPERTY_HINT_RANGE,"0,50,0.01"),"set_voice_delay_ms","get_voice_delay_ms",3);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/rate_hz",PROPERTY_HINT_RANGE,"0.1,20,0.1"),"set_voice_rate_hz","get_voice_rate_hz",3);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/depth_ms",PROPERTY_HINT_RANGE,"0,20,0.01"),"set_voice_depth_ms","get_voice_depth_ms",3);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/level_db",PROPERTY_HINT_RANGE,"-60,24,0.1"),"set_voice_level_db","get_voice_level_db",3);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/cutoff_hz",PROPERTY_HINT_RANGE,"1,16000,1"),"set_voice_cutoff_hz","get_voice_cutoff_hz",3);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL,"voice/4/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_voice_pan","get_voice_pan",3);
+
+}
+
+AudioEffectChorus::AudioEffectChorus()
+{
+ voice_count=2;
+ voice[0].delay=15;
+ voice[1].delay=20;
+ voice[0].rate=0.8;
+ voice[1].rate=1.2;
+ voice[0].depth=2;
+ voice[1].depth=3;
+ voice[0].cutoff=8000;
+ voice[1].cutoff=8000;
+ voice[0].pan=-0.5;
+ voice[1].pan=0.5;
+
+ wet=0.5;
+ dry=1.0;
+}
diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h
new file mode 100644
index 0000000000..4cfba5d61a
--- /dev/null
+++ b/servers/audio/effects/audio_effect_chorus.h
@@ -0,0 +1,115 @@
+#ifndef AUDIOEFFECTCHORUS_H
+#define AUDIOEFFECTCHORUS_H
+
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectChorus;
+
+class AudioEffectChorusInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectChorusInstance,AudioEffectInstance)
+friend class AudioEffectChorus;
+ Ref<AudioEffectChorus> base;
+
+ Vector<AudioFrame> audio_buffer;
+ unsigned int buffer_pos;
+ unsigned int buffer_mask;
+
+ AudioFrame filter_h[4];
+ uint64_t cycles[4];
+
+ void _process_chunk(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectChorus : public AudioEffect {
+ GDCLASS(AudioEffectChorus,AudioEffect)
+
+friend class AudioEffectChorusInstance;
+public:
+ enum {
+
+ MAX_DELAY_MS=50,
+ MAX_DEPTH_MS=20,
+ MAX_WIDTH_MS=50,
+ MAX_VOICES=4,
+ CYCLES_FRAC=16,
+ CYCLES_MASK=(1<<CYCLES_FRAC)-1,
+ MAX_CHANNELS=4,
+ MS_CUTOFF_MAX=16000
+ };
+
+private:
+
+ struct Voice {
+
+ float delay;
+ float rate;
+ float depth;
+ float level;
+ float cutoff;
+ float pan;
+
+ Voice() {
+
+ delay=12.0;
+ rate=1;
+ depth=0;
+ level=0;
+ cutoff=MS_CUTOFF_MAX;
+ pan=0;
+
+ }
+
+ } voice[MAX_VOICES];
+
+ int voice_count;
+
+ float wet;
+ float dry;
+
+
+protected:
+ void _validate_property(PropertyInfo& property) const;
+
+ static void _bind_methods();
+public:
+
+ void set_voice_count(int p_voices);
+ int get_voice_count() const;
+
+ void set_voice_delay_ms(int p_voice,float p_delay_ms);
+ float get_voice_delay_ms(int p_voice) const;
+
+ void set_voice_rate_hz(int p_voice,float p_rate_hz);
+ float get_voice_rate_hz(int p_voice) const;
+
+ void set_voice_depth_ms(int p_voice,float p_depth_ms);
+ float get_voice_depth_ms(int p_voice) const;
+
+ void set_voice_level_db(int p_voice,float p_level_db);
+ float get_voice_level_db(int p_voice) const;
+
+ void set_voice_cutoff_hz(int p_voice,float p_cutoff_hz);
+ float get_voice_cutoff_hz(int p_voice) const;
+
+ void set_voice_pan(int p_voice,float p_pan);
+ float get_voice_pan(int p_voice) const;
+
+ void set_wet(float amount);
+ float get_wet() const;
+
+ void set_dry(float amount);
+ float get_dry() const;
+
+ Ref<AudioEffectInstance> instance();
+
+ AudioEffectChorus();
+};
+
+#endif // AUDIOEFFECTCHORUS_H
diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp
new file mode 100644
index 0000000000..d20c5bb4bd
--- /dev/null
+++ b/servers/audio/effects/audio_effect_compressor.cpp
@@ -0,0 +1,227 @@
+#include "audio_effect_compressor.h"
+#include "servers/audio_server.h"
+
+void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+ float treshold = Math::db2linear(base->treshold);
+ float sample_rate=AudioServer::get_singleton()->get_mix_rate();
+
+ float ratatcoef = exp(-1 / (0.00001f * sample_rate));
+ float ratrelcoef = exp(-1 / (0.5f * sample_rate));
+ float attime = base->attack_us / 1000000.0;
+ float reltime = base->release_ms / 1000.0;
+ float atcoef = exp(-1 / (attime * sample_rate));
+ float relcoef = exp(-1 / (reltime * sample_rate));
+
+ float makeup = Math::db2linear(base->gain);
+
+ float mix = base->mix;
+ float gr_meter_decay = exp(1 / (1 * sample_rate));
+
+ const AudioFrame *src = p_src_frames;
+
+ if (base->sidechain!=StringName() && current_channel!=-1) {
+
+ int bus = AudioServer::get_singleton()->thread_find_bus_index(base->sidechain);
+ if (bus>=0) {
+ src = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus,current_channel);
+ }
+ }
+
+ for(int i=0;i<p_frame_count;i++) {
+
+ AudioFrame s = src[i];
+ //convert to positive
+ s.l = Math::abs(s.l);
+ s.r = Math::abs(s.r);
+
+ float peak = MAX(s.l,s.r);
+
+ float overdb = 2.08136898f * Math::linear2db(peak/treshold);
+
+ if (overdb<0.0) //we only care about what goes over to compress
+ overdb=0.0;
+
+ if(overdb-rundb>5) // diffeence is too large
+ averatio = 4;
+
+ if(overdb > rundb) {
+ rundb = overdb + atcoef * (rundb - overdb);
+ runratio = averatio + ratatcoef * (runratio - averatio);
+ } else {
+ rundb = overdb + relcoef * (rundb - overdb);
+ runratio = averatio + ratrelcoef * (runratio - averatio);
+ }
+
+ overdb = rundb;
+ averatio = runratio;
+
+ float cratio;
+
+ if(false) { //rato all-in
+ cratio = 12 + averatio;
+ } else {
+ cratio = base->ratio;
+ }
+
+ float gr = -overdb * (cratio-1)/cratio;
+ float grv = Math::db2linear(gr);
+
+ runmax = maxover + relcoef * (runmax - maxover); // highest peak for setting att/rel decays in reltime
+ maxover = runmax;
+
+ if (grv < gr_meter) {
+ gr_meter=grv;
+ } else {
+ gr_meter*=gr_meter_decay;
+ if(gr_meter>1)
+ gr_meter=1;
+ }
+
+
+ p_dst_frames[i] = p_src_frames[i] * grv * makeup * mix + p_src_frames[i] * (1.0-mix);
+
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectCompressor::instance() {
+ Ref<AudioEffectCompressorInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectCompressor>(this);
+ ins->rundb=0;
+ ins->runratio=0;
+ ins->averatio=0;
+ ins->runmax=0;
+ ins->maxover=0;
+ ins->gr_meter=1.0;
+ ins->current_channel=-1;
+ return ins;
+}
+
+
+void AudioEffectCompressor::set_treshold(float p_treshold) {
+
+ treshold=p_treshold;
+}
+
+float AudioEffectCompressor::get_treshold() const {
+
+ return treshold;
+}
+
+void AudioEffectCompressor::set_ratio(float p_ratio) {
+
+ ratio=p_ratio;
+}
+float AudioEffectCompressor::get_ratio() const {
+
+ return ratio;
+}
+
+void AudioEffectCompressor::set_gain(float p_gain) {
+
+ gain=p_gain;
+}
+float AudioEffectCompressor::get_gain() const {
+
+ return gain;
+}
+
+void AudioEffectCompressor::set_attack_us(float p_attack_us) {
+
+ attack_us=p_attack_us;
+}
+float AudioEffectCompressor::get_attack_us() const {
+
+ return attack_us;
+}
+
+void AudioEffectCompressor::set_release_ms(float p_release_ms) {
+
+ release_ms=p_release_ms;
+}
+float AudioEffectCompressor::get_release_ms() const {
+
+ return release_ms;
+}
+
+void AudioEffectCompressor::set_mix(float p_mix) {
+
+ mix=p_mix;
+}
+float AudioEffectCompressor::get_mix() const {
+
+ return mix;
+}
+
+void AudioEffectCompressor::set_sidechain(const StringName& p_sidechain) {
+
+ AudioServer::get_singleton()->lock();
+ sidechain=p_sidechain;
+ AudioServer::get_singleton()->unlock();
+}
+
+StringName AudioEffectCompressor::get_sidechain() const {
+
+ return sidechain;
+}
+
+void AudioEffectCompressor::_validate_property(PropertyInfo& property) const {
+
+ if (property.name=="sidechain") {
+
+ String buses="";
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+ buses+=",";
+ buses+=AudioServer::get_singleton()->get_bus_name(i);
+ }
+
+ property.hint_string=buses;
+ }
+}
+
+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_ratio","ratio"),&AudioEffectCompressor::set_ratio);
+ ClassDB::bind_method(D_METHOD("get_ratio"),&AudioEffectCompressor::get_ratio);
+
+ ClassDB::bind_method(D_METHOD("set_gain","gain"),&AudioEffectCompressor::set_gain);
+ ClassDB::bind_method(D_METHOD("get_gain"),&AudioEffectCompressor::get_gain);
+
+ ClassDB::bind_method(D_METHOD("set_attack_us","attack_us"),&AudioEffectCompressor::set_attack_us);
+ ClassDB::bind_method(D_METHOD("get_attack_us"),&AudioEffectCompressor::get_attack_us);
+
+ ClassDB::bind_method(D_METHOD("set_release_ms","release_ms"),&AudioEffectCompressor::set_release_ms);
+ ClassDB::bind_method(D_METHOD("get_release_ms"),&AudioEffectCompressor::get_release_ms);
+
+ ClassDB::bind_method(D_METHOD("set_mix","mix"),&AudioEffectCompressor::set_mix);
+ ClassDB::bind_method(D_METHOD("get_mix"),&AudioEffectCompressor::get_mix);
+
+ 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,"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");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"release_ms",PROPERTY_HINT_RANGE,"20,2000,1"),"set_release_ms","get_release_ms");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"mix",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_mix","get_mix");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"sidechain",PROPERTY_HINT_ENUM),"set_sidechain","get_sidechain");
+
+}
+
+AudioEffectCompressor::AudioEffectCompressor()
+{
+ treshold=0;
+ ratio=4;
+ gain=0;
+ attack_us=20;
+ release_ms=250;
+ mix=1;
+}
diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h
new file mode 100644
index 0000000000..eb06b3db77
--- /dev/null
+++ b/servers/audio/effects/audio_effect_compressor.h
@@ -0,0 +1,70 @@
+#ifndef AUDIOEFFECTCOMPRESSOR_H
+#define AUDIOEFFECTCOMPRESSOR_H
+
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectCompressor;
+
+class AudioEffectCompressorInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectCompressorInstance,AudioEffectInstance)
+friend class AudioEffectCompressor;
+ Ref<AudioEffectCompressor> base;
+
+ float rundb,averatio,runratio,runmax,maxover,gr_meter;
+ int current_channel;
+public:
+
+ void set_current_channel(int p_channel) { current_channel=p_channel; }
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectCompressor : public AudioEffect {
+ GDCLASS(AudioEffectCompressor,AudioEffect)
+
+friend class AudioEffectCompressorInstance;
+ float treshold;
+ float ratio;
+ float gain;
+ float attack_us;
+ float release_ms;
+ float mix;
+ StringName sidechain;
+
+
+protected:
+ void _validate_property(PropertyInfo& property) const;
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+
+
+ void set_treshold(float p_treshold);
+ float get_treshold() const;
+
+ void set_ratio(float p_ratio);
+ float get_ratio() const;
+
+ void set_gain(float p_gain);
+ float get_gain() const;
+
+ void set_attack_us(float p_attack_us);
+ float get_attack_us() const;
+
+ void set_release_ms(float p_release_ms);
+ float get_release_ms() const;
+
+ void set_mix(float p_mix);
+ float get_mix() const;
+
+ void set_sidechain(const StringName& p_sidechain);
+ StringName get_sidechain() const;
+
+ AudioEffectCompressor();
+};
+
+#endif // AUDIOEFFECTCOMPRESSOR_H
diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp
new file mode 100644
index 0000000000..3d3a956b92
--- /dev/null
+++ b/servers/audio/effects/audio_effect_delay.cpp
@@ -0,0 +1,326 @@
+#include "audio_effect_delay.h"
+#include "servers/audio_server.h"
+#include "math_funcs.h"
+
+void AudioEffectDelayInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ int todo = p_frame_count;
+
+ while(todo) {
+
+ int to_mix = MIN(todo,256); //can't mix too much
+
+ _process_chunk(p_src_frames,p_dst_frames,to_mix);
+
+ p_src_frames+=to_mix;
+ p_dst_frames+=to_mix;
+
+ todo-=to_mix;
+ }
+}
+
+void AudioEffectDelayInstance::_process_chunk(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+
+ float main_level_f=base->dry;
+
+
+ float mix_rate = AudioServer::get_singleton()->get_mix_rate();
+
+ float tap_1_level_f=base->tap_1_active?Math::db2linear(base->tap_1_level):0.0;
+ int tap_1_delay_frames=int((base->tap_1_delay_ms/1000.0)*mix_rate);;
+
+ float tap_2_level_f=base->tap_2_active?Math::db2linear(base->tap_2_level):0.0;
+ int tap_2_delay_frames=int((base->tap_2_delay_ms/1000.0)*mix_rate);;
+
+ float feedback_level_f=base->feedback_active?Math::db2linear(base->feedback_level):0.0;
+ unsigned int feedback_delay_frames=int((base->feedback_delay_ms/1000.0)*mix_rate);;
+
+
+ AudioFrame tap1_vol=AudioFrame(tap_1_level_f,tap_1_level_f);
+
+ tap1_vol.l*=CLAMP( 1.0 - base->tap_1_pan, 0, 1);
+ tap1_vol.r*=CLAMP( 1.0 + base->tap_1_pan, 0, 1);
+
+ AudioFrame tap2_vol=AudioFrame(tap_2_level_f,tap_2_level_f);
+
+ tap2_vol.l*=CLAMP( 1.0 - base->tap_2_pan, 0, 1);
+ tap2_vol.r*=CLAMP( 1.0 + base->tap_2_pan, 0, 1);
+
+ // feedback lowpass here
+ float lpf_c=expf(-2.0*Math_PI*base->feedback_lowpass/mix_rate); // 0 .. 10khz
+ float lpf_ic=1.0-lpf_c;
+
+ const AudioFrame *src=p_src_frames;
+ AudioFrame *dst=p_dst_frames;
+ AudioFrame *rb_buf=ring_buffer.ptr();
+ AudioFrame *fb_buf=feedback_buffer.ptr();
+
+
+ for (int i=0;i<p_frame_count;i++) {
+
+
+ rb_buf[ring_buffer_pos&ring_buffer_mask]=src[i];
+
+ AudioFrame main_val=src[i]*main_level_f;
+ AudioFrame tap_1_val=rb_buf[(ring_buffer_pos-tap_1_delay_frames)&ring_buffer_mask]*tap1_vol;
+ AudioFrame tap_2_val=rb_buf[(ring_buffer_pos-tap_2_delay_frames)&ring_buffer_mask]*tap2_vol;
+
+ AudioFrame out=main_val+tap_1_val+tap_2_val;
+
+ out+=fb_buf[ feedback_buffer_pos ];
+
+ //apply lowpass and feedback gain
+ AudioFrame fb_in=out*feedback_level_f*lpf_ic+h*lpf_c;
+ fb_in.undenormalise(); //avoid denormals
+
+ h=fb_in;
+ fb_buf[ feedback_buffer_pos ]=fb_in;
+
+ dst[i]=out;
+
+ ring_buffer_pos++;
+
+ if ( (++feedback_buffer_pos) >= feedback_delay_frames )
+ feedback_buffer_pos=0;
+ }
+}
+
+
+
+Ref<AudioEffectInstance> AudioEffectDelay::instance() {
+ Ref<AudioEffectDelayInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectDelay>(this);
+
+ float ring_buffer_max_size=MAX_DELAY_MS+100; //add 100ms of extra room, just in case
+ ring_buffer_max_size/=1000.0;//convert to seconds
+ ring_buffer_max_size*=AudioServer::get_singleton()->get_mix_rate();
+
+ int ringbuff_size=ring_buffer_max_size;
+
+ int bits=0;
+
+ while(ringbuff_size>0) {
+ bits++;
+ ringbuff_size/=2;
+ }
+
+ ringbuff_size=1<<bits;
+ ins->ring_buffer_mask=ringbuff_size-1;
+ ins->ring_buffer_pos=0;
+
+ ins->ring_buffer.resize( ringbuff_size );
+ ins->feedback_buffer.resize( ringbuff_size );
+
+ ins->feedback_buffer_pos=0;
+
+ ins->h=AudioFrame(0,0);
+
+ return ins;
+}
+
+
+void AudioEffectDelay::set_dry(float p_dry) {
+
+ dry=p_dry;
+}
+
+float AudioEffectDelay::get_dry(){
+
+ return dry;
+}
+
+void AudioEffectDelay::set_tap1_active(bool p_active){
+
+ tap_1_active=p_active;
+}
+bool AudioEffectDelay::is_tap1_active() const{
+
+ return tap_1_active;
+}
+
+void AudioEffectDelay::set_tap1_delay_ms(float p_delay_ms){
+
+ tap_1_delay_ms=p_delay_ms;
+}
+float AudioEffectDelay::get_tap1_delay_ms() const{
+
+ return tap_1_delay_ms;
+}
+
+void AudioEffectDelay::set_tap1_level_db(float p_level_db){
+
+ tap_1_level=p_level_db;
+}
+float AudioEffectDelay::get_tap1_level_db() const{
+
+ return tap_1_level;
+}
+
+void AudioEffectDelay::set_tap1_pan(float p_pan){
+
+ tap_1_pan=p_pan;
+}
+float AudioEffectDelay::get_tap1_pan() const{
+
+ return tap_1_pan;
+}
+
+
+void AudioEffectDelay::set_tap2_active(bool p_active){
+
+ tap_2_active=p_active;
+}
+bool AudioEffectDelay::is_tap2_active() const{
+
+ return tap_2_active;
+}
+
+void AudioEffectDelay::set_tap2_delay_ms(float p_delay_ms){
+
+ tap_2_delay_ms=p_delay_ms;
+}
+float AudioEffectDelay::get_tap2_delay_ms() const{
+
+ return tap_2_delay_ms;
+}
+
+void AudioEffectDelay::set_tap2_level_db(float p_level_db){
+
+ tap_2_level=p_level_db;
+}
+float AudioEffectDelay::get_tap2_level_db() const{
+
+ return tap_2_level;
+}
+
+void AudioEffectDelay::set_tap2_pan(float p_pan){
+
+ tap_2_pan=p_pan;
+}
+float AudioEffectDelay::get_tap2_pan() const{
+
+ return tap_2_pan;
+}
+
+void AudioEffectDelay::set_feedback_active(bool p_active){
+
+ feedback_active=p_active;
+}
+bool AudioEffectDelay::is_feedback_active() const{
+
+ return feedback_active;
+}
+
+void AudioEffectDelay::set_feedback_delay_ms(float p_delay_ms){
+
+ feedback_delay_ms=p_delay_ms;
+}
+float AudioEffectDelay::get_feedback_delay_ms() const{
+
+ return feedback_delay_ms;
+}
+
+void AudioEffectDelay::set_feedback_level_db(float p_level_db){
+
+ feedback_level=p_level_db;
+}
+float AudioEffectDelay::get_feedback_level_db() const{
+
+ return feedback_level;
+}
+
+void AudioEffectDelay::set_feedback_lowpass(float p_lowpass){
+
+ feedback_lowpass=p_lowpass;
+}
+float AudioEffectDelay::get_feedback_lowpass() const{
+
+ return feedback_lowpass;
+}
+
+
+void AudioEffectDelay::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_dry","amount"),&AudioEffectDelay::set_dry);
+ ClassDB::bind_method(D_METHOD("get_dry"),&AudioEffectDelay::get_dry);
+
+ ClassDB::bind_method(D_METHOD("set_tap1_active","amount"),&AudioEffectDelay::set_tap1_active);
+ ClassDB::bind_method(D_METHOD("is_tap1_active"),&AudioEffectDelay::is_tap1_active);
+
+ ClassDB::bind_method(D_METHOD("set_tap1_delay_ms","amount"),&AudioEffectDelay::set_tap1_delay_ms);
+ ClassDB::bind_method(D_METHOD("get_tap1_delay_ms"),&AudioEffectDelay::get_tap1_delay_ms);
+
+ ClassDB::bind_method(D_METHOD("set_tap1_level_db","amount"),&AudioEffectDelay::set_tap1_level_db);
+ ClassDB::bind_method(D_METHOD("get_tap1_level_db"),&AudioEffectDelay::get_tap1_level_db);
+
+ ClassDB::bind_method(D_METHOD("set_tap1_pan","amount"),&AudioEffectDelay::set_tap1_pan);
+ ClassDB::bind_method(D_METHOD("get_tap1_pan"),&AudioEffectDelay::get_tap1_pan);
+
+ ClassDB::bind_method(D_METHOD("set_tap2_active","amount"),&AudioEffectDelay::set_tap2_active);
+ ClassDB::bind_method(D_METHOD("is_tap2_active"),&AudioEffectDelay::is_tap2_active);
+
+ ClassDB::bind_method(D_METHOD("set_tap2_delay_ms","amount"),&AudioEffectDelay::set_tap2_delay_ms);
+ ClassDB::bind_method(D_METHOD("get_tap2_delay_ms"),&AudioEffectDelay::get_tap2_delay_ms);
+
+ ClassDB::bind_method(D_METHOD("set_tap2_level_db","amount"),&AudioEffectDelay::set_tap2_level_db);
+ ClassDB::bind_method(D_METHOD("get_tap2_level_db"),&AudioEffectDelay::get_tap2_level_db);
+
+ ClassDB::bind_method(D_METHOD("set_tap2_pan","amount"),&AudioEffectDelay::set_tap2_pan);
+ ClassDB::bind_method(D_METHOD("get_tap2_pan"),&AudioEffectDelay::get_tap2_pan);
+
+
+ ClassDB::bind_method(D_METHOD("set_feedback_active","amount"),&AudioEffectDelay::set_feedback_active);
+ ClassDB::bind_method(D_METHOD("is_feedback_active"),&AudioEffectDelay::is_feedback_active);
+
+ ClassDB::bind_method(D_METHOD("set_feedback_delay_ms","amount"),&AudioEffectDelay::set_feedback_delay_ms);
+ ClassDB::bind_method(D_METHOD("get_feedback_delay_ms"),&AudioEffectDelay::get_feedback_delay_ms);
+
+ ClassDB::bind_method(D_METHOD("set_feedback_level_db","amount"),&AudioEffectDelay::set_feedback_level_db);
+ ClassDB::bind_method(D_METHOD("get_feedback_level_db"),&AudioEffectDelay::get_feedback_level_db);
+
+ ClassDB::bind_method(D_METHOD("set_feedback_lowpass","amount"),&AudioEffectDelay::set_feedback_lowpass);
+ ClassDB::bind_method(D_METHOD("get_feedback_lowpass"),&AudioEffectDelay::get_feedback_lowpass);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dry",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_dry","get_dry");
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"tap1/active"),"set_tap1_active","is_tap1_active");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap1/delay_ms",PROPERTY_HINT_RANGE,"0,1500,1"),"set_tap1_delay_ms","get_tap1_delay_ms");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap1/level_db",PROPERTY_HINT_RANGE,"-60,0,0.01"),"set_tap1_level_db","get_tap1_level_db");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap1/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_tap1_pan","get_tap1_pan");
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"tap2/active"),"set_tap2_active","is_tap2_active");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap2/delay_ms",PROPERTY_HINT_RANGE,"0,1500,1"),"set_tap2_delay_ms","get_tap2_delay_ms");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap2/level_db",PROPERTY_HINT_RANGE,"-60,0,0.01"),"set_tap2_level_db","get_tap2_level_db");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tap2/pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_tap2_pan","get_tap2_pan");
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"feedback/active"),"set_feedback_active","is_feedback_active");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"feedback/delay_ms",PROPERTY_HINT_RANGE,"0,1500,1"),"set_feedback_delay_ms","get_feedback_delay_ms");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"feedback/level_db",PROPERTY_HINT_RANGE,"-60,0,0.01"),"set_feedback_level_db","get_feedback_level_db");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"feedback/lowpass",PROPERTY_HINT_RANGE,"1,16000,1"),"set_feedback_lowpass","get_feedback_lowpass");
+
+
+}
+
+AudioEffectDelay::AudioEffectDelay()
+{
+ tap_1_active=true;
+ tap_1_delay_ms=250;
+ tap_1_level=-6;
+ tap_1_pan=0.2;
+
+ tap_2_active=true;
+ tap_2_delay_ms=500;
+ tap_2_level=-12;
+ tap_2_pan=-0.4;
+
+ feedback_active=false;
+ feedback_delay_ms=340;
+ feedback_level=-6;
+ feedback_lowpass=16000;
+
+ dry=1.0;
+
+}
diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h
new file mode 100644
index 0000000000..645561138b
--- /dev/null
+++ b/servers/audio/effects/audio_effect_delay.h
@@ -0,0 +1,112 @@
+#ifndef AUDIOEFFECTECHO_H
+#define AUDIOEFFECTECHO_H
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectDelay;
+
+class AudioEffectDelayInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectDelayInstance,AudioEffectInstance)
+friend class AudioEffectDelay;
+ Ref<AudioEffectDelay> base;
+
+ Vector<AudioFrame> ring_buffer;
+
+ unsigned int ring_buffer_pos;
+ unsigned int ring_buffer_mask;
+
+ /* feedback buffer */
+ Vector<AudioFrame> feedback_buffer;
+
+ unsigned int feedback_buffer_pos;
+
+ AudioFrame h;
+ void _process_chunk(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectDelay : public AudioEffect {
+ GDCLASS(AudioEffectDelay,AudioEffect)
+
+friend class AudioEffectDelayInstance;
+ enum {
+
+ MAX_DELAY_MS=3000,
+ MAX_TAPS=2
+ };
+
+ float dry;
+
+ bool tap_1_active;
+ float tap_1_delay_ms;
+ float tap_1_level;
+ float tap_1_pan;
+
+ bool tap_2_active;
+ float tap_2_delay_ms;
+ float tap_2_level;
+ float tap_2_pan;
+
+ bool feedback_active;
+ float feedback_delay_ms;
+ float feedback_level;
+ float feedback_lowpass;
+
+
+
+protected:
+
+ static void _bind_methods();
+public:
+
+ void set_dry(float p_dry);
+ float get_dry();
+
+ void set_tap1_active(bool p_active);
+ bool is_tap1_active() const;
+
+ void set_tap1_delay_ms(float p_delay_ms);
+ float get_tap1_delay_ms() const;
+
+ void set_tap1_level_db(float p_level_db);
+ float get_tap1_level_db() const;
+
+ void set_tap1_pan(float p_pan);
+ float get_tap1_pan() const;
+
+ void set_tap2_active(bool p_active);
+ bool is_tap2_active() const;
+
+ void set_tap2_delay_ms(float p_delay_ms);
+ float get_tap2_delay_ms() const;
+
+ void set_tap2_level_db(float p_level_db);
+ float get_tap2_level_db() const;
+
+ void set_tap2_pan(float p_pan);
+ float get_tap2_pan() const;
+
+ void set_feedback_active(bool p_active);
+ bool is_feedback_active() const;
+
+ void set_feedback_delay_ms(float p_delay_ms);
+ float get_feedback_delay_ms() const;
+
+ void set_feedback_level_db(float p_level_db);
+ float get_feedback_level_db() const;
+
+ void set_feedback_lowpass(float p_lowpass);
+ float get_feedback_lowpass() const;
+
+ Ref<AudioEffectInstance> instance();
+
+ AudioEffectDelay();
+};
+
+
+#endif // AUDIOEFFECTECHO_H
diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp
new file mode 100644
index 0000000000..d0f526fe24
--- /dev/null
+++ b/servers/audio/effects/audio_effect_distortion.cpp
@@ -0,0 +1,171 @@
+#include "audio_effect_distortion.h"
+#include "servers/audio_server.h"
+#include "math_funcs.h"
+
+
+
+void AudioEffectDistortionInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ const float *src = (const float*)p_src_frames;
+ float *dst = (float*)p_dst_frames;
+
+ //float lpf_c=expf(-2.0*Math_PI*keep_hf_hz.get()/(mix_rate*(float)OVERSAMPLE));
+ float lpf_c=expf(-2.0*Math_PI*base->keep_hf_hz/(AudioServer::get_singleton()->get_mix_rate()));
+ float lpf_ic=1.0-lpf_c;
+
+ float drive_f=base->drive;
+ float pregain_f=Math::db2linear(base->pre_gain);
+ float postgain_f=Math::db2linear(base->post_gain);
+
+ float atan_mult=pow(10,drive_f*drive_f*3.0)-1.0+0.001;
+ float atan_div=1.0/(atanf(atan_mult)*(1.0+drive_f*8));
+
+ float lofi_mult=powf(2.0,2.0+(1.0-drive_f)*14); //goes from 16 to 2 bits
+
+ for (int i=0;i<p_frame_count*2;i++) {
+
+ float out=undenormalise(src[i]*lpf_ic+lpf_c*h[i&1]);
+ h[i&1]=out;
+ float a=out;
+ float ha=src[i]-out; //high freqs
+ a*=pregain_f;
+
+ switch (base->mode) {
+
+ case AudioEffectDistortion::MODE_CLIP: {
+
+ a=powf(a,1.0001-drive_f);
+ if (a>1.0)
+ a=1.0;
+ else if (a<(-1.0))
+ a=-1.0;
+
+ } break;
+ case AudioEffectDistortion::MODE_ATAN: {
+
+
+ a=atanf(a*atan_mult)*atan_div;
+
+ } break;
+ case AudioEffectDistortion::MODE_LOFI: {
+
+ a = floorf(a*lofi_mult+0.5)/lofi_mult;
+
+ } break;
+ case AudioEffectDistortion::MODE_OVERDRIVE: {
+
+
+ const double x = a * 0.686306;
+ const double z = 1 + exp (sqrt (fabs (x)) * -0.75);
+ a = (expf(x) - expf(-x * z)) / (expf(x) + expf(-x));
+ } break;
+ case AudioEffectDistortion::MODE_WAVESHAPE: {
+ float x = a;
+ float k= 2*drive_f/(1.00001-drive_f);
+
+ a = (1.0+k)*x/(1.0+k*fabsf(x));
+
+
+ } break;
+ }
+
+ dst[i]=a*postgain_f+ha;
+
+ }
+
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectDistortion::instance() {
+ Ref<AudioEffectDistortionInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectDistortion>(this);
+ ins->h[0]=0;
+ ins->h[1]=0;
+
+ return ins;
+}
+
+
+void AudioEffectDistortion::set_mode(Mode p_mode) {
+
+ mode=p_mode;
+}
+
+AudioEffectDistortion::Mode AudioEffectDistortion::get_mode() const{
+
+ return mode;
+}
+
+void AudioEffectDistortion::set_pre_gain(float p_pre_gain){
+
+ pre_gain=p_pre_gain;
+}
+float AudioEffectDistortion::get_pre_gain() const{
+
+ return pre_gain;
+}
+
+void AudioEffectDistortion::set_keep_hf_hz(float p_keep_hf_hz){
+
+ keep_hf_hz=p_keep_hf_hz;
+}
+float AudioEffectDistortion::get_keep_hf_hz() const{
+
+ return keep_hf_hz;
+}
+
+void AudioEffectDistortion::set_drive(float p_drive){
+
+ drive=p_drive;
+}
+float AudioEffectDistortion::get_drive() const{
+
+ return drive;
+}
+
+void AudioEffectDistortion::set_post_gain(float p_post_gain){
+
+ post_gain=p_post_gain;
+}
+float AudioEffectDistortion::get_post_gain() const{
+
+ return post_gain;
+}
+
+
+void AudioEffectDistortion::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&AudioEffectDistortion::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&AudioEffectDistortion::get_mode);
+
+ ClassDB::bind_method(D_METHOD("set_pre_gain","pre_gain"),&AudioEffectDistortion::set_pre_gain);
+ ClassDB::bind_method(D_METHOD("get_pre_gain"),&AudioEffectDistortion::get_pre_gain);
+
+ ClassDB::bind_method(D_METHOD("set_keep_hf_hz","keep_hf_hz"),&AudioEffectDistortion::set_keep_hf_hz);
+ ClassDB::bind_method(D_METHOD("get_keep_hf_hz"),&AudioEffectDistortion::get_keep_hf_hz);
+
+ ClassDB::bind_method(D_METHOD("set_drive","drive"),&AudioEffectDistortion::set_drive);
+ ClassDB::bind_method(D_METHOD("get_drive"),&AudioEffectDistortion::get_drive);
+
+
+ ClassDB::bind_method(D_METHOD("set_post_gain","post_gain"),&AudioEffectDistortion::set_post_gain);
+ ClassDB::bind_method(D_METHOD("get_post_gain"),&AudioEffectDistortion::get_post_gain);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Clip,ATan,LoFi,Overdrive,WaveShape"),"set_mode","get_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"pre_gain",PROPERTY_HINT_RANGE,"-60,60,0.01"),"set_pre_gain","get_pre_gain");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"keep_hf_hz",PROPERTY_HINT_RANGE,"1,20000,1"),"set_keep_hf_hz","get_keep_hf_hz");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"drive",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_drive","get_drive");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"post_gain",PROPERTY_HINT_RANGE,"-80,24,0.01"),"set_post_gain","get_post_gain");
+}
+
+AudioEffectDistortion::AudioEffectDistortion()
+{
+ mode=MODE_CLIP;
+ pre_gain=0;
+ post_gain=0;
+ keep_hf_hz=16000;
+ drive=0;
+}
+
diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h
new file mode 100644
index 0000000000..1d2433faeb
--- /dev/null
+++ b/servers/audio/effects/audio_effect_distortion.h
@@ -0,0 +1,69 @@
+#ifndef AUDIOEFFECTDISTORTION_H
+#define AUDIOEFFECTDISTORTION_H
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectDistortion;
+
+class AudioEffectDistortionInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectDistortionInstance,AudioEffectInstance)
+friend class AudioEffectDistortion;
+ Ref<AudioEffectDistortion> base;
+ float h[2];
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectDistortion : public AudioEffect {
+ GDCLASS(AudioEffectDistortion,AudioEffect)
+public:
+ enum Mode {
+ MODE_CLIP,
+ MODE_ATAN,
+ MODE_LOFI,
+ MODE_OVERDRIVE,
+ MODE_WAVESHAPE,
+ };
+
+friend class AudioEffectDistortionInstance;
+ Mode mode;
+ float pre_gain;
+ float post_gain;
+ float keep_hf_hz;
+ float drive;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+
+
+ void set_mode(Mode p_mode);
+ Mode get_mode() const;
+
+ void set_pre_gain(float pre_gain);
+ float get_pre_gain() const;
+
+ void set_keep_hf_hz(float keep_hf_hz);
+ float get_keep_hf_hz() const;
+
+ void set_drive(float drive);
+ float get_drive() const;
+
+ void set_post_gain(float post_gain);
+ float get_post_gain() const;
+
+
+
+ AudioEffectDistortion();
+};
+
+VARIANT_ENUM_CAST( AudioEffectDistortion::Mode )
+
+#endif // AUDIOEFFECTDISTORTION_H
diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp
new file mode 100644
index 0000000000..5f42f2826f
--- /dev/null
+++ b/servers/audio/effects/audio_effect_eq.cpp
@@ -0,0 +1,122 @@
+#include "audio_effect_eq.h"
+#include "servers/audio_server.h"
+
+
+void AudioEffectEQInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ int band_count = bands[0].size();
+ EQ::BandProcess *proc_l = bands[0].ptr();
+ EQ::BandProcess *proc_r = bands[1].ptr();
+ float *bgain = gains.ptr();
+ for(int i=0;i<band_count;i++) {
+ bgain[i]=Math::db2linear(base->gain[i]);
+ }
+
+
+ for(int i=0;i<p_frame_count;i++) {
+
+ AudioFrame src = p_src_frames[i];
+ AudioFrame dst = AudioFrame(0,0);
+
+ for(int j=0;j<band_count;j++) {
+
+ float l = src.l;
+ float r = src.r;
+
+ proc_l[j].process_one(l);
+ proc_r[j].process_one(r);
+
+ dst.l+=l * bgain[j];
+ dst.r+=r * bgain[j];
+ }
+
+ p_dst_frames[i]=dst;
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectEQ::instance() {
+ Ref<AudioEffectEQInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectEQ>(this);
+ ins->gains.resize(eq.get_band_count());
+ for(int i=0;i<2;i++) {
+ ins->bands[i].resize(eq.get_band_count());
+ for(int j=0;j<ins->bands[i].size();j++) {
+ ins->bands[i][j]=eq.get_band_processor(j);
+ }
+ }
+
+ return ins;
+}
+
+void AudioEffectEQ::set_band_gain_db(int p_band,float p_volume) {
+ ERR_FAIL_INDEX(p_band,gain.size());
+ gain[p_band]=p_volume;
+}
+
+float AudioEffectEQ::get_band_gain_db(int p_band) const {
+ ERR_FAIL_INDEX_V(p_band,gain.size(),0);
+
+ return gain[p_band];
+}
+int AudioEffectEQ::get_band_count() const {
+ return gain.size();
+}
+
+bool AudioEffectEQ::_set(const StringName& p_name, const Variant& p_value) {
+
+ const Map<StringName,int>::Element *E=prop_band_map.find(p_name);
+ if (E) {
+ set_band_gain_db(E->get(),p_value);
+ return true;
+ }
+
+ return false;
+}
+
+bool AudioEffectEQ::_get(const StringName& p_name,Variant &r_ret) const{
+
+ const Map<StringName,int>::Element *E=prop_band_map.find(p_name);
+ if (E) {
+ r_ret=get_band_gain_db(E->get());
+ return true;
+ }
+
+ return false;
+
+}
+
+void AudioEffectEQ::_get_property_list( List<PropertyInfo> *p_list) const{
+
+ for(int i=0;i<band_names.size();i++) {
+
+ p_list->push_back(PropertyInfo(Variant::REAL,band_names[i],PROPERTY_HINT_RANGE,"-60,24,0.1"));
+ }
+}
+
+
+
+void AudioEffectEQ::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_band_gain_db","band_idx","volume_db"),&AudioEffectEQ::set_band_gain_db);
+ ClassDB::bind_method(D_METHOD("get_band_gain_db","band_idx"),&AudioEffectEQ::get_band_gain_db);
+ ClassDB::bind_method(D_METHOD("get_band_count"),&AudioEffectEQ::get_band_count);
+
+}
+
+AudioEffectEQ::AudioEffectEQ(EQ::Preset p_preset)
+{
+
+
+ eq.set_mix_rate(AudioServer::get_singleton()->get_mix_rate());
+ eq.set_preset_band_mode(p_preset);
+ gain.resize(eq.get_band_count());
+ for(int i=0;i<gain.size();i++) {
+ gain[i]=0.0;
+ String name = "band_db/"+itos(eq.get_band_frequency(i))+"_hz";
+ prop_band_map[name]=i;
+ band_names.push_back(name);
+ }
+}
diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h
new file mode 100644
index 0000000000..3fcc2c0056
--- /dev/null
+++ b/servers/audio/effects/audio_effect_eq.h
@@ -0,0 +1,72 @@
+#ifndef AUDIOEFFECTEQ_H
+#define AUDIOEFFECTEQ_H
+
+
+#include "servers/audio/audio_effect.h"
+#include "servers/audio/effects/eq.h"
+
+class AudioEffectEQ;
+
+class AudioEffectEQInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectEQInstance,AudioEffectInstance)
+friend class AudioEffectEQ;
+ Ref<AudioEffectEQ> base;
+
+ Vector<EQ::BandProcess> bands[2];
+ Vector<float> gains;
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectEQ : public AudioEffect {
+ GDCLASS(AudioEffectEQ,AudioEffect)
+
+friend class AudioEffectEQInstance;
+
+ EQ eq;
+ Vector<float> gain;
+ Map<StringName,int> prop_band_map;
+ Vector<String> band_names;
+
+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;
+
+
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+ void set_band_gain_db(int p_band,float p_volume);
+ float get_band_gain_db(int p_band) const;
+ int get_band_count() const;
+
+ AudioEffectEQ(EQ::Preset p_preset=EQ::PRESET_6_BANDS);
+};
+
+
+class AudioEffectEQ6 : public AudioEffectEQ {
+ GDCLASS(AudioEffectEQ6,AudioEffectEQ)
+public:
+ AudioEffectEQ6() : AudioEffectEQ(EQ::PRESET_6_BANDS) {}
+};
+
+class AudioEffectEQ10 : public AudioEffectEQ {
+ GDCLASS(AudioEffectEQ10,AudioEffectEQ)
+public:
+ AudioEffectEQ10() : AudioEffectEQ(EQ::PRESET_10_BANDS) {}
+};
+
+class AudioEffectEQ21 : public AudioEffectEQ {
+ GDCLASS(AudioEffectEQ21,AudioEffectEQ)
+public:
+ AudioEffectEQ21() : AudioEffectEQ(EQ::PRESET_21_BANDS) {}
+};
+
+#endif // AUDIOEFFECTEQ_H
diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp
new file mode 100644
index 0000000000..e7af7ca9c0
--- /dev/null
+++ b/servers/audio/effects/audio_effect_filter.cpp
@@ -0,0 +1,151 @@
+#include "audio_effect_filter.h"
+#include "servers/audio_server.h"
+
+template<int S>
+void AudioEffectFilterInstance::_process_filter(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ for(int i=0;i<p_frame_count;i++) {
+ float f = p_src_frames[i].l;
+ filter_process[0][0].process_one(f);
+ if (S>1)
+ filter_process[0][1].process_one(f);
+ if (S>2)
+ filter_process[0][2].process_one(f);
+ if (S>3)
+ filter_process[0][3].process_one(f);
+
+ p_dst_frames[i].l=f;
+ }
+
+ for(int i=0;i<p_frame_count;i++) {
+ float f = p_src_frames[i].r;
+ filter_process[1][0].process_one(f);
+ if (S>1)
+ filter_process[1][1].process_one(f);
+ if (S>2)
+ filter_process[1][2].process_one(f);
+ if (S>3)
+ filter_process[1][3].process_one(f);
+
+ p_dst_frames[i].r=f;
+ }
+
+}
+
+void AudioEffectFilterInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ filter.set_cutoff(base->cutoff);
+ filter.set_gain(base->gain);
+ filter.set_resonance(base->resonance);
+ filter.set_mode(base->mode);
+ int stages = int(base->db)+1;
+ filter.set_stages(stages);
+ filter.set_sampling_rate(AudioServer::get_singleton()->get_mix_rate());
+
+ for(int i=0;i<2;i++) {
+ for(int j=0;j<4;j++) {
+ filter_process[i][j].update_coeffs();
+ }
+ }
+
+
+ if (stages==1) {
+ _process_filter<1>(p_src_frames,p_dst_frames,p_frame_count);
+ } else if (stages==2) {
+ _process_filter<2>(p_src_frames,p_dst_frames,p_frame_count);
+ } else if (stages==3) {
+ _process_filter<3>(p_src_frames,p_dst_frames,p_frame_count);
+ } else if (stages==4) {
+ _process_filter<4>(p_src_frames,p_dst_frames,p_frame_count);
+ }
+
+}
+
+
+AudioEffectFilterInstance::AudioEffectFilterInstance() {
+
+ for(int i=0;i<2;i++) {
+ for(int j=0;j<4;j++) {
+ filter_process[i][j].set_filter(&filter);
+ }
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectFilter::instance() {
+ Ref<AudioEffectFilterInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectFilter>(this);
+
+ return ins;
+}
+
+void AudioEffectFilter::set_cutoff(float p_freq) {
+
+ cutoff=p_freq;
+}
+
+float AudioEffectFilter::get_cutoff() const{
+
+ return cutoff;
+}
+
+void AudioEffectFilter::set_resonance(float p_amount){
+
+ resonance=p_amount;
+}
+float AudioEffectFilter::get_resonance() const{
+
+ return resonance;
+}
+
+void AudioEffectFilter::set_gain(float p_amount){
+
+ gain=p_amount;
+}
+float AudioEffectFilter::get_gain() const {
+
+ return gain;
+}
+
+
+
+void AudioEffectFilter::set_db(FilterDB p_db) {
+ db=p_db;
+}
+
+AudioEffectFilter::FilterDB AudioEffectFilter::get_db() const {
+
+ return db;
+}
+
+void AudioEffectFilter::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_cutoff","freq"),&AudioEffectFilter::set_cutoff);
+ ClassDB::bind_method(D_METHOD("get_cutoff"),&AudioEffectFilter::get_cutoff);
+
+ ClassDB::bind_method(D_METHOD("set_resonance","amount"),&AudioEffectFilter::set_resonance);
+ ClassDB::bind_method(D_METHOD("get_resonance"),&AudioEffectFilter::get_resonance);
+
+ ClassDB::bind_method(D_METHOD("set_gain","amount"),&AudioEffectFilter::set_gain);
+ ClassDB::bind_method(D_METHOD("get_gain"),&AudioEffectFilter::get_gain);
+
+ ClassDB::bind_method(D_METHOD("set_db","amount"),&AudioEffectFilter::set_db);
+ ClassDB::bind_method(D_METHOD("get_db"),&AudioEffectFilter::get_db);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"cutoff_hz",PROPERTY_HINT_RANGE,"1,40000,0.1"),"set_cutoff","get_cutoff");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"resonance",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_resonance","get_resonance");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"gain",PROPERTY_HINT_RANGE,"0,4,0.01"),"set_gain","get_gain");
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dB",PROPERTY_HINT_ENUM,"6db,12db,18db,24db"),"set_db","get_db");
+}
+
+AudioEffectFilter::AudioEffectFilter(AudioFilterSW::Mode p_mode)
+{
+
+ mode=p_mode;
+ cutoff=2000;
+ resonance=0.5;
+ gain=1.0;
+ db=FILTER_6DB;
+}
diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h
new file mode 100644
index 0000000000..d0bc7a446a
--- /dev/null
+++ b/servers/audio/effects/audio_effect_filter.h
@@ -0,0 +1,125 @@
+#ifndef AUDIOEFFECTFILTER_H
+#define AUDIOEFFECTFILTER_H
+
+#include "servers/audio/audio_effect.h"
+#include "servers/audio/audio_filter_sw.h"
+
+class AudioEffectFilter;
+
+class AudioEffectFilterInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectFilterInstance,AudioEffectInstance)
+friend class AudioEffectFilter;
+
+ Ref<AudioEffectFilter> base;
+
+ AudioFilterSW filter;
+ AudioFilterSW::Processor filter_process[2][4];
+
+ template<int S>
+ void _process_filter(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+ AudioEffectFilterInstance();
+};
+
+
+class AudioEffectFilter : public AudioEffect {
+ GDCLASS(AudioEffectFilter,AudioEffect)
+public:
+
+ enum FilterDB {
+ FILTER_6DB,
+ FILTER_12DB,
+ FILTER_18DB,
+ FILTER_24DB,
+ };
+ friend class AudioEffectFilterInstance;
+
+ AudioFilterSW::Mode mode;
+ float cutoff;
+ float resonance;
+ float gain;
+ FilterDB db;
+
+
+protected:
+
+
+ static void _bind_methods();
+public:
+
+ void set_cutoff(float p_freq);
+ float get_cutoff() const;
+
+ void set_resonance(float p_amount);
+ float get_resonance() const;
+
+ void set_gain(float p_amount);
+ float get_gain() const;
+
+ void set_db(FilterDB p_db);
+ FilterDB get_db() const;
+
+ Ref<AudioEffectInstance> instance();
+
+ AudioEffectFilter(AudioFilterSW::Mode p_mode=AudioFilterSW::LOWPASS);
+};
+
+VARIANT_ENUM_CAST(AudioEffectFilter::FilterDB)
+
+class AudioEffectLowPassFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectLowPassFilter,AudioEffectFilter)
+public:
+
+ AudioEffectLowPassFilter() : AudioEffectFilter(AudioFilterSW::LOWPASS) {}
+};
+
+class AudioEffectHighPassFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectHighPassFilter,AudioEffectFilter)
+public:
+
+ AudioEffectHighPassFilter() : AudioEffectFilter(AudioFilterSW::HIGHPASS) {}
+};
+
+class AudioEffectBandPassFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectBandPassFilter,AudioEffectFilter)
+public:
+
+ AudioEffectBandPassFilter() : AudioEffectFilter(AudioFilterSW::BANDPASS) {}
+};
+
+class AudioEffectNotchFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectNotchFilter,AudioEffectFilter)
+public:
+
+ AudioEffectNotchFilter() : AudioEffectFilter(AudioFilterSW::NOTCH) {}
+};
+
+class AudioEffectBandLimitFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectBandLimitFilter,AudioEffectFilter)
+public:
+
+ AudioEffectBandLimitFilter() : AudioEffectFilter(AudioFilterSW::BANDLIMIT) {}
+};
+
+
+class AudioEffectLowShelfFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectLowShelfFilter,AudioEffectFilter)
+public:
+
+ AudioEffectLowShelfFilter() : AudioEffectFilter(AudioFilterSW::LOWSHELF) {}
+};
+
+
+class AudioEffectHighShelfFilter : public AudioEffectFilter {
+ GDCLASS(AudioEffectHighShelfFilter,AudioEffectFilter)
+public:
+
+ AudioEffectHighShelfFilter() : AudioEffectFilter(AudioFilterSW::HIGHSHELF) {}
+};
+
+
+
+#endif // AUDIOEFFECTFILTER_H
diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp
new file mode 100644
index 0000000000..bce1e0a0df
--- /dev/null
+++ b/servers/audio/effects/audio_effect_limiter.cpp
@@ -0,0 +1,124 @@
+#include "audio_effect_limiter.h"
+
+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 ceiling = Math::db2linear(base->ceiling);
+ float ceildb = base->ceiling;
+ float makeup = Math::db2linear(ceildb - threshdb);
+ float makeupdb = ceildb - threshdb;
+ float sc = -base->soft_clip;
+ float scv = Math::db2linear(sc);
+ float sccomp = Math::db2linear(-sc);
+ float peakdb = ceildb + 25;
+ float peaklvl = Math::db2linear(peakdb);
+ float scratio = base->soft_clip_ratio;
+ float scmult = Math::abs((ceildb - sc) / (peakdb - sc));
+
+ for(int i=0;i<p_frame_count;i++) {
+
+ float spl0 = p_src_frames[i].l;
+ float spl1 = p_src_frames[i].r;
+ spl0 = spl0 * makeup;
+ spl1 = spl1 * makeup;
+ float sign0 = (spl0 < 0.0 ? -1.0 : 1.0 );
+ float sign1 = (spl1 < 0.0 ? -1.0 : 1.0 );
+ float abs0 = Math::abs(spl0);
+ float abs1 = Math::abs(spl1);
+ float overdb0 = Math::linear2db(abs0) - ceildb;
+ float overdb1 = Math::linear2db(abs1) - ceildb;
+
+ if (abs0 > scv)
+ {
+ spl0 = sign0 * (scv + Math::db2linear(overdb0 * scmult));
+ }
+ if (abs1 > scv)
+ {
+ spl1 = sign1 * (scv + Math::db2linear(overdb1 * scmult));
+ }
+
+ spl0 = MIN(ceiling, Math::abs(spl0)) * (spl0 < 0.0 ? -1.0 : 1.0);
+ spl1 = MIN(ceiling, Math::abs(spl1)) * (spl1 < 0.0 ? -1.0 : 1.0);
+
+ p_dst_frames[i].l = spl0;
+ p_dst_frames[i].r = spl1;
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectLimiter::instance() {
+ Ref<AudioEffectLimiterInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectLimiter>(this);
+
+ return ins;
+}
+
+
+void AudioEffectLimiter::set_treshold_db(float p_treshold) {
+
+ treshold=p_treshold;
+}
+
+float AudioEffectLimiter::get_treshold_db() const{
+
+ return treshold;
+}
+
+void AudioEffectLimiter::set_ceiling_db(float p_ceiling){
+
+ ceiling=p_ceiling;
+}
+float AudioEffectLimiter::get_ceiling_db() const{
+
+ return ceiling;
+}
+
+void AudioEffectLimiter::set_soft_clip_db(float p_soft_clip){
+
+ soft_clip=p_soft_clip;
+}
+float AudioEffectLimiter::get_soft_clip_db() const{
+
+ return soft_clip;
+}
+
+void AudioEffectLimiter::set_soft_clip_ratio(float p_soft_clip){
+
+ soft_clip_ratio=p_soft_clip;
+}
+float AudioEffectLimiter::get_soft_clip_ratio() const{
+
+ return soft_clip;
+}
+
+
+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_soft_clip_db","soft_clip"),&AudioEffectLimiter::set_soft_clip_db);
+ ClassDB::bind_method(D_METHOD("get_soft_clip_db"),&AudioEffectLimiter::get_soft_clip_db);
+
+ ClassDB::bind_method(D_METHOD("set_soft_clip_ratio","soft_clip"),&AudioEffectLimiter::set_soft_clip_ratio);
+ 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,"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;
+ 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
new file mode 100644
index 0000000000..b0d7321205
--- /dev/null
+++ b/servers/audio/effects/audio_effect_limiter.h
@@ -0,0 +1,58 @@
+#ifndef AUDIO_EFFECT_LIMITER_H
+#define AUDIO_EFFECT_LIMITER_H
+
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectLimiter;
+
+class AudioEffectLimiterInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectLimiterInstance,AudioEffectInstance)
+friend class AudioEffectLimiter;
+ Ref<AudioEffectLimiter> base;
+
+ float mix_volume_db;
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectLimiter : public AudioEffect {
+ GDCLASS(AudioEffectLimiter,AudioEffect)
+
+friend class AudioEffectLimiterInstance;
+ float treshold;
+ float ceiling;
+ float soft_clip;
+ float soft_clip_ratio;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ void set_treshold_db(float p_treshold);
+ float get_treshold_db() const;
+
+ void set_ceiling_db(float p_ceiling);
+ float get_ceiling_db() const;
+
+ void set_soft_clip_db(float p_soft_clip);
+ float get_soft_clip_db() const;
+
+ void set_soft_clip_ratio(float p_soft_clip);
+ float get_soft_clip_ratio() const;
+
+
+ Ref<AudioEffectInstance> instance();
+ void set_volume_db(float p_volume);
+ float get_volume_db() const;
+
+ AudioEffectLimiter();
+};
+
+
+#endif // AUDIO_EFFECT_LIMITER_H
diff --git a/servers/audio/effects/audio_effect_panner.cpp b/servers/audio/effects/audio_effect_panner.cpp
new file mode 100644
index 0000000000..75ef9c3e3a
--- /dev/null
+++ b/servers/audio/effects/audio_effect_panner.cpp
@@ -0,0 +1,47 @@
+#include "audio_effect_panner.h"
+
+
+void AudioEffectPannerInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+ float lvol = CLAMP( 1.0 - base->pan, 0, 1);
+ float rvol = CLAMP( 1.0 + base->pan, 0, 1);
+
+ for(int i=0;i<p_frame_count;i++) {
+
+ p_dst_frames[i].l = p_src_frames[i].l * lvol + p_src_frames[i].r * (1.0 - rvol);
+ p_dst_frames[i].r = p_src_frames[i].r * rvol + p_src_frames[i].l * (1.0 - lvol);
+
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectPanner::instance() {
+ Ref<AudioEffectPannerInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectPanner>(this);
+ return ins;
+}
+
+void AudioEffectPanner::set_pan(float p_cpanume) {
+ pan=p_cpanume;
+}
+
+float AudioEffectPanner::get_pan() const {
+
+ return pan;
+}
+
+void AudioEffectPanner::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_pan","cpanume"),&AudioEffectPanner::set_pan);
+ ClassDB::bind_method(D_METHOD("get_pan"),&AudioEffectPanner::get_pan);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"pan",PROPERTY_HINT_RANGE,"-1,1,0.01"),"set_pan","get_pan");
+}
+
+AudioEffectPanner::AudioEffectPanner()
+{
+ pan=0;
+}
diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h
new file mode 100644
index 0000000000..bc1bb00815
--- /dev/null
+++ b/servers/audio/effects/audio_effect_panner.h
@@ -0,0 +1,40 @@
+#ifndef AUDIOEFFECTPANNER_H
+#define AUDIOEFFECTPANNER_H
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectPanner;
+
+class AudioEffectPannerInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectPannerInstance,AudioEffectInstance)
+friend class AudioEffectPanner;
+ Ref<AudioEffectPanner> base;
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectPanner : public AudioEffect {
+ GDCLASS(AudioEffectPanner,AudioEffect)
+
+friend class AudioEffectPannerInstance;
+ float pan;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+ void set_pan(float p_volume);
+ float get_pan() const;
+
+ AudioEffectPanner();
+};
+
+
+#endif // AUDIOEFFECTPANNER_H
diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp
new file mode 100644
index 0000000000..c5e49e6cc6
--- /dev/null
+++ b/servers/audio/effects/audio_effect_phaser.cpp
@@ -0,0 +1,148 @@
+#include "audio_effect_phaser.h"
+#include "servers/audio_server.h"
+#include "math_funcs.h"
+
+void AudioEffectPhaserInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ float sampling_rate = AudioServer::get_singleton()->get_mix_rate();
+
+ float dmin = base->range_min / (sampling_rate/2.0);
+ float dmax = base->range_max / (sampling_rate/2.0);
+
+ float increment = 2.f * Math_PI * (base->rate / sampling_rate);
+
+ for(int i=0;i<p_frame_count;i++) {
+
+ phase += increment;
+
+ while ( phase >= Math_PI * 2.f ) {
+ phase -= Math_PI * 2.f;
+ }
+
+ float d = dmin + (dmax-dmin) * ((sin( phase ) + 1.f)/2.f);
+
+
+ //update filter coeffs
+ for( int j=0; j<6; j++ ) {
+ allpass[0][j].delay( d );
+ allpass[1][j].delay( d );
+ }
+
+ //calculate output
+ float y = allpass[0][0].update(
+ allpass[0][1].update(
+ allpass[0][2].update(
+ allpass[0][3].update(
+ allpass[0][4].update(
+ allpass[0][5].update( p_src_frames[i].l + h.l * base->feedback ))))));
+ h.l=y;
+
+ p_dst_frames[i].l = p_src_frames[i].l + y * base->depth;
+
+ y = allpass[1][0].update(
+ allpass[1][1].update(
+ allpass[1][2].update(
+ allpass[1][3].update(
+ allpass[1][4].update(
+ allpass[1][5].update( p_src_frames[i].r + h.r * base->feedback ))))));
+ h.r=y;
+
+ p_dst_frames[i].r = p_src_frames[i].r + y * base->depth;
+
+
+ }
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectPhaser::instance() {
+ Ref<AudioEffectPhaserInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectPhaser>(this);
+ ins->phase=0;
+ ins->h=AudioFrame(0,0);
+
+ return ins;
+}
+
+
+void AudioEffectPhaser::set_range_min_hz(float p_hz) {
+
+ range_min=p_hz;
+}
+
+float AudioEffectPhaser::get_range_min_hz() const{
+
+ return range_min;
+}
+
+void AudioEffectPhaser::set_range_max_hz(float p_hz){
+
+ range_max=p_hz;
+}
+float AudioEffectPhaser::get_range_max_hz() const{
+
+ return range_max;
+}
+
+void AudioEffectPhaser::set_rate_hz(float p_hz){
+
+ rate=p_hz;
+}
+float AudioEffectPhaser::get_rate_hz() const{
+
+ return rate;
+}
+
+void AudioEffectPhaser::set_feedback(float p_fbk){
+
+ feedback=p_fbk;
+}
+float AudioEffectPhaser::get_feedback() const{
+
+ return feedback;
+}
+
+void AudioEffectPhaser::set_depth(float p_depth) {
+
+ depth=p_depth;
+}
+
+float AudioEffectPhaser::get_depth() const {
+
+ return depth;
+}
+
+void AudioEffectPhaser::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_range_min_hz","hz"),&AudioEffectPhaser::set_range_min_hz);
+ ClassDB::bind_method(D_METHOD("get_range_min_hz"),&AudioEffectPhaser::get_range_min_hz);
+
+ ClassDB::bind_method(D_METHOD("set_range_max_hz","hz"),&AudioEffectPhaser::set_range_max_hz);
+ ClassDB::bind_method(D_METHOD("get_range_max_hz"),&AudioEffectPhaser::get_range_max_hz);
+
+ ClassDB::bind_method(D_METHOD("set_rate_hz","hz"),&AudioEffectPhaser::set_rate_hz);
+ ClassDB::bind_method(D_METHOD("get_rate_hz"),&AudioEffectPhaser::get_rate_hz);
+
+ ClassDB::bind_method(D_METHOD("set_feedback","fbk"),&AudioEffectPhaser::set_feedback);
+ ClassDB::bind_method(D_METHOD("get_feedback"),&AudioEffectPhaser::get_feedback);
+
+ ClassDB::bind_method(D_METHOD("set_depth","depth"),&AudioEffectPhaser::set_depth);
+ ClassDB::bind_method(D_METHOD("get_depth"),&AudioEffectPhaser::get_depth);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"range_min_hz",PROPERTY_HINT_RANGE,"10,10000"),"set_range_min_hz","get_range_min_hz");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"range_max_hz",PROPERTY_HINT_RANGE,"10,10000"),"set_range_max_hz","get_range_max_hz");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rate_hz",PROPERTY_HINT_RANGE,"0.01,20"),"set_rate_hz","get_rate_hz");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"feedback",PROPERTY_HINT_RANGE,"0.1,0.9,0.1"),"set_feedback","get_feedback");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"depth",PROPERTY_HINT_RANGE,"0.1,4,0.1"),"set_depth","get_depth");
+
+}
+
+AudioEffectPhaser::AudioEffectPhaser()
+{
+ range_min=440;
+ range_max=1600;
+ rate=0.5;
+ feedback=0.7;
+ depth=1;
+}
diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h
new file mode 100644
index 0000000000..53a8ab8bd8
--- /dev/null
+++ b/servers/audio/effects/audio_effect_phaser.h
@@ -0,0 +1,81 @@
+#ifndef AUDIO_EFFECT_PHASER_H
+#define AUDIO_EFFECT_PHASER_H
+
+
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectPhaser;
+
+class AudioEffectPhaserInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectPhaserInstance,AudioEffectInstance)
+friend class AudioEffectPhaser;
+ Ref<AudioEffectPhaser> base;
+
+ float phase;
+ AudioFrame h;
+
+ class AllpassDelay{
+ float a, h;
+ public:
+
+ _ALWAYS_INLINE_ void delay( float d ) {
+ a = (1.f - d) / (1.f + d);
+ }
+
+ _ALWAYS_INLINE_ float update( float s ){
+ float y = s * -a + h;
+ h = y * a + s;
+ return y;
+ }
+
+ AllpassDelay() { a =0; h = 0;}
+
+ };
+
+ AllpassDelay allpass[2][6];
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectPhaser : public AudioEffect {
+ GDCLASS(AudioEffectPhaser,AudioEffect)
+
+friend class AudioEffectPhaserInstance;
+ float range_min;
+ float range_max;
+ float rate;
+ float feedback;
+ float depth;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+
+ void set_range_min_hz(float p_hz);
+ float get_range_min_hz() const;
+
+ void set_range_max_hz(float p_hz);
+ float get_range_max_hz() const;
+
+ void set_rate_hz(float p_hz);
+ float get_rate_hz() const;
+
+ void set_feedback(float p_fbk);
+ float get_feedback() const;
+
+ void set_depth(float p_depth);
+ float get_depth() const;
+
+ AudioEffectPhaser();
+};
+
+
+#endif // AUDIO_EFFECT_PHASER_H
diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp
new file mode 100644
index 0000000000..1222c7b1b2
--- /dev/null
+++ b/servers/audio/effects/audio_effect_pitch_shift.cpp
@@ -0,0 +1,298 @@
+#include "audio_effect_pitch_shift.h"
+#include "servers/audio_server.h"
+#include "math_funcs.h"
+/****************************************************************************
+*
+* NAME: smbPitchShift.cpp
+* VERSION: 1.2
+* HOME URL: http://blogs.zynaptiq.com/bernsee
+* KNOWN BUGS: none
+*
+* SYNOPSIS: Routine for doing pitch shifting while maintaining
+* duration using the Short Time Fourier Transform.
+*
+* DESCRIPTION: The routine takes a pitchShift factor value which is between 0.5
+* (one octave down) and 2. (one octave up). A value of exactly 1 does not change
+* the pitch. numSampsToProcess tells the routine how many samples in indata[0...
+* numSampsToProcess-1] should be pitch shifted and moved to outdata[0 ...
+* numSampsToProcess-1]. The two buffers can be identical (ie. it can process the
+* data in-place). fftFrameSize defines the FFT frame size used for the
+* processing. Typical values are 1024, 2048 and 4096. It may be any value <=
+* MAX_FRAME_LENGTH but it MUST be a power of 2. osamp is the STFT
+* oversampling factor which also determines the overlap between adjacent STFT
+* frames. It should at least be 4 for moderate scaling ratios. A value of 32 is
+* recommended for best quality. sampleRate takes the sample rate for the signal
+* in unit Hz, ie. 44100 for 44.1 kHz audio. The data passed to the routine in
+* indata[] should be in the range [-1.0, 1.0), which is also the output range
+* for the data, make sure you scale the data accordingly (for 16bit signed integers
+* you would have to divide (and multiply) by 32768).
+*
+* COPYRIGHT 1999-2015 Stephan M. Bernsee <s.bernsee [AT] zynaptiq [DOT] com>
+*
+* The Wide Open License (WOL)
+*
+* Permission to use, copy, modify, distribute and sell this software and its
+* documentation for any purpose is hereby granted without fee, provided that
+* the above copyright notice and this license appear in all source copies.
+* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
+* ANY KIND. See http://www.dspguru.com/wol.htm for more information.
+*
+*****************************************************************************/
+
+
+void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long fftFrameSize, long osamp, float sampleRate, float *indata, float *outdata,int stride) {
+
+
+ /*
+ Routine smbPitchShift(). See top of file for explanation
+ Purpose: doing pitch shifting while maintaining duration using the Short
+ Time Fourier Transform.
+ Author: (c)1999-2015 Stephan M. Bernsee <s.bernsee [AT] zynaptiq [DOT] com>
+ */
+
+ double magn, phase, tmp, window, real, imag;
+ double freqPerBin, expct;
+ long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
+
+ /* set up some handy variables */
+ fftFrameSize2 = fftFrameSize/2;
+ stepSize = fftFrameSize/osamp;
+ freqPerBin = sampleRate/(double)fftFrameSize;
+ expct = 2.*Math_PI*(double)stepSize/(double)fftFrameSize;
+ inFifoLatency = fftFrameSize-stepSize;
+ if (gRover == 0) gRover = inFifoLatency;
+
+ /* initialize our static arrays */
+
+ /* main processing loop */
+ for (i = 0; i < numSampsToProcess; i++){
+
+ /* As long as we have not yet collected enough data just read in */
+ gInFIFO[gRover] = indata[i*stride];
+ outdata[i*stride] = gOutFIFO[gRover-inFifoLatency];
+ gRover++;
+
+ /* now we have enough data for processing */
+ if (gRover >= fftFrameSize) {
+ gRover = inFifoLatency;
+
+ /* do windowing and re,im interleave */
+ for (k = 0; k < fftFrameSize;k++) {
+ window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5;
+ gFFTworksp[2*k] = gInFIFO[k] * window;
+ gFFTworksp[2*k+1] = 0.;
+ }
+
+
+ /* ***************** ANALYSIS ******************* */
+ /* do transform */
+ smbFft(gFFTworksp, fftFrameSize, -1);
+
+ /* this is the analysis step */
+ for (k = 0; k <= fftFrameSize2; k++) {
+
+ /* de-interlace FFT buffer */
+ real = gFFTworksp[2*k];
+ imag = gFFTworksp[2*k+1];
+
+ /* compute magnitude and phase */
+ magn = 2.*sqrt(real*real + imag*imag);
+ phase = atan2(imag,real);
+
+ /* compute phase difference */
+ tmp = phase - gLastPhase[k];
+ gLastPhase[k] = phase;
+
+ /* subtract expected phase difference */
+ tmp -= (double)k*expct;
+
+ /* map delta phase into +/- Pi interval */
+ qpd = tmp/Math_PI;
+ if (qpd >= 0) qpd += qpd&1;
+ else qpd -= qpd&1;
+ tmp -= Math_PI*(double)qpd;
+
+ /* get deviation from bin frequency from the +/- Pi interval */
+ tmp = osamp*tmp/(2.*Math_PI);
+
+ /* compute the k-th partials' true frequency */
+ tmp = (double)k*freqPerBin + tmp*freqPerBin;
+
+ /* store magnitude and true frequency in analysis arrays */
+ gAnaMagn[k] = magn;
+ gAnaFreq[k] = tmp;
+
+ }
+
+ /* ***************** PROCESSING ******************* */
+ /* this does the actual pitch shifting */
+ memset(gSynMagn, 0, fftFrameSize*sizeof(float));
+ memset(gSynFreq, 0, fftFrameSize*sizeof(float));
+ for (k = 0; k <= fftFrameSize2; k++) {
+ index = k*pitchShift;
+ if (index <= fftFrameSize2) {
+ gSynMagn[index] += gAnaMagn[k];
+ gSynFreq[index] = gAnaFreq[k] * pitchShift;
+ }
+ }
+
+ /* ***************** SYNTHESIS ******************* */
+ /* this is the synthesis step */
+ for (k = 0; k <= fftFrameSize2; k++) {
+
+ /* get magnitude and true frequency from synthesis arrays */
+ magn = gSynMagn[k];
+ tmp = gSynFreq[k];
+
+ /* subtract bin mid frequency */
+ tmp -= (double)k*freqPerBin;
+
+ /* get bin deviation from freq deviation */
+ tmp /= freqPerBin;
+
+ /* take osamp into account */
+ tmp = 2.*Math_PI*tmp/osamp;
+
+ /* add the overlap phase advance back in */
+ tmp += (double)k*expct;
+
+ /* accumulate delta phase to get bin phase */
+ gSumPhase[k] += tmp;
+ phase = gSumPhase[k];
+
+ /* get real and imag part and re-interleave */
+ gFFTworksp[2*k] = magn*cos(phase);
+ gFFTworksp[2*k+1] = magn*sin(phase);
+ }
+
+ /* zero negative frequencies */
+ for (k = fftFrameSize+2; k < 2*fftFrameSize; k++) gFFTworksp[k] = 0.;
+
+ /* do inverse transform */
+ smbFft(gFFTworksp, fftFrameSize, 1);
+
+ /* do windowing and add to output accumulator */
+ for(k=0; k < fftFrameSize; k++) {
+ window = -.5*cos(2.*Math_PI*(double)k/(double)fftFrameSize)+.5;
+ gOutputAccum[k] += 2.*window*gFFTworksp[2*k]/(fftFrameSize2*osamp);
+ }
+ for (k = 0; k < stepSize; k++) gOutFIFO[k] = gOutputAccum[k];
+
+ /* shift accumulator */
+ memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(float));
+
+ /* move input FIFO */
+ for (k = 0; k < inFifoLatency; k++) gInFIFO[k] = gInFIFO[k+stepSize];
+ }
+ }
+
+
+
+}
+
+
+void SMBPitchShift::smbFft(float *fftBuffer, long fftFrameSize, long sign)
+/*
+ FFT routine, (C)1996 S.M.Bernsee. Sign = -1 is FFT, 1 is iFFT (inverse)
+ Fills fftBuffer[0...2*fftFrameSize-1] with the Fourier transform of the
+ time domain data in fftBuffer[0...2*fftFrameSize-1]. The FFT array takes
+ and returns the cosine and sine parts in an interleaved manner, ie.
+ fftBuffer[0] = cosPart[0], fftBuffer[1] = sinPart[0], asf. fftFrameSize
+ must be a power of 2. It expects a complex input signal (see footnote 2),
+ ie. when working with 'common' audio signals our input signal has to be
+ passed as {in[0],0.,in[1],0.,in[2],0.,...} asf. In that case, the transform
+ of the frequencies of interest is in fftBuffer[0...fftFrameSize].
+*/
+{
+ float wr, wi, arg, *p1, *p2, temp;
+ float tr, ti, ur, ui, *p1r, *p1i, *p2r, *p2i;
+ long i, bitm, j, le, le2, k;
+
+ for (i = 2; i < 2*fftFrameSize-2; i += 2) {
+ for (bitm = 2, j = 0; bitm < 2*fftFrameSize; bitm <<= 1) {
+ if (i & bitm) j++;
+ j <<= 1;
+ }
+ if (i < j) {
+ p1 = fftBuffer+i; p2 = fftBuffer+j;
+ temp = *p1; *(p1++) = *p2;
+ *(p2++) = temp; temp = *p1;
+ *p1 = *p2; *p2 = temp;
+ }
+ }
+ for (k = 0, le = 2; k < (long)(log((double)fftFrameSize)/log(2.)+.5); k++) {
+ le <<= 1;
+ le2 = le>>1;
+ ur = 1.0;
+ ui = 0.0;
+ arg = Math_PI / (le2>>1);
+ wr = cos(arg);
+ wi = sign*sin(arg);
+ for (j = 0; j < le2; j += 2) {
+ p1r = fftBuffer+j; p1i = p1r+1;
+ p2r = p1r+le2; p2i = p2r+1;
+ for (i = j; i < 2*fftFrameSize; i += le) {
+ tr = *p2r * ur - *p2i * ui;
+ ti = *p2r * ui + *p2i * ur;
+ *p2r = *p1r - tr; *p2i = *p1i - ti;
+ *p1r += tr; *p1i += ti;
+ p1r += le; p1i += le;
+ p2r += le; p2i += le;
+ }
+ tr = ur*wr - ui*wi;
+ ui = ur*wi + ui*wr;
+ ur = tr;
+ }
+ }
+}
+
+
+void AudioEffectPitchShiftInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ float sample_rate = AudioServer::get_singleton()->get_mix_rate();
+
+ float *in_l = (float*)p_src_frames;
+ float *in_r = in_l + 1;
+
+ float *out_l = (float*)p_dst_frames;
+ float *out_r = out_l + 1;
+
+ shift_l.PitchShift(base->pitch_scale,p_frame_count,2048,4,sample_rate,in_l,out_l,2);
+ shift_r.PitchShift(base->pitch_scale,p_frame_count,2048,4,sample_rate,in_r,out_r,2);
+
+}
+
+
+Ref<AudioEffectInstance> AudioEffectPitchShift::instance() {
+ Ref<AudioEffectPitchShiftInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectPitchShift>(this);
+
+
+ return ins;
+}
+
+void AudioEffectPitchShift::set_pitch_scale(float p_adjust) {
+
+ pitch_scale=p_adjust;
+}
+
+float AudioEffectPitchShift::get_pitch_scale() const {
+
+ return pitch_scale;
+}
+
+
+void AudioEffectPitchShift::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_pitch_scale","rate"),&AudioEffectPitchShift::set_pitch_scale);
+ ClassDB::bind_method(D_METHOD("get_pitch_scale"),&AudioEffectPitchShift::get_pitch_scale);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"pitch_scale",PROPERTY_HINT_RANGE,"0.01,16,0.01"),"set_pitch_scale","get_pitch_scale");
+
+}
+
+AudioEffectPitchShift::AudioEffectPitchShift() {
+ pitch_scale=1.0;
+
+}
diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h
new file mode 100644
index 0000000000..d1343a0745
--- /dev/null
+++ b/servers/audio/effects/audio_effect_pitch_shift.h
@@ -0,0 +1,89 @@
+#ifndef AUDIO_EFFECT_PITCH_SHIFT_H
+#define AUDIO_EFFECT_PITCH_SHIFT_H
+
+
+#include "servers/audio/audio_effect.h"
+
+class SMBPitchShift {
+
+ enum {
+ MAX_FRAME_LENGTH=8192
+ };
+
+ float gInFIFO[MAX_FRAME_LENGTH];
+ float gOutFIFO[MAX_FRAME_LENGTH];
+ float gFFTworksp[2*MAX_FRAME_LENGTH];
+ float gLastPhase[MAX_FRAME_LENGTH/2+1];
+ float gSumPhase[MAX_FRAME_LENGTH/2+1];
+ float gOutputAccum[2*MAX_FRAME_LENGTH];
+ float gAnaFreq[MAX_FRAME_LENGTH];
+ float gAnaMagn[MAX_FRAME_LENGTH];
+ float gSynFreq[MAX_FRAME_LENGTH];
+ float gSynMagn[MAX_FRAME_LENGTH];
+ long gRover;
+
+ void smbFft(float *fftBuffer, long fftFrameSize, long sign);
+public:
+ void PitchShift(float pitchShift, long numSampsToProcess, long fftFrameSize, long osamp, float sampleRate, float *indata, float *outdata, int stride);
+
+ SMBPitchShift() {
+ gRover=0;
+ memset(gInFIFO, 0, MAX_FRAME_LENGTH*sizeof(float));
+ memset(gOutFIFO, 0, MAX_FRAME_LENGTH*sizeof(float));
+ memset(gFFTworksp, 0, 2*MAX_FRAME_LENGTH*sizeof(float));
+ memset(gLastPhase, 0, (MAX_FRAME_LENGTH/2+1)*sizeof(float));
+ memset(gSumPhase, 0, (MAX_FRAME_LENGTH/2+1)*sizeof(float));
+ memset(gOutputAccum, 0, 2*MAX_FRAME_LENGTH*sizeof(float));
+ memset(gAnaFreq, 0, MAX_FRAME_LENGTH*sizeof(float));
+ memset(gAnaMagn, 0, MAX_FRAME_LENGTH*sizeof(float));
+ }
+
+
+};
+
+
+class AudioEffectPitchShift;
+
+class AudioEffectPitchShiftInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectPitchShiftInstance,AudioEffectInstance)
+friend class AudioEffectPitchShift;
+ Ref<AudioEffectPitchShift> base;
+
+ SMBPitchShift shift_l;
+ SMBPitchShift shift_r;
+
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+};
+
+
+class AudioEffectPitchShift : public AudioEffect {
+ GDCLASS(AudioEffectPitchShift,AudioEffect)
+
+friend class AudioEffectPitchShiftInstance;
+
+ float pitch_scale;
+ int window_size;
+ float wet;
+ float dry;
+ bool filter;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+
+ void set_pitch_scale(float p_adjust);
+ float get_pitch_scale() const;
+
+ AudioEffectPitchShift();
+};
+
+
+#endif // AUDIO_EFFECT_PITCH_SHIFT_H
diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp
new file mode 100644
index 0000000000..f84dffdd36
--- /dev/null
+++ b/servers/audio/effects/audio_effect_reverb.cpp
@@ -0,0 +1,182 @@
+#include "audio_effect_reverb.h"
+#include "servers/audio_server.h"
+void AudioEffectReverbInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+ for(int i=0;i<2;i++) {
+ Reverb &r=reverb[i];
+
+ r.set_predelay( base->predelay);
+ r.set_predelay_feedback( base->predelay_fb );
+ r.set_highpass( base->hpf );
+ r.set_room_size( base->room_size );
+ r.set_damp( base->damping );
+ r.set_extra_spread( base->spread );
+ r.set_wet( base->wet );
+ r.set_dry( base->dry );
+ }
+
+ int todo = p_frame_count;
+ int offset=0;
+
+ while(todo) {
+
+ int to_mix = MIN(todo,Reverb::INPUT_BUFFER_MAX_SIZE);
+
+ for(int j=0;j<to_mix;j++) {
+ tmp_src[j]=p_src_frames[offset+j].l;
+ }
+
+ reverb[0].process(tmp_src,tmp_dst,to_mix);
+
+ for(int j=0;j<to_mix;j++) {
+ p_dst_frames[offset+j].l=tmp_dst[j];
+ tmp_src[j]=p_src_frames[offset+j].r;
+ }
+
+ reverb[1].process(tmp_src,tmp_dst,to_mix);
+
+ for(int j=0;j<to_mix;j++) {
+ p_dst_frames[offset+j].r=tmp_dst[j];
+ }
+
+ offset+=to_mix;
+ todo-=to_mix;
+ }
+}
+
+AudioEffectReverbInstance::AudioEffectReverbInstance() {
+
+ reverb[0].set_mix_rate( AudioServer::get_singleton()->get_mix_rate() );
+ reverb[0].set_extra_spread_base(0);
+ reverb[1].set_mix_rate( AudioServer::get_singleton()->get_mix_rate() );
+ reverb[1].set_extra_spread_base(0.000521); //for stereo effect
+
+}
+
+Ref<AudioEffectInstance> AudioEffectReverb::instance() {
+ Ref<AudioEffectReverbInstance> ins;
+ ins.instance();
+ ins->base=Ref<AudioEffectReverb>(this);
+ return ins;
+}
+
+void AudioEffectReverb::set_predelay_msec(float p_msec) {
+
+ predelay=p_msec;
+}
+
+void AudioEffectReverb::set_predelay_feedback(float p_feedback){
+
+ predelay_fb=p_feedback;
+}
+void AudioEffectReverb::set_room_size(float p_size){
+
+ room_size=p_size;
+}
+void AudioEffectReverb::set_damping(float p_damping){
+
+ damping=p_damping;
+}
+void AudioEffectReverb::set_spread(float p_spread){
+
+ spread=p_spread;
+}
+
+void AudioEffectReverb::set_dry(float p_dry){
+
+ dry=p_dry;
+}
+void AudioEffectReverb::set_wet(float p_wet){
+
+ wet=p_wet;
+}
+void AudioEffectReverb::set_hpf(float p_hpf) {
+
+ hpf=p_hpf;
+}
+
+float AudioEffectReverb::get_predelay_msec() const {
+
+ return predelay;
+}
+float AudioEffectReverb::get_predelay_feedback() const {
+
+ return predelay_fb;
+}
+float AudioEffectReverb::get_room_size() const {
+
+ return room_size;
+}
+float AudioEffectReverb::get_damping() const {
+
+ return damping;
+}
+float AudioEffectReverb::get_spread() const {
+
+ return spread;
+}
+float AudioEffectReverb::get_dry() const {
+
+ return dry;
+}
+float AudioEffectReverb::get_wet() const {
+
+ return wet;
+}
+float AudioEffectReverb::get_hpf() const {
+
+ return hpf;
+}
+
+
+void AudioEffectReverb::_bind_methods() {
+
+
+ ClassDB::bind_method(D_METHOD("set_predelay_msec","msec"),&AudioEffectReverb::set_predelay_msec);
+ ClassDB::bind_method(D_METHOD("get_predelay_msec"),&AudioEffectReverb::get_predelay_msec);
+
+ ClassDB::bind_method(D_METHOD("set_predelay_feedback","feedback"),&AudioEffectReverb::set_predelay_feedback);
+ ClassDB::bind_method(D_METHOD("get_predelay_feedback"),&AudioEffectReverb::get_predelay_feedback);
+
+ ClassDB::bind_method(D_METHOD("set_room_size","size"),&AudioEffectReverb::set_room_size);
+ ClassDB::bind_method(D_METHOD("get_room_size"),&AudioEffectReverb::get_room_size);
+
+ ClassDB::bind_method(D_METHOD("set_damping","amount"),&AudioEffectReverb::set_damping);
+ ClassDB::bind_method(D_METHOD("get_damping"),&AudioEffectReverb::get_damping);
+
+ ClassDB::bind_method(D_METHOD("set_spread","amount"),&AudioEffectReverb::set_spread);
+ ClassDB::bind_method(D_METHOD("get_spread"),&AudioEffectReverb::get_spread);
+
+ ClassDB::bind_method(D_METHOD("set_dry","amount"),&AudioEffectReverb::set_dry);
+ ClassDB::bind_method(D_METHOD("get_dry"),&AudioEffectReverb::get_dry);
+
+ ClassDB::bind_method(D_METHOD("set_wet","amount"),&AudioEffectReverb::set_wet);
+ ClassDB::bind_method(D_METHOD("get_wet"),&AudioEffectReverb::get_wet);
+
+ ClassDB::bind_method(D_METHOD("set_hpf","amount"),&AudioEffectReverb::set_hpf);
+ ClassDB::bind_method(D_METHOD("get_hpf"),&AudioEffectReverb::get_hpf);
+
+
+ ADD_GROUP("Predelay","predelay_");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"predelay_msec",PROPERTY_HINT_RANGE,"20,500,1"),"set_predelay_msec","get_predelay_msec");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"predelay_feedback",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_predelay_msec","get_predelay_msec");
+ ADD_GROUP("","");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"room_size",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_room_size","get_room_size");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_damping","get_damping");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"spread",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_spread","get_spread");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"hipass",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_hpf","get_hpf");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dry",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_dry","get_dry");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"wet",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_wet","get_wet");
+}
+
+AudioEffectReverb::AudioEffectReverb() {
+ predelay=150;
+ predelay_fb=0.4;
+ hpf=0;
+ room_size=0.8;
+ damping=0.5;
+ spread=1.0;
+ dry=1.0;
+ wet=0.5;
+
+}
diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h
new file mode 100644
index 0000000000..e05ffe422f
--- /dev/null
+++ b/servers/audio/effects/audio_effect_reverb.h
@@ -0,0 +1,76 @@
+#ifndef AUDIOEFFECTREVERB_H
+#define AUDIOEFFECTREVERB_H
+
+
+#include "servers/audio/audio_effect.h"
+#include "servers/audio/effects/reverb.h"
+
+class AudioEffectReverb;
+
+class AudioEffectReverbInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectReverbInstance,AudioEffectInstance)
+
+ Ref<AudioEffectReverb> base;
+
+ float tmp_src[Reverb::INPUT_BUFFER_MAX_SIZE];
+ float tmp_dst[Reverb::INPUT_BUFFER_MAX_SIZE];
+
+friend class AudioEffectReverb;
+
+ Reverb reverb[2];
+
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+ AudioEffectReverbInstance();
+};
+
+
+class AudioEffectReverb : public AudioEffect {
+ GDCLASS(AudioEffectReverb,AudioEffect)
+
+friend class AudioEffectReverbInstance;
+
+ float predelay;
+ float predelay_fb;
+ float hpf;
+ float room_size;
+ float damping;
+ float spread;
+ float dry;
+ float wet;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ void set_predelay_msec(float p_msec);
+ void set_predelay_feedback(float p_feedback);
+ void set_room_size(float p_size);
+ void set_damping(float p_damping);
+ void set_spread(float p_spread);
+ void set_dry(float p_dry);
+ void set_wet(float p_wet);
+ void set_hpf(float p_hpf);
+
+ float get_predelay_msec() const;
+ float get_predelay_feedback() const;
+ float get_room_size() const;
+ float get_damping() const;
+ float get_spread() const;
+ float get_dry() const;
+ float get_wet() const;
+ float get_hpf() const;
+
+ Ref<AudioEffectInstance> instance();
+ void set_volume_db(float p_volume);
+ float get_volume_db() const;
+
+ AudioEffectReverb();
+};
+
+
+#endif // AUDIOEFFECTREVERB_H
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp
new file mode 100644
index 0000000000..0afabc8f3d
--- /dev/null
+++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp
@@ -0,0 +1,135 @@
+#include "audio_effect_stereo_enhance.h"
+#include "servers/audio_server.h"
+void AudioEffectStereoEnhanceInstance::process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count) {
+
+
+ float intensity=base->pan_pullout;
+ bool surround_mode=base->surround>0;
+ float surround_amount=base->surround;
+ unsigned int delay_frames=(base->time_pullout/1000.0)*AudioServer::get_singleton()->get_mix_rate();
+
+ for (int i=0;i<p_frame_count;i++) {
+
+ float l=p_src_frames[i].l;
+ float r=p_src_frames[i].r;
+
+ float center=(l+r)/2.0f;
+
+ l=( center+(l-center)*intensity );
+ r=( center+(r-center)*intensity );
+
+ if (surround_mode) {
+
+ float val=(l+r)/2.0;
+
+ delay_ringbuff[ringbuff_pos&ringbuff_mask]=val;
+
+ float out=delay_ringbuff[(ringbuff_pos-delay_frames)&ringbuff_mask]*surround_amount;
+
+ l+=out;
+ r+=-out;
+ } else {
+
+ float val=r;
+
+ delay_ringbuff[ringbuff_pos&ringbuff_mask]=val;
+
+ //r is delayed
+ r=delay_ringbuff[(ringbuff_pos-delay_frames)&ringbuff_mask];;
+
+
+ }
+
+ p_dst_frames[i].l=l;
+ p_dst_frames[i].r=r;
+ ringbuff_pos++;
+
+ }
+
+}
+
+
+AudioEffectStereoEnhanceInstance::~AudioEffectStereoEnhanceInstance() {
+
+ memdelete_arr(delay_ringbuff);
+}
+
+Ref<AudioEffectInstance> AudioEffectStereoEnhance::instance() {
+ Ref<AudioEffectStereoEnhanceInstance> ins;
+ ins.instance();
+
+ ins->base=Ref<AudioEffectStereoEnhance>(this);
+
+
+ float ring_buffer_max_size=AudioEffectStereoEnhanceInstance::MAX_DELAY_MS+2;
+ ring_buffer_max_size/=1000.0;//convert to seconds
+ ring_buffer_max_size*=AudioServer::get_singleton()->get_mix_rate();
+
+ int ringbuff_size=(int)ring_buffer_max_size;
+
+ int bits=0;
+
+ while(ringbuff_size>0) {
+ bits++;
+ ringbuff_size/=2;
+ }
+
+ ringbuff_size=1<<bits;
+ ins->ringbuff_mask=ringbuff_size-1;
+ ins->ringbuff_pos=0;
+
+ ins->delay_ringbuff = memnew_arr(float,ringbuff_size );
+
+ return ins;
+}
+
+void AudioEffectStereoEnhance::set_pan_pullout(float p_amount) {
+
+ pan_pullout=p_amount;
+}
+
+float AudioEffectStereoEnhance::get_pan_pullout() const {
+
+ return pan_pullout;
+}
+
+void AudioEffectStereoEnhance::set_time_pullout(float p_amount) {
+
+ time_pullout=p_amount;
+}
+float AudioEffectStereoEnhance::get_time_pullout() const {
+
+ return time_pullout;
+}
+
+void AudioEffectStereoEnhance::set_surround(float p_amount) {
+
+ surround=p_amount;
+}
+float AudioEffectStereoEnhance::get_surround() const {
+
+ return surround;
+}
+
+void AudioEffectStereoEnhance::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_pan_pullout","amount"),&AudioEffectStereoEnhance::set_pan_pullout);
+ ClassDB::bind_method(D_METHOD("get_pan_pullout"),&AudioEffectStereoEnhance::get_pan_pullout);
+
+ ClassDB::bind_method(D_METHOD("set_time_pullout","amount"),&AudioEffectStereoEnhance::set_time_pullout);
+ ClassDB::bind_method(D_METHOD("get_time_pullout"),&AudioEffectStereoEnhance::get_time_pullout);
+
+ ClassDB::bind_method(D_METHOD("set_surround","amount"),&AudioEffectStereoEnhance::set_surround);
+ ClassDB::bind_method(D_METHOD("get_surround"),&AudioEffectStereoEnhance::get_surround);
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"pan_pullout",PROPERTY_HINT_RANGE,"0,4,0.01"),"set_pan_pullout","get_pan_pullout");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"time_pullout_ms",PROPERTY_HINT_RANGE,"0,50,0.01"),"set_time_pullout","get_time_pullout");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"surround",PROPERTY_HINT_RANGE,"0,1,0.01"),"set_surround","get_surround");
+}
+
+AudioEffectStereoEnhance::AudioEffectStereoEnhance()
+{
+ pan_pullout=1;
+ time_pullout=0;
+ surround=0;
+}
diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h
new file mode 100644
index 0000000000..06762acbf3
--- /dev/null
+++ b/servers/audio/effects/audio_effect_stereo_enhance.h
@@ -0,0 +1,62 @@
+#ifndef AUDIOEFFECTSTEREOENHANCE_H
+#define AUDIOEFFECTSTEREOENHANCE_H
+
+
+#include "servers/audio/audio_effect.h"
+
+class AudioEffectStereoEnhance;
+
+class AudioEffectStereoEnhanceInstance : public AudioEffectInstance {
+ GDCLASS(AudioEffectStereoEnhanceInstance,AudioEffectInstance)
+friend class AudioEffectStereoEnhance;
+ Ref<AudioEffectStereoEnhance> base;
+
+ enum {
+
+ MAX_DELAY_MS=50
+ };
+
+ float *delay_ringbuff;
+ unsigned int ringbuff_pos;
+ unsigned int ringbuff_mask;
+
+
+public:
+
+ virtual void process(const AudioFrame *p_src_frames,AudioFrame *p_dst_frames,int p_frame_count);
+
+ ~AudioEffectStereoEnhanceInstance();
+};
+
+
+class AudioEffectStereoEnhance : public AudioEffect {
+ GDCLASS(AudioEffectStereoEnhance,AudioEffect)
+
+friend class AudioEffectStereoEnhanceInstance;
+ float volume_db;
+
+ float pan_pullout;
+ float time_pullout;
+ float surround;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+
+ Ref<AudioEffectInstance> instance();
+
+ void set_pan_pullout(float p_amount);
+ float get_pan_pullout() const;
+
+ void set_time_pullout(float p_amount);
+ float get_time_pullout() const;
+
+ void set_surround(float p_amount);
+ float get_surround() const;
+
+ AudioEffectStereoEnhance();
+};
+
+#endif // AUDIOEFFECTSTEREOENHANCE_H
diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp
new file mode 100644
index 0000000000..5aab60a558
--- /dev/null
+++ b/servers/audio/effects/eq.cpp
@@ -0,0 +1,219 @@
+//
+// C++ Interface: eq
+//
+// Description:
+//
+//
+// Author: reduzio@gmail.com (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "eq.h"
+#include <math.h>
+#include "error_macros.h"
+#include "math_funcs.h"
+
+#define POW2(v) ((v)*(v))
+
+/* Helper */
+ static int solve_quadratic(double a,double b,double c,double *r1, double *r2) {
+//solves quadractic and returns number of roots
+
+ double base=2*a;
+ if (base == 0.0f)
+ return 0;
+
+ double squared=b*b-4*a*c;
+ if (squared<0.0)
+ return 0;
+
+ squared=sqrt(squared);
+
+ *r1=(-b+squared)/base;
+ *r2=(-b-squared)/base;
+
+ if (*r1==*r2)
+ return 1;
+ else
+ return 2;
+ }
+
+EQ::BandProcess::BandProcess() {
+
+ c1=c2=c3=history.a1=history.a2=history.a3=0;
+ history.b1=history.b2=history.b3=0;
+}
+
+void EQ::recalculate_band_coefficients() {
+
+#define BAND_LOG( m_f ) ( log((m_f)) / log(2.) )
+
+ for (int i=0;i<band.size();i++) {
+
+ double octave_size;
+
+ double frq=band[i].freq;
+
+ if (i==0) {
+
+ octave_size=BAND_LOG(band[1].freq)-BAND_LOG(frq);
+ } else if (i==(band.size()-1)) {
+
+ octave_size=BAND_LOG(frq)-BAND_LOG(band[i-1].freq);
+ } else {
+
+ double next=BAND_LOG(band[i+1].freq)-BAND_LOG(frq);
+ double prev=BAND_LOG(frq)-BAND_LOG(band[i-1].freq);
+ octave_size=(next+prev)/2.0;
+ }
+
+
+
+ double frq_l=round(frq/pow(2.0,octave_size/2.0));
+
+
+
+ double side_gain2=POW2(Math_SQRT12);
+ double th=2.0*Math_PI*frq/mix_rate;
+ double th_l=2.0*Math_PI*frq_l/mix_rate;
+
+ double c2a=side_gain2 * POW2(cos(th))
+ - 2.0 * side_gain2 * cos(th_l) * cos(th)
+ + side_gain2
+ - POW2(sin(th_l));
+
+ double c2b=2.0 * side_gain2 * POW2(cos(th_l))
+ + side_gain2 * POW2(cos(th))
+ - 2.0 * side_gain2 * cos(th_l) * cos(th)
+ - side_gain2
+ + POW2(sin(th_l));
+
+ double c2c=0.25 * side_gain2 * POW2(cos(th))
+ - 0.5 * side_gain2 * cos(th_l) * cos(th)
+ + 0.25 * side_gain2
+ - 0.25 * POW2(sin(th_l));
+
+ //printf("band %i, precoefs = %f,%f,%f\n",i,c2a,c2b,c2c);
+
+ double r1,r2; //roots
+ int roots=solve_quadratic(c2a,c2b,c2c,&r1,&r2);
+
+ ERR_CONTINUE( roots==0 );
+
+ band[i].c1=2.0 * ((0.5-r1)/2.0);
+ band[i].c2=2.0 * r1;
+ band[i].c3=2.0 * (0.5+r1) * cos(th);
+ //printf("band %i, coefs = %f,%f,%f\n",i,(float)bands[i].c1,(float)bands[i].c2,(float)bands[i].c3);
+
+ }
+}
+
+void EQ::set_preset_band_mode(Preset p_preset) {
+
+
+ band.clear();
+
+#define PUSH_BANDS(m_bands) \
+ for (int i=0;i<m_bands;i++) { \
+ Band b; \
+ b.freq=bands[i];\
+ band.push_back(b);\
+ }
+
+ switch (p_preset) {
+
+ case PRESET_6_BANDS: {
+
+ static const double bands[] = { 32 , 100 , 320 , 1e3, 3200, 10e3 };
+ PUSH_BANDS(6);
+
+ } break;
+
+ case PRESET_8_BANDS: {
+
+ static const double bands[] = { 32,72,192,512,1200,3000,7500,16e3 };
+
+ PUSH_BANDS(8);
+ } break;
+
+ case PRESET_10_BANDS: {
+ static const double bands[] = { 31.25, 62.5, 125 , 250 , 500 , 1e3, 2e3, 4e3, 8e3, 16e3 };
+
+ PUSH_BANDS(10);
+
+ } break;
+
+ case PRESET_21_BANDS: {
+
+ static const double bands[] = { 22 , 32 , 44 , 63 , 90 , 125 , 175 , 250 , 350 , 500 , 700 , 1e3, 1400 , 2e3, 2800 , 4e3, 5600 , 8e3, 11e3, 16e3, 22e3 };
+ PUSH_BANDS(21);
+
+ } break;
+
+ case PRESET_31_BANDS: {
+
+ static const double bands[] = { 20, 25, 31.5, 40 , 50 , 63 , 80 , 100 , 125 , 160 , 200 , 250 , 315 , 400 , 500 , 630 , 800 , 1e3 , 1250 , 1600 , 2e3, 2500 , 3150 , 4e3, 5e3, 6300 , 8e3, 10e3, 12500 , 16e3, 20e3 };
+ PUSH_BANDS(31);
+ } break;
+
+ };
+
+ recalculate_band_coefficients();
+}
+
+int EQ::get_band_count() const {
+
+ return band.size();
+}
+float EQ::get_band_frequency(int p_band) {
+
+ ERR_FAIL_INDEX_V(p_band,band.size(),0);
+ return band[p_band].freq;
+}
+void EQ::set_bands(const Vector<float>& p_bands) {
+
+ band.resize(p_bands.size());
+ for (int i=0;i<p_bands.size();i++) {
+
+ band[i].freq=p_bands[i];
+ }
+
+ recalculate_band_coefficients();
+
+}
+
+void EQ::set_mix_rate(float p_mix_rate) {
+
+ mix_rate=p_mix_rate;
+ recalculate_band_coefficients();
+}
+
+EQ::BandProcess EQ::get_band_processor(int p_band) const {
+
+
+ EQ::BandProcess band_proc;
+
+ ERR_FAIL_INDEX_V(p_band,band.size(),band_proc);
+
+ band_proc.c1=band[p_band].c1;
+ band_proc.c2=band[p_band].c2;
+ band_proc.c3=band[p_band].c3;
+
+ return band_proc;
+
+
+}
+
+
+EQ::EQ()
+{
+ mix_rate=44100;
+}
+
+
+EQ::~EQ()
+{
+}
+
+
diff --git a/servers/audio/effects/eq.h b/servers/audio/effects/eq.h
new file mode 100644
index 0000000000..2c4668cd0b
--- /dev/null
+++ b/servers/audio/effects/eq.h
@@ -0,0 +1,106 @@
+//
+// C++ Interface: eq
+//
+// Description:
+//
+//
+// Author: reduzio@gmail.com (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef EQ_FILTER_H
+#define EQ_FILTER_H
+
+
+#include "typedefs.h"
+#include "vector.h"
+
+
+/**
+@author Juan Linietsky
+*/
+
+class EQ {
+public:
+
+ enum Preset {
+
+ PRESET_6_BANDS,
+ PRESET_8_BANDS,
+ PRESET_10_BANDS,
+ PRESET_21_BANDS,
+ PRESET_31_BANDS
+ };
+
+
+
+ class BandProcess {
+
+ friend class EQ;
+ float c1,c2,c3;
+ struct History {
+ float a1,a2,a3;
+ float b1,b2,b3;
+
+ } history;
+
+ public:
+
+ inline void process_one(float & p_data);
+
+ BandProcess();
+ };
+
+private:
+ struct Band {
+
+ float freq;
+ float c1,c2,c3;
+ };
+
+ Vector<Band> band;
+
+ float mix_rate;
+
+ void recalculate_band_coefficients();
+
+public:
+
+
+ void set_mix_rate(float p_mix_rate);
+
+ int get_band_count() const;
+ void set_preset_band_mode(Preset p_preset);
+ void set_bands(const Vector<float>& p_bands);
+ BandProcess get_band_processor(int p_band) const;
+ float get_band_frequency(int p_band);
+
+ EQ();
+ ~EQ();
+
+};
+
+
+/* Inline Function */
+
+inline void EQ::BandProcess::process_one(float & p_data) {
+
+
+ history.a1=p_data;
+
+ history.b1= c1 * ( history.a1 - history.a3 )
+ + c3 * history.b2
+ - c2 * history.b3;
+
+ p_data = history.b1;
+
+ history.a3=history.a2;
+ history.a2=history.a1;
+ history.b3=history.b2;
+ history.b2=history.b1;
+
+}
+
+
+#endif
diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp
new file mode 100644
index 0000000000..43ea0edb3a
--- /dev/null
+++ b/servers/audio/effects/reverb.cpp
@@ -0,0 +1,364 @@
+//
+// C++ Interface: reverb
+//
+// Description:
+//
+//
+// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "reverb.h"
+#include <math.h>
+#include "math_funcs.h"
+
+
+const float Reverb::comb_tunings[MAX_COMBS]={
+ //freeverb comb tunings
+ 0.025306122448979593,
+ 0.026938775510204082,
+ 0.028956916099773241,
+ 0.03074829931972789,
+ 0.032244897959183672,
+ 0.03380952380952381,
+ 0.035306122448979592,
+ 0.036666666666666667
+};
+
+const float Reverb::allpass_tunings[MAX_ALLPASS]={
+ //freeverb allpass tunings
+ 0.0051020408163265302,
+ 0.007732426303854875,
+ 0.01,
+ 0.012607709750566893
+};
+
+
+
+void Reverb::process(float *p_src,float *p_dst,int p_frames) {
+
+ if (p_frames>INPUT_BUFFER_MAX_SIZE)
+ p_frames=INPUT_BUFFER_MAX_SIZE;
+
+ int predelay_frames=lrint((params.predelay/1000.0)*params.mix_rate);
+ if (predelay_frames<10)
+ predelay_frames=10;
+ if (predelay_frames>=echo_buffer_size)
+ predelay_frames=echo_buffer_size-1;
+
+ for (int i=0;i<p_frames;i++) {
+
+ if (echo_buffer_pos>=echo_buffer_size)
+ echo_buffer_pos=0;
+
+ int read_pos=echo_buffer_pos-predelay_frames;
+ while (read_pos<0)
+ read_pos+=echo_buffer_size;
+
+ float in=undenormalise(echo_buffer[read_pos]*params.predelay_fb+p_src[i]);
+
+ echo_buffer[echo_buffer_pos]=in;
+
+ input_buffer[i]=in;
+
+ p_dst[i]=0; //take the chance and clear this
+
+ echo_buffer_pos++;
+ }
+
+ if (params.hpf>0) {
+ float hpaux=expf(-2.0*Math_PI*params.hpf*6000/params.mix_rate);
+ float hp_a1=(1.0+hpaux)/2.0;
+ float hp_a2=-(1.0+hpaux)/2.0;
+ float hp_b1=hpaux;
+
+ for (int i=0;i<p_frames;i++) {
+
+ float in=input_buffer[i];
+ input_buffer[i]=in*hp_a1+hpf_h1*hp_a2+hpf_h2*hp_b1;
+ hpf_h2=input_buffer[i];
+ hpf_h1=in;
+ }
+ }
+
+ for (int i=0;i<MAX_COMBS;i++) {
+
+ Comb &c=comb[i];
+
+ int size_limit=c.size-lrintf((float)c.extra_spread_frames*(1.0-params.extra_spread));
+ for (int j=0;j<p_frames;j++) {
+
+ if (c.pos>=size_limit) //reset this now just in case
+ c.pos=0;
+
+ float out=undenormalise(c.buffer[c.pos]*c.feedback);
+ out=out*(1.0-c.damp)+c.damp_h*c.damp; //lowpass
+ c.damp_h=out;
+ c.buffer[c.pos]=input_buffer[j]+out;
+ p_dst[j]+=out;
+ c.pos++;
+ }
+
+ }
+
+
+ static const float allpass_feedback=0.7;
+ /* this one works, but the other version is just nicer....
+ int ap_size_limit[MAX_ALLPASS];
+
+ for (int i=0;i<MAX_ALLPASS;i++) {
+
+ AllPass &a=allpass[i];
+ ap_size_limit[i]=a.size-lrintf((float)a.extra_spread_frames*(1.0-params.extra_spread));
+ }
+
+ for (int i=0;i<p_frames;i++) {
+
+ float sample=p_dst[i];
+ float aux,in;
+ float AllPass*ap;
+
+#define PROCESS_ALLPASS(m_ap) \
+ ap=&allpass[m_ap]; \
+ if (ap->pos>=ap_size_limit[m_ap]) \
+ ap->pos=0; \
+ aux=undenormalise(ap->buffer[ap->pos]); \
+ in=sample; \
+ sample=-in+aux; \
+ ap->pos++;
+
+
+ PROCESS_ALLPASS(0);
+ PROCESS_ALLPASS(1);
+ PROCESS_ALLPASS(2);
+ PROCESS_ALLPASS(3);
+
+ p_dst[i]=sample;
+ }
+ */
+
+ for (int i=0;i<MAX_ALLPASS;i++) {
+
+ AllPass &a=allpass[i];
+ int size_limit=a.size-lrintf((float)a.extra_spread_frames*(1.0-params.extra_spread));
+
+ for (int j=0;j<p_frames;j++) {
+
+ if (a.pos>=size_limit)
+ a.pos=0;
+
+ float aux=a.buffer[a.pos];
+ a.buffer[a.pos]=undenormalise(allpass_feedback*aux+p_dst[j]);
+ p_dst[j]=aux-allpass_feedback*a.buffer[a.pos];
+ a.pos++;
+
+ }
+ }
+
+ static const float wet_scale=0.6;
+
+ for (int i=0;i<p_frames;i++) {
+
+
+ p_dst[i]=p_dst[i]*params.wet*wet_scale+p_src[i]*params.dry;
+ }
+
+}
+
+
+void Reverb::set_room_size(float p_size) {
+
+ params.room_size=p_size;
+ update_parameters();
+
+}
+void Reverb::set_damp(float p_damp) {
+
+ params.damp=p_damp;
+ update_parameters();
+
+}
+void Reverb::set_wet(float p_wet) {
+
+ params.wet=p_wet;
+
+}
+
+void Reverb::set_dry(float p_dry) {
+
+ params.dry=p_dry;
+
+}
+
+void Reverb::set_predelay(float p_predelay) {
+
+ params.predelay=p_predelay;
+}
+void Reverb::set_predelay_feedback(float p_predelay_fb) {
+
+ params.predelay_fb=p_predelay_fb;
+
+}
+
+void Reverb::set_highpass(float p_frq) {
+
+ if (p_frq>1)
+ p_frq=1;
+ if (p_frq<0)
+ p_frq=0;
+ params.hpf=p_frq;
+}
+
+void Reverb::set_extra_spread(float p_spread) {
+
+ params.extra_spread=p_spread;
+
+}
+
+
+void Reverb::set_mix_rate(float p_mix_rate) {
+
+ params.mix_rate=p_mix_rate;
+ configure_buffers();
+}
+
+void Reverb::set_extra_spread_base(float p_sec) {
+
+ params.extra_spread_base=p_sec;
+ configure_buffers();
+}
+
+
+void Reverb::configure_buffers() {
+
+ clear_buffers(); //clear if necesary
+
+ for (int i=0;i<MAX_COMBS;i++) {
+
+ Comb &c=comb[i];
+
+
+ c.extra_spread_frames=lrint(params.extra_spread_base*params.mix_rate);
+
+ int len=lrint(comb_tunings[i]*params.mix_rate)+c.extra_spread_frames;
+ if (len<5)
+ len=5; //may this happen?
+
+ c.buffer = memnew_arr(float,len);
+ c.pos=0;
+ for (int j=0;j<len;j++)
+ c.buffer[j]=0;
+ c.size=len;
+
+ }
+
+ for (int i=0;i<MAX_ALLPASS;i++) {
+
+ AllPass &a=allpass[i];
+
+ a.extra_spread_frames=lrint(params.extra_spread_base*params.mix_rate);
+
+ int len=lrint(allpass_tunings[i]*params.mix_rate)+a.extra_spread_frames;
+ if (len<5)
+ len=5; //may this happen?
+
+ a.buffer = memnew_arr(float,len);
+ a.pos=0;
+ for (int j=0;j<len;j++)
+ a.buffer[j]=0;
+ a.size=len;
+ }
+
+ echo_buffer_size=(int)(((float)MAX_ECHO_MS/1000.0)*params.mix_rate+1.0);
+ echo_buffer = memnew_arr(float,echo_buffer_size);
+ for (int i=0;i<echo_buffer_size;i++) {
+
+ echo_buffer[i]=0;
+ }
+
+ echo_buffer_pos=0;
+}
+
+
+void Reverb::update_parameters() {
+
+ //more freeverb derived constants
+ static const float room_scale = 0.28f;
+ static const float room_offset = 0.7f;
+
+ for (int i=0;i<MAX_COMBS;i++) {
+
+ Comb &c=comb[i];
+ c.feedback=room_offset+params.room_size*room_scale;
+ if (c.feedback<room_offset)
+ c.feedback=room_offset;
+ else if (c.feedback>(room_offset+room_scale))
+ c.feedback=(room_offset+room_scale);
+
+ float auxdmp=params.damp/2.0+0.5; //only half the range (0.5 .. 1.0 is enough)
+ auxdmp*=auxdmp;
+
+ c.damp=expf(-2.0*Math_PI*auxdmp*10000/params.mix_rate); // 0 .. 10khz
+ }
+
+}
+
+void Reverb::clear_buffers() {
+
+ if (echo_buffer)
+ memdelete_arr(echo_buffer);
+
+ for (int i=0;i<MAX_COMBS;i++) {
+
+ if (comb[i].buffer)
+ memdelete_arr(comb[i].buffer);
+
+ comb[i].buffer=0;
+
+ }
+
+ for (int i=0;i<MAX_ALLPASS;i++) {
+
+ if (allpass[i].buffer)
+ memdelete_arr(allpass[i].buffer);
+
+ allpass[i].buffer=0;
+ }
+
+}
+
+Reverb::Reverb() {
+
+ params.room_size=0.8;
+ params.damp=0.5;
+ params.dry=1.0;
+ params.wet=0.0;
+ params.mix_rate=44100;
+ params.extra_spread_base=0;
+ params.extra_spread=1.0;
+ params.predelay=150;
+ params.predelay_fb=0.4;
+ params.hpf=0;
+ hpf_h1=0;
+ hpf_h2=0;
+
+
+ input_buffer=memnew_arr(float,INPUT_BUFFER_MAX_SIZE);
+ echo_buffer=0;
+
+ configure_buffers();
+ update_parameters();
+
+
+}
+
+
+Reverb::~Reverb() {
+
+ memdelete_arr(input_buffer);
+ clear_buffers();
+}
+
+
diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h
new file mode 100644
index 0000000000..2c82be9156
--- /dev/null
+++ b/servers/audio/effects/reverb.h
@@ -0,0 +1,111 @@
+//
+// C++ Interface: reverb
+//
+// Description:
+//
+//
+// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef REVERB_H
+#define REVERB_H
+
+#include "typedefs.h"
+#include "os/memory.h"
+#include "audio_frame.h"
+
+class Reverb {
+public:
+ enum {
+ INPUT_BUFFER_MAX_SIZE=1024,
+
+ };
+private:
+ enum {
+
+ MAX_COMBS=8,
+ MAX_ALLPASS=4,
+ MAX_ECHO_MS=500
+
+ };
+
+
+
+ static const float comb_tunings[MAX_COMBS];
+ static const float allpass_tunings[MAX_ALLPASS];
+
+ struct Comb {
+
+ int size;
+ float *buffer;
+ float feedback;
+ float damp; //lowpass
+ float damp_h; //history
+ int pos;
+ int extra_spread_frames;
+
+ Comb() { size=0; buffer=0; feedback=0; damp_h=0; pos=0; }
+ };
+
+ struct AllPass {
+
+ int size;
+ float *buffer;
+ int pos;
+ int extra_spread_frames;
+ AllPass() { size=0; buffer=0; pos=0; }
+ };
+
+ Comb comb[MAX_COMBS];
+ AllPass allpass[MAX_ALLPASS];
+ float *input_buffer;
+ float *echo_buffer;
+ int echo_buffer_size;
+ int echo_buffer_pos;
+
+ float hpf_h1,hpf_h2;
+
+
+ struct Parameters {
+
+ float room_size;
+ float damp;
+ float wet;
+ float dry;
+ float mix_rate;
+ float extra_spread_base;
+ float extra_spread;
+ float predelay;
+ float predelay_fb;
+ float hpf;
+ } params;
+
+ void configure_buffers();
+ void update_parameters();
+ void clear_buffers();
+public:
+
+ void set_room_size(float p_size);
+ void set_damp(float p_damp);
+ void set_wet(float p_wet);
+ void set_dry(float p_dry);
+ void set_predelay(float p_predelay); // in ms
+ void set_predelay_feedback(float p_predelay_fb); // in ms
+ void set_highpass(float p_frq);
+ void set_mix_rate(float p_mix_rate);
+ void set_extra_spread(float p_spread);
+ void set_extra_spread_base(float p_sec);
+
+ void process(float *p_src,float *p_dst,int p_frames);
+
+ Reverb();
+
+ ~Reverb();
+
+};
+
+
+
+#endif
diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp
index 0050dbedeb..5e02f37679 100644
--- a/servers/audio/reverb_sw.cpp
+++ b/servers/audio/reverb_sw.cpp
@@ -100,145 +100,145 @@ struct ReverbParamsSW {
static ReverbParamsSW reverb_params_Room = {
0x26C0/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x6D80, 0x54B8, -0x4130, 0x0000, 0x0000, -0x4580,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x5800, 0x5300, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x01B4 - 0x007D, 0x0136 - 0x007D, 0x00B8 - 0x005B, 0x005C - 0x005B,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x04D6, 0x0333, 0x03F0, 0x0227, 0x0374, 0x01EF,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x0334, 0x01B5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x0000, 0x0000, 0x01B4, 0x0136, 0x00B8, 0x005C
};
static ReverbParamsSW reverb_params_StudioSmall = {
0x1F40/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x70F0, 0x4FA8, -0x4320, 0x4410, -0x3F10, -0x6400,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x5280, 0x4EC0, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x00B4 - 0x0033, 0x0080 - 0x0033, 0x004C - 0x0025, 0x0026 - 0x0025,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x03E4, 0x031B, 0x03A4, 0x02AF, 0x0372, 0x0266,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x031C, 0x025D, 0x025C, 0x018E, 0x022F, 0x0135, 0x01D2, 0x00B7,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x018F, 0x00B5, 0x00B4, 0x0080, 0x004C, 0x0026
};
static ReverbParamsSW reverb_params_StudioMedium = {
0x4840/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x70F0, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x4B40,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x5280, 0x4EC0, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x0264 - 0x00B1, 0x01B2 - 0x00B1, 0x0100 - 0x007F, 0x0080 - 0x007F,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x0904, 0x076B, 0x0824, 0x065F, 0x07A2, 0x0616,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x076C, 0x05ED, 0x05EC, 0x042E, 0x050F, 0x0305, 0x0462, 0x02B7,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x042F, 0x0265, 0x0264, 0x01B2, 0x0100, 0x0080
};
static ReverbParamsSW reverb_params_StudioLarge = {
0x6FE0/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x6F60, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x5980,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x5680, 0x52C0, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x031C - 0x00E3, 0x0238 - 0x00E3, 0x0154 - 0x00A9, 0x00AA - 0x00A9,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x0DFB, 0x0B58, 0x0D09, 0x0A3C, 0x0BD9, 0x0973,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x0B59, 0x08DA, 0x08D9, 0x05E9, 0x07EC, 0x04B0, 0x06EF, 0x03D2,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x05EA, 0x031D, 0x031C, 0x0238, 0x0154, 0x00AA
};
static ReverbParamsSW reverb_params_Hall = {
0xADE0/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x6000, 0x5000, 0x4C00, -0x4800, -0x4400, -0x4000,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x6000, 0x5C00, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x05C0 - 0x01A5, 0x041A - 0x01A5, 0x0274 - 0x0139, 0x013A - 0x0139,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x15BA, 0x11BB, 0x14C2, 0x10BD, 0x11BC, 0x0DC1,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x11C0, 0x0DC3, 0x0DC0, 0x09C1, 0x0BC4, 0x07C1, 0x0A00, 0x06CD,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x09C2, 0x05C1, 0x05C0, 0x041A, 0x0274, 0x013A
};
static ReverbParamsSW reverb_params_SpaceEcho = {
0xF6C0/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x7E00, 0x5000, -0x4C00, -0x5000, 0x4C00, -0x5000,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x6000, 0x5400, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x0AE0 - 0x033D, 0x07A2 - 0x033D, 0x0464 - 0x0231, 0x0232 - 0x0231,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x1ED6, 0x1A31, 0x1D14, 0x183B, 0x1BC2, 0x16B2,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x1A32, 0x15EF, 0x15EE, 0x1055, 0x1334, 0x0F2D, 0x11F6, 0x0C5D,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x1056, 0x0AE1, 0x0AE0, 0x07A2, 0x0464, 0x0232
};
static ReverbParamsSW reverb_params_Echo = {
0x18040/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, -0x7F00,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x0000, 0x0000, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x1004 - 0x0001, 0x1002 - 0x0001, 0x0004 - 0x0001, 0x0002 - 0x0001,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x1FFF, 0x0FFF, 0x1005, 0x0005, 0x0000, 0x0000,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x1005, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x0000, 0x0000, 0x1004, 0x1002, 0x0004, 0x0002
};
static ReverbParamsSW reverb_params_Delay = {
0x18040/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x7FFF, 0x7FFF, 0x0000, 0x0000, 0x0000, 0x0000,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x0000, 0x0000, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x1004 - 0x0001, 0x1002 - 0x0001, 0x0004 - 0x0001, 0x0002 - 0x0001,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x1FFF, 0x0FFF, 0x1005, 0x0005, 0x0000, 0x0000,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x1005, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x0000, 0x0000, 0x1004, 0x1002, 0x0004, 0x0002
};
static ReverbParamsSW reverb_params_HalfEcho = {
0x3C00/2,
-// gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
+ //gLPF gEcho0 gEcho1 gEcho2 gEcho3 gWall
0x70F0, 0x4FA8, -0x4320, 0x4510, -0x4110, -0x7B00,
-// gReva gRevb gInputL gInputR
+ //gReva gRevb gInputL gInputR
0x5F80, 0x54C0, -0x8000, -0x8000,
-// nRevaOldL nRevaOldR nRevbOldL nRevbOldR
+ //nRevaOldL nRevaOldR nRevbOldL nRevbOldR
0x0058 - 0x0017, 0x0040 - 0x0017, 0x0028 - 0x0013, 0x0014 - 0x0013,
-// nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
+ //nLwlNew nRwrNew nEcho0L nEcho0R nEcho1L nEcho1R
0x0371, 0x02AF, 0x02E5, 0x01DF, 0x02B0, 0x01D7,
-// nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
+ //nLwlOld nRwrOld nLwrNew nRwlNew nEcho2L nEcho2R nEcho3L nEcho3R
0x0358, 0x026A, 0x01D6, 0x011E, 0x012D, 0x00B1, 0x011F, 0x0059,
-// nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
+ //nLwrOld nRwlOld nRevaNewL nRevaNewR nRevbNewL nRevbNewR
0x01A0, 0x00E3, 0x0058, 0x0040, 0x0028, 0x0014
};
@@ -265,7 +265,7 @@ bool ReverbSW::process(int *p_input,int *p_output,int p_frames,int p_stereo_stri
// p_input must point to a non-looping buffer.
// BOTH p_input and p_output must be touched (use ClearModuleBuffer).
- // �������LOCAL MACROS ������۲
+ // LOCAL MACROS
#undef LM_SETSRCOFFSET
#define LM_SETSRCOFFSET(x) \
@@ -296,14 +296,14 @@ MULSHIFT_S32 ( x, current_params->y, 15 )
#undef LM_REVERB
#define LM_REVERB(x) reverb_buffer[ (x) + cSample ]
- // �������LOCAL VARIABLES ������۲
+ // LOCAL VARIABLES
unsigned int Offset;
int lwl, lwr, rwl, rwr;
-// unsigned char HZShift;
+ //unsigned char HZShift;
- // �������CODE ������۲
+ // CODE
lwl = state.lwl;
diff --git a/servers/audio/sample_manager_sw.cpp b/servers/audio/sample_manager_sw.cpp
deleted file mode 100644
index fe4cc36776..0000000000
--- a/servers/audio/sample_manager_sw.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/*************************************************************************/
-/* sample_manager_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "sample_manager_sw.h"
-
-#include "print_string.h"
-
-SampleManagerSW::~SampleManagerSW()
-{
-}
-
-
-
-RID SampleManagerMallocSW::sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length) {
-
- Sample *s = memnew( Sample );
- int datalen = p_length;
- if (p_format==AS::SAMPLE_FORMAT_PCM16)
- datalen*=2;
- else if (p_format==AS::SAMPLE_FORMAT_IMA_ADPCM) {
- if (datalen&1) {
- datalen++;
- }
- datalen/=2;
- datalen+=4;
- }
-
- if (p_stereo)
- datalen*=2;
-
-#define SAMPLE_EXTRA 16
-
- s->data = memalloc(datalen+SAMPLE_EXTRA); //help the interpolator by allocating a little more..
- for(int i=0;i<SAMPLE_EXTRA;i++) {
-
- uint8_t *data = (uint8_t*)s->data;
- data[datalen+i]=0;
- }
- if (!s->data) {
-
- memdelete(s);
- ERR_EXPLAIN("Cannot allocate sample of requested size.");
- ERR_FAIL_V(RID());
- }
-
- s->format=p_format;
- s->length=p_length;
- s->length_bytes=datalen;
- s->stereo=p_stereo;
- s->loop_begin=0;
- s->loop_end=0;
- s->loop_format=AS::SAMPLE_LOOP_NONE;
- s->mix_rate=44100;
-
- AudioServer::get_singleton()->lock();
- RID rid = sample_owner.make_rid(s);
- AudioServer::get_singleton()->unlock();
-
- return rid;
-}
-
-void SampleManagerMallocSW::sample_set_description(RID p_sample, const String& p_description) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
-
- s->description=p_description;
-}
-
-String SampleManagerMallocSW::sample_get_description(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,String());
-
- return s->description;
-}
-
-
-AS::SampleFormat SampleManagerMallocSW::sample_get_format(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,AS::SAMPLE_FORMAT_PCM8);
-
- return s->format;
-}
-
-bool SampleManagerMallocSW::sample_is_stereo(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,false);
-
- return s->stereo;
-
-}
-int SampleManagerMallocSW::sample_get_length(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,-1);
-
- return s->length;
-}
-
-void SampleManagerMallocSW::sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
-
- int buff_size=p_buffer.size();
- ERR_FAIL_COND(buff_size==0);
-
-
- ERR_EXPLAIN("Sample buffer size does not match sample size.");
- //print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size));
- ERR_FAIL_COND(s->length_bytes!=buff_size);
- PoolVector<uint8_t>::Read buffer_r=p_buffer.read();
- const uint8_t *src = buffer_r.ptr();
- uint8_t *dst = (uint8_t*)s->data;
- //print_line("set data: "+itos(s->length_bytes));
-
- for(int i=0;i<s->length_bytes;i++) {
-
- dst[i]=src[i];
- }
-
- switch(s->format) {
-
- case AS::SAMPLE_FORMAT_PCM8: {
-
- if (s->stereo) {
- dst[s->length]=dst[s->length-2];
- dst[s->length+1]=dst[s->length-1];
- } else {
-
- dst[s->length]=dst[s->length-1];
- }
-
- } break;
- case AS::SAMPLE_FORMAT_PCM16: {
-
- if (s->stereo) {
- dst[s->length]=dst[s->length-4];
- dst[s->length+1]=dst[s->length-3];
- dst[s->length+2]=dst[s->length-2];
- dst[s->length+3]=dst[s->length-1];
- } else {
-
- dst[s->length]=dst[s->length-2];
- dst[s->length+1]=dst[s->length-1];
- }
-
- } break;
-
- }
-
-
-
-}
-
-const PoolVector<uint8_t> SampleManagerMallocSW::sample_get_data(RID p_sample) const {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,PoolVector<uint8_t>());
-
- PoolVector<uint8_t> ret_buffer;
- ret_buffer.resize(s->length_bytes);
- PoolVector<uint8_t>::Write buffer_w=ret_buffer.write();
- uint8_t *dst = buffer_w.ptr();
- const uint8_t *src = (const uint8_t*)s->data;
-
- for(int i=0;i<s->length_bytes;i++) {
-
- dst[i]=src[i];
- }
-
- buffer_w = PoolVector<uint8_t>::Write(); //unlock
-
- return ret_buffer;
-}
-
-void *SampleManagerMallocSW::sample_get_data_ptr(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,NULL);
-
- return s->data;
-
-}
-
-void SampleManagerMallocSW::sample_set_mix_rate(RID p_sample,int p_rate) {
-
- ERR_FAIL_COND(p_rate<1);
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
-
- s->mix_rate=p_rate;
-
-
-}
-int SampleManagerMallocSW::sample_get_mix_rate(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,-1);
-
- return s->mix_rate;
-
-}
-void SampleManagerMallocSW::sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
-
- s->loop_format=p_format;
-
-}
-AS::SampleLoopFormat SampleManagerMallocSW::sample_get_loop_format(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,AS::SAMPLE_LOOP_NONE);
-
- return s->loop_format;
-}
-
-void SampleManagerMallocSW::sample_set_loop_begin(RID p_sample,int p_pos) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
- ERR_FAIL_INDEX(p_pos,s->length);
-
- s->loop_begin=p_pos;
-}
-int SampleManagerMallocSW::sample_get_loop_begin(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,-1);
-
- return s->loop_begin;
-}
-
-void SampleManagerMallocSW::sample_set_loop_end(RID p_sample,int p_pos) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
- if (p_pos>s->length)
- p_pos=s->length;
- s->loop_end=p_pos;
-
-}
-int SampleManagerMallocSW::sample_get_loop_end(RID p_sample) const {
-
- const Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND_V(!s,-1);
-
- return s->loop_end;
-}
-
-bool SampleManagerMallocSW::is_sample(RID p_sample) const {
-
- return sample_owner.owns(p_sample);
-
-}
-void SampleManagerMallocSW::free(RID p_sample) {
-
- Sample *s = sample_owner.get(p_sample);
- ERR_FAIL_COND(!s);
- AudioServer::get_singleton()->lock();
- sample_owner.free(p_sample);
- AudioServer::get_singleton()->unlock();
-
- memfree(s->data);
- memdelete(s);
-
-}
-
-SampleManagerMallocSW::SampleManagerMallocSW() {
-
-
-}
-
-SampleManagerMallocSW::~SampleManagerMallocSW() {
-
- // check for sample leakage
- List<RID> owned_list;
- sample_owner.get_owned_list(&owned_list);
-
- while(owned_list.size()) {
-
- Sample *s = sample_owner.get(owned_list.front()->get());
- String err="Leaked sample of size: "+itos(s->length_bytes)+" description: "+s->description;
- ERR_PRINT(err.utf8().get_data());
- free(owned_list.front()->get());
- owned_list.pop_front();
- }
-
-}
diff --git a/servers/audio/sample_manager_sw.h b/servers/audio/sample_manager_sw.h
deleted file mode 100644
index 93cad96f1a..0000000000
--- a/servers/audio/sample_manager_sw.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*************************************************************************/
-/* sample_manager_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SAMPLE_MANAGER_SW_H
-#define SAMPLE_MANAGER_SW_H
-
-#include "servers/audio_server.h"
-
-class SampleManagerSW {
-public:
-
- /* SAMPLE API */
-
- virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length)=0;
-
- virtual void sample_set_description(RID p_sample, const String& p_description)=0;
- virtual String sample_get_description(RID p_sample) const=0;
-
- virtual AS::SampleFormat sample_get_format(RID p_sample) const=0;
- virtual bool sample_is_stereo(RID p_sample) const=0;
- virtual int sample_get_length(RID p_sample) const=0;
-
- virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer)=0;
- virtual const PoolVector<uint8_t> sample_get_data(RID p_sample) const=0;
-
- virtual void *sample_get_data_ptr(RID p_sample) const=0;
-
- virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0;
- virtual int sample_get_mix_rate(RID p_sample) const=0;
-
- virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format)=0;
- virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const=0;
-
- virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_begin(RID p_sample) const=0;
-
- virtual void sample_set_loop_end(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_end(RID p_sample) const=0;
-
- virtual bool is_sample(RID) const=0;
- virtual void free(RID p_sample)=0;
-
-
-
- virtual ~SampleManagerSW();
-};
-
-
-class SampleManagerMallocSW : public SampleManagerSW {
-
-
- struct Sample : public RID_Data {
-
- void *data;
- int length;
- int length_bytes;
- AS::SampleFormat format;
- bool stereo;
- AS::SampleLoopFormat loop_format;
- int loop_begin;
- int loop_end;
- int mix_rate;
- String description;
- };
-
- mutable RID_Owner<Sample> sample_owner;
-public:
-
- /* SAMPLE API */
-
- virtual RID sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length);
-
- virtual void sample_set_description(RID p_sample, const String& p_description);
- virtual String sample_get_description(RID p_sample) const;
-
- virtual AS::SampleFormat sample_get_format(RID p_sample) const;
- virtual bool sample_is_stereo(RID p_sample) const;
- virtual int sample_get_length(RID p_sample) const;
-
- virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer);
- virtual const PoolVector<uint8_t> sample_get_data(RID p_sample) const;
-
- virtual void *sample_get_data_ptr(RID p_sample) const;
-
- virtual void sample_set_mix_rate(RID p_sample,int p_rate);
- virtual int sample_get_mix_rate(RID p_sample) const;
-
- virtual void sample_set_loop_format(RID p_sample,AS::SampleLoopFormat p_format);
- virtual AS::SampleLoopFormat sample_get_loop_format(RID p_sample) const;
-
- virtual void sample_set_loop_begin(RID p_sample,int p_pos);
- virtual int sample_get_loop_begin(RID p_sample) const;
-
- virtual void sample_set_loop_end(RID p_sample,int p_pos);
- virtual int sample_get_loop_end(RID p_sample) const;
-
- virtual bool is_sample(RID) const;
- virtual void free(RID p_sample);
-
- SampleManagerMallocSW();
- virtual ~SampleManagerMallocSW();
-};
-
-#endif // SAMPLE_MANAGER_SW_H
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 5037b19924..192d958a64 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -27,178 +27,1195 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_server.h"
-#include "globals.h"
+#include "global_config.h"
+#include "os/os.h"
+#include "servers/audio/effects/audio_effect_compressor.h"
+#include "io/resource_loader.h"
+#include "os/file_access.h"
+#ifdef TOOLS_ENABLED
-void AudioMixer::audio_mixer_chunk_call(int p_frames) {
+#define MARK_EDITED set_edited(true);
- AudioServer::get_singleton()->audio_mixer_chunk_callback(p_frames);
+#else
+
+#define MARK_EDITED
+
+#endif
+
+AudioDriver *AudioDriver::singleton=NULL;
+AudioDriver *AudioDriver::get_singleton() {
+
+ return singleton;
}
-AudioMixer *AudioServer::EventStream::get_mixer() const {
+void AudioDriver::set_singleton() {
- return AudioServer::get_singleton()->get_mixer();
+ singleton=this;
}
-AudioServer *AudioServer::singleton=NULL;
+void AudioDriver::audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time) {
-AudioServer *AudioServer::get_singleton() {
- return singleton;
+ if (p_update_mix_time)
+ update_mix_time(p_frames);
+
+ if (AudioServer::get_singleton())
+ AudioServer::get_singleton()->_driver_process(p_frames,p_buffer);
+}
+
+
+
+void AudioDriver::update_mix_time(int p_frames) {
+
+ _mix_amount+=p_frames;
+ _last_mix_time=OS::get_singleton()->get_ticks_usec();
+}
+
+double AudioDriver::get_mix_time() const {
+
+ double total = (OS::get_singleton()->get_ticks_usec() - _last_mix_time) / 1000000.0;
+ total+=_mix_amount/(double)get_mix_rate();
+ return total;
+
+}
+
+
+AudioDriver::AudioDriver() {
+
+ _last_mix_time=0;
+ _mix_amount=0;
+}
+
+
+AudioDriver *AudioDriverManager::drivers[MAX_DRIVERS];
+int AudioDriverManager::driver_count=0;
+
+
+void AudioDriverManager::add_driver(AudioDriver *p_driver) {
+
+ ERR_FAIL_COND(driver_count>=MAX_DRIVERS);
+ drivers[driver_count++]=p_driver;
}
-void AudioServer::sample_set_signed_data(RID p_sample, const PoolVector<float>& p_buffer) {
+int AudioDriverManager::get_driver_count() {
- SampleFormat format = sample_get_format(p_sample);
+ return driver_count;
+}
+AudioDriver *AudioDriverManager::get_driver(int p_driver) {
+
+ ERR_FAIL_INDEX_V(p_driver,driver_count,NULL);
+ return drivers[p_driver];
+}
+
+
+//////////////////////////////////////////////
+//////////////////////////////////////////////
+//////////////////////////////////////////////
+//////////////////////////////////////////////
+
+void AudioServer::_driver_process(int p_frames,int32_t* p_buffer) {
+
+ int todo=p_frames;
- ERR_EXPLAIN("IMA ADPCM is not supported.");
- ERR_FAIL_COND(format==SAMPLE_FORMAT_IMA_ADPCM);
+ while(todo) {
- int len = p_buffer.size();
- ERR_FAIL_COND( len == 0 );
+ if (to_mix==0) {
+ _mix_step();
+ }
- PoolVector<uint8_t> data;
- PoolVector<uint8_t>::Write w;
- PoolVector<float>::Read r = p_buffer.read();
+ int to_copy = MIN(to_mix,todo);
- switch(format) {
- case SAMPLE_FORMAT_PCM8: {
- data.resize(len);
- w=data.write();
+ Bus *master = buses[0];
- int8_t *samples8 = (int8_t*)w.ptr();
+ int from = buffer_size-to_mix;
+ int from_buf=p_frames-todo;
- for(int i=0;i<len;i++) {
+ //master master, send to output
+ int cs = master->channels.size();
+ for(int k=0;k<cs;k++) {
- float sample = Math::floor( r[i] * (1<<8) );
- if (sample<-128)
- sample=-128;
- else if (sample>127)
- sample=127;
- samples8[i]=sample;
+ if (master->channels[k].active) {
+
+ AudioFrame *buf = master->channels[k].buffer.ptr();
+
+ for(int j=0;j<to_copy;j++) {
+
+ float l = CLAMP(buf[from+j].l,-1.0,1.0);
+ int32_t vl = l*((1<<20)-1);
+ p_buffer[(from_buf+j)*(cs*2)+k*2+0]=vl<<11;
+
+ float r = CLAMP(buf[from+j].r,-1.0,1.0);
+ int32_t vr = r*((1<<20)-1);
+ p_buffer[(from_buf+j)*(cs*2)+k*2+1]=vr<<11;
+ }
+
+ } else {
+ for(int j=0;j<to_copy;j++) {
+
+ p_buffer[(from_buf+j)*(cs*2)+k*2+0]=0;
+ p_buffer[(from_buf+j)*(cs*2)+k*2+1]=0;
+ }
}
- } break;
- case SAMPLE_FORMAT_PCM16: {
- data.resize(len*2);
- w=data.write();
- int16_t *samples16 = (int16_t*)w.ptr();
+ }
+
+ todo-=to_copy;
+ to_mix-=to_copy;
+
+ }
+
+}
+
+void AudioServer::_mix_step() {
+
+ for(int i=0;i<buses.size();i++) {
+ Bus *bus = buses[i];
+ bus->index_cache=i; //might be moved around by editor, so..
+ for(int k=0;k<bus->channels.size();k++) {
+
+ bus->channels[k].used=false;
+ }
+ }
+
+ //make callbacks for mixing the audio
+ for (Set<CallbackItem>::Element *E=callbacks.front();E;E=E->next()) {
+
+ E->get().callback(E->get().userdata);
+ }
+
+ for(int i=buses.size()-1;i>=0;i--) {
+ //go bus by bus
+ Bus *bus = buses[i];
+
+
+ for(int k=0;k<bus->channels.size();k++) {
+
+ if (bus->channels[k].active && !bus->channels[k].used) {
+ //buffer was not used, but it's still active, so it must be cleaned
+ AudioFrame *buf = bus->channels[k].buffer.ptr();
+
+ for(uint32_t j=0;j<buffer_size;j++) {
+
+ buf[j]=AudioFrame(0,0);
+ }
+ }
+
+ }
+
+
+ //process effects
+ for(int j=0;j<bus->effects.size();j++) {
+
+ if (!bus->effects[j].enabled)
+ continue;
+
+ for(int k=0;k<bus->channels.size();k++) {
+
+ if (!bus->channels[k].active)
+ continue;
+ bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(),temp_buffer[k].ptr(),buffer_size);
+ }
+
+ //swap buffers, so internal buffer always has the right data
+ for(int k=0;k<bus->channels.size();k++) {
+
+ if (!buses[i]->channels[k].active)
+ continue;
+ SWAP(bus->channels[k].buffer,temp_buffer[k]);
+ }
+ }
+
+ //process send
+
+ Bus *send=NULL;
+
+ if (i>0) {
+ //everything has a send save for master bus
+ if (!bus_map.has(bus->send)) {
+ send=buses[0];
+ } else {
+ send=bus_map[bus->send];
+ if (send->index_cache>=bus->index_cache) { //invalid, send to master
+ send=buses[0];
+ }
+ }
+ }
+
+
+ for(int k=0;k<bus->channels.size();k++) {
+
+ if (!bus->channels[k].active)
+ continue;
+
+ AudioFrame *buf = bus->channels[k].buffer.ptr();
+
+
+ AudioFrame peak = AudioFrame(0,0);
+ for(uint32_t j=0;j<buffer_size;j++) {
+ float l = ABS(buf[j].l);
+ if (l>peak.l) {
+ peak.l=l;
+ }
+ float r = ABS(buf[j].r);
+ if (r>peak.r) {
+ peak.r=r;
+ }
+ }
+
+ bus->channels[k].peak_volume=AudioFrame(Math::linear2db(peak.l+0.0000000001),Math::linear2db(peak.r+0.0000000001));
+
+
+ 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)) {
+ 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;
+ continue; //went inactive, dont mix.
+ }
+ }
+
+ if (send) {
+ //if not master bus, send
+ AudioFrame *target_buf = thread_get_channel_mix_buffer(send->index_cache,k);
+
+ for(uint32_t j=0;j<buffer_size;j++) {
+ target_buf[j]+=buf[j];
+ }
+ }
+
+ }
+
+ }
+
+
+ mix_frames+=buffer_size;
+ to_mix=buffer_size;
+
+}
+
+AudioFrame *AudioServer::thread_get_channel_mix_buffer(int p_bus,int p_buffer) {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),NULL);
+ ERR_FAIL_INDEX_V(p_buffer,buses[p_bus]->channels.size(),NULL);
+
+ AudioFrame *data = buses[p_bus]->channels[p_buffer].buffer.ptr();
+
+
+ if (!buses[p_bus]->channels[p_buffer].used) {
+ buses[p_bus]->channels[p_buffer].used=true;
+ buses[p_bus]->channels[p_buffer].active=true;
+ buses[p_bus]->channels[p_buffer].last_mix_with_audio=mix_frames;
+ for(uint32_t i=0;i<buffer_size;i++) {
+ data[i]=AudioFrame(0,0);
+ }
+ }
+
+ return data;
+}
+
+int AudioServer::thread_get_mix_buffer_size() const {
+
+ return buffer_size;
+}
+
+int AudioServer::thread_find_bus_index(const StringName& p_name) {
+
+ if (bus_map.has(p_name)) {
+ return bus_map[p_name]->index_cache;
+ } else {
+ return 0;
+ }
+
+}
+
+void AudioServer::set_bus_count(int p_count) {
+
+ ERR_FAIL_COND(p_count<1);
+ ERR_FAIL_INDEX(p_count,256);
+
+ MARK_EDITED
+
+ lock();
+ int cb = buses.size();
+
+ if (p_count<buses.size()) {
+ for(int i=p_count;i<buses.size();i++) {
+ bus_map.erase(buses[i]->name);
+ memdelete(buses[i]);
+ }
+ }
+
+ buses.resize(p_count);
+
+ for(int i=cb;i<buses.size();i++) {
+
+ String attempt="New Bus";
+ int attempts=1;
+ while(true) {
+
+ bool name_free=true;
+ for(int j=0;j<i;j++) {
+
+ if (buses[j]->name==attempt) {
+ name_free=false;
+ break;
+ }
+ }
+
+ if (!name_free) {
+ attempts++;
+ attempt="New Bus " +itos(attempts);
+ } else {
+ break;
+ }
+
+ }
+
+
+ buses[i]=memnew(Bus);
+ buses[i]->channels.resize(_get_channel_count());
+ for(int j=0;j<_get_channel_count();j++) {
+ buses[i]->channels[j].buffer.resize(buffer_size);
+ }
+ buses[i]->name=attempt;
+ buses[i]->solo=false;
+ buses[i]->mute=false;
+ buses[i]->bypass=false;
+ buses[i]->volume_db=0;
+ if (i>0) {
+ buses[i]->send="Master";
+ }
+
+ bus_map[attempt]=buses[i];
+
+ }
+
+ unlock();
+
+ emit_signal("bus_layout_changed");
+}
+
+
+void AudioServer::remove_bus(int p_index) {
- for(int i=0;i<len;i++) {
+ ERR_FAIL_INDEX(p_index,buses.size());
+ ERR_FAIL_COND(p_index==0);
- float sample = Math::floor( r[i] * (1<<16) );
- if (sample<-32768)
- sample=-32768;
- else if (sample>32767)
- sample=32767;
- samples16[i]=sample;
+ MARK_EDITED
+
+ lock();
+ bus_map.erase(buses[p_index]->name);
+ memdelete(buses[p_index]);
+ buses.remove(p_index);
+ unlock();
+}
+
+void AudioServer::add_bus(int p_at_pos) {
+
+ MARK_EDITED
+
+ if (p_at_pos>=buses.size()) {
+ p_at_pos=-1;
+ } else if (p_at_pos==0) {
+ if (buses.size()>1)
+ p_at_pos=1;
+ else
+ p_at_pos=-1;
+ }
+
+ String attempt="New Bus";
+ int attempts=1;
+ while(true) {
+
+ bool name_free=true;
+ for(int j=0;j<buses.size();j++) {
+
+ if (buses[j]->name==attempt) {
+ name_free=false;
+ break;
}
+ }
+
+ if (!name_free) {
+ attempts++;
+ attempt="New Bus " +itos(attempts);
+ } else {
+ break;
+ }
+
+ }
+
+ Bus* bus =memnew(Bus);
+ bus->channels.resize(_get_channel_count());
+ for(int j=0;j<_get_channel_count();j++) {
+ bus->channels[j].buffer.resize(buffer_size);
+ }
+ bus->name=attempt;
+ bus->solo=false;
+ bus->mute=false;
+ bus->bypass=false;
+ bus->volume_db=0;
+
+ bus_map[attempt]=bus;
+
+ if (p_at_pos==-1)
+ buses.push_back(bus);
+ else
+ buses.insert(p_at_pos,bus);
+
+}
+
+void AudioServer::move_bus(int p_bus,int p_to_pos) {
+
+ ERR_FAIL_COND(p_bus<1 || p_bus>=buses.size());
+ ERR_FAIL_COND(p_to_pos!=-1 && (p_to_pos<1 || p_to_pos>buses.size()));
+
+ MARK_EDITED
+
+ if (p_bus==p_to_pos)
+ return;
+
+ Bus *bus = buses[p_bus];
+ buses.remove(p_bus);
+
+ if (p_to_pos==-1) {
+ buses.push_back(bus);
+ } else if (p_to_pos<p_bus) {
+ buses.insert(p_to_pos,bus);
+ } else {
+ buses.insert(p_to_pos-1,bus);
+ }
+}
+
+int AudioServer::get_bus_count() const {
+
+ return buses.size();
+}
+
+
+void AudioServer::set_bus_name(int p_bus,const String& p_name) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+ if (p_bus==0 && p_name!="Master")
+ return; //bus 0 is always master
+
+ MARK_EDITED
+
+ lock();
+
+ if (buses[p_bus]->name==p_name) {
+ unlock();
+ return;
+ }
+
+ String attempt=p_name;
+ int attempts=1;
+
+ while(true) {
+
+ bool name_free=true;
+ for(int i=0;i<buses.size();i++) {
+
+ if (buses[i]->name==attempt) {
+ name_free=false;
+ break;
+ }
+ }
+
+ if (name_free) {
+ break;
+ }
+
+ attempts++;
+ attempt=p_name+" "+itos(attempts);
+ }
+ bus_map.erase(buses[p_bus]->name);
+ buses[p_bus]->name=attempt;
+ bus_map[attempt]=buses[p_bus];
+ unlock();
+
+ emit_signal("bus_layout_changed");
+
+}
+String AudioServer::get_bus_name(int p_bus) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),String());
+ return buses[p_bus]->name;
+}
+
+void AudioServer::set_bus_volume_db(int p_bus,float p_volume_db) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+ buses[p_bus]->volume_db=p_volume_db;
+
+}
+float AudioServer::get_bus_volume_db(int p_bus) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),0);
+ return buses[p_bus]->volume_db;
+
+}
+
+void AudioServer::set_bus_send(int p_bus,const StringName& p_send) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+ buses[p_bus]->send=p_send;
+
+}
+
+StringName AudioServer::get_bus_send(int p_bus) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),StringName());
+ return buses[p_bus]->send;
+
+}
+
+
+void AudioServer::set_bus_solo(int p_bus,bool p_enable) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+ buses[p_bus]->solo=p_enable;
+
+}
+
+bool AudioServer::is_bus_solo(int p_bus) const{
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),false);
+
+ return buses[p_bus]->solo;
+
+}
+
+void AudioServer::set_bus_mute(int p_bus,bool p_enable){
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+ buses[p_bus]->mute=p_enable;
+}
+bool AudioServer::is_bus_mute(int p_bus) const{
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),false);
+
+ return buses[p_bus]->mute;
+
+}
+
+void AudioServer::set_bus_bypass_effects(int p_bus,bool p_enable){
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+ buses[p_bus]->bypass=p_enable;
+}
+bool AudioServer::is_bus_bypassing_effects(int p_bus) const{
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),false);
+
+ return buses[p_bus]->bypass;
+
+}
+
+
+void AudioServer::_update_bus_effects(int p_bus) {
+
+ for(int i=0;i<buses[p_bus]->channels.size();i++) {
+ buses[p_bus]->channels[i].effect_instances.resize(buses[p_bus]->effects.size());
+ for(int j=0;j<buses[p_bus]->effects.size();j++) {
+ Ref<AudioEffectInstance> fx = buses[p_bus]->effects[j].effect->instance();
+ if (fx->cast_to<AudioEffectCompressorInstance>()) {
+ fx->cast_to<AudioEffectCompressorInstance>()->set_current_channel(i);
+ }
+ buses[p_bus]->channels[i].effect_instances[j]=fx;
+
+ }
+ }
+}
+
+
+void AudioServer::add_bus_effect(int p_bus,const Ref<AudioEffect>& p_effect,int p_at_pos) {
+
+ ERR_FAIL_COND(p_effect.is_null());
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+
+ lock();
+
+ Bus::Effect fx;
+ fx.effect=p_effect;
+ //fx.instance=p_effect->instance();
+ fx.enabled=true;
+
+ if (p_at_pos>=buses[p_bus]->effects.size() || p_at_pos<0) {
+ buses[p_bus]->effects.push_back(fx);
+ } else {
+ buses[p_bus]->effects.insert(p_at_pos,fx);
+ }
+
+ _update_bus_effects(p_bus);
+
+ unlock();
+}
+
+
+void AudioServer::remove_bus_effect(int p_bus,int p_effect) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+
+ MARK_EDITED
+
+
+ lock();
+
+ buses[p_bus]->effects.remove(p_effect);
+ _update_bus_effects(p_bus);
+
+ unlock();
+}
+
+int AudioServer::get_bus_effect_count(int p_bus) {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),0);
+
+ return buses[p_bus]->effects.size();
+
+}
+
+Ref<AudioEffect> AudioServer::get_bus_effect(int p_bus,int p_effect) {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),Ref<AudioEffect>());
+ ERR_FAIL_INDEX_V(p_effect,buses[p_bus]->effects.size(),Ref<AudioEffect>());
+
+ return buses[p_bus]->effects[p_effect].effect;
+
+}
+
+void AudioServer::swap_bus_effects(int p_bus,int p_effect,int p_by_effect) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+ ERR_FAIL_INDEX(p_effect,buses[p_bus]->effects.size());
+ ERR_FAIL_INDEX(p_by_effect,buses[p_bus]->effects.size());
+
+ MARK_EDITED
+
+
+ lock();
+ SWAP( buses[p_bus]->effects[p_effect], buses[p_bus]->effects[p_by_effect] );
+ _update_bus_effects(p_bus);
+ unlock();
+}
+
+void AudioServer::set_bus_effect_enabled(int p_bus,int p_effect,bool p_enabled) {
+
+ ERR_FAIL_INDEX(p_bus,buses.size());
+ ERR_FAIL_INDEX(p_effect,buses[p_bus]->effects.size());
+
+ MARK_EDITED
+
+
+ buses[p_bus]->effects[p_effect].enabled=p_enabled;
+
+}
+bool AudioServer::is_bus_effect_enabled(int p_bus,int p_effect) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),false);
+ ERR_FAIL_INDEX_V(p_effect,buses[p_bus]->effects.size(),false);
+ return buses[p_bus]->effects[p_effect].enabled;
+
+}
+
+
+float AudioServer::get_bus_peak_volume_left_db(int p_bus,int p_channel) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),0);
+ ERR_FAIL_INDEX_V(p_channel,buses[p_bus]->channels.size(),0);
+
+ return buses[p_bus]->channels[p_channel].peak_volume.l;
+
+}
+float AudioServer::get_bus_peak_volume_right_db(int p_bus,int p_channel) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),0);
+ ERR_FAIL_INDEX_V(p_channel,buses[p_bus]->channels.size(),0);
+
+ return buses[p_bus]->channels[p_channel].peak_volume.r;
+
+}
+
+bool AudioServer::is_bus_channel_active(int p_bus,int p_channel) const {
+
+ ERR_FAIL_INDEX_V(p_bus,buses.size(),false);
+ ERR_FAIL_INDEX_V(p_channel,buses[p_bus]->channels.size(),false);
+
+ return buses[p_bus]->channels[p_channel].active;
+
+}
+
+void AudioServer::init() {
+
+ channel_disable_treshold_db=GLOBAL_DEF("audio/channel_disable_treshold_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() ) {
+ case SPEAKER_MODE_STEREO: {
+ temp_buffer.resize(1);
+ } break;
+ case SPEAKER_SURROUND_51: {
+ temp_buffer.resize(3);
+ } break;
+ case SPEAKER_SURROUND_71: {
+ temp_buffer.resize(4);
} break;
}
- w = PoolVector<uint8_t>::Write();
+ for(int i=0;i<temp_buffer.size();i++) {
+ temp_buffer[i].resize(buffer_size);
+ }
+
+ mix_count=0;
+ set_bus_count(1);;
+ set_bus_name(0,"Master");
- sample_set_data(p_sample,data);
+ if (AudioDriver::get_singleton())
+ AudioDriver::get_singleton()->start();
+#ifdef TOOLS_ENABLED
+ set_edited(false); //avoid editors from thinking this was edited
+#endif
}
-void AudioServer::_bind_methods() {
+void AudioServer::load_default_bus_layout() {
- ClassDB::bind_method(_MD("sample_create","format","stereo","length"), &AudioServer::sample_create );
- ClassDB::bind_method(_MD("sample_set_description","sample","description"), &AudioServer::sample_set_description );
- ClassDB::bind_method(_MD("sample_get_description","sample"), &AudioServer::sample_get_description );
+ if (FileAccess::exists("res://default_bus_layout.tres")) {
+ Ref<AudioBusLayout> default_layout = ResourceLoader::load("res://default_bus_layout.tres");
+ if (default_layout.is_valid()) {
+ set_bus_layout(default_layout);
+ }
+ }
- ClassDB::bind_method(_MD("sample_get_format","sample"), &AudioServer::sample_get_format );
- ClassDB::bind_method(_MD("sample_is_stereo","sample"), &AudioServer::sample_is_stereo );
- ClassDB::bind_method(_MD("sample_get_length","sample"), &AudioServer::sample_get_length );
+}
- ClassDB::bind_method(_MD("sample_set_signed_data","sample","data"), &AudioServer::sample_set_signed_data );
- ClassDB::bind_method(_MD("sample_set_data","sample","data"), &AudioServer::sample_set_data );
- ClassDB::bind_method(_MD("sample_get_data","sample"), &AudioServer::sample_get_data );
+void AudioServer::finish() {
- ClassDB::bind_method(_MD("sample_set_mix_rate","sample","mix_rate"), &AudioServer::sample_set_mix_rate );
- ClassDB::bind_method(_MD("sample_get_mix_rate","sample"), &AudioServer::sample_get_mix_rate );
+ for(int i=0;i<buses.size();i++) {
+ memdelete(buses[i]);
+ }
- ClassDB::bind_method(_MD("sample_set_loop_format","sample","loop_format"), &AudioServer::sample_set_loop_format );
- ClassDB::bind_method(_MD("sample_get_loop_format","sample"), &AudioServer::sample_get_loop_format );
+ buses.clear();
+}
+void AudioServer::update() {
- ClassDB::bind_method(_MD("sample_set_loop_begin","sample","pos"), &AudioServer::sample_set_loop_begin );
- ClassDB::bind_method(_MD("sample_get_loop_begin","sample"), &AudioServer::sample_get_loop_begin );
+}
- ClassDB::bind_method(_MD("sample_set_loop_end","sample","pos"), &AudioServer::sample_set_loop_end );
- ClassDB::bind_method(_MD("sample_get_loop_end","sample"), &AudioServer::sample_get_loop_end );
+/* MISC config */
+void AudioServer::lock() {
+ AudioDriver::get_singleton()->lock();
+}
+void AudioServer::unlock() {
- ClassDB::bind_method(_MD("voice_create"), &AudioServer::voice_create );
- ClassDB::bind_method(_MD("voice_play","voice","sample"), &AudioServer::voice_play );
- ClassDB::bind_method(_MD("voice_set_volume","voice","volume"), &AudioServer::voice_set_volume );
- ClassDB::bind_method(_MD("voice_set_pan","voice","pan","depth","height"), &AudioServer::voice_set_pan,DEFVAL(0),DEFVAL(0) );
- ClassDB::bind_method(_MD("voice_set_filter","voice","type","cutoff","resonance","gain"), &AudioServer::voice_set_filter,DEFVAL(0) );
- ClassDB::bind_method(_MD("voice_set_chorus","voice","chorus"), &AudioServer::voice_set_chorus );
- ClassDB::bind_method(_MD("voice_set_reverb","voice","room","reverb"), &AudioServer::voice_set_reverb );
- ClassDB::bind_method(_MD("voice_set_mix_rate","voice","rate"), &AudioServer::voice_set_mix_rate );
- ClassDB::bind_method(_MD("voice_set_positional","voice","enabled"), &AudioServer::voice_set_positional );
+ AudioDriver::get_singleton()->unlock();
+}
- ClassDB::bind_method(_MD("voice_get_volume","voice"), &AudioServer::voice_get_volume );
- ClassDB::bind_method(_MD("voice_get_pan","voice"), &AudioServer::voice_get_pan );
- ClassDB::bind_method(_MD("voice_get_pan_height","voice"), &AudioServer::voice_get_pan_height );
- ClassDB::bind_method(_MD("voice_get_pan_depth","voice"), &AudioServer::voice_get_pan_depth );
- ClassDB::bind_method(_MD("voice_get_filter_type","voice"), &AudioServer::voice_get_filter_type );
- ClassDB::bind_method(_MD("voice_get_filter_cutoff","voice"), &AudioServer::voice_get_filter_cutoff );
- ClassDB::bind_method(_MD("voice_get_filter_resonance","voice"), &AudioServer::voice_get_filter_resonance );
- ClassDB::bind_method(_MD("voice_get_chorus","voice"), &AudioServer::voice_get_chorus );
- ClassDB::bind_method(_MD("voice_get_reverb_type","voice"), &AudioServer::voice_get_reverb_type );
- ClassDB::bind_method(_MD("voice_get_reverb","voice"), &AudioServer::voice_get_reverb );
- ClassDB::bind_method(_MD("voice_get_mix_rate","voice"), &AudioServer::voice_get_mix_rate );
- ClassDB::bind_method(_MD("voice_is_positional","voice"), &AudioServer::voice_is_positional );
- ClassDB::bind_method(_MD("voice_stop","voice"), &AudioServer::voice_stop );
+AudioServer::SpeakerMode AudioServer::get_speaker_mode() const {
- ClassDB::bind_method(_MD("free_rid","rid"), &AudioServer::free );
+ return (AudioServer::SpeakerMode)AudioDriver::get_singleton()->get_speaker_mode();
+}
+float AudioServer::get_mix_rate() const {
+
+ return AudioDriver::get_singleton()->get_mix_rate();
+}
- ClassDB::bind_method(_MD("set_stream_global_volume_scale","scale"), &AudioServer::set_stream_global_volume_scale );
- ClassDB::bind_method(_MD("get_stream_global_volume_scale"), &AudioServer::get_stream_global_volume_scale );
+float AudioServer::read_output_peak_db() const {
- ClassDB::bind_method(_MD("set_fx_global_volume_scale","scale"), &AudioServer::set_fx_global_volume_scale );
- ClassDB::bind_method(_MD("get_fx_global_volume_scale"), &AudioServer::get_fx_global_volume_scale );
+ return 0;
+}
- ClassDB::bind_method(_MD("set_event_voice_global_volume_scale","scale"), &AudioServer::set_event_voice_global_volume_scale );
- ClassDB::bind_method(_MD("get_event_voice_global_volume_scale"), &AudioServer::get_event_voice_global_volume_scale );
+AudioServer *AudioServer::get_singleton() {
+
+ return singleton;
+}
+
+double AudioServer::get_mix_time() const {
+
+ return 0;
+}
+double AudioServer::get_output_delay() const {
+
+ return 0;
+}
- BIND_CONSTANT( SAMPLE_FORMAT_PCM8 );
- BIND_CONSTANT( SAMPLE_FORMAT_PCM16 );
- BIND_CONSTANT( SAMPLE_FORMAT_IMA_ADPCM );
+AudioServer* AudioServer::singleton=NULL;
- BIND_CONSTANT( SAMPLE_LOOP_NONE );
- BIND_CONSTANT( SAMPLE_LOOP_FORWARD );
- BIND_CONSTANT( SAMPLE_LOOP_PING_PONG );
- BIND_CONSTANT( FILTER_NONE );
- BIND_CONSTANT( FILTER_LOWPASS );
- BIND_CONSTANT( FILTER_BANDPASS );
- BIND_CONSTANT( FILTER_HIPASS );
- BIND_CONSTANT( FILTER_NOTCH );
- BIND_CONSTANT( FILTER_BANDLIMIT ); ///< cutoff is LP resonace is HP
- BIND_CONSTANT( REVERB_SMALL );
- BIND_CONSTANT( REVERB_MEDIUM );
- BIND_CONSTANT( REVERB_LARGE );
- BIND_CONSTANT( REVERB_HALL );
- GLOBAL_DEF("audio/stream_buffering_ms",500);
- GLOBAL_DEF("audio/video_delay_compensation_ms",300);
+void* AudioServer::audio_data_alloc(uint32_t p_data_len,const uint8_t *p_from_data) {
+ void * ad = memalloc( p_data_len );
+ ERR_FAIL_COND_V(!ad,NULL);
+ if (p_from_data) {
+ copymem(ad,p_from_data,p_data_len);
+ }
+
+ audio_data_lock->lock();
+ audio_data[ad]=p_data_len;
+ audio_data_total_mem+=p_data_len;
+ audio_data_max_mem=MAX(audio_data_total_mem,audio_data_max_mem);
+ audio_data_lock->unlock();
+
+ return ad;
+}
+
+void AudioServer::audio_data_free(void* p_data) {
+
+ audio_data_lock->lock();
+ if (!audio_data.has(p_data)) {
+ audio_data_lock->unlock();
+ ERR_FAIL();
+ }
+
+ audio_data_total_mem-=audio_data[p_data];
+ audio_data.erase(p_data);
+ memfree(p_data);
+ audio_data_lock->unlock();
+
+
+}
+
+size_t AudioServer::audio_data_get_total_memory_usage() const{
+
+ return audio_data_total_mem;
+}
+size_t AudioServer::audio_data_get_max_memory_usage() const{
+
+ return audio_data_max_mem;
+
+}
+
+void AudioServer::add_callback(AudioCallback p_callback,void *p_userdata) {
+ lock();
+ CallbackItem ci;
+ ci.callback=p_callback;
+ ci.userdata=p_userdata;
+ callbacks.insert(ci);
+ unlock();
+}
+
+void AudioServer::remove_callback(AudioCallback p_callback,void *p_userdata) {
+
+ lock();
+ CallbackItem ci;
+ ci.callback=p_callback;
+ ci.userdata=p_userdata;
+ callbacks.erase(ci);
+ unlock();
+
+}
+
+void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_state) {
+
+ ERR_FAIL_COND(p_state.is_null() || p_state->buses.size()==0);
+
+ lock();
+ for(int i=0;i<buses.size();i++) {
+ memdelete(buses[i]);
+ }
+ buses.resize(p_state->buses.size());
+ bus_map.clear();
+ for(int i=0;i<p_state->buses.size();i++) {
+ Bus * bus = memnew(Bus);
+ if (i==0) {
+ bus->name="Master";
+ } else {
+ bus->name=p_state->buses[i].name;
+ bus->send=p_state->buses[i].send;
+ }
+
+ bus->solo=p_state->buses[i].solo;
+ bus->mute=p_state->buses[i].mute;
+ bus->bypass=p_state->buses[i].bypass;
+ bus->volume_db=p_state->buses[i].volume_db;
+
+ for(int j=0;j<p_state->buses[i].effects.size();j++) {
+
+ Ref<AudioEffect> fx = p_state->buses[i].effects[j].effect;
+
+ if (fx.is_valid()) {
+
+ Bus::Effect bfx;
+ bfx.effect=fx;
+ bfx.enabled=p_state->buses[i].effects[j].enabled;
+ bus->effects.push_back(bfx);
+ }
+ }
+
+ bus_map[bus->name]=bus;
+ buses[i]=bus;
+
+ buses[i]->channels.resize(_get_channel_count());
+ for(int j=0;j<_get_channel_count();j++) {
+ buses[i]->channels[j].buffer.resize(buffer_size);
+ }
+ _update_bus_effects(i);
+ }
+#ifdef TOOLS_ENABLED
+ set_edited(false);
+#endif
+ unlock();
+
+}
+
+
+Ref<AudioBusLayout> AudioServer::generate_bus_layout() const {
+
+ Ref<AudioBusLayout> state;
+ state.instance();
+
+ state->buses.resize( buses.size() );
+
+ for(int i=0;i<buses.size();i++) {
+
+ state->buses[i].name=buses[i]->name;
+ state->buses[i].send=buses[i]->send;
+ state->buses[i].mute=buses[i]->mute;
+ state->buses[i].solo=buses[i]->solo;
+ state->buses[i].bypass=buses[i]->bypass;
+ state->buses[i].volume_db=buses[i]->volume_db;
+ for(int j=0;j<buses[i]->effects.size();j++) {
+ AudioBusLayout::Bus::Effect fx;
+ fx.effect=buses[i]->effects[j].effect;
+ fx.enabled=buses[i]->effects[j].enabled;
+ state->buses[i].effects.push_back(fx);
+
+ }
+ }
+
+ return state;
+}
+
+
+void AudioServer::_bind_methods() {
+
+
+ ClassDB::bind_method(D_METHOD("set_bus_count","amount"),&AudioServer::set_bus_count);
+ ClassDB::bind_method(D_METHOD("get_bus_count"),&AudioServer::get_bus_count);
+
+ ClassDB::bind_method(D_METHOD("remove_bus","index"),&AudioServer::remove_bus);
+ ClassDB::bind_method(D_METHOD("add_bus","at_pos"),&AudioServer::add_bus,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("move_bus","index","to_index"),&AudioServer::move_bus);
+
+ 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("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);
+
+ ClassDB::bind_method(D_METHOD("set_bus_send","bus_idx","send"),&AudioServer::set_bus_send);
+ ClassDB::bind_method(D_METHOD("get_bus_send","bus_idx"),&AudioServer::get_bus_send);
+
+ ClassDB::bind_method(D_METHOD("set_bus_solo","bus_idx","enable"),&AudioServer::set_bus_solo);
+ ClassDB::bind_method(D_METHOD("is_bus_solo","bus_idx"),&AudioServer::is_bus_solo);
+
+ ClassDB::bind_method(D_METHOD("set_bus_mute","bus_idx","enable"),&AudioServer::set_bus_mute);
+ ClassDB::bind_method(D_METHOD("is_bus_mute","bus_idx"),&AudioServer::is_bus_mute);
+
+ 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("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: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);
+
+ ClassDB::bind_method(D_METHOD("set_bus_effect_enabled","bus_idx","effect_idx","enabled"),&AudioServer::set_bus_effect_enabled);
+ ClassDB::bind_method(D_METHOD("is_bus_effect_enabled","bus_idx","effect_idx"),&AudioServer::is_bus_effect_enabled);
+
+ ClassDB::bind_method(D_METHOD("get_bus_peak_volume_left_db","bus_idx","channel"),&AudioServer::get_bus_peak_volume_left_db);
+ ClassDB::bind_method(D_METHOD("get_bus_peak_volume_right_db","bus_idx","channel"),&AudioServer::get_bus_peak_volume_right_db);
+
+ ClassDB::bind_method(D_METHOD("lock"),&AudioServer::lock);
+ ClassDB::bind_method(D_METHOD("unlock"),&AudioServer::unlock);
+
+ ClassDB::bind_method(D_METHOD("get_speaker_mode"),&AudioServer::get_speaker_mode);
+ ClassDB::bind_method(D_METHOD("get_mix_rate"),&AudioServer::get_mix_rate);
+
+ ClassDB::bind_method(D_METHOD("set_state","state:AudioServerState"),&AudioServer::set_bus_layout);
+ ClassDB::bind_method(D_METHOD("generate_state:AudioServerState"),&AudioServer::generate_bus_layout);
+
+ ADD_SIGNAL(MethodInfo("bus_layout_changed") );
}
AudioServer::AudioServer() {
singleton=this;
+ audio_data_total_mem=0;
+ audio_data_max_mem=0;
+ audio_data_lock=Mutex::create();
+ mix_frames=0;
+ to_mix=0;
+
}
AudioServer::~AudioServer() {
+ memdelete(audio_data_lock);
+}
+
+/////////////////////////////////
+
+
+
+bool AudioBusLayout::_set(const StringName& p_name, const Variant& p_value) {
+
+ String s = p_name;
+ if (s.begins_with("bus/")) {
+ int index = s.get_slice("/",1).to_int();
+ if (buses.size()<=index) {
+ buses.resize(index+1);
+ }
+
+ Bus &bus = buses[index];
+
+ String what = s.get_slice("/",2);
+
+ if (what=="name") {
+ bus.name=p_value;
+ } else if (what=="solo") {
+ bus.solo=p_value;
+ } else if (what=="mute") {
+ bus.mute=p_value;
+ } else if (what=="bypass_fx") {
+ bus.bypass=p_value;
+ } else if (what=="volume_db") {
+ bus.volume_db=p_value;
+ } else if (what=="send") {
+ bus.send=p_value;
+ } else if (what=="effect") {
+ int which = s.get_slice("/",3).to_int();
+ if (bus.effects.size()<=which) {
+ bus.effects.resize(which+1);
+ }
+
+ Bus::Effect &fx = bus.effects[which];
+
+ String fxwhat = s.get_slice("/",4);
+ if (fxwhat=="effect") {
+ fx.effect=p_value;
+ } else if (fxwhat=="enabled") {
+ fx.enabled=p_value;
+ } else {
+ return false;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+
+bool AudioBusLayout::_get(const StringName& p_name,Variant &r_ret) const{
+
+ String s = p_name;
+ if (s.begins_with("bus/")) {
+
+ int index = s.get_slice("/",1).to_int();
+ if (index<0 || index>=buses.size())
+ return false;
+
+ const Bus &bus = buses[index];
+
+ String what = s.get_slice("/",2);
+
+ if (what=="name") {
+ r_ret=bus.name;
+ } else if (what=="solo") {
+ r_ret=bus.solo;
+ } else if (what=="mute") {
+ r_ret=bus.mute;
+ } else if (what=="bypass_fx") {
+ r_ret=bus.bypass;
+ } else if (what=="volume_db") {
+ r_ret=bus.volume_db;
+ } else if (what=="send") {
+ r_ret=bus.send;
+ } else if (what=="effect") {
+ int which = s.get_slice("/",3).to_int();
+ if (which<0 || which>=bus.effects.size()) {
+ return false;
+ }
+
+ const Bus::Effect &fx = bus.effects[which];
+
+ String fxwhat = s.get_slice("/",4);
+ if (fxwhat=="effect") {
+ r_ret=fx.effect;
+ } else if (fxwhat=="enabled") {
+ r_ret=fx.enabled;
+ } else {
+ return false;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+void AudioBusLayout::_get_property_list( List<PropertyInfo> *p_list) const{
+
+ for(int i=0;i<buses.size();i++) {
+ p_list->push_back(PropertyInfo(Variant::STRING,"bus/"+itos(i)+"/name",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL,"bus/"+itos(i)+"/solo",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL,"bus/"+itos(i)+"/mute",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL,"bus/"+itos(i)+"/bypass_fx",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::REAL,"bus/"+itos(i)+"/volume_db",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::REAL,"bus/"+itos(i)+"/send",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+
+ for(int j=0;j<buses[i].effects.size();j++) {
+ p_list->push_back(PropertyInfo(Variant::OBJECT,"bus/"+itos(i)+"/effect/"+itos(j)+"/effect",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL,"bus/"+itos(i)+"/effect/"+itos(j)+"/enabled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ }
+ }
+}
+
+
+AudioBusLayout::AudioBusLayout() {
+ buses.resize(1);
+ buses[0].name="Master";
}
diff --git a/servers/audio_server.h b/servers/audio_server.h
index 1482b40d4c..88849bb591 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -31,261 +31,326 @@
#include "variant.h"
#include "object.h"
+#include "audio_frame.h"
+#include "servers/audio/audio_effect.h"
+
+
+class AudioDriver {
+
+
+ static AudioDriver *singleton;
+ uint64_t _last_mix_time;
+ uint64_t _mix_amount;
+
-class AudioMixer {
protected:
- void audio_mixer_chunk_call(int p_frames);
+ void audio_server_process(int p_frames,int32_t *p_buffer,bool p_update_mix_time=true);
+ void update_mix_time(int p_frames);
+
public:
- enum {
- INVALID_CHANNEL=0xFFFFFFFF
+ double get_mix_time() const; //useful for video -> audio sync
+
+ enum SpeakerMode {
+ SPEAKER_MODE_STEREO,
+ SPEAKER_SURROUND_51,
+ SPEAKER_SURROUND_71,
};
- typedef uint32_t ChannelID;
+ static AudioDriver *get_singleton();
+ void set_singleton();
- /* CHANNEL API */
+ virtual const char* get_name() const=0;
- enum FilterType {
- FILTER_NONE,
- FILTER_LOWPASS,
- FILTER_BANDPASS,
- FILTER_HIPASS,
- FILTER_NOTCH,
- FILTER_PEAK,
- FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP
- FILTER_LOW_SHELF,
- FILTER_HIGH_SHELF
+ virtual Error init()=0;
+ virtual void start()=0;
+ virtual int get_mix_rate() const =0;
+ virtual SpeakerMode get_speaker_mode() const=0;
+ virtual void lock()=0;
+ virtual void unlock()=0;
+ virtual void finish()=0;
- };
+ virtual float get_latency() { return 0; }
- enum ReverbRoomType {
- REVERB_SMALL,
- REVERB_MEDIUM,
- REVERB_LARGE,
- REVERB_HALL,
- MAX_REVERBS
- };
- virtual ChannelID channel_alloc(RID p_sample)=0;
- virtual void channel_set_volume(ChannelID p_channel, float p_gain)=0;
- virtual void channel_set_pan(ChannelID p_channel, float p_pan, float p_depth=0,float height=0)=0; //pan and depth go from -1 to 1
- virtual void channel_set_filter(ChannelID p_channel, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=1.0)=0;
- virtual void channel_set_chorus(ChannelID p_channel, float p_chorus )=0;
- virtual void channel_set_reverb(ChannelID p_channel, ReverbRoomType p_room_type, float p_reverb)=0;
- virtual void channel_set_mix_rate(ChannelID p_channel, int p_mix_rate)=0;
- virtual void channel_set_positional(ChannelID p_channel, bool p_positional)=0;
+ AudioDriver();
+ virtual ~AudioDriver() {}
+};
- virtual float channel_get_volume(ChannelID p_channel) const=0;
- virtual float channel_get_pan(ChannelID p_channel) const=0; //pan and depth go from -1 to 1
- virtual float channel_get_pan_depth(ChannelID p_channel) const=0; //pan and depth go from -1 to 1
- virtual float channel_get_pan_height(ChannelID p_channel) const=0; //pan and depth go from -1 to 1
- virtual FilterType channel_get_filter_type(ChannelID p_channel) const=0;
- virtual float channel_get_filter_cutoff(ChannelID p_channel) const=0;
- virtual float channel_get_filter_resonance(ChannelID p_channel) const=0;
- virtual float channel_get_filter_gain(ChannelID p_channel) const=0;
- virtual float channel_get_chorus(ChannelID p_channel) const=0;
- virtual ReverbRoomType channel_get_reverb_type(ChannelID p_channel) const=0;
- virtual float channel_get_reverb(ChannelID p_channel) const=0;
- virtual int channel_get_mix_rate(ChannelID p_channel) const=0;
- virtual bool channel_is_positional(ChannelID p_channel) const=0;
- virtual bool channel_is_valid(ChannelID p_channel) const=0;
+class AudioDriverManager {
- virtual void channel_free(ChannelID p_channel)=0;
+ enum {
- virtual void set_mixer_volume(float p_volume)=0;
+ MAX_DRIVERS=10
+ };
+ static AudioDriver *drivers[MAX_DRIVERS];
+ static int driver_count;
+public:
- virtual ~AudioMixer() {}
+ static void add_driver(AudioDriver *p_driver);
+ static int get_driver_count();
+ static AudioDriver *get_driver(int p_driver);
};
+class AudioBusLayout;
+
class AudioServer : public Object {
- GDCLASS( AudioServer, Object );
+ GDCLASS( AudioServer, Object )
+public:
+ //re-expose this her, as AudioDriver is not exposed to script
+ enum SpeakerMode {
+ SPEAKER_MODE_STEREO,
+ SPEAKER_SURROUND_51,
+ SPEAKER_SURROUND_71,
+ };
+
+ enum {
+ AUDIO_DATA_INVALID_ID=-1
+ };
- static AudioServer *singleton;
-protected:
-friend class AudioStream;
-friend class EventStream;
-friend class AudioMixer;
+ typedef void (*AudioCallback)(void* p_userdata);
- virtual AudioMixer *get_mixer()=0;
- virtual void audio_mixer_chunk_callback(int p_frames)=0;
+private:
+ uint32_t buffer_size;
+ uint64_t mix_count;
+ uint64_t mix_frames;
- static void _bind_methods();
-public:
+ float channel_disable_treshold_db;
+ uint32_t channel_disable_frames;
+ int to_mix;
- class EventStream {
- protected:
- AudioMixer *get_mixer() const;
- public:
- virtual void update(uint64_t p_usec)=0;
+ struct Bus {
- virtual ~EventStream() {}
- };
+ StringName name;
+ bool solo;
+ bool mute;
+ bool bypass;
- class AudioStream {
- public:
- virtual int get_channel_count() const=0;
- virtual void set_mix_rate(int p_rate)=0; //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames)=0;
- virtual void update()=0;
- virtual bool can_update_mt() const { return true; }
- virtual ~AudioStream() {}
- };
+ //Each channel is a stereo pair.
+ struct Channel {
+ bool used;
+ bool active;
+ AudioFrame peak_volume;
+ Vector<AudioFrame> buffer;
+ Vector<Ref<AudioEffectInstance> > effect_instances;
+ uint64_t last_mix_with_audio;
+ Channel() { last_mix_with_audio=0; used=false; active=false; peak_volume=AudioFrame(0,0); }
+ };
+
+ Vector<Channel> channels;
- enum SampleFormat {
+ struct Effect {
+ Ref<AudioEffect> effect;
+ bool enabled;
+ };
- SAMPLE_FORMAT_PCM8,
- SAMPLE_FORMAT_PCM16,
- SAMPLE_FORMAT_IMA_ADPCM
+ Vector<Effect> effects;
+ float volume_db;
+ StringName send;
+ int index_cache;
};
- enum SampleLoopFormat {
- SAMPLE_LOOP_NONE,
- SAMPLE_LOOP_FORWARD,
- SAMPLE_LOOP_PING_PONG // not supported in every platform
- };
+ Vector< Vector<AudioFrame> >temp_buffer; //temp_buffer for each level
+ Vector<Bus*> buses;
+ Map<StringName,Bus*> bus_map;
- /* SAMPLE API */
+ _FORCE_INLINE_ int _get_channel_count() const {
+ switch (AudioDriver::get_singleton()->get_speaker_mode()) {
+ case AudioDriver::SPEAKER_MODE_STEREO: return 1;
+ case AudioDriver::SPEAKER_SURROUND_51: return 3;
+ case AudioDriver::SPEAKER_SURROUND_71: return 4;
- virtual RID sample_create(SampleFormat p_format, bool p_stereo, int p_length)=0;
+ }
+ ERR_FAIL_V(1);
+ }
- virtual void sample_set_description(RID p_sample, const String& p_description)=0;
- virtual String sample_get_description(RID p_sample) const=0;
- virtual SampleFormat sample_get_format(RID p_sample) const=0;
- virtual bool sample_is_stereo(RID p_sample) const=0;
- virtual int sample_get_length(RID p_sample) const=0;
- virtual const void* sample_get_data_ptr(RID p_sample) const=0;
+ void _update_bus_effects(int p_bus);
- virtual void sample_set_signed_data(RID p_sample, const PoolVector<float>& p_buffer);
- virtual void sample_set_data(RID p_sample, const PoolVector<uint8_t>& p_buffer)=0;
- virtual PoolVector<uint8_t> sample_get_data(RID p_sample) const=0;
- virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0;
- virtual int sample_get_mix_rate(RID p_sample) const=0;
+ static AudioServer* singleton;
- virtual void sample_set_loop_format(RID p_sample,SampleLoopFormat p_format)=0;
- virtual SampleLoopFormat sample_get_loop_format(RID p_sample) const=0;
+ // TODO create an audiodata pool to optimize memory
- virtual void sample_set_loop_begin(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_begin(RID p_sample) const=0;
- virtual void sample_set_loop_end(RID p_sample,int p_pos)=0;
- virtual int sample_get_loop_end(RID p_sample) const=0;
+ Map<void*,uint32_t> audio_data;
+ size_t audio_data_total_mem;
+ size_t audio_data_max_mem;
+ Mutex *audio_data_lock;
- /* VOICE API */
+ void _mix_step();
- enum FilterType {
- FILTER_NONE,
- FILTER_LOWPASS,
- FILTER_BANDPASS,
- FILTER_HIPASS,
- FILTER_NOTCH,
- FILTER_PEAK,
- FILTER_BANDLIMIT, ///< cutoff is LP resonace is HP
- FILTER_LOW_SHELF,
- FILTER_HIGH_SHELF
- };
+ struct CallbackItem {
- enum ReverbRoomType {
+ AudioCallback callback;
+ void *userdata;
- REVERB_SMALL,
- REVERB_MEDIUM,
- REVERB_LARGE,
- REVERB_HALL
+ bool operator<(const CallbackItem& p_item) const {
+ return (callback==p_item.callback ? userdata < p_item.userdata : callback < p_item.callback);
+ }
};
- virtual RID voice_create()=0;
+ Set<CallbackItem> callbacks;
- virtual void voice_play(RID p_voice, RID p_sample)=0;
+friend class AudioDriver;
+ void _driver_process(int p_frames, int32_t *p_buffer);
+protected:
- virtual void voice_set_volume(RID p_voice, float p_volume)=0;
- virtual void voice_set_pan(RID p_voice, float p_pan, float p_depth=0,float height=0)=0; //pan and depth go from -1 to 1
- virtual void voice_set_filter(RID p_voice, FilterType p_type, float p_cutoff, float p_resonance, float p_gain=0)=0;
- virtual void voice_set_chorus(RID p_voice, float p_chorus )=0;
- virtual void voice_set_reverb(RID p_voice, ReverbRoomType p_room_type, float p_reverb)=0;
- virtual void voice_set_mix_rate(RID p_voice, int p_mix_rate)=0;
- virtual void voice_set_positional(RID p_voice, bool p_positional)=0;
+ static void _bind_methods();
+public:
- virtual float voice_get_volume(RID p_voice) const=0;
- virtual float voice_get_pan(RID p_voice) const=0; //pan and depth go from -1 to 1
- virtual float voice_get_pan_depth(RID p_voice) const=0; //pan and depth go from -1 to 1
- virtual float voice_get_pan_height(RID p_voice) const=0; //pan and depth go from -1 to 1
- virtual FilterType voice_get_filter_type(RID p_voice) const=0;
- virtual float voice_get_filter_cutoff(RID p_voice) const=0;
- virtual float voice_get_filter_resonance(RID p_voice) const=0;
- virtual float voice_get_chorus(RID p_voice) const=0;
- virtual ReverbRoomType voice_get_reverb_type(RID p_voice) const=0;
- virtual float voice_get_reverb(RID p_voice) const=0;
+ //do not use from outside audio thread
+ AudioFrame *thread_get_channel_mix_buffer(int p_bus,int p_buffer);
+ int thread_get_mix_buffer_size() const;
+ int thread_find_bus_index(const StringName& p_name);
- virtual int voice_get_mix_rate(RID p_voice) const=0;
- virtual bool voice_is_positional(RID p_voice) const=0;
- virtual void voice_stop(RID p_voice)=0;
- virtual bool voice_is_active(RID p_voice) const=0;
+ void set_bus_count(int p_count);
+ int get_bus_count() const;
- /* STREAM API */
+ void remove_bus(int p_index);
+ void add_bus(int p_at_pos=-1);
- virtual RID audio_stream_create(AudioStream *p_stream)=0;
- virtual RID event_stream_create(EventStream *p_stream)=0;
+ void move_bus(int p_bus,int p_to_pos);
- virtual void stream_set_active(RID p_stream, bool p_active)=0;
- virtual bool stream_is_active(RID p_stream) const=0;
+ void set_bus_name(int p_bus,const String& p_name);
+ String get_bus_name(int p_bus) const;
- virtual void stream_set_volume_scale(RID p_stream, float p_scale)=0;
- virtual float stream_set_volume_scale(RID p_stream) const=0;
+ void set_bus_volume_db(int p_bus,float p_volume_db);
+ float get_bus_volume_db(int p_bus) const;
- /* Audio Physics API */
- virtual void free(RID p_id)=0;
+ void set_bus_send(int p_bus,const StringName& p_send);
+ StringName get_bus_send(int p_bus) const;
- virtual void init()=0;
- virtual void finish()=0;
- virtual void update()=0;
+ void set_bus_solo(int p_bus,bool p_enable);
+ bool is_bus_solo(int p_bus) const;
+
+ void set_bus_mute(int p_bus,bool p_enable);
+ bool is_bus_mute(int p_bus) const;
+
+ void set_bus_bypass_effects(int p_bus,bool p_enable);
+ bool is_bus_bypassing_effects(int p_bus) const;
+
+ void add_bus_effect(int p_bus,const Ref<AudioEffect>& p_effect,int p_at_pos=-1);
+ void remove_bus_effect(int p_bus,int p_effect);
+
+ int get_bus_effect_count(int p_bus);
+ Ref<AudioEffect> get_bus_effect(int p_bus,int p_effect);
+
+ void swap_bus_effects(int p_bus,int p_effect,int p_by_effect);
+
+ void set_bus_effect_enabled(int p_bus,int p_effect,bool p_enabled);
+ bool is_bus_effect_enabled(int p_bus,int p_effect) const;
+
+ float get_bus_peak_volume_left_db(int p_bus,int p_channel) const;
+ float get_bus_peak_volume_right_db(int p_bus,int p_channel) const;
+
+ bool is_bus_channel_active(int p_bus,int p_channel) const;
+
+ virtual void init();
+ virtual void finish();
+ virtual void update();
+ virtual void load_default_bus_layout();
/* MISC config */
- virtual void lock()=0;
- virtual void unlock()=0;
- virtual int get_default_channel_count() const=0;
- virtual int get_default_mix_rate() const=0;
+ virtual void lock();
+ virtual void unlock();
- virtual void set_stream_global_volume_scale(float p_volume)=0;
- virtual void set_fx_global_volume_scale(float p_volume)=0;
- virtual void set_event_voice_global_volume_scale(float p_volume)=0;
- virtual float get_stream_global_volume_scale() const=0;
- virtual float get_fx_global_volume_scale() const=0;
- virtual float get_event_voice_global_volume_scale() const=0;
+ virtual SpeakerMode get_speaker_mode() const;
+ virtual float get_mix_rate() const;
- virtual uint32_t read_output_peak() const=0;
+ virtual float read_output_peak_db() const;
static AudioServer *get_singleton();
- virtual double get_mix_time() const=0; //useful for video -> audio sync
- virtual double get_output_delay() const=0;
+ virtual double get_mix_time() const; //useful for video -> audio sync
+ virtual double get_output_delay() const;
+
+ void* audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data=NULL);
+ void audio_data_free(void* p_data);
+
+ size_t audio_data_get_total_memory_usage() const;
+ size_t audio_data_get_max_memory_usage() const;
+
+
+ void add_callback(AudioCallback p_callback,void *p_userdata);
+ void remove_callback(AudioCallback p_callback,void *p_userdata);
+
+ void set_bus_layout(const Ref<AudioBusLayout>& p_state);
+ Ref<AudioBusLayout> generate_bus_layout() const;
AudioServer();
virtual ~AudioServer();
};
-VARIANT_ENUM_CAST( AudioServer::SampleFormat );
-VARIANT_ENUM_CAST( AudioServer::SampleLoopFormat );
-VARIANT_ENUM_CAST( AudioServer::FilterType );
-VARIANT_ENUM_CAST( AudioServer::ReverbRoomType );
+VARIANT_ENUM_CAST( AudioServer::SpeakerMode )
+
+class AudioBusLayout : public Resource {
+
+ GDCLASS(AudioBusLayout,Resource)
+
+friend class AudioServer;
+
+ struct Bus {
+
+ StringName name;
+ bool solo;
+ bool mute;
+ bool bypass;
+
+ struct Effect {
+ Ref<AudioEffect> effect;
+ bool enabled;
+ };
+
+ Vector<Effect> effects;
+
+ float volume_db;
+ StringName send;
+
+ Bus() {
+ solo=false;
+ mute=false;
+ bypass=false;
+ volume_db=0;
+ }
+ };
+
+ Vector<Bus> buses;
+
+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:
+
+ AudioBusLayout();
+};
+
+
+
+
+
typedef AudioServer AS;
+
#endif // AUDIO_SERVER_H
diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics/area_pair_sw.cpp
index 1131aa90d3..3aa0816b06 100644
--- a/servers/physics/area_pair_sw.cpp
+++ b/servers/physics/area_pair_sw.cpp
@@ -30,7 +30,7 @@
#include "collision_solver_sw.h"
-bool AreaPairSW::setup(float p_step) {
+bool AreaPairSW::setup(real_t p_step) {
if (!area->test_collision_mask(body)) {
colliding = false;
@@ -64,7 +64,7 @@ bool AreaPairSW::setup(float p_step) {
return false; //never do any post solving
}
-void AreaPairSW::solve(float p_step) {
+void AreaPairSW::solve(real_t p_step) {
}
@@ -103,14 +103,14 @@ AreaPairSW::~AreaPairSW() {
-bool Area2PairSW::setup(float p_step) {
+bool Area2PairSW::setup(real_t p_step) {
if (!area_a->test_collision_mask(area_b)) {
colliding = false;
return false;
}
-// 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 = 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) {
@@ -139,7 +139,7 @@ bool Area2PairSW::setup(float p_step) {
return false; //never do any post solving
}
-void Area2PairSW::solve(float p_step) {
+void Area2PairSW::solve(real_t p_step) {
}
diff --git a/servers/physics/area_pair_sw.h b/servers/physics/area_pair_sw.h
index 17477dcbd2..637976a095 100644
--- a/servers/physics/area_pair_sw.h
+++ b/servers/physics/area_pair_sw.h
@@ -42,8 +42,8 @@ class AreaPairSW : public ConstraintSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
AreaPairSW(BodySW *p_body,int p_body_shape, AreaSW *p_area,int p_area_shape);
~AreaPairSW();
@@ -59,8 +59,8 @@ class Area2PairSW : public ConstraintSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
Area2PairSW(AreaSW *p_area_a,int p_shape_a, AreaSW *p_area_b,int p_shape_b);
~Area2PairSW();
diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp
index 84389c9b78..8aed07d5e5 100644
--- a/servers/physics/area_sw.cpp
+++ b/servers/physics/area_sw.cpp
@@ -126,14 +126,14 @@ void AreaSW::set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode
void AreaSW::set_param(PhysicsServer::AreaParameter p_param, const Variant& p_value) {
switch(p_param) {
- case PhysicsServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break;
- case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break;
- case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; ; break;
- case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; ; break;
- case PhysicsServer::AREA_PARAM_PRIORITY: priority=p_value; ; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY: gravity=p_value; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; break;
+ case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; break;
+ case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; break;
+ case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; break;
+ case PhysicsServer::AREA_PARAM_PRIORITY: priority=p_value; break;
}
diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h
index 5ac6985409..4e6f1c5a51 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics/area_sw.h
@@ -42,13 +42,13 @@ class AreaSW : public CollisionObjectSW{
PhysicsServer::AreaSpaceOverrideMode space_override_mode;
- float gravity;
+ real_t gravity;
Vector3 gravity_vector;
bool gravity_is_point;
- float gravity_distance_scale;
- float point_attenuation;
- float linear_damp;
- float angular_damp;
+ real_t gravity_distance_scale;
+ real_t point_attenuation;
+ real_t linear_damp;
+ real_t angular_damp;
int priority;
bool monitorable;
@@ -131,8 +131,8 @@ public:
void set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode);
PhysicsServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
- _FORCE_INLINE_ void set_gravity(float p_gravity) { gravity=p_gravity; }
- _FORCE_INLINE_ float get_gravity() const { return gravity; }
+ _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity=p_gravity; }
+ _FORCE_INLINE_ real_t get_gravity() const { return gravity; }
_FORCE_INLINE_ void set_gravity_vector(const Vector3& p_gravity) { gravity_vector=p_gravity; }
_FORCE_INLINE_ Vector3 get_gravity_vector() const { return gravity_vector; }
@@ -140,17 +140,17 @@ public:
_FORCE_INLINE_ void set_gravity_as_point(bool p_enable) { gravity_is_point=p_enable; }
_FORCE_INLINE_ bool is_gravity_point() const { return gravity_is_point; }
- _FORCE_INLINE_ void set_gravity_distance_scale(float scale) { gravity_distance_scale=scale; }
- _FORCE_INLINE_ float get_gravity_distance_scale() const { return gravity_distance_scale; }
+ _FORCE_INLINE_ void set_gravity_distance_scale(real_t scale) { gravity_distance_scale=scale; }
+ _FORCE_INLINE_ real_t get_gravity_distance_scale() const { return gravity_distance_scale; }
- _FORCE_INLINE_ void set_point_attenuation(float p_point_attenuation) { point_attenuation=p_point_attenuation; }
- _FORCE_INLINE_ float get_point_attenuation() const { return point_attenuation; }
+ _FORCE_INLINE_ void set_point_attenuation(real_t p_point_attenuation) { point_attenuation=p_point_attenuation; }
+ _FORCE_INLINE_ real_t get_point_attenuation() const { return point_attenuation; }
- _FORCE_INLINE_ void set_linear_damp(float p_linear_damp) { linear_damp=p_linear_damp; }
- _FORCE_INLINE_ float get_linear_damp() const { return linear_damp; }
+ _FORCE_INLINE_ void set_linear_damp(real_t p_linear_damp) { linear_damp=p_linear_damp; }
+ _FORCE_INLINE_ real_t get_linear_damp() const { return linear_damp; }
- _FORCE_INLINE_ void set_angular_damp(float p_angular_damp) { angular_damp=p_angular_damp; }
- _FORCE_INLINE_ float get_angular_damp() const { return angular_damp; }
+ _FORCE_INLINE_ void set_angular_damp(real_t p_angular_damp) { angular_damp=p_angular_damp; }
+ _FORCE_INLINE_ real_t get_angular_damp() const { return angular_damp; }
_FORCE_INLINE_ void set_priority(int p_priority) { priority=p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }
diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp
index 7defa87bb1..7fb3def387 100644
--- a/servers/physics/body_pair_sw.cpp
+++ b/servers/physics/body_pair_sw.cpp
@@ -105,7 +105,7 @@ void BodyPairSW::contact_added_callback(const Vector3& p_point_A,const Vector3&
// remove the contact with the minimum depth
int least_deep=-1;
- float min_depth=1e10;
+ real_t min_depth=1e10;
for (int i=0;i<=contact_count;i++) {
@@ -114,7 +114,7 @@ void BodyPairSW::contact_added_callback(const Vector3& p_point_A,const Vector3&
Vector3 global_B = B->get_transform().basis.xform(c.local_B)+offset_B;
Vector3 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
if (depth<min_depth) {
@@ -154,7 +154,7 @@ void BodyPairSW::validate_contacts() {
Vector3 global_A = A->get_transform().basis.xform(c.local_A);
Vector3 global_B = B->get_transform().basis.xform(c.local_B)+offset_B;
Vector3 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
if (depth < -contact_max_separation || (global_B + c.normal * depth - global_A).length() > contact_max_separation) {
// contact no longer needed, remove
@@ -173,7 +173,7 @@ void BodyPairSW::validate_contacts() {
}
-bool BodyPairSW::_test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B) {
+bool BodyPairSW::_test_ccd(real_t p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B) {
@@ -211,14 +211,14 @@ bool BodyPairSW::_test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transfo
//shorten the linear velocity so it does not hit, but gets close enough, next frame will hit softly or soft enough
Vector3 hitpos = p_xform_B.xform(rpos);
- float newlen = hitpos.distance_to(from)-(max-min)*0.01;
+ real_t newlen = hitpos.distance_to(from)-(max-min)*0.01;
p_A->set_linear_velocity((mnormal*newlen)/p_step);
return true;
}
-bool BodyPairSW::setup(float p_step) {
+bool BodyPairSW::setup(real_t p_step) {
//cannot collide
if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode()<=PhysicsServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
@@ -264,7 +264,7 @@ bool BodyPairSW::setup(float p_step) {
real_t max_penetration = space->get_contact_max_allowed_penetration();
- float bias = 0.3f;
+ real_t bias = (real_t)0.3;
if (shape_A_ptr->get_custom_bias() || shape_B_ptr->get_custom_bias()) {
@@ -356,7 +356,7 @@ bool BodyPairSW::setup(float p_step) {
if (depth > max_penetration) {
c.bias = (depth - max_penetration) * (1.0/(p_step*(1.0/RELAXATION_TIMESTEPS)));
} else {
- float approach = -0.1f * (depth - max_penetration) / (CMP_EPSILON + max_penetration);
+ real_t approach = -0.1 * (depth - max_penetration) / (CMP_EPSILON + max_penetration);
approach = CLAMP( approach, CMP_EPSILON, 1.0 );
c.bias = approach * (depth - max_penetration) * (1.0/p_step);
}
@@ -387,7 +387,7 @@ bool BodyPairSW::setup(float p_step) {
return true;
}
-void BodyPairSW::solve(float p_step) {
+void BodyPairSW::solve(real_t p_step) {
if (!collided)
return;
diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h
index a37f75d13c..f282a56b9e 100644
--- a/servers/physics/body_pair_sw.h
+++ b/servers/physics/body_pair_sw.h
@@ -82,14 +82,14 @@ class BodyPairSW : public ConstraintSW {
void contact_added_callback(const Vector3& p_point_A,const Vector3& p_point_B);
void validate_contacts();
- bool _test_ccd(float p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B);
+ bool _test_ccd(real_t p_step,BodySW *p_A, int p_shape_A,const Transform& p_xform_A,BodySW *p_B, int p_shape_B,const Transform& p_xform_B);
SpaceSW *space;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
BodyPairSW(BodySW *p_A, int p_shape_A,BodySW *p_B, int p_shape_B);
~BodyPairSW();
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index ceeeafe04a..7fcd767268 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -59,7 +59,7 @@ void BodySW::update_inertias() {
case PhysicsServer::BODY_MODE_RIGID: {
//update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet)
- float total_area=0;
+ real_t total_area=0;
for (int i=0;i<get_shape_count();i++) {
@@ -70,9 +70,9 @@ void BodySW::update_inertias() {
center_of_mass_local.zero();
for (int i=0; i<get_shape_count(); i++) {
- float area=get_shape_area(i);
+ real_t area=get_shape_area(i);
- float mass = area * this->mass / total_area;
+ real_t mass = area * this->mass / total_area;
// NOTE: we assume that the shape origin is also its center of mass
center_of_mass_local += mass * get_shape_transform(i).origin;
@@ -88,9 +88,9 @@ void BodySW::update_inertias() {
const ShapeSW* shape=get_shape(i);
- float area=get_shape_area(i);
+ real_t area=get_shape_area(i);
- float mass = area * this->mass / total_area;
+ real_t mass = area * this->mass / total_area;
Basis shape_inertia_tensor=shape->get_moment_of_inertia(mass).to_diagonal_matrix();
Transform shape_transform=get_shape_transform(i);
@@ -170,7 +170,7 @@ void BodySW::set_active(bool p_active) {
-void BodySW::set_param(PhysicsServer::BodyParameter p_param, float p_value) {
+void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::BODY_PARAM_BOUNCE: {
@@ -202,7 +202,7 @@ void BodySW::set_param(PhysicsServer::BodyParameter p_param, float p_value) {
}
}
-float BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
+real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const {
switch(p_param) {
case PhysicsServer::BODY_PARAM_BOUNCE: {
@@ -270,8 +270,10 @@ void BodySW::set_mode(PhysicsServer::BodyMode p_mode) {
}
_update_inertia();
- //if (get_space())
-// _update_queries();
+ /*
+ if (get_space())
+ _update_queries();
+ */
}
PhysicsServer::BodyMode BodySW::get_mode() const {
@@ -319,14 +321,18 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant& p_varian
} break;
case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: {
- //if (mode==PhysicsServer::BODY_MODE_STATIC)
- // break;
+ /*
+ if (mode==PhysicsServer::BODY_MODE_STATIC)
+ break;
+ */
linear_velocity=p_variant;
wakeup();
} break;
case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: {
- //if (mode!=PhysicsServer::BODY_MODE_RIGID)
- // break;
+ /*
+ if (mode!=PhysicsServer::BODY_MODE_RIGID)
+ break;
+ */
angular_velocity=p_variant;
wakeup();
@@ -400,11 +406,13 @@ void BodySW::set_space(SpaceSW *p_space){
_update_inertia();
if (active)
get_space()->body_add_to_active_list(&active_list);
-// _update_queries();
- //if (is_active()) {
- // active=false;
- // set_active(true);
- //}
+ /*
+ _update_queries();
+ if (is_active()) {
+ active=false;
+ set_active(true);
+ }
+ */
}
@@ -479,13 +487,17 @@ void BodySW::integrate_forces(real_t p_step) {
// If less than 0, override dampenings with that of the Body
if (angular_damp>=0)
area_angular_damp=angular_damp;
- //else
- // area_angular_damp=damp_area->get_angular_damp();
+ /*
+ else
+ area_angular_damp=damp_area->get_angular_damp();
+ */
if (linear_damp>=0)
area_linear_damp=linear_damp;
- //else
- // area_linear_damp=damp_area->get_linear_damp();
+ /*
+ else
+ area_linear_damp=damp_area->get_linear_damp();
+ */
Vector3 motion;
@@ -499,7 +511,7 @@ void BodySW::integrate_forces(real_t p_step) {
//compute a FAKE angular velocity, not so easy
Basis rot=new_transform.basis.orthonormalized().transposed() * get_transform().basis.orthonormalized();
Vector3 axis;
- float angle;
+ real_t angle;
rot.get_axis_and_angle(axis,angle);
axis.normalize();
@@ -603,13 +615,13 @@ void BodySW::integrate_velocities(real_t p_step) {
- float ang_vel = total_angular_velocity.length();
+ real_t ang_vel = total_angular_velocity.length();
Transform transform = get_transform();
if (ang_vel!=0.0) {
Vector3 ang_vel_axis = total_angular_velocity / ang_vel;
- Basis rot( ang_vel_axis, -ang_vel*p_step );
+ Basis rot( ang_vel_axis, ang_vel*p_step );
Basis identity3(1, 0, 0, 0, 1, 0, 0, 0, 1);
transform.origin += ((identity3 - rot) * transform.basis).xform(center_of_mass_local);
transform.basis = rot * transform.basis;
@@ -630,10 +642,10 @@ void BodySW::integrate_velocities(real_t p_step) {
_update_transform_dependant();
- //if (fi_callback) {
-
- // get_space()->body_add_to_state_query_list(&direct_state_query_list);
- //
+ /*
+ if (fi_callback) {
+ get_space()->body_add_to_state_query_list(&direct_state_query_list);
+ */
}
/*
@@ -654,7 +666,7 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) {
//compute a FAKE angular velocity, not so easy
Matrix3 rot=get_transform().basis.orthonormalized().transposed() * p_xform.basis.orthonormalized();
Vector3 axis;
- float angle;
+ real_t angle;
rot.get_axis_and_angle(axis,angle);
axis.normalize();
@@ -772,12 +784,12 @@ BodySW::BodySW() : CollisionObjectSW(TYPE_BODY), active_list(this), inertia_upda
active=true;
mass=1;
-// _inv_inertia=Transform();
+ //_inv_inertia=Transform();
_inv_mass=1;
bounce=0;
friction=1;
omit_force_integration=false;
-// applied_torque=0;
+ //applied_torque=0;
island_step=0;
island_next=NULL;
island_list_next=NULL;
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index e6ed3e75e5..2383d2d688 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -75,8 +75,8 @@ class BodySW : public CollisionObjectSW {
Vector3 applied_force;
Vector3 applied_torque;
- float area_angular_damp;
- float area_linear_damp;
+ real_t area_angular_damp;
+ real_t area_linear_damp;
SelfList<BodySW> active_list;
@@ -115,7 +115,7 @@ class BodySW : public CollisionObjectSW {
Vector3 local_pos;
Vector3 local_normal;
- float depth;
+ real_t depth;
int local_shape;
Vector3 collider_pos;
int collider_shape;
@@ -174,7 +174,7 @@ public:
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
_FORCE_INLINE_ bool can_report_contacts() const { return !contacts.empty(); }
- _FORCE_INLINE_ void add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, float p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos);
+ _FORCE_INLINE_ void add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos);
_FORCE_INLINE_ void add_exception(const RID& p_exception) { exceptions.insert(p_exception);}
@@ -248,8 +248,8 @@ public:
set_active(true);
}
- void set_param(PhysicsServer::BodyParameter p_param, float);
- float get_param(PhysicsServer::BodyParameter p_param) const;
+ void set_param(PhysicsServer::BodyParameter p_param, real_t);
+ real_t get_param(PhysicsServer::BodyParameter p_param) const;
void set_mode(PhysicsServer::BodyMode p_mode);
PhysicsServer::BodyMode get_mode() const;
@@ -319,7 +319,7 @@ public:
//add contact inline
-void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, float p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos) {
+void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos) {
int c_max=contacts.size();
@@ -335,7 +335,7 @@ void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_norma
idx=contact_count++;
} else {
- float least_depth=1e20;
+ real_t least_depth=1e20;
int least_deep=-1;
for(int i=0;i<c_max;i++) {
@@ -377,13 +377,13 @@ public:
real_t step;
virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
- virtual float get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
- virtual float get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
+ virtual real_t get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
+ virtual real_t get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
virtual Vector3 get_center_of_mass() const { return body->get_center_of_mass(); }
virtual Basis get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); }
- virtual float get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
+ virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space
virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space
diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h
index 2cc2d7d45e..20b3efc7fb 100644
--- a/servers/physics/broad_phase_sw.h
+++ b/servers/physics/broad_phase_sw.h
@@ -30,7 +30,7 @@
#define BROAD_PHASE_SW_H
#include "math_funcs.h"
-#include "aabb.h"
+#include "rect3.h"
class CollisionObjectSW;
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp
index 7f8153611f..9d3e1db47b 100644
--- a/servers/physics/collision_solver_sat.cpp
+++ b/servers/physics/collision_solver_sat.cpp
@@ -42,9 +42,11 @@ struct _CollectorCallback {
_FORCE_INLINE_ void call(const Vector3& p_point_A, const Vector3& p_point_B) {
- //if (normal.dot(p_point_A) >= normal.dot(p_point_B))
- // return;
-// print_line("** A: "+p_point_A+" B: "+p_point_B+" D: "+rtos(p_point_A.distance_to(p_point_B)));
+ /*
+ if (normal.dot(p_point_A) >= normal.dot(p_point_B))
+ return;
+ print_line("** A: "+p_point_A+" B: "+p_point_B+" D: "+rtos(p_point_A.distance_to(p_point_B)));
+ */
if (swap)
callback(p_point_B,p_point_A,userdata);
@@ -108,7 +110,7 @@ static void _generate_contacts_edge_edge(const Vector3 * p_points_A,int p_point_
Vector3 c=rel_A.cross(rel_B).cross(rel_B);
-// if ( Math::abs(rel_A.dot(c) )<_EDGE_IS_VALID_SUPPORT_TRESHOLD ) {
+ //if ( Math::abs(rel_A.dot(c) )<_EDGE_IS_VALID_SUPPORT_TRESHOLD ) {
if ( Math::abs(rel_A.dot(c) )<CMP_EPSILON ) {
// should handle somehow..
@@ -120,9 +122,9 @@ static void _generate_contacts_edge_edge(const Vector3 * p_points_A,int p_point_
Vector3 base_B = p_points_B[0] - axis * axis.dot(p_points_B[0]);
//sort all 4 points in axis
- float dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
+ real_t dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
- SortArray<float> sa;
+ SortArray<real_t> sa;
sa.sort(dvec,4);
//use the middle ones as contacts
@@ -205,7 +207,7 @@ static void _generate_contacts_face_face(const Vector3 * p_points_A,int p_point_
// check for different sides and non coplanar
-// if ( (dist0*dist1) < -CMP_EPSILON && !(edge && j)) {
+ //if ( (dist0*dist1) < -CMP_EPSILON && !(edge && j)) {
if ( (dist0*dist1) < 0 && !(edge && j)) {
// calculate intersection
@@ -232,9 +234,11 @@ static void _generate_contacts_face_face(const Vector3 * p_points_A,int p_point_
for (int i=0;i<clipbuf_len;i++) {
- float d = plane_B.distance_to(clipbuf_src[i]);
- //if (d>CMP_EPSILON)
- // continue;
+ real_t d = plane_B.distance_to(clipbuf_src[i]);
+ /*
+ if (d>CMP_EPSILON)
+ continue;
+ */
Vector3 closest_B=clipbuf_src[i] - plane_B.normal*d;
@@ -472,11 +476,11 @@ public:
/****** SAT TESTS *******/
-typedef void (*CollisionFunc)(const ShapeSW*,const Transform&,const ShapeSW*,const Transform&,_CollectorCallback *p_callback,float,float);
+typedef void (*CollisionFunc)(const ShapeSW*,const Transform&,const ShapeSW*,const Transform&,_CollectorCallback *p_callback,real_t,real_t);
template<bool withMargin>
-static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -496,7 +500,7 @@ static void _collision_sphere_sphere(const ShapeSW *p_a,const Transform &p_trans
}
template<bool withMargin>
-static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -551,7 +555,7 @@ static void _collision_sphere_box(const ShapeSW *p_a,const Transform &p_transfor
}
template<bool withMargin>
-static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -591,7 +595,7 @@ static void _collision_sphere_capsule(const ShapeSW *p_a,const Transform &p_tran
}
template<bool withMargin>
-static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
@@ -635,7 +639,7 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform
Vector3 n1=v2-v1;
Vector3 n2=v2-v3;
- Vector3 axis = n1.cross(n2).cross(n1).normalized();;
+ Vector3 axis = n1.cross(n2).cross(n1).normalized();
if (!separator.test_axis( axis ))
return;
@@ -662,7 +666,7 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a,const Transform
}
template<bool withMargin>
-static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW*>(p_a);
const FaceShapeSW *face_B = static_cast<const FaceShapeSW*>(p_b);
@@ -706,7 +710,7 @@ static void _collision_sphere_face(const ShapeSW *p_a,const Transform &p_transfo
template<bool withMargin>
-static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
@@ -814,7 +818,7 @@ static void _collision_box_box(const ShapeSW *p_a,const Transform &p_transform_a
}
template<bool withMargin>
-static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -914,7 +918,7 @@ static void _collision_box_capsule(const ShapeSW *p_a,const Transform &p_transfo
}
template<bool withMargin>
-static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
@@ -1042,7 +1046,7 @@ static void _collision_box_convex_polygon(const ShapeSW *p_a,const Transform &p_
template<bool withMargin>
-static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const BoxShapeSW *box_A = static_cast<const BoxShapeSW*>(p_a);
@@ -1154,7 +1158,7 @@ static void _collision_box_face(const ShapeSW *p_a,const Transform &p_transform_
template<bool withMargin>
-static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW*>(p_b);
@@ -1212,7 +1216,7 @@ static void _collision_capsule_capsule(const ShapeSW *p_a,const Transform &p_tra
}
template<bool withMargin>
-static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
@@ -1283,7 +1287,7 @@ static void _collision_capsule_convex_polygon(const ShapeSW *p_a,const Transform
template<bool withMargin>
-static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW*>(p_a);
const FaceShapeSW *face_B = static_cast<const FaceShapeSW*>(p_b);
@@ -1346,7 +1350,7 @@ static void _collision_capsule_face(const ShapeSW *p_a,const Transform &p_transf
template<bool withMargin>
-static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Transform &p_transform_a,const ShapeSW *p_b,const Transform &p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW*>(p_a);
@@ -1379,7 +1383,7 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Tr
for (int i=0;i<face_count_A;i++) {
Vector3 axis = p_transform_a.xform( faces_A[i].plane ).normal;
-// Vector3 axis = p_transform_a.basis.xform( faces_A[i].plane.normal ).normalized();
+ //Vector3 axis = p_transform_a.basis.xform( faces_A[i].plane.normal ).normalized();
if (!separator.test_axis( axis ))
return;
@@ -1389,7 +1393,7 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Tr
for (int i=0;i<face_count_B;i++) {
Vector3 axis = p_transform_b.xform( faces_B[i].plane ).normal;
-// Vector3 axis = p_transform_b.basis.xform( faces_B[i].plane.normal ).normalized();
+ //Vector3 axis = p_transform_b.basis.xform( faces_B[i].plane.normal ).normalized();
if (!separator.test_axis( axis ))
@@ -1470,7 +1474,7 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a,const Tr
template<bool withMargin>
-static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,float p_margin_a,float p_margin_b) {
+static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p_transform_a, const ShapeSW *p_b,const Transform& p_transform_b,_CollectorCallback *p_collector,real_t p_margin_a,real_t p_margin_b) {
const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW*>(p_a);
@@ -1502,7 +1506,7 @@ static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p
// faces of A
for (int i=0;i<face_count;i++) {
-// Vector3 axis = p_transform_a.xform( faces[i].plane ).normal;
+ //Vector3 axis = p_transform_a.xform( faces[i].plane ).normal;
Vector3 axis = p_transform_a.basis.xform( faces[i].plane.normal ).normalized();
if (!separator.test_axis( axis ))
@@ -1581,7 +1585,7 @@ static void _collision_convex_polygon_face(const ShapeSW *p_a,const Transform &p
}
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata,bool p_swap,Vector3* r_prev_axis,float p_margin_a,float p_margin_b) {
+bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata,bool p_swap,Vector3* r_prev_axis,real_t p_margin_a,real_t p_margin_b) {
PhysicsServer::ShapeType type_A=p_shape_A->get_type();
@@ -1663,8 +1667,8 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_tran
const ShapeSW *B=p_shape_B;
const Transform *transform_A=&p_transform_A;
const Transform *transform_B=&p_transform_B;
- float margin_A=p_margin_a;
- float margin_B=p_margin_b;
+ real_t margin_A=p_margin_a;
+ real_t margin_B=p_margin_b;
if (type_A > type_B) {
SWAP(A,B);
diff --git a/servers/physics/collision_solver_sat.h b/servers/physics/collision_solver_sat.h
index 60387a978d..15fe7dc34a 100644
--- a/servers/physics/collision_solver_sat.h
+++ b/servers/physics/collision_solver_sat.h
@@ -32,6 +32,6 @@
#include "collision_solver_sw.h"
-bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector3* r_prev_axis=NULL,float p_margin_a=0,float p_margin_b=0);
+bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform& p_transform_A, const ShapeSW *p_shape_B, const Transform& p_transform_B, CollisionSolverSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector3* r_prev_axis=NULL,real_t p_margin_a=0,real_t p_margin_b=0);
#endif // COLLISION_SOLVER_SAT_H
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 91ef7913cf..f0ddde3a76 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -115,8 +115,8 @@ struct _ConcaveCollisionInfo {
int aabb_tests;
int collisions;
bool tested;
- float margin_A;
- float margin_B;
+ real_t margin_A;
+ real_t margin_B;
Vector3 close_A,close_B;
};
@@ -136,7 +136,7 @@ void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) {
}
-bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,float p_margin_A,float p_margin_B) {
+bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,real_t p_margin_A,real_t p_margin_B) {
const ConcaveShapeSW *concave_B=static_cast<const ConcaveShapeSW*>(p_shape_B);
@@ -164,10 +164,10 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform&
for(int i=0;i<3;i++) {
Vector3 axis( p_transform_B.basis.get_axis(i) );
- float axis_scale = 1.0/axis.length();
+ real_t axis_scale = 1.0/axis.length();
axis*=axis_scale;
- float smin,smax;
+ real_t smin,smax;
p_shape_A->project_range(axis,rel_transform,smin,smax);
smin-=p_margin_A;
smax+=p_margin_A;
@@ -186,7 +186,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform&
}
-bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis,float p_margin_A,float p_margin_B) {
+bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis,real_t p_margin_A,real_t p_margin_B) {
PhysicsServer::ShapeType type_A=p_shape_A->get_type();
@@ -291,7 +291,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A,const Tran
bool collided=false;
Vector3 closest;
- float closest_d;
+ real_t closest_d;
for(int i=0;i<support_count;i++) {
@@ -362,10 +362,10 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform&
for(int i=0;i<3;i++) {
Vector3 axis( p_transform_B.basis.get_axis(i) );
- float axis_scale = 1.0/axis.length();
+ real_t axis_scale = ((real_t)1.0)/axis.length();
axis*=axis_scale;
- float smin,smax;
+ real_t smin,smax;
if (use_cc_hint) {
cc_hint_aabb.project_range_in_plane(Plane(axis,0),smin,smax);
@@ -383,7 +383,7 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform&
concave_B->cull(local_aabb,concave_distance_callback,&cinfo);
if (!cinfo.collided) {
-// print_line(itos(cinfo.tested));
+ //print_line(itos(cinfo.tested));
r_point_A=cinfo.close_A;
r_point_B=cinfo.close_B;
diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h
index 16d2b92d70..b8d37a8a96 100644
--- a/servers/physics/collision_solver_sw.h
+++ b/servers/physics/collision_solver_sw.h
@@ -40,14 +40,14 @@ private:
static void concave_callback(void *p_userdata, ShapeSW *p_convex);
static bool solve_static_plane(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result);
static bool solve_ray(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result);
- static bool solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,float p_margin_A=0,float p_margin_B=0);
+ static bool solve_concave(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,real_t p_margin_A=0,real_t p_margin_B=0);
static void concave_distance_callback(void *p_userdata, ShapeSW *p_convex);
static bool solve_distance_plane(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B);
public:
- static bool solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis=NULL,float p_margin_A=0,float p_margin_B=0);
+ static bool solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis=NULL,real_t p_margin_A=0,real_t p_margin_B=0);
static bool solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const Rect3& p_concave_hint,Vector3 *r_sep_axis=NULL);
};
diff --git a/servers/physics/constraint_sw.h b/servers/physics/constraint_sw.h
index adc17cb753..f5bbe4bbd0 100644
--- a/servers/physics/constraint_sw.h
+++ b/servers/physics/constraint_sw.h
@@ -67,8 +67,8 @@ public:
_FORCE_INLINE_ int get_priority() const { return priority; }
- virtual bool setup(float p_step)=0;
- virtual void solve(float p_step)=0;
+ virtual bool setup(real_t p_step)=0;
+ virtual void solve(real_t p_step)=0;
virtual ~ConstraintSW() {}
};
diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp
index 5036a1d8a3..d78bcbd16d 100644
--- a/servers/physics/joints/cone_twist_joint_sw.cpp
+++ b/servers/physics/joints/cone_twist_joint_sw.cpp
@@ -96,7 +96,7 @@ ConeTwistJointSW::ConeTwistJointSW(BodySW* rbA,BodySW* rbB,const Transform& rbAF
}
-bool ConeTwistJointSW::setup(float p_step) {
+bool ConeTwistJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
//set bias, sign, clear accumulator
@@ -156,7 +156,7 @@ bool ConeTwistJointSW::setup(float p_step) {
if (m_swingSpan1 >= real_t(0.05f))
{
b1Axis2 = A->get_transform().basis.xform( this->m_rbAFrame.basis.get_axis(1) );
-// swing1 = btAtan2Fast( b2Axis1.dot(b1Axis2),b2Axis1.dot(b1Axis1) );
+ //swing1 = btAtan2Fast( b2Axis1.dot(b1Axis2),b2Axis1.dot(b1Axis1) );
swx = b2Axis1.dot(b1Axis1);
swy = b2Axis1.dot(b1Axis2);
swing1 = atan2fast(swy, swx);
@@ -169,7 +169,7 @@ bool ConeTwistJointSW::setup(float p_step) {
if (m_swingSpan2 >= real_t(0.05f))
{
b1Axis3 = A->get_transform().basis.xform( this->m_rbAFrame.basis.get_axis(2) );
-// swing2 = btAtan2Fast( b2Axis1.dot(b1Axis3),b2Axis1.dot(b1Axis1) );
+ //swing2 = btAtan2Fast( b2Axis1.dot(b1Axis3),b2Axis1.dot(b1Axis1) );
swx = b2Axis1.dot(b1Axis1);
swy = b2Axis1.dot(b1Axis3);
swing2 = atan2fast(swy, swx);
@@ -318,7 +318,7 @@ void ConeTwistJointSW::solve(real_t timeStep)
}
-void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, float p_value) {
+void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
@@ -345,7 +345,7 @@ void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, flo
}
}
-float ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const{
+real_t ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const{
switch(p_param) {
case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: {
diff --git a/servers/physics/joints/cone_twist_joint_sw.h b/servers/physics/joints/cone_twist_joint_sw.h
index 0d64d67443..eb7a5cd1b1 100644
--- a/servers/physics/joints/cone_twist_joint_sw.h
+++ b/servers/physics/joints/cone_twist_joint_sw.h
@@ -109,8 +109,8 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
ConeTwistJointSW(BodySW* rbA,BodySW* rbB,const Transform& rbAFrame, const Transform& rbBFrame);
@@ -146,8 +146,8 @@ public:
return m_twistLimitSign;
}
- void set_param(PhysicsServer::ConeTwistJointParam p_param, float p_value);
- float get_param(PhysicsServer::ConeTwistJointParam p_param) const;
+ void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const;
};
diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp
index 5824de0127..bd07f3122a 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.cpp
+++ b/servers/physics/joints/generic_6dof_joint_sw.cpp
@@ -38,55 +38,6 @@ See corresponding header file for licensing info.
#define GENERIC_D6_DISABLE_WARMSTARTING 1
-real_t btGetMatrixElem(const Basis& mat, int index);
-real_t btGetMatrixElem(const Basis& mat, int index)
-{
- int i = index%3;
- int j = index/3;
- return mat[i][j];
-}
-
-///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html
-bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz);
-bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz)
-{
-// // rot = cy*cz -cy*sz sy
-// // cz*sx*sy+cx*sz cx*cz-sx*sy*sz -cy*sx
-// // -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy
-//
-
- if (btGetMatrixElem(mat,2) < real_t(1.0))
- {
- if (btGetMatrixElem(mat,2) > real_t(-1.0))
- {
- xyz[0] = Math::atan2(-btGetMatrixElem(mat,5),btGetMatrixElem(mat,8));
- xyz[1] = Math::asin(btGetMatrixElem(mat,2));
- xyz[2] = Math::atan2(-btGetMatrixElem(mat,1),btGetMatrixElem(mat,0));
- return true;
- }
- else
- {
- // WARNING. Not unique. XA - ZA = -atan2(r10,r11)
- xyz[0] = -Math::atan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
- xyz[1] = -Math_PI*0.5;
- xyz[2] = real_t(0.0);
- return false;
- }
- }
- else
- {
- // WARNING. Not unique. XAngle + ZAngle = atan2(r10,r11)
- xyz[0] = Math::atan2(btGetMatrixElem(mat,3),btGetMatrixElem(mat,4));
- xyz[1] = Math_PI*0.5;
- xyz[2] = 0.0;
-
- }
-
-
- return false;
-}
-
-
//////////////////////////// G6DOFRotationalLimitMotorSW ////////////////////////////////////
@@ -298,7 +249,7 @@ void Generic6DOFJointSW::calculateAngleInfo()
{
Basis relative_frame = m_calculatedTransformA.basis.inverse()*m_calculatedTransformB.basis;
- matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff);
+ m_calculatedAxisAngleDiff = relative_frame.get_euler();
@@ -325,16 +276,18 @@ void Generic6DOFJointSW::calculateAngleInfo()
m_calculatedAxis[2] = axis0.cross(m_calculatedAxis[1]);
-// if(m_debugDrawer)
-// {
-//
-// char buff[300];
-// sprintf(buff,"\n X: %.2f ; Y: %.2f ; Z: %.2f ",
-// m_calculatedAxisAngleDiff[0],
-// m_calculatedAxisAngleDiff[1],
-// m_calculatedAxisAngleDiff[2]);
-// m_debugDrawer->reportErrorWarning(buff);
-// }
+ /*
+ if(m_debugDrawer)
+ {
+
+ char buff[300];
+ sprintf(buff,"\n X: %.2f ; Y: %.2f ; Z: %.2f ",
+ m_calculatedAxisAngleDiff[0],
+ m_calculatedAxisAngleDiff[1],
+ m_calculatedAxisAngleDiff[2]);
+ m_debugDrawer->reportErrorWarning(buff);
+ }
+ */
}
@@ -384,7 +337,7 @@ bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index)
return m_angularLimits[axis_index].needApplyTorques();
}
-bool Generic6DOFJointSW::setup(float p_step) {
+bool Generic6DOFJointSW::setup(real_t p_step) {
// Clear accumulated impulses for the next simulation step
m_linearLimits.m_accumulatedImpulse=Vector3(real_t(0.), real_t(0.), real_t(0.));
@@ -530,7 +483,7 @@ void Generic6DOFJointSW::calcAnchorPos(void)
} // Generic6DOFJointSW::calcAnchorPos()
-void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, float p_value) {
+void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) {
ERR_FAIL_INDEX(p_axis,3);
switch(p_param) {
@@ -606,7 +559,7 @@ void Generic6DOFJointSW::set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJoin
}
}
-float Generic6DOFJointSW::get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const{
+real_t Generic6DOFJointSW::get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const{
ERR_FAIL_INDEX_V(p_axis,3,0);
switch(p_param) {
case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: {
@@ -675,7 +628,7 @@ float Generic6DOFJointSW::get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJoi
} break;
case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: {
- return m_angularLimits[p_axis].m_maxLimitForce;
+ return m_angularLimits[p_axis].m_maxMotorForce;
} break;
}
diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics/joints/generic_6dof_joint_sw.h
index 4ac727c124..207ae85a45 100644
--- a/servers/physics/joints/generic_6dof_joint_sw.h
+++ b/servers/physics/joints/generic_6dof_joint_sw.h
@@ -295,8 +295,8 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
//! Calcs global transform of the offsets
@@ -449,8 +449,8 @@ public:
virtual void calcAnchorPos(void); // overridable
- void set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, float p_value);
- float get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const;
+ void set_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value);
+ real_t get_param(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisParam p_param) const;
void set_flag(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
bool get_flag(Vector3::Axis p_axis,PhysicsServer::G6DOFJointAxisFlag p_flag) const;
diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp
index 2f07779131..9617eb8794 100644
--- a/servers/physics/joints/hinge_joint_sw.cpp
+++ b/servers/physics/joints/hinge_joint_sw.cpp
@@ -148,7 +148,7 @@ HingeJointSW::HingeJointSW(BodySW* rbA,BodySW* rbB, const Vector3& pivotInA,cons
-bool HingeJointSW::setup(float p_step) {
+bool HingeJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -221,7 +221,7 @@ bool HingeJointSW::setup(float p_step) {
// Compute limit information
real_t hingeAngle = get_hinge_angle();
-// print_line("angle: "+rtos(hingeAngle));
+ //print_line("angle: "+rtos(hingeAngle));
//set bias, sign, clear accumulator
m_correction = real_t(0.);
m_limitSign = real_t(0.);
@@ -235,17 +235,17 @@ bool HingeJointSW::setup(float p_step) {
print_line("hi: "+rtos(m_upperLimit));
}*/
-// if (m_lowerLimit < m_upperLimit)
+ //if (m_lowerLimit < m_upperLimit)
if (m_useLimit && m_lowerLimit <= m_upperLimit)
{
-// if (hingeAngle <= m_lowerLimit*m_limitSoftness)
+ //if (hingeAngle <= m_lowerLimit*m_limitSoftness)
if (hingeAngle <= m_lowerLimit)
{
m_correction = (m_lowerLimit - hingeAngle);
m_limitSign = 1.0f;
m_solveLimit = true;
}
-// else if (hingeAngle >= m_upperLimit*m_limitSoftness)
+ //else if (hingeAngle >= m_upperLimit*m_limitSoftness)
else if (hingeAngle >= m_upperLimit)
{
m_correction = m_upperLimit - hingeAngle;
@@ -262,7 +262,7 @@ bool HingeJointSW::setup(float p_step) {
return true;
}
-void HingeJointSW::solve(float p_step) {
+void HingeJointSW::solve(real_t p_step) {
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
@@ -371,7 +371,7 @@ void HingeJointSW::solve(float p_step) {
real_t desiredMotorVel = m_motorTargetVelocity;
real_t motor_relvel = desiredMotorVel - projRelVel;
- real_t unclippedMotorImpulse = m_kHinge * motor_relvel;;
+ real_t unclippedMotorImpulse = m_kHinge * motor_relvel;
//todo: should clip against accumulated impulse
real_t clippedMotorImpulse = unclippedMotorImpulse > m_maxMotorImpulse ? m_maxMotorImpulse : unclippedMotorImpulse;
clippedMotorImpulse = clippedMotorImpulse < -m_maxMotorImpulse ? -m_maxMotorImpulse : clippedMotorImpulse;
@@ -418,7 +418,7 @@ real_t HingeJointSW::get_hinge_angle() {
}
-void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, float p_value) {
+void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
@@ -434,7 +434,7 @@ void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, float p_val
}
}
-float HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const{
+real_t HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const{
switch (p_param) {
diff --git a/servers/physics/joints/hinge_joint_sw.h b/servers/physics/joints/hinge_joint_sw.h
index 60203e3cc4..8469fd1ca0 100644
--- a/servers/physics/joints/hinge_joint_sw.h
+++ b/servers/physics/joints/hinge_joint_sw.h
@@ -103,13 +103,13 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
real_t get_hinge_angle();
- void set_param(PhysicsServer::HingeJointParam p_param, float p_value);
- float get_param(PhysicsServer::HingeJointParam p_param) const;
+ void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::HingeJointParam p_param) const;
void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value);
bool get_flag(PhysicsServer::HingeJointFlag p_flag) const;
diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics/joints/pin_joint_sw.cpp
index 292d30443c..b545ae630b 100644
--- a/servers/physics/joints/pin_joint_sw.cpp
+++ b/servers/physics/joints/pin_joint_sw.cpp
@@ -34,7 +34,7 @@ See corresponding header file for licensing info.
#include "pin_joint_sw.h"
-bool PinJointSW::setup(float p_step) {
+bool PinJointSW::setup(real_t p_step) {
m_appliedImpulse = real_t(0.);
@@ -59,7 +59,7 @@ bool PinJointSW::setup(float p_step) {
return true;
}
-void PinJointSW::solve(float p_step){
+void PinJointSW::solve(real_t p_step){
Vector3 pivotAInW = A->get_transform().xform(m_pivotInA);
Vector3 pivotBInW = B->get_transform().xform(m_pivotInB);
@@ -68,8 +68,8 @@ void PinJointSW::solve(float p_step){
Vector3 normal(0,0,0);
-// Vector3 angvelA = A->get_transform().origin.getBasis().transpose() * A->getAngularVelocity();
-// Vector3 angvelB = B->get_transform().origin.getBasis().transpose() * B->getAngularVelocity();
+ //Vector3 angvelA = A->get_transform().origin.getBasis().transpose() * A->getAngularVelocity();
+ //Vector3 angvelB = B->get_transform().origin.getBasis().transpose() * B->getAngularVelocity();
for (int i=0;i<3;i++)
{
@@ -116,7 +116,7 @@ void PinJointSW::solve(float p_step){
}
}
-void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,float p_value) {
+void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,real_t p_value) {
switch(p_param) {
case PhysicsServer::PIN_JOINT_BIAS: m_tau=p_value; break;
@@ -125,7 +125,7 @@ void PinJointSW::set_param(PhysicsServer::PinJointParam p_param,float p_value) {
}
}
-float PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const{
+real_t PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const{
switch(p_param) {
case PhysicsServer::PIN_JOINT_BIAS: return m_tau;
diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics/joints/pin_joint_sw.h
index 6797972496..b72b21219d 100644
--- a/servers/physics/joints/pin_joint_sw.h
+++ b/servers/physics/joints/pin_joint_sw.h
@@ -79,11 +79,11 @@ public:
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
- void set_param(PhysicsServer::PinJointParam p_param,float p_value);
- float get_param(PhysicsServer::PinJointParam p_param) const;
+ void set_param(PhysicsServer::PinJointParam p_param,real_t p_value);
+ real_t get_param(PhysicsServer::PinJointParam p_param) const;
void set_pos_A(const Vector3& p_pos) { m_pivotInA=p_pos; }
void set_pos_B(const Vector3& p_pos) { m_pivotInB=p_pos; }
diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics/joints/slider_joint_sw.cpp
index bdcae08ca4..fc728ed0ba 100644
--- a/servers/physics/joints/slider_joint_sw.cpp
+++ b/servers/physics/joints/slider_joint_sw.cpp
@@ -112,7 +112,7 @@ SliderJointSW::SliderJointSW(BodySW* rbA, BodySW* rbB, const Transform& frameInA
//-----------------------------------------------------------------------------
-bool SliderJointSW::setup(float p_step)
+bool SliderJointSW::setup(real_t p_step)
{
//calculate transforms
@@ -406,7 +406,7 @@ Vector3 SliderJointSW::getAncorInB(void)
return ancorInB;
} // SliderJointSW::getAncorInB();
-void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, float p_value) {
+void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) {
switch(p_param) {
case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit=p_value; break;
@@ -437,7 +437,7 @@ void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, float p_v
}
-float SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const {
+real_t SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const {
switch(p_param) {
case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit;
diff --git a/servers/physics/joints/slider_joint_sw.h b/servers/physics/joints/slider_joint_sw.h
index 4e697e6f64..d01038df59 100644
--- a/servers/physics/joints/slider_joint_sw.h
+++ b/servers/physics/joints/slider_joint_sw.h
@@ -237,11 +237,11 @@ public:
Vector3 getAncorInA(void);
Vector3 getAncorInB(void);
- void set_param(PhysicsServer::SliderJointParam p_param, float p_value);
- float get_param(PhysicsServer::SliderJointParam p_param) const;
+ void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value);
+ real_t get_param(PhysicsServer::SliderJointParam p_param) const;
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; }
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 4069ccdccb..67e3b27852 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -727,7 +727,7 @@ uint32_t PhysicsServerSW::body_get_user_flags(RID p_body, uint32_t p_flags) cons
return 0;
};
-void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
+void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -735,7 +735,7 @@ void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_
body->set_param(p_param,p_value);
};
-float PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
+real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -879,14 +879,14 @@ void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exc
};
-void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) {
+void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
};
-float PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
+real_t PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
BodySW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -971,7 +971,7 @@ RID PhysicsServerSW::joint_create_pin(RID p_body_A,const Vector3& p_local_A,RID
return rid;
}
-void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, float p_value){
+void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -980,7 +980,7 @@ void PhysicsServerSW::pin_joint_set_param(RID p_joint,PinJointParam p_param, flo
pin_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::pin_joint_get_param(RID p_joint,PinJointParam p_param) const{
+real_t PhysicsServerSW::pin_joint_get_param(RID p_joint,PinJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1074,7 +1074,7 @@ RID PhysicsServerSW::joint_create_hinge_simple(RID p_body_A,const Vector3& p_piv
}
-void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param, float p_value){
+void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1083,7 +1083,7 @@ void PhysicsServerSW::hinge_joint_set_param(RID p_joint,HingeJointParam p_param,
hinge_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const{
+real_t PhysicsServerSW::hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1154,7 +1154,7 @@ RID PhysicsServerSW::joint_create_slider(RID p_body_A,const Transform& p_local_f
return rid;
}
-void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_param, float p_value){
+void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1162,7 +1162,7 @@ void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_para
SliderJointSW *slider_joint = static_cast<SliderJointSW*>(joint);
slider_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::slider_joint_get_param(RID p_joint,SliderJointParam p_param) const{
+real_t PhysicsServerSW::slider_joint_get_param(RID p_joint,SliderJointParam p_param) const{
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1193,7 +1193,7 @@ RID PhysicsServerSW::joint_create_cone_twist(RID p_body_A,const Transform& p_loc
return rid;
}
-void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, float p_value) {
+void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, real_t p_value) {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1201,7 +1201,7 @@ void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam
ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW*>(joint);
cone_twist_joint->set_param(p_param,p_value);
}
-float PhysicsServerSW::cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const {
+real_t PhysicsServerSW::cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const {
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1232,7 +1232,7 @@ RID PhysicsServerSW::joint_create_generic_6dof(RID p_body_A,const Transform& p_l
return rid;
}
-void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param, float p_value){
+void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param, real_t p_value){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND(!joint);
@@ -1240,7 +1240,7 @@ void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_a
Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint);
generic_6dof_joint->set_param(p_axis,p_param,p_value);
}
-float PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param){
+real_t PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param){
JointSW *joint = joint_owner.get(p_joint);
ERR_FAIL_COND_V(!joint,0);
@@ -1395,11 +1395,13 @@ void PhysicsServerSW::free(RID p_rid) {
BodySW *body = body_owner.get(p_rid);
-// if (body->get_state_query())
-// _clear_query(body->get_state_query());
+ /*
+ if (body->get_state_query())
+ _clear_query(body->get_state_query());
-// if (body->get_direct_state_query())
-// _clear_query(body->get_direct_state_query());
+ if (body->get_direct_state_query())
+ _clear_query(body->get_direct_state_query());
+ */
body->set_space(NULL);
@@ -1422,8 +1424,10 @@ void PhysicsServerSW::free(RID p_rid) {
AreaSW *area = area_owner.get(p_rid);
-// if (area->get_monitor_query())
-// _clear_query(area->get_monitor_query());
+ /*
+ if (area->get_monitor_query())
+ _clear_query(area->get_monitor_query());
+ */
area->set_space(NULL);
@@ -1484,7 +1488,7 @@ void PhysicsServerSW::init() {
};
-void PhysicsServerSW::step(float p_step) {
+void PhysicsServerSW::step(real_t p_step) {
if (!active)
@@ -1607,11 +1611,11 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3& p_point_A,const Vector3& p_p
if (cbk->amount == cbk->max) {
//find least deep
- float min_depth=1e20;
+ real_t min_depth=1e20;
int min_depth_idx=0;
for(int i=0;i<cbk->amount;i++) {
- float d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
+ real_t d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
if (d<min_depth) {
min_depth=d;
min_depth_idx=i;
@@ -1619,7 +1623,7 @@ void PhysicsServerSW::_shape_col_cbk(const Vector3& p_point_A,const Vector3& p_p
}
- float d = p_point_A.distance_squared_to(p_point_B);
+ real_t d = p_point_A.distance_squared_to(p_point_B);
if (d<min_depth)
return;
cbk->ptr[min_depth_idx*2+0]=p_point_A;
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index a3f98392fc..6e20474350 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -62,7 +62,7 @@ friend class PhysicsDirectSpaceStateSW;
mutable RID_Owner<BodySW> body_owner;
mutable RID_Owner<JointSW> joint_owner;
-// void _clear_query(QuerySW *p_query);
+ //void _clear_query(QuerySW *p_query);
public:
struct CollCbkData {
@@ -180,8 +180,8 @@ public:
virtual void body_set_user_flags(RID p_body, uint32_t p_flags);
virtual uint32_t body_get_user_flags(RID p_body, uint32_t p_flags) const;
- virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
- virtual float body_get_param(RID p_body, BodyParameter p_param) const;
+ virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value);
+ virtual real_t body_get_param(RID p_body, BodyParameter p_param) const;
virtual void body_set_state(RID p_body, BodyState p_state, const Variant& p_variant);
virtual Variant body_get_state(RID p_body, BodyState p_state) const;
@@ -203,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, float p_treshold);
- virtual float body_get_contacts_reported_depth_treshold(RID p_body) const;
+ 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_omit_force_integration(RID p_body,bool p_omit);
virtual bool body_is_omitting_force_integration(RID p_body) const;
@@ -221,8 +221,8 @@ public:
virtual RID joint_create_pin(RID p_body_A,const Vector3& p_local_A,RID p_body_B,const Vector3& p_local_B);
- virtual void pin_joint_set_param(RID p_joint,PinJointParam p_param, float p_value);
- virtual float pin_joint_get_param(RID p_joint,PinJointParam p_param) const;
+ virtual void pin_joint_set_param(RID p_joint,PinJointParam p_param, real_t p_value);
+ virtual real_t pin_joint_get_param(RID p_joint,PinJointParam p_param) const;
virtual void pin_joint_set_local_A(RID p_joint, const Vector3& p_A);
virtual Vector3 pin_joint_get_local_A(RID p_joint) const;
@@ -233,8 +233,8 @@ public:
virtual RID joint_create_hinge(RID p_body_A,const Transform& p_frame_A,RID p_body_B,const Transform& p_frame_B);
virtual RID joint_create_hinge_simple(RID p_body_A,const Vector3& p_pivot_A,const Vector3& p_axis_A,RID p_body_B,const Vector3& p_pivot_B,const Vector3& p_axis_B);
- virtual void hinge_joint_set_param(RID p_joint,HingeJointParam p_param, float p_value);
- virtual float hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const;
+ virtual void hinge_joint_set_param(RID p_joint,HingeJointParam p_param, real_t p_value);
+ virtual real_t hinge_joint_get_param(RID p_joint,HingeJointParam p_param) const;
virtual void hinge_joint_set_flag(RID p_joint,HingeJointFlag p_flag, bool p_value);
virtual bool hinge_joint_get_flag(RID p_joint,HingeJointFlag p_flag) const;
@@ -242,18 +242,18 @@ public:
virtual RID joint_create_slider(RID p_body_A,const Transform& p_local_frame_A,RID p_body_B,const Transform& p_local_frame_B); //reference frame is A
- virtual void slider_joint_set_param(RID p_joint,SliderJointParam p_param, float p_value);
- virtual float slider_joint_get_param(RID p_joint,SliderJointParam p_param) const;
+ virtual void slider_joint_set_param(RID p_joint,SliderJointParam p_param, real_t p_value);
+ virtual real_t slider_joint_get_param(RID p_joint,SliderJointParam p_param) const;
virtual RID joint_create_cone_twist(RID p_body_A,const Transform& p_local_frame_A,RID p_body_B,const Transform& p_local_frame_B); //reference frame is A
- virtual void cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, float p_value);
- virtual float cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const;
+ virtual void cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, real_t p_value);
+ virtual real_t cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const;
virtual RID joint_create_generic_6dof(RID p_body_A,const Transform& p_local_frame_A,RID p_body_B,const Transform& p_local_frame_B); //reference frame is A
- virtual void generic_6dof_joint_set_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param, float p_value);
- virtual float generic_6dof_joint_get_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param);
+ virtual void generic_6dof_joint_set_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param, real_t p_value);
+ virtual real_t generic_6dof_joint_get_param(RID p_joint,Vector3::Axis,G6DOFJointAxisParam p_param);
virtual void generic_6dof_joint_set_flag(RID p_joint,Vector3::Axis,G6DOFJointAxisFlag p_flag, bool p_enable);
virtual bool generic_6dof_joint_get_flag(RID p_joint,Vector3::Axis,G6DOFJointAxisFlag p_flag);
@@ -281,7 +281,7 @@ public:
virtual void set_active(bool p_active);
virtual void init();
- virtual void step(float p_step);
+ virtual void step(real_t p_step);
virtual void sync();
virtual void flush_queries();
virtual void finish();
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 59ade71475..dec1c75d9f 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -125,7 +125,7 @@ bool PlaneShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end
return inters;
}
-Vector3 PlaneShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); //wtf
}
@@ -154,7 +154,7 @@ PlaneShapeSW::PlaneShapeSW() {
//
-float RayShapeSW::get_length() const {
+real_t RayShapeSW::get_length() const {
return length;
}
@@ -181,7 +181,7 @@ void RayShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo
r_amount=2;
r_supports[0]=Vector3(0,0,0);
r_supports[1]=Vector3(0,0,length);
- } if (p_normal.z>0) {
+ } else if (p_normal.z>0) {
r_amount=1;
*r_supports=Vector3(0,0,length);
} else {
@@ -196,12 +196,12 @@ bool RayShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,V
return false; //simply not possible
}
-Vector3 RayShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3();
}
-void RayShapeSW::_setup(float p_length) {
+void RayShapeSW::_setup(real_t p_length) {
length=p_length;
configure(Rect3(Vector3(0,0,0),Vector3(0.1,0.1,length)));
@@ -234,11 +234,11 @@ real_t SphereShapeSW::get_radius() const {
void SphereShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
- float d = p_normal.dot( p_transform.origin );
+ real_t d = p_normal.dot( p_transform.origin );
// figure out scale at point
Vector3 local_normal = p_transform.basis.xform_inv(p_normal);
- float scale = local_normal.length();
+ real_t scale = local_normal.length();
r_min = d - (radius) * scale;
r_max = d + (radius) * scale;
@@ -261,9 +261,9 @@ bool SphereShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_en
return Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(),radius,&r_result,&r_normal);
}
-Vector3 SphereShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const {
- float s = 0.4 * p_mass * radius * radius;
+ real_t s = 0.4 * p_mass * radius * radius;
return Vector3(s,s,s);
}
@@ -299,8 +299,8 @@ void BoxShapeSW::project_range(const Vector3& p_normal, const Transform& p_trans
// no matter the angle, the box is mirrored anyway
Vector3 local_normal=p_transform.basis.xform_inv(p_normal);
- float length = local_normal.abs().dot(half_extents);
- float distance = p_normal.dot( p_transform.origin );
+ real_t length = local_normal.abs().dot(half_extents);
+ real_t distance = p_normal.dot( p_transform.origin );
r_min = distance - length;
r_max = distance + length;
@@ -329,7 +329,7 @@ void BoxShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo
Vector3 axis;
axis[i]=1.0;
- float dot = p_normal.dot( axis );
+ real_t dot = p_normal.dot( axis );
if ( Math::abs( dot ) > _FACE_IS_VALID_SUPPORT_TRESHOLD ) {
//Vector3 axis_b;
@@ -343,7 +343,7 @@ void BoxShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo
int i_n=next[i];
int i_n2=next2[i];
- static const float sign[4][2]={
+ static const real_t sign[4][2]={
{-1.0, 1.0},
{ 1.0, 1.0},
@@ -418,11 +418,11 @@ bool BoxShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,V
}
-Vector3 BoxShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const {
- float lx=half_extents.x;
- float ly=half_extents.y;
- float lz=half_extents.z;
+ real_t lx=half_extents.x;
+ real_t ly=half_extents.y;
+ real_t lz=half_extents.z;
return Vector3( (p_mass/3.0) * (ly*ly + lz*lz), (p_mass/3.0) * (lx*lx + lz*lz), (p_mass/3.0) * (lx*lx + ly*ly) );
@@ -460,7 +460,7 @@ BoxShapeSW::BoxShapeSW() {
void CapsuleShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
Vector3 n=p_transform.basis.xform_inv(p_normal).normalized();
- float h = (n.z > 0) ? height : -height;
+ real_t h = (n.z > 0) ? height : -height;
n *= radius;
n.z += h * 0.5;
@@ -471,8 +471,8 @@ void CapsuleShapeSW::project_range(const Vector3& p_normal, const Transform& p_t
n = p_transform.basis.xform(n);
- float distance = p_normal.dot( p_transform.origin );
- float length = Math::abs(p_normal.dot(n));
+ real_t distance = p_normal.dot( p_transform.origin );
+ real_t length = Math::abs(p_normal.dot(n));
r_min = distance - length;
r_max = distance + length;
@@ -484,7 +484,7 @@ Vector3 CapsuleShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
- float h = (n.z > 0) ? height : -height;
+ real_t h = (n.z > 0) ? height : -height;
n*=radius;
n.z += h*0.5;
@@ -496,7 +496,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
Vector3 n=p_normal;
- float d = n.z;
+ real_t d = n.z;
if (Math::abs( d )<_EDGE_IS_VALID_SUPPORT_TRESHOLD ) {
@@ -513,7 +513,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
} else {
- float h = (d > 0) ? height : -height;
+ real_t h = (d > 0) ? height : -height;
n*=radius;
n.z += h*0.5;
@@ -528,7 +528,7 @@ void CapsuleShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_s
bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const {
Vector3 norm=(p_end-p_begin).normalized();
- float min_d=1e20;
+ real_t min_d=1e20;
Vector3 res,n;
@@ -542,7 +542,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_cylinder(p_begin,p_end,height,radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
res=auxres;
@@ -554,7 +554,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(0,0,height*0.5),radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
res=auxres;
@@ -566,7 +566,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
collided = Geometry::segment_intersects_sphere(p_begin,p_end,Vector3(0,0,height*-0.5),radius,&auxres,&auxn);
if (collided) {
- float d=norm.dot(auxres);
+ real_t d=norm.dot(auxres);
if (d<min_d) {
min_d=d;
@@ -584,7 +584,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_e
return collision;
}
-Vector3 CapsuleShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -647,7 +647,7 @@ void ConvexPolygonShapeSW::project_range(const Vector3& p_normal, const Transfor
for (int i=0;i<vertex_count;i++) {
- float d=p_normal.dot( p_transform.xform( vrts[i] ) );
+ real_t d=p_normal.dot( p_transform.xform( vrts[i] ) );
if (i==0 || d > r_max)
r_max=d;
@@ -661,7 +661,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
int vertex_count=mesh.vertices.size();
if (vertex_count==0)
@@ -671,7 +671,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3& p_normal) const {
for (int i=0;i<vertex_count;i++) {
- float d=n.dot(vrts[i]);
+ real_t d=n.dot(vrts[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -702,7 +702,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector
for (int i=0;i<vc;i++) {
- float d=p_normal.dot(vertices[i]);
+ real_t d=p_normal.dot(vertices[i]);
if (i==0 || d > max) {
max=d;
@@ -742,7 +742,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector
for(int i=0;i<ec;i++) {
- float dot=(vertices[edges[i].a]-vertices[edges[i].b]).normalized().dot(p_normal);
+ 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)) {
@@ -768,7 +768,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
const Vector3 *vertices = mesh.vertices.ptr();
Vector3 n = p_end-p_begin;
- float min = 1e20;
+ real_t min = 1e20;
bool col=false;
for(int i=0;i<fc;i++) {
@@ -784,7 +784,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
Face3 f(vertices[ind[0]],vertices[ind[j]],vertices[ind[j+1]]);
Vector3 result;
if (f.intersects_segment(p_begin,p_end,&result)) {
- float d = n.dot(result);
+ real_t d = n.dot(result);
if (d<min) {
min=d;
r_result=result;
@@ -802,7 +802,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector
}
-Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -859,7 +859,7 @@ void FaceShapeSW::project_range(const Vector3& p_normal, const Transform& p_tran
for (int i=0;i<3;i++) {
Vector3 v=p_transform.xform(vertex[i]);
- float d=p_normal.dot(v);
+ real_t d=p_normal.dot(v);
if (i==0 || d > r_max)
r_max=d;
@@ -873,11 +873,11 @@ Vector3 FaceShapeSW::get_support(const Vector3& p_normal) const {
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<3;i++) {
- float d=p_normal.dot(vertex[i]);
+ real_t d=p_normal.dot(vertex[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -907,11 +907,11 @@ void FaceShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supp
/** FIND SUPPORT VERTEX **/
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<3;i++) {
- float d=n.dot(vertex[i]);
+ real_t d=n.dot(vertex[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -928,7 +928,7 @@ void FaceShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supp
continue;
// check if edge is valid as a support
- float dot=(vertex[i]-vertex[nx]).normalized().dot(n);
+ real_t dot=(vertex[i]-vertex[nx]).normalized().dot(n);
dot=ABS(dot);
if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) {
@@ -957,7 +957,7 @@ bool FaceShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,
return c;
}
-Vector3 FaceShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const {
return Vector3(); // Sorry, but i don't think anyone cares, FaceShape!
@@ -1003,7 +1003,7 @@ void ConcavePolygonShapeSW::project_range(const Vector3& p_normal, const Transfo
for (int i=0;i<count;i++) {
- float d=p_normal.dot( p_transform.xform( vptr[i] ) );
+ real_t d=p_normal.dot( p_transform.xform( vptr[i] ) );
if (i==0 || d > r_max)
r_max=d;
@@ -1026,11 +1026,11 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3& p_normal) const {
Vector3 n=p_normal;
int vert_support_idx=-1;
- float support_max;
+ real_t support_max;
for (int i=0;i<count;i++) {
- float d=n.dot(vptr[i]);
+ real_t d=n.dot(vptr[i]);
if (i==0 || d > support_max) {
support_max=d;
@@ -1048,8 +1048,10 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
const BVH *bvh=&p_params->bvh[p_idx];
- //if (p_params->dir.dot(bvh->aabb.get_support(-p_params->dir))>p_params->min_d)
- // return; //test against whole AABB, which isn't very costly
+ /*
+ if (p_params->dir.dot(bvh->aabb.get_support(-p_params->dir))>p_params->min_d)
+ return; //test against whole AABB, which isn't very costly
+ */
//printf("addr: %p\n",bvh);
@@ -1078,7 +1080,7 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
&res)) {
- float d=p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
+ real_t d=p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
//TODO, seems segmen/triangle intersection is broken :(
if (d>0 && d<p_params->min_d) {
@@ -1204,7 +1206,7 @@ void ConcavePolygonShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,v
}
-Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
Vector3 extents=get_aabb().size*0.5;
@@ -1309,7 +1311,7 @@ _VolumeSW_BVH* _volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements,int p_size
bvh->left=_volume_sw_build_bvh(p_elements,split,count);
bvh->right=_volume_sw_build_bvh(&p_elements[split],p_size-split,count);
-// printf("branch at %p - %i: %i\n",bvh,count,bvh->face_index);
+ //printf("branch at %p - %i: %i\n",bvh,count,bvh->face_index);
count++;
return bvh;
}
@@ -1322,7 +1324,7 @@ void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH* p_bvh_tree,BVH* p_bvh_array
p_bvh_array[idx].aabb=p_bvh_tree->aabb;
p_bvh_array[idx].face_index=p_bvh_tree->face_index;
-// printf("%p - %i: %i(%p) -- %p:%p\n",%p_bvh_array[idx],p_idx,p_bvh_array[i]->face_index,&p_bvh_tree->face_index,p_bvh_tree->left,p_bvh_tree->right);
+ //printf("%p - %i: %i(%p) -- %p:%p\n",%p_bvh_array[idx],p_idx,p_bvh_array[i]->face_index,&p_bvh_tree->face_index,p_bvh_tree->left,p_bvh_tree->right);
if (p_bvh_tree->left) {
@@ -1553,7 +1555,7 @@ ConcavePolygonShapeSW::ConcavePolygonShapeSW() {
/* HEIGHT MAP SHAPE */
-PoolVector<float> HeightMapShapeSW::get_heights() const {
+PoolVector<real_t> HeightMapShapeSW::get_heights() const {
return heights;
}
@@ -1565,7 +1567,7 @@ int HeightMapShapeSW::get_depth() const {
return depth;
}
-float HeightMapShapeSW::get_cell_size() const {
+real_t HeightMapShapeSW::get_cell_size() const {
return cell_size;
}
@@ -1600,7 +1602,7 @@ void HeightMapShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,void*
}
-Vector3 HeightMapShapeSW::get_moment_of_inertia(float p_mass) const {
+Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const {
// use crappy AABB approximation
@@ -1618,7 +1620,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights,int p_width,int p_dep
heights=p_heights;
width=p_width;
- depth=p_depth;;
+ depth=p_depth;
cell_size=p_cell_size;
PoolVector<real_t>::Read r = heights. read();
@@ -1629,7 +1631,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights,int p_width,int p_dep
for(int j=0;j<width;j++) {
- float h = r[i*width+j];
+ real_t h = r[i*width+j];
Vector3 pos( j*cell_size, h, i*cell_size );
if (i==0 || j==0)
@@ -1655,8 +1657,8 @@ void HeightMapShapeSW::set_data(const Variant& p_data) {
int width=d["width"];
int depth=d["depth"];
- float cell_size=d["cell_size"];
- PoolVector<float> heights=d["heights"];
+ real_t cell_size=d["cell_size"];
+ PoolVector<real_t> heights=d["heights"];
ERR_FAIL_COND( width<= 0);
ERR_FAIL_COND( depth<= 0);
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index 3cbd1c9609..55daa5856d 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -35,8 +35,8 @@
/*
SHAPE_LINE, ///< plane:"plane"
-SHAPE_SEGMENT, ///< float:"length"
-SHAPE_CIRCLE, ///< float:"radius"
+SHAPE_SEGMENT, ///< real_t:"length"
+SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector3 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector3 array)
@@ -90,7 +90,7 @@ public:
virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const=0;
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_point, Vector3 &r_normal) const=0;
- virtual Vector3 get_moment_of_inertia(float p_mass) const=0;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const=0;
virtual void set_data(const Variant& p_data)=0;
virtual Variant get_data() const=0;
@@ -130,7 +130,7 @@ public:
Plane get_plane() const;
- virtual real_t get_area() const { return INFINITY; }
+ virtual real_t get_area() const { return Math_INF; }
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; }
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;
@@ -138,7 +138,7 @@ public:
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -148,12 +148,12 @@ public:
class RayShapeSW : public ShapeSW {
- float length;
+ real_t length;
- void _setup(float p_length);
+ void _setup(real_t p_length);
public:
- float get_length() const;
+ real_t get_length() const;
virtual real_t get_area() const { return 0.0; }
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; }
@@ -163,7 +163,7 @@ public:
virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -189,7 +189,7 @@ 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 Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -213,7 +213,7 @@ 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 Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -242,7 +242,7 @@ 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 Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -266,7 +266,7 @@ 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 Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -349,7 +349,7 @@ public:
virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -364,18 +364,18 @@ struct HeightMapShapeSW : public ConcaveShapeSW {
PoolVector<real_t> heights;
int width;
int depth;
- float cell_size;
+ real_t cell_size;
-// void _cull_segment(int p_idx,_SegmentCullParams *p_params) const;
-// void _cull(int p_idx,_CullParams *p_params) const;
+ //void _cull_segment(int p_idx,_SegmentCullParams *p_params) const;
+ //void _cull(int p_idx,_CullParams *p_params) const;
- void _setup(PoolVector<float> p_heights,int p_width,int p_depth,float p_cell_size);
+ void _setup(PoolVector<real_t> p_heights,int p_width,int p_depth,real_t p_cell_size);
public:
PoolVector<real_t> get_heights() const;
int get_width() const;
int get_depth() const;
- float get_cell_size() const;
+ real_t get_cell_size() const;
virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; }
@@ -385,7 +385,7 @@ public:
virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const;
- virtual Vector3 get_moment_of_inertia(float p_mass) const;
+ virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -409,7 +409,7 @@ struct FaceShapeSW : public ShapeSW {
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;
- Vector3 get_moment_of_inertia(float p_mass) const;
+ Vector3 get_moment_of_inertia(real_t p_mass) const;
virtual void set_data(const Variant& p_data) {}
virtual Variant get_data() const { return Variant(); }
@@ -450,7 +450,7 @@ 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; }
- Vector3 get_moment_of_inertia(float p_mass) const { return Vector3(); }
+ Vector3 get_moment_of_inertia(real_t p_mass) const { return Vector3(); }
virtual void set_data(const Variant& p_data) {}
virtual Variant get_data() const { return Variant(); }
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index d73d5f140e..0bc11041de 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "globals.h"
+#include "global_config.h"
#include "space_sw.h"
#include "collision_solver_sw.h"
#include "physics_server_sw.h"
@@ -138,7 +138,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3& p_from, const Vecto
}
-int PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+int PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
if (p_result_max<=0)
return 0;
@@ -193,7 +193,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transfo
}
-bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform& p_xform,const Vector3& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask,ShapeRestInfo *r_info) {
+bool PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask,ShapeRestInfo *r_info) {
@@ -204,13 +204,15 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
aabb=aabb.merge(Rect3(aabb.pos+p_motion,aabb.size)); //motion
aabb=aabb.grow(p_margin);
- //if (p_motion!=Vector3())
- // print_line(p_motion);
+ /*
+ if (p_motion!=Vector3())
+ print_line(p_motion);
+ */
int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,SpaceSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results);
- float best_safe=1;
- float best_unsafe=1;
+ real_t best_safe=1;
+ real_t best_unsafe=1;
Transform xform_inv = p_xform.affine_inverse();
MotionShapeSW mshape;
@@ -262,13 +264,13 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
//just do kinematic solving
- float low=0;
- float hi=1;
+ real_t low=0;
+ real_t hi=1;
Vector3 mnormal=p_motion.normalized();
for(int i=0;i<8;i++) { //steps should be customizable..
- float ofs = (low+hi)*0.5;
+ real_t ofs = (low+hi)*0.5;
Vector3 sep=mnormal; //important optimization for this to work fast enough
@@ -321,7 +323,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform&
return true;
}
-bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform& p_shape_xform,float p_margin,Vector3 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask){
+bool PhysicsDirectSpaceStateSW::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,uint32_t p_layer_mask,uint32_t p_object_type_mask){
if (p_result_max<=0)
return 0;
@@ -386,7 +388,7 @@ struct _RestCallbackData {
int best_shape;
Vector3 best_contact;
Vector3 best_normal;
- float best_len;
+ real_t best_len;
};
static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,void *p_userdata) {
@@ -395,7 +397,7 @@ static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,v
_RestCallbackData *rd=(_RestCallbackData*)p_userdata;
Vector3 contact_rel = p_point_B - p_point_A;
- float len = contact_rel.length();
+ real_t len = contact_rel.length();
if (len <= rd->best_len)
return;
@@ -406,7 +408,7 @@ static void _rest_cbk_result(const Vector3& p_point_A,const Vector3& p_point_B,v
rd->best_shape=rd->shape;
}
-bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform& p_shape_xform,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform& p_shape_xform,real_t p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h
index 0abc4726ea..208831914f 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics/space_sw.h
@@ -37,7 +37,7 @@
#include "area_pair_sw.h"
#include "broad_phase_sw.h"
#include "collision_object_sw.h"
-#include "globals.h"
+#include "global_config.h"
class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {
@@ -48,10 +48,10 @@ public:
SpaceSW *space;
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_layer_mask=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,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=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,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=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,float p_margin,Vector3 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ 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_layer_mask=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_layer_mask=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_layer_mask=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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
PhysicsDirectSpaceStateSW();
};
@@ -105,10 +105,10 @@ private:
CollisionObjectSW *intersection_query_results[INTERSECTION_QUERY_MAX];
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
- float body_linear_velocity_sleep_threshold;
- float body_angular_velocity_sleep_threshold;
- float body_time_to_sleep;
- float body_angular_velocity_damp_ratio;
+ real_t body_linear_velocity_sleep_threshold;
+ real_t body_angular_velocity_sleep_threshold;
+ real_t body_time_to_sleep;
+ real_t body_angular_velocity_damp_ratio;
bool locked;
diff --git a/servers/physics/step_sw.cpp b/servers/physics/step_sw.cpp
index e24081761b..0bd5a874ea 100644
--- a/servers/physics/step_sw.cpp
+++ b/servers/physics/step_sw.cpp
@@ -58,7 +58,7 @@ void StepSW::_populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_
}
}
-void StepSW::_setup_island(ConstraintSW *p_island,float p_delta) {
+void StepSW::_setup_island(ConstraintSW *p_island,real_t p_delta) {
ConstraintSW *ci=p_island;
while(ci) {
@@ -68,7 +68,7 @@ void StepSW::_setup_island(ConstraintSW *p_island,float p_delta) {
}
}
-void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,float p_delta){
+void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,real_t p_delta){
int at_priority=1;
@@ -107,7 +107,7 @@ void StepSW::_solve_island(ConstraintSW *p_island,int p_iterations,float p_delta
}
-void StepSW::_check_suspend(BodySW *p_island,float p_delta) {
+void StepSW::_check_suspend(BodySW *p_island,real_t p_delta) {
bool can_sleep=true;
@@ -145,7 +145,7 @@ void StepSW::_check_suspend(BodySW *p_island,float p_delta) {
}
}
-void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
+void StepSW::step(SpaceSW* p_space,real_t p_delta,int p_iterations) {
p_space->lock(); // can't access space during this
@@ -233,7 +233,7 @@ void StepSW::step(SpaceSW* p_space,float p_delta,int p_iterations) {
}
-// print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
+ //print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
/* SETUP CONSTRAINT ISLANDS */
{
diff --git a/servers/physics/step_sw.h b/servers/physics/step_sw.h
index 2f67b3c8df..7048a76937 100644
--- a/servers/physics/step_sw.h
+++ b/servers/physics/step_sw.h
@@ -36,12 +36,12 @@ class StepSW {
uint64_t _step;
void _populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_constraint_island);
- void _setup_island(ConstraintSW *p_island,float p_delta);
- void _solve_island(ConstraintSW *p_island,int p_iterations,float p_delta);
- void _check_suspend(BodySW *p_island,float p_delta);
+ void _setup_island(ConstraintSW *p_island,real_t p_delta);
+ void _solve_island(ConstraintSW *p_island,int p_iterations,real_t p_delta);
+ void _check_suspend(BodySW *p_island,real_t p_delta);
public:
- void step(SpaceSW* p_space,float p_delta,int p_iterations);
+ void step(SpaceSW* p_space,real_t p_delta,int p_iterations);
StepSW();
};
diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp
index 8ccdd51067..2625502717 100644
--- a/servers/physics_2d/area_2d_sw.cpp
+++ b/servers/physics_2d/area_2d_sw.cpp
@@ -125,14 +125,14 @@ void Area2DSW::set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_
void Area2DSW::set_param(Physics2DServer::AreaParameter p_param, const Variant& p_value) {
switch(p_param) {
- case Physics2DServer::AREA_PARAM_GRAVITY: gravity=p_value; ; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; ; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; ; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; ; break;
- case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; ; break;
- case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; ; break;
- case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; ; break;
- case Physics2DServer::AREA_PARAM_PRIORITY: priority=p_value; ; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY: gravity=p_value; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector=p_value; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point=p_value; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale=p_value; break;
+ case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation=p_value; break;
+ case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp=p_value; break;
+ case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp=p_value; break;
+ case Physics2DServer::AREA_PARAM_PRIORITY: priority=p_value; break;
}
diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h
index 6e79b28afc..02a65962e5 100644
--- a/servers/physics_2d/area_2d_sw.h
+++ b/servers/physics_2d/area_2d_sw.h
@@ -43,13 +43,13 @@ class Area2DSW : public CollisionObject2DSW{
Physics2DServer::AreaSpaceOverrideMode space_override_mode;
- float gravity;
+ real_t gravity;
Vector2 gravity_vector;
bool gravity_is_point;
- float gravity_distance_scale;
- float point_attenuation;
- float linear_damp;
- float angular_damp;
+ real_t gravity_distance_scale;
+ real_t point_attenuation;
+ real_t linear_damp;
+ real_t angular_damp;
int priority;
bool monitorable;
@@ -131,8 +131,8 @@ public:
void set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_mode);
Physics2DServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; }
- _FORCE_INLINE_ void set_gravity(float p_gravity) { gravity=p_gravity; }
- _FORCE_INLINE_ float get_gravity() const { return gravity; }
+ _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity=p_gravity; }
+ _FORCE_INLINE_ real_t get_gravity() const { return gravity; }
_FORCE_INLINE_ void set_gravity_vector(const Vector2& p_gravity) { gravity_vector=p_gravity; }
_FORCE_INLINE_ Vector2 get_gravity_vector() const { return gravity_vector; }
@@ -140,17 +140,17 @@ public:
_FORCE_INLINE_ void set_gravity_as_point(bool p_enable) { gravity_is_point=p_enable; }
_FORCE_INLINE_ bool is_gravity_point() const { return gravity_is_point; }
- _FORCE_INLINE_ void set_gravity_distance_scale(float scale) { gravity_distance_scale=scale; }
- _FORCE_INLINE_ float get_gravity_distance_scale() const { return gravity_distance_scale; }
+ _FORCE_INLINE_ void set_gravity_distance_scale(real_t scale) { gravity_distance_scale=scale; }
+ _FORCE_INLINE_ real_t get_gravity_distance_scale() const { return gravity_distance_scale; }
- _FORCE_INLINE_ void set_point_attenuation(float p_point_attenuation) { point_attenuation=p_point_attenuation; }
- _FORCE_INLINE_ float get_point_attenuation() const { return point_attenuation; }
+ _FORCE_INLINE_ void set_point_attenuation(real_t p_point_attenuation) { point_attenuation=p_point_attenuation; }
+ _FORCE_INLINE_ real_t get_point_attenuation() const { return point_attenuation; }
- _FORCE_INLINE_ void set_linear_damp(float p_linear_damp) { linear_damp=p_linear_damp; }
- _FORCE_INLINE_ float get_linear_damp() const { return linear_damp; }
+ _FORCE_INLINE_ void set_linear_damp(real_t p_linear_damp) { linear_damp=p_linear_damp; }
+ _FORCE_INLINE_ real_t get_linear_damp() const { return linear_damp; }
- _FORCE_INLINE_ void set_angular_damp(float p_angular_damp) { angular_damp=p_angular_damp; }
- _FORCE_INLINE_ float get_angular_damp() const { return angular_damp; }
+ _FORCE_INLINE_ void set_angular_damp(real_t p_angular_damp) { angular_damp=p_angular_damp; }
+ _FORCE_INLINE_ real_t get_angular_damp() const { return angular_damp; }
_FORCE_INLINE_ void set_priority(int p_priority) { priority=p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }
diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp
index c26f6c45fd..cb91caf626 100644
--- a/servers/physics_2d/area_pair_2d_sw.cpp
+++ b/servers/physics_2d/area_pair_2d_sw.cpp
@@ -30,7 +30,7 @@
#include "collision_solver_2d_sw.h"
-bool AreaPair2DSW::setup(float p_step) {
+bool AreaPair2DSW::setup(real_t p_step) {
bool result = area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this);
@@ -59,7 +59,7 @@ bool AreaPair2DSW::setup(float p_step) {
return false; //never do any post solving
}
-void AreaPair2DSW::solve(float p_step) {
+void AreaPair2DSW::solve(real_t p_step) {
}
@@ -100,7 +100,7 @@ AreaPair2DSW::~AreaPair2DSW() {
-bool Area2Pair2DSW::setup(float p_step) {
+bool Area2Pair2DSW::setup(real_t p_step) {
bool result = area_a->test_collision_mask(area_b) && CollisionSolver2DSW::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);
@@ -130,7 +130,7 @@ bool Area2Pair2DSW::setup(float p_step) {
return false; //never do any post solving
}
-void Area2Pair2DSW::solve(float p_step) {
+void Area2Pair2DSW::solve(real_t p_step) {
}
diff --git a/servers/physics_2d/area_pair_2d_sw.h b/servers/physics_2d/area_pair_2d_sw.h
index db77bff5d4..219ca30c4b 100644
--- a/servers/physics_2d/area_pair_2d_sw.h
+++ b/servers/physics_2d/area_pair_2d_sw.h
@@ -42,8 +42,8 @@ class AreaPair2DSW : public Constraint2DSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
AreaPair2DSW(Body2DSW *p_body,int p_body_shape, Area2DSW *p_area,int p_area_shape);
~AreaPair2DSW();
@@ -59,8 +59,8 @@ class Area2Pair2DSW : public Constraint2DSW {
bool colliding;
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
Area2Pair2DSW(Area2DSW *p_area_a,int p_shape_a, Area2DSW *p_area_b,int p_shape_b);
~Area2Pair2DSW();
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index a32e024fe9..0dab534ef9 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -51,7 +51,7 @@ void Body2DSW::update_inertias() {
if(user_inertia) break;
//update tensor for allshapes, not the best way but should be somehow OK. (inspired from bullet)
- float total_area=0;
+ real_t total_area=0;
for (int i=0;i<get_shape_count();i++) {
@@ -64,9 +64,9 @@ void Body2DSW::update_inertias() {
const Shape2DSW* shape=get_shape(i);
- float area=get_shape_aabb(i).get_area();
+ real_t area=get_shape_aabb(i).get_area();
- float mass = area * this->mass / total_area;
+ real_t mass = area * this->mass / total_area;
Transform2D mtx = get_shape_transform(i);
Vector2 scale = mtx.get_scale();
@@ -142,7 +142,7 @@ void Body2DSW::set_active(bool p_active) {
-void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, float p_value) {
+void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value) {
switch(p_param) {
case Physics2DServer::BODY_PARAM_BOUNCE: {
@@ -183,7 +183,7 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, float p_value)
}
}
-float Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
+real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const {
switch(p_param) {
case Physics2DServer::BODY_PARAM_BOUNCE: {
@@ -251,8 +251,10 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
}
_update_inertia();
- //if (get_space())
-// _update_queries();
+ /*
+ if (get_space())
+ _update_queries();
+ */
}
Physics2DServer::BodyMode Body2DSW::get_mode() const {
@@ -301,15 +303,19 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant& p_va
} break;
case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
- //if (mode==Physics2DServer::BODY_MODE_STATIC)
- // break;
+ /*
+ if (mode==Physics2DServer::BODY_MODE_STATIC)
+ break;
+ */
linear_velocity=p_variant;
wakeup();
} break;
case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
- //if (mode!=Physics2DServer::BODY_MODE_RIGID)
- // break;
+ /*
+ if (mode!=Physics2DServer::BODY_MODE_RIGID)
+ break;
+ */
angular_velocity=p_variant;
wakeup();
@@ -385,11 +391,13 @@ void Body2DSW::set_space(Space2DSW *p_space){
_update_inertia();
if (active)
get_space()->body_add_to_active_list(&active_list);
-// _update_queries();
- //if (is_active()) {
- // active=false;
- // set_active(true);
- //}
+ /*
+ _update_queries();
+ if (is_active()) {
+ active=false;
+ set_active(true);
+ }
+ */
}
@@ -459,13 +467,17 @@ void Body2DSW::integrate_forces(real_t p_step) {
// If less than 0, override dampenings with that of the Body2D
if (angular_damp>=0)
area_angular_damp = angular_damp;
- //else
- // area_angular_damp=damp_area->get_angular_damp();
+ /*
+ else
+ area_angular_damp=damp_area->get_angular_damp();
+ */
if (linear_damp>=0)
area_linear_damp = linear_damp;
- //else
- // area_linear_damp=damp_area->get_linear_damp();
+ /*
+ else
+ area_linear_damp=damp_area->get_linear_damp();
+ */
Vector2 motion;
bool do_motion=false;
@@ -482,10 +494,12 @@ void Body2DSW::integrate_forces(real_t p_step) {
do_motion=true;
- //for(int i=0;i<get_shape_count();i++) {
- // set_shape_kinematic_advance(i,Vector2());
- // set_shape_kinematic_retreat(i,0);
- //}
+ /*
+ for(int i=0;i<get_shape_count();i++) {
+ set_shape_kinematic_advance(i,Vector2());
+ set_shape_kinematic_retreat(i,0);
+ }
+ */
} else {
if (!omit_force_integration && !first_integration) {
diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h
index bf9dcaa9b0..3fb01959a9 100644
--- a/servers/physics_2d/body_2d_sw.h
+++ b/servers/physics_2d/body_2d_sw.h
@@ -69,7 +69,7 @@ class Body2DSW : public CollisionObject2DSW {
real_t applied_torque;
Vector2 one_way_collision_direction;
- float one_way_collision_max_depth;
+ real_t one_way_collision_max_depth;
SelfList<Body2DSW> active_list;
@@ -109,7 +109,7 @@ class Body2DSW : public CollisionObject2DSW {
Vector2 local_pos;
Vector2 local_normal;
- float depth;
+ real_t depth;
int local_shape;
Vector2 collider_pos;
int collider_shape;
@@ -168,7 +168,7 @@ public:
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
_FORCE_INLINE_ bool can_report_contacts() const { return !contacts.empty(); }
- _FORCE_INLINE_ void add_contact(const Vector2& p_local_pos,const Vector2& p_local_normal, float p_depth, int p_local_shape, const Vector2& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector2& p_collider_velocity_at_pos);
+ _FORCE_INLINE_ void add_contact(const Vector2& p_local_pos,const Vector2& p_local_normal, real_t p_depth, int p_local_shape, const Vector2& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector2& p_collider_velocity_at_pos);
_FORCE_INLINE_ void add_exception(const RID& p_exception) { exceptions.insert(p_exception);}
@@ -229,8 +229,8 @@ public:
- void set_param(Physics2DServer::BodyParameter p_param, float);
- float get_param(Physics2DServer::BodyParameter p_param) const;
+ void set_param(Physics2DServer::BodyParameter p_param, real_t);
+ real_t get_param(Physics2DServer::BodyParameter p_param) const;
void set_mode(Physics2DServer::BodyMode p_mode);
Physics2DServer::BodyMode get_mode() const;
@@ -259,8 +259,8 @@ public:
}
Vector2 get_one_way_collision_direction() const { return one_way_collision_direction; }
- void set_one_way_collision_max_depth(float p_depth) { one_way_collision_max_depth=p_depth; }
- float get_one_way_collision_max_depth() const { return one_way_collision_max_depth; }
+ void set_one_way_collision_max_depth(real_t p_depth) { one_way_collision_max_depth=p_depth; }
+ real_t get_one_way_collision_max_depth() const { return one_way_collision_max_depth; }
_FORCE_INLINE_ bool is_using_one_way_collision() const { return using_one_way_cache; }
@@ -303,7 +303,7 @@ public:
//add contact inline
-void Body2DSW::add_contact(const Vector2& p_local_pos,const Vector2& p_local_normal, float p_depth, int p_local_shape, const Vector2& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector2& p_collider_velocity_at_pos) {
+void Body2DSW::add_contact(const Vector2& p_local_pos,const Vector2& p_local_normal, real_t p_depth, int p_local_shape, const Vector2& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector2& p_collider_velocity_at_pos) {
int c_max=contacts.size();
@@ -319,7 +319,7 @@ void Body2DSW::add_contact(const Vector2& p_local_pos,const Vector2& p_local_nor
idx=contact_count++;
} else {
- float least_depth=1e20;
+ real_t least_depth=1e20;
int least_deep=-1;
for(int i=0;i<c_max;i++) {
@@ -361,10 +361,10 @@ public:
real_t step;
virtual Vector2 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
- virtual float get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
- virtual float get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
+ virtual real_t get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
+ virtual real_t get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
- virtual float get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
+ virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
virtual real_t get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space
virtual void set_linear_velocity(const Vector2& p_velocity) { body->set_linear_velocity(p_velocity); }
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 72ae221c39..c05d61b658 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -99,7 +99,7 @@ void BodyPair2DSW::_contact_added_callback(const Vector2& p_point_A,const Vector
Vector2 global_B = B->get_transform().basis_xform(c.local_B)+offset_B;
Vector2 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
if (depth<min_depth) {
@@ -149,7 +149,7 @@ void BodyPair2DSW::_validate_contacts() {
Vector2 global_A = A->get_transform().basis_xform(c.local_A);
Vector2 global_B = B->get_transform().basis_xform(c.local_B)+offset_B;
Vector2 axis = global_A - global_B;
- float depth = axis.dot( c.normal );
+ real_t depth = axis.dot( c.normal );
@@ -175,7 +175,7 @@ void BodyPair2DSW::_validate_contacts() {
}
-bool BodyPair2DSW::_test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result) {
+bool BodyPair2DSW::_test_ccd(real_t p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result) {
@@ -230,7 +230,7 @@ bool BodyPair2DSW::_test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Tra
return true;
}
-bool BodyPair2DSW::setup(float p_step) {
+bool BodyPair2DSW::setup(real_t p_step) {
//cannot collide
@@ -249,7 +249,7 @@ bool BodyPair2DSW::setup(float p_step) {
Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A);
Transform2D xform_Bu = B->get_transform();
- xform_Bu.translate(-A->get_transform().get_origin());
+ xform_Bu.elements[2]-=A->get_transform().get_origin();
Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B);
Shape2DSW *shape_A_ptr=A->get_shape(shape_A);
@@ -343,7 +343,7 @@ bool BodyPair2DSW::setup(float p_step) {
real_t max_penetration = space->get_contact_max_allowed_penetration();
- float bias = 0.3f;
+ real_t bias = 0.3;
if (shape_A_ptr->get_custom_bias() || shape_B_ptr->get_custom_bias()) {
if (shape_A_ptr->get_custom_bias()==0)
@@ -464,7 +464,7 @@ bool BodyPair2DSW::setup(float p_step) {
return do_process;
}
-void BodyPair2DSW::solve(float p_step) {
+void BodyPair2DSW::solve(real_t p_step) {
if (!collided)
return;
diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h
index b9ff1bd758..7a4771782a 100644
--- a/servers/physics_2d/body_pair_2d_sw.h
+++ b/servers/physics_2d/body_pair_2d_sw.h
@@ -66,7 +66,7 @@ class BodyPair2DSW : public Constraint2DSW {
bool active;
Vector2 rA,rB;
bool reused;
- float bounce;
+ real_t bounce;
};
@@ -80,15 +80,15 @@ class BodyPair2DSW : public Constraint2DSW {
int cc;
- bool _test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result=false);
+ bool _test_ccd(real_t p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result=false);
void _validate_contacts();
static void _add_contact(const Vector2& p_point_A,const Vector2& p_point_B,void *p_self);
_FORCE_INLINE_ void _contact_added_callback(const Vector2& p_point_A,const Vector2& p_point_B);
public:
- bool setup(float p_step);
- void solve(float p_step);
+ bool setup(real_t p_step);
+ void solve(real_t p_step);
BodyPair2DSW(Body2DSW *p_A, int p_shape_A,Body2DSW *p_B, int p_shape_B);
~BodyPair2DSW();
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index efa12c37cb..06eead64cd 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "broad_phase_2d_hash_grid.h"
-#include "globals.h"
+#include "global_config.h"
#define LARGE_ELEMENT_FI 1.01239812
@@ -539,14 +539,14 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2& p_from, const Vector2& p_t
Vector2 max;
if (dir.x<0)
- max.x= (Math::floor(pos.x)*cell_size - p_from.x) / dir.x;
+ max.x= (Math::floor((double)pos.x)*cell_size - p_from.x) / dir.x;
else
- max.x= (Math::floor(pos.x + 1)*cell_size - p_from.x) / dir.x;
+ max.x= (Math::floor((double)pos.x + 1)*cell_size - p_from.x) / dir.x;
if (dir.y<0)
- max.y= (Math::floor(pos.y)*cell_size - p_from.y) / dir.y;
+ max.y= (Math::floor((double)pos.y)*cell_size - p_from.y) / dir.y;
else
- max.y= (Math::floor(pos.y + 1)*cell_size - p_from.y) / dir.y;
+ max.y= (Math::floor((double)pos.y + 1)*cell_size - p_from.y) / dir.y;
int cullcount=0;
_cull<false,true>(pos,Rect2(),p_from,p_to,p_results,p_max_results,p_result_indices,cullcount);
@@ -599,8 +599,10 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2& p_from, const Vector2& p_t
E->key()->pass=pass;
-// if (use_aabb && !p_aabb.intersects(E->key()->aabb))
-// continue;
+ /*
+ if (use_aabb && !p_aabb.intersects(E->key()->aabb))
+ continue;
+ */
if (!E->key()->aabb.intersects_segment(p_from,p_to))
continue;
@@ -645,8 +647,10 @@ int BroadPhase2DHashGrid::cull_aabb(const Rect2& p_aabb,CollisionObject2DSW** p_
if (!p_aabb.intersects(E->key()->aabb))
continue;
-// if (!E->key()->aabb.intersects_segment(p_from,p_to))
-// continue;
+ /*
+ if (!E->key()->aabb.intersects_segment(p_from,p_to))
+ continue;
+ */
p_results[cullcount]=E->key()->owner;
p_result_indices[cullcount]=E->key()->subindex;
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index 2e7b0d8835..4c116cee3f 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -40,8 +40,10 @@ struct _CollectorCallback2D {
_FORCE_INLINE_ void call(const Vector2& p_point_A, const Vector2& p_point_B) {
- //if (normal.dot(p_point_A) >= normal.dot(p_point_B))
- // return;
+ /*
+ if (normal.dot(p_point_A) >= normal.dot(p_point_B))
+ return;
+ */
if (swap)
callback(p_point_B,p_point_A,userdata);
else
@@ -79,7 +81,7 @@ _FORCE_INLINE_ static void _generate_contacts_point_edge(const Vector2 * p_point
struct _generate_contacts_Pair {
bool a;
int idx;
- float d;
+ real_t d;
_FORCE_INLINE_ bool operator <(const _generate_contacts_Pair& l) const { return d< l.d; }
};
@@ -106,7 +108,7 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 * p_points
SWAP(pA[0],pA[1]);
}
- float dB[2]={t.dot(p_points_B[0]),t.dot(p_points_B[1])};
+ real_t dB[2]={t.dot(p_points_B[0]),t.dot(p_points_B[1])};
Vector2 pB[2]={p_points_B[0],p_points_B[1]};
if (dB[0]>dB[1]) {
SWAP(dB[0],dB[1]);
@@ -263,10 +265,10 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 * p_points
Vector2 base_B = p_points_B[0] - axis * axis.dot(p_points_B[0]);
//sort all 4 points in axis
- float dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
+ real_t dvec[4]={ axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) };
//todo , find max/min and then use 2 central points
- SortArray<float> sa;
+ SortArray<real_t> sa;
sa.sort(dvec,4);
//use the middle ones as contacts
@@ -462,7 +464,7 @@ public:
}
}
- // print_line("test axis: "+p_axis+" depth: "+rtos(best_depth));
+ //print_line("test axis: "+p_axis+" depth: "+rtos(best_depth));
#ifdef DEBUG_ENABLED
best_axis_count++;
#endif
@@ -594,11 +596,11 @@ public:
(castA && castB && !separator.test_axis(((m_a)+p_motion_a-((m_b)+p_motion_b)).normalized())) )
-typedef void (*CollisionFunc)(const Shape2DSW*,const Transform2D&,const Shape2DSW*,const Transform2D&,_CollectorCallback2D *p_collector,const Vector2&,const Vector2&,float,float);
+typedef void (*CollisionFunc)(const Shape2DSW*,const Transform2D&,const Shape2DSW*,const Transform2D&,_CollectorCallback2D *p_collector,const Vector2&,const Vector2&,real_t,real_t);
template<bool castA, bool castB,bool withMargin>
-static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a);
const SegmentShape2DSW *segment_B = static_cast<const SegmentShape2DSW*>(p_b);
@@ -610,8 +612,10 @@ static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p
//this collision is kind of pointless
- //if (!separator.test_previous_axis())
- // return;
+ /*
+ if (!separator.test_previous_axis())
+ return;
+ */
if (!separator.test_cast())
return;
@@ -641,7 +645,7 @@ static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_segment_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_segment_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a);
@@ -674,7 +678,7 @@ static void _collision_segment_circle(const Shape2DSW* p_a,const Transform2D& p_
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_segment_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_segment_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b);
@@ -739,7 +743,7 @@ static void _collision_segment_rectangle(const Shape2DSW* p_a,const Transform2D&
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_segment_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_segment_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b);
@@ -771,7 +775,7 @@ static void _collision_segment_capsule(const Shape2DSW* p_a,const Transform2D& p
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b);
@@ -811,7 +815,7 @@ static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Transfo
/////////
template<bool castA, bool castB,bool withMargin>
-static void _collision_circle_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_circle_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
const CircleShape2DSW *circle_B = static_cast<const CircleShape2DSW*>(p_b);
@@ -834,7 +838,7 @@ static void _collision_circle_circle(const Shape2DSW* p_a,const Transform2D& p_t
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b);
@@ -850,7 +854,7 @@ static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D&
const Vector2 &sphere=p_transform_a.elements[2];
const Vector2 *axis=&p_transform_b.elements[0];
-// const Vector2& half_extents = rectangle_B->get_half_extents();
+ //const Vector2& half_extents = rectangle_B->get_half_extents();
if (!separator.test_axis(axis[0].normalized()))
return;
@@ -890,7 +894,7 @@ static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D&
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_circle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_circle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b);
@@ -920,7 +924,7 @@ static void _collision_circle_capsule(const Shape2DSW* p_a,const Transform2D& p_
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b);
@@ -952,7 +956,7 @@ static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Transfor
/////////
template<bool castA, bool castB,bool withMargin>
-static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b);
@@ -1023,7 +1027,7 @@ static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Transform2
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b);
@@ -1096,7 +1100,7 @@ static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Transform2D&
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b);
@@ -1158,7 +1162,7 @@ static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Trans
/////////
template<bool castA, bool castB,bool withMargin>
-static void _collision_capsule_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_capsule_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW*>(p_a);
const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b);
@@ -1201,7 +1205,7 @@ static void _collision_capsule_capsule(const Shape2DSW* p_a,const Transform2D& p
}
template<bool castA, bool castB,bool withMargin>
-static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW*>(p_a);
const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b);
@@ -1247,7 +1251,7 @@ static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Transfo
template<bool castA, bool castB,bool withMargin>
-static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
+static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,real_t p_margin_A,real_t p_margin_B) {
const ConvexPolygonShape2DSW *convex_A = static_cast<const ConvexPolygonShape2DSW*>(p_a);
@@ -1294,7 +1298,7 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const
////////
-bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A, const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap,Vector2 *sep_axis,float p_margin_A,float p_margin_B) {
+bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A, const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap,Vector2 *sep_axis,real_t p_margin_A,real_t p_margin_B) {
Physics2DServer::ShapeType type_A=p_shape_A->get_type();
diff --git a/servers/physics_2d/collision_solver_2d_sat.h b/servers/physics_2d/collision_solver_2d_sat.h
index 01acf319c7..6b698a09f2 100644
--- a/servers/physics_2d/collision_solver_2d_sat.h
+++ b/servers/physics_2d/collision_solver_2d_sat.h
@@ -32,6 +32,6 @@
#include "collision_solver_2d_sw.h"
-bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A,const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0);
+bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A,const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector2 *sep_axis=NULL,real_t p_margin_A=0,real_t p_margin_B=0);
#endif // COLLISION_SOLVER_2D_SAT_H
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index e509bb76cd..3fdecdf413 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -181,7 +181,7 @@ void CollisionSolver2DSW::concave_callback(void *p_userdata, Shape2DSW *p_convex
}
-bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis,float p_margin_A,float p_margin_B) {
+bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis,real_t p_margin_A,real_t p_margin_B) {
const ConcaveShape2DSW *concave_B=static_cast<const ConcaveShape2DSW*>(p_shape_B);
@@ -203,18 +203,18 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transfo
cinfo.aabb_tests=0;
Transform2D rel_transform = p_transform_A;
- rel_transform.translate(-p_transform_B.get_origin());
+ rel_transform.elements[2]-=p_transform_B.get_origin();
//quickly compute a local Rect2
Rect2 local_aabb;
for(int i=0;i<2;i++) {
- Vector2 axis( p_transform_B.get_axis(i) );
- float axis_scale = 1.0/axis.length();
+ Vector2 axis( p_transform_B.elements[i] );
+ real_t axis_scale = 1.0/axis.length();
axis*=axis_scale;
- float smin,smax;
+ real_t smin,smax;
p_shape_A->project_rangev(axis,rel_transform,smin,smax);
smin*=axis_scale;
smax*=axis_scale;
@@ -226,12 +226,12 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transfo
concave_B->cull(local_aabb,concave_callback,&cinfo);
-// print_line("Rect2 TESTS: "+itos(cinfo.aabb_tests));
+ //print_line("Rect2 TESTS: "+itos(cinfo.aabb_tests));
return cinfo.collided;
}
-bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis,float p_margin_A,float p_margin_B) {
+bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis,real_t p_margin_A,real_t p_margin_B) {
@@ -255,9 +255,11 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Transform2D& p_
if (type_B==Physics2DServer::SHAPE_LINE || type_B==Physics2DServer::SHAPE_RAY) {
return false;
- //if (type_B==Physics2DServer::SHAPE_RAY) {
- // return false;
}
+ /*
+ if (type_B==Physics2DServer::SHAPE_RAY) {
+ return false;
+ */
if (swap) {
return solve_static_line(p_shape_B,p_transform_B,p_shape_A,p_transform_A,p_result_callback,p_userdata,true);
diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h
index 085d3a49fb..2a5fc9fe1d 100644
--- a/servers/physics_2d/collision_solver_2d_sw.h
+++ b/servers/physics_2d/collision_solver_2d_sw.h
@@ -37,14 +37,14 @@ public:
private:
static bool solve_static_line(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result);
static void concave_callback(void *p_userdata, Shape2DSW *p_convex);
- static bool solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0);
+ static bool solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL,real_t p_margin_A=0,real_t p_margin_B=0);
static bool solve_raycast(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL);
public:
- static bool solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0);
+ static bool solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis=NULL,real_t p_margin_A=0,real_t p_margin_B=0);
};
diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h
index 4436f1f689..cce668405c 100644
--- a/servers/physics_2d/constraint_2d_sw.h
+++ b/servers/physics_2d/constraint_2d_sw.h
@@ -63,8 +63,8 @@ public:
_FORCE_INLINE_ int get_body_count() const { return _body_count; }
- virtual bool setup(float p_step)=0;
- virtual void solve(float p_step)=0;
+ virtual bool setup(real_t p_step)=0;
+ virtual void solve(real_t p_step)=0;
virtual ~Constraint2DSW() {}
};
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 7205e90d27..76adf06429 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -91,7 +91,7 @@ normal_relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB, Vecto
#if 0
-bool PinJoint2DSW::setup(float p_step) {
+bool PinJoint2DSW::setup(real_t p_step) {
Space2DSW *space = A->get_space();
ERR_FAIL_COND_V(!space,false;)
@@ -136,7 +136,7 @@ bool PinJoint2DSW::setup(float p_step) {
-void PinJoint2DSW::solve(float p_step){
+void PinJoint2DSW::solve(real_t p_step){
if (!correct)
return;
@@ -189,7 +189,7 @@ PinJoint2DSW::~PinJoint2DSW() {
#else
-bool PinJoint2DSW::setup(float p_step) {
+bool PinJoint2DSW::setup(real_t p_step) {
Space2DSW *space = A->get_space();
ERR_FAIL_COND_V(!space,false;)
@@ -257,7 +257,7 @@ bool PinJoint2DSW::setup(float p_step) {
return true;
}
-void PinJoint2DSW::solve(float p_step){
+void PinJoint2DSW::solve(real_t p_step){
// compute relative velocity
@@ -370,7 +370,7 @@ mult_k(const Vector2& vr, const Vector2 &k1, const Vector2 &k2)
return Vector2(vr.dot(k1), vr.dot(k2));
}
-bool GrooveJoint2DSW::setup(float p_step) {
+bool GrooveJoint2DSW::setup(real_t p_step) {
// calculate endpoints in worldspace
@@ -407,12 +407,12 @@ bool GrooveJoint2DSW::setup(float p_step) {
jn_max = get_max_force() * p_step;
// calculate bias velocity
-// cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1));
-// joint->bias = cpvclamp(cpvmult(delta, -joint->constraint.biasCoef*dt_inv), joint->constraint.maxBias);
+ //cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1));
+ //joint->bias = cpvclamp(cpvmult(delta, -joint->constraint.biasCoef*dt_inv), joint->constraint.maxBias);
Vector2 delta = (B->get_transform().get_origin() +rB) - (A->get_transform().get_origin() + rA);
- float _b = get_bias();
+ real_t _b = get_bias();
_b=0.001;
gbias=(delta*-(_b==0?space->get_constraint_bias():_b)*(1.0/p_step)).clamped(get_max_bias());
@@ -424,7 +424,7 @@ bool GrooveJoint2DSW::setup(float p_step) {
return true;
}
-void GrooveJoint2DSW::solve(float p_step){
+void GrooveJoint2DSW::solve(real_t p_step){
// compute impulse
@@ -470,7 +470,7 @@ GrooveJoint2DSW::~GrooveJoint2DSW() {
//////////////////////////////////////////////
-bool DampedSpringJoint2DSW::setup(float p_step) {
+bool DampedSpringJoint2DSW::setup(real_t p_step) {
rA = A->get_transform().basis_xform(anchor_A);
rB = B->get_transform().basis_xform(anchor_B);
@@ -500,7 +500,7 @@ bool DampedSpringJoint2DSW::setup(float p_step) {
return true;
}
-void DampedSpringJoint2DSW::solve(float p_step) {
+void DampedSpringJoint2DSW::solve(real_t p_step) {
// compute relative velocity
real_t vrn = normal_relative_velocity(A, B, rA, rB, n) - target_vrn;
diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h
index 91113fa26d..1be15e4edc 100644
--- a/servers/physics_2d/joints_2d_sw.h
+++ b/servers/physics_2d/joints_2d_sw.h
@@ -85,8 +85,8 @@ public:
virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_PIN; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
PinJoint2DSW(const Vector2& p_pos,Body2DSW* p_body_a,Body2DSW* p_body_b=NULL);
@@ -118,8 +118,8 @@ public:
virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_PIN; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
void set_param(Physics2DServer::PinJointParam p_param, real_t p_value);
real_t get_param(Physics2DServer::PinJointParam p_param) const;
@@ -160,8 +160,8 @@ public:
virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_GROOVE; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
GrooveJoint2DSW(const Vector2& p_a_groove1,const Vector2& p_a_groove2, const Vector2& p_b_anchor, Body2DSW* p_body_a,Body2DSW* p_body_b);
@@ -198,8 +198,8 @@ public:
virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_DAMPED_SPRING; }
- virtual bool setup(float p_step);
- virtual void solve(float p_step);
+ virtual bool setup(real_t p_step);
+ virtual void solve(real_t p_step);
void set_param(Physics2DServer::DampedStringParam p_param, real_t p_value);
real_t get_param(Physics2DServer::DampedStringParam p_param) const;
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 3cc69f470e..920742ea0b 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -30,7 +30,7 @@
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
-#include "globals.h"
+#include "global_config.h"
#include "script_language.h"
#include "os/os.h"
@@ -158,11 +158,11 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2& p_point_A,const Vector2& p
if (cbk->amount == cbk->max) {
//find least deep
- float min_depth=1e20;
+ real_t min_depth=1e20;
int min_depth_idx=0;
for(int i=0;i<cbk->amount;i++) {
- float d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
+ real_t d = cbk->ptr[i*2+0].distance_squared_to(cbk->ptr[i*2+1]);
if (d<min_depth) {
min_depth=d;
min_depth_idx=i;
@@ -170,7 +170,7 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2& p_point_A,const Vector2& p
}
- float d = p_point_A.distance_squared_to(p_point_B);
+ real_t d = p_point_A.distance_squared_to(p_point_B);
if (d<min_depth)
return;
cbk->ptr[min_depth_idx*2+0]=p_point_A;
@@ -785,7 +785,7 @@ uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
return body->get_collision_mask();
};
-void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
+void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -793,7 +793,7 @@ void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, float
body->set_param(p_param,p_value);
};
-float Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
+real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -837,7 +837,7 @@ Vector2 Physics2DServerSW::body_get_applied_force(RID p_body) const {
return body->get_applied_force();
};
-void Physics2DServerSW::body_set_applied_torque(RID p_body, float p_torque) {
+void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -846,7 +846,7 @@ void Physics2DServerSW::body_set_applied_torque(RID p_body, float p_torque) {
body->wakeup();
};
-float Physics2DServerSW::body_get_applied_torque(RID p_body) const {
+real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -915,14 +915,14 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
};
-void Physics2DServerSW::body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) {
+void Physics2DServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
};
-float Physics2DServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
+real_t Physics2DServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -973,7 +973,7 @@ Vector2 Physics2DServerSW::body_get_one_way_collision_direction(RID p_body) cons
}
-void Physics2DServerSW::body_set_one_way_collision_max_depth(RID p_body,float p_max_depth) {
+void Physics2DServerSW::body_set_one_way_collision_max_depth(RID p_body,real_t p_max_depth) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND(!body);
@@ -981,7 +981,7 @@ void Physics2DServerSW::body_set_one_way_collision_max_depth(RID p_body,float p_
}
-float Physics2DServerSW::body_get_one_way_collision_max_depth(RID p_body) const {
+real_t Physics2DServerSW::body_get_one_way_collision_max_depth(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@@ -1016,7 +1016,7 @@ void Physics2DServerSW::body_set_pickable(RID p_body,bool p_pickable) {
}
-bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2& p_motion, float p_margin, MotionResult *r_result) {
+bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2& p_motion, real_t p_margin, MotionResult *r_result) {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,false);
@@ -1176,11 +1176,13 @@ void Physics2DServerSW::free(RID p_rid) {
Body2DSW *body = body_owner.get(p_rid);
-// if (body->get_state_query())
-// _clear_query(body->get_state_query());
+ /*
+ if (body->get_state_query())
+ _clear_query(body->get_state_query());
-// if (body->get_direct_state_query())
-// _clear_query(body->get_direct_state_query());
+ if (body->get_direct_state_query())
+ _clear_query(body->get_direct_state_query());
+ */
body->set_space(NULL);
@@ -1203,8 +1205,10 @@ void Physics2DServerSW::free(RID p_rid) {
Area2DSW *area = area_owner.get(p_rid);
-// if (area->get_monitor_query())
-// _clear_query(area->get_monitor_query());
+ /*
+ if (area->get_monitor_query())
+ _clear_query(area->get_monitor_query());
+ */
area->set_space(NULL);
@@ -1259,7 +1263,7 @@ void Physics2DServerSW::init() {
};
-void Physics2DServerSW::step(float p_step) {
+void Physics2DServerSW::step(real_t p_step) {
if (!active)
@@ -1380,7 +1384,7 @@ Physics2DServerSW::Physics2DServerSW() {
singletonsw=this;
BroadPhase2DSW::create_func=BroadPhase2DHashGrid::_create;
-// BroadPhase2DSW::create_func=BroadPhase2DBasic::_create;
+ //BroadPhase2DSW::create_func=BroadPhase2DBasic::_create;
active=true;
island_count=0;
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index ba45dd9272..e33e2d78c7 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -70,13 +70,13 @@ friend class Physics2DDirectBodyStateSW;
static Physics2DServerSW *singletonsw;
-// void _clear_query(Query2DSW *p_query);
+ //void _clear_query(Query2DSW *p_query);
public:
struct CollCbkData {
Vector2 valid_dir;
- float valid_depth;
+ real_t valid_depth;
int max;
int amount;
Vector2 *ptr;
@@ -193,8 +193,8 @@ public:
virtual void body_set_collision_mask(RID p_body, uint32_t p_mask);
virtual uint32_t body_get_collision_mask(RID p_) const;
- virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
- virtual float body_get_param(RID p_body, BodyParameter p_param) const;
+ virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value);
+ virtual real_t body_get_param(RID p_body, BodyParameter p_param) const;
virtual void body_set_state(RID p_body, BodyState p_state, const Variant& p_variant);
@@ -203,8 +203,8 @@ public:
virtual void body_set_applied_force(RID p_body, const Vector2& p_force);
virtual Vector2 body_get_applied_force(RID p_body) const;
- virtual void body_set_applied_torque(RID p_body, float p_torque);
- virtual float body_get_applied_torque(RID p_body) const;
+ virtual void body_set_applied_torque(RID p_body, real_t p_torque);
+ virtual real_t body_get_applied_torque(RID p_body) const;
virtual void body_add_force(RID p_body, const Vector2& p_offset, const Vector2& p_force);
@@ -215,8 +215,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, float p_treshold);
- virtual float body_get_contacts_reported_depth_treshold(RID p_body) const;
+ 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_omit_force_integration(RID p_body,bool p_omit);
virtual bool body_is_omitting_force_integration(RID p_body) const;
@@ -227,8 +227,8 @@ public:
virtual void body_set_one_way_collision_direction(RID p_body,const Vector2& p_direction);
virtual Vector2 body_get_one_way_collision_direction(RID p_body) const;
- virtual void body_set_one_way_collision_max_depth(RID p_body,float p_max_depth);
- virtual float body_get_one_way_collision_max_depth(RID p_body) const;
+ virtual void body_set_one_way_collision_max_depth(RID p_body,real_t p_max_depth);
+ virtual real_t body_get_one_way_collision_max_depth(RID p_body) const;
virtual void body_set_force_integration_callback(RID p_body,Object *p_receiver,const StringName& p_method,const Variant& p_udata=Variant());
@@ -236,7 +236,7 @@ public:
virtual void body_set_pickable(RID p_body,bool p_pickable);
- virtual bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL);
+ virtual bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,real_t p_margin=0.001,MotionResult *r_result=NULL);
/* JOINT API */
@@ -260,7 +260,7 @@ public:
virtual void set_active(bool p_active);
virtual void init();
- virtual void step(float p_step);
+ virtual void step(real_t p_step);
virtual void sync();
virtual void flush_queries();
virtual void end_sync();
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
index 8730bb9ee8..34ba149d23 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -35,7 +35,7 @@ void Physics2DServerWrapMT::thread_exit() {
exit=true;
}
-void Physics2DServerWrapMT::thread_step(float p_delta) {
+void Physics2DServerWrapMT::thread_step(real_t p_delta) {
physics_2d_server->step(p_delta);
step_sem->post();
@@ -75,7 +75,7 @@ void Physics2DServerWrapMT::thread_loop() {
/* EVENT QUEUING */
-void Physics2DServerWrapMT::step(float p_step) {
+void Physics2DServerWrapMT::step(real_t p_step) {
if (create_thread) {
@@ -95,7 +95,7 @@ void Physics2DServerWrapMT::sync() {
else
step_sem->wait(); //must not wait if a step was not issued
}
- physics_2d_server->sync();;
+ physics_2d_server->sync();
}
void Physics2DServerWrapMT::flush_queries(){
@@ -105,7 +105,7 @@ void Physics2DServerWrapMT::flush_queries(){
void Physics2DServerWrapMT::end_sync() {
- physics_2d_server->end_sync();;
+ physics_2d_server->end_sync();
}
void Physics2DServerWrapMT::init() {
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 851ba901ec..f8b533080e 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -33,7 +33,7 @@
#include "servers/physics_2d_server.h"
#include "command_queue_mt.h"
#include "os/thread.h"
-#include "globals.h"
+#include "global_config.h"
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__));
@@ -60,7 +60,7 @@ class Physics2DServerWrapMT : public Physics2DServer {
Semaphore *step_sem;
int step_pending;
- void thread_step(float p_delta);
+ void thread_step(real_t p_delta);
void thread_flush();
void thread_exit();
@@ -220,8 +220,8 @@ public:
FUNC1RC(uint32_t,body_get_collision_mask,RID);
- FUNC3(body_set_param,RID,BodyParameter,float);
- FUNC2RC(float,body_get_param,RID,BodyParameter);
+ FUNC3(body_set_param,RID,BodyParameter,real_t);
+ FUNC2RC(real_t,body_get_param,RID,BodyParameter);
FUNC3(body_set_state,RID,BodyState,const Variant&);
@@ -230,8 +230,8 @@ public:
FUNC2(body_set_applied_force,RID,const Vector2&);
FUNC1RC(Vector2,body_get_applied_force,RID);
- FUNC2(body_set_applied_torque,RID,float);
- FUNC1RC(float,body_get_applied_torque,RID);
+ FUNC2(body_set_applied_torque,RID,real_t);
+ FUNC1RC(real_t,body_get_applied_torque,RID);
FUNC3(body_add_force,RID,const Vector2&,const Vector2&);
FUNC3(body_apply_impulse,RID,const Vector2&,const Vector2&);
@@ -247,12 +247,12 @@ public:
FUNC2(body_set_one_way_collision_direction,RID,const Vector2&);
FUNC1RC(Vector2,body_get_one_way_collision_direction,RID);
- FUNC2(body_set_one_way_collision_max_depth,RID,float);
- FUNC1RC(float,body_get_one_way_collision_max_depth,RID);
+ FUNC2(body_set_one_way_collision_max_depth,RID,real_t);
+ FUNC1RC(real_t,body_get_one_way_collision_max_depth,RID);
- FUNC2(body_set_contacts_reported_depth_treshold,RID,float);
- FUNC1RC(float,body_get_contacts_reported_depth_treshold,RID);
+ FUNC2(body_set_contacts_reported_depth_treshold,RID,real_t);
+ FUNC1RC(real_t,body_get_contacts_reported_depth_treshold,RID);
FUNC2(body_set_omit_force_integration,RID,bool);
FUNC1RC(bool,body_is_omitting_force_integration,RID);
@@ -266,7 +266,7 @@ public:
FUNC2(body_set_pickable,RID,bool);
- bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL) {
+ bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,real_t p_margin=0.001,MotionResult *r_result=NULL) {
ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),false);
return physics_2d_server->body_test_motion(p_body,p_from,p_motion,p_margin,r_result);
@@ -303,7 +303,7 @@ public:
FUNC1(set_active,bool);
virtual void init();
- virtual void step(float p_step);
+ virtual void step(real_t p_step);
virtual void sync();
virtual void end_sync();
virtual void flush_queries();
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 8b19122f17..b6eb427131 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -136,7 +136,7 @@ bool LineShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_en
return true;
}
-real_t LineShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
+real_t LineShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
return 0;
}
@@ -191,7 +191,7 @@ bool RayShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_end
}
-real_t RayShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
+real_t RayShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
return 0; //rays are mass-less
}
@@ -224,7 +224,7 @@ void SegmentShape2DSW::get_supports(const Vector2& p_normal,Vector2 *r_supports,
}
- float dp=p_normal.dot(b-a);
+ real_t dp=p_normal.dot(b-a);
if (dp>0)
*r_supports=b;
else
@@ -252,14 +252,14 @@ bool SegmentShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
return true;
}
-real_t SegmentShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
+real_t SegmentShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
Vector2 s[2]={a*p_scale,b*p_scale};
real_t l = s[1].distance_to(s[0]);
Vector2 ofs = (s[0]+s[1])*0.5;
- return p_mass*(l*l/12.0f + ofs.length_squared());
+ return p_mass*(l*l/12.0 + ofs.length_squared());
}
void SegmentShape2DSW::set_data(const Variant& p_data) {
@@ -336,7 +336,7 @@ bool CircleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_
return true;
}
-real_t CircleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
+real_t CircleShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
return (radius*radius)*(p_scale.x*0.5+p_scale.y*0.5);
@@ -367,11 +367,11 @@ void RectangleShape2DSW::get_supports(const Vector2& p_normal,Vector2 *r_support
Vector2 ag;
ag[i]=1.0;
- float dp = ag.dot(p_normal);
+ real_t dp = ag.dot(p_normal);
if (Math::abs(dp)<_SEGMENT_IS_VALID_SUPPORT_TRESHOLD)
continue;
- float sgn = dp>0 ? 1.0 : -1.0;
+ real_t sgn = dp>0 ? 1.0 : -1.0;
r_amount=2;
@@ -407,10 +407,10 @@ bool RectangleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2&
return get_aabb().intersects_segment(p_begin,p_end,&r_point,&r_normal);
}
-real_t RectangleShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
+real_t RectangleShape2DSW::get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const {
Vector2 he2=half_extents*2*p_scale;
- return p_mass*he2.dot(he2)/12.0f;
+ return p_mass*he2.dot(he2)/12.0;
}
void RectangleShape2DSW::set_data(const Variant& p_data) {
@@ -438,7 +438,7 @@ void CapsuleShape2DSW::get_supports(const Vector2& p_normal,Vector2 *r_supports,
Vector2 n=p_normal;
- float d = n.y;
+ real_t d = n.y;
if (Math::abs( d )<(1.0-_SEGMENT_IS_VALID_SUPPORT_TRESHOLD) ) {
@@ -455,7 +455,7 @@ void CapsuleShape2DSW::get_supports(const Vector2& p_normal,Vector2 *r_supports,
} else {
- float h = (d > 0) ? height : -height;
+ real_t h = (d > 0) ? height : -height;
n*=radius;
n.y += h*0.5;
@@ -479,7 +479,7 @@ bool CapsuleShape2DSW::contains_point(const Vector2& p_point) const {
bool CapsuleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const {
- float d = 1e10;
+ real_t d = 1e10;
Vector2 n = (p_end-p_begin).normalized();
bool collided=false;
@@ -488,7 +488,7 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
Vector2 begin = p_begin;
Vector2 end = p_end;
- float ofs = (i==0)?-height*0.5:height*0.5;
+ real_t ofs = (i==0)?-height*0.5:height*0.5;
begin.y+=ofs;
end.y+=ofs;
@@ -540,10 +540,10 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
return collided; //todo
}
-real_t CapsuleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
+real_t CapsuleShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const {
Vector2 he2=Vector2(radius*2,height+radius*2)*p_scale;
- return p_mass*he2.dot(he2)/12.0f;
+ return p_mass*he2.dot(he2)/12.0;
}
void CapsuleShape2DSW::set_data(const Variant& p_data) {
@@ -619,7 +619,7 @@ bool ConvexPolygonShape2DSW::contains_point(const Vector2& p_point) const {
for(int i=0;i<point_count;i++) {
- float d = points[i].normal.dot(p_point) - points[i].normal.dot(points[i].pos);
+ real_t d = points[i].normal.dot(p_point) - points[i].normal.dot(points[i].pos);
if (d>0)
out=true;
else
@@ -639,8 +639,10 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
for(int i=0;i<point_count;i++) {
//hmm crap.. no can do..
- //if (d.dot(points[i].normal)>=0)
- // continue;
+ /*
+ if (d.dot(points[i].normal)>=0)
+ continue;
+ */
Vector2 res;
@@ -648,7 +650,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
if (!Geometry::segment_intersects_segment_2d(p_begin,p_end,points[i].pos,points[(i+1)%point_count].pos,&res))
continue;
- float nd = n.dot(res);
+ real_t nd = n.dot(res);
if (nd<d) {
d=nd;
@@ -670,7 +672,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
return inters; //todo
}
-real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
+real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const {
Rect2 aabb;
aabb.pos=points[0].pos*p_scale;
@@ -679,7 +681,7 @@ real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p
aabb.expand_to(points[i].pos*p_scale);
}
- return p_mass*aabb.size.dot(aabb.size)/12.0f + p_mass * (aabb.pos+aabb.size*0.5).length_squared();
+ return p_mass*aabb.size.dot(aabb.size)/12.0 + p_mass * (aabb.pos+aabb.size*0.5).length_squared();
}
void ConvexPolygonShape2DSW::set_data(const Variant& p_data) {
@@ -816,8 +818,10 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vec
real_t d=1e10;
bool inters=false;
- //for(int i=0;i<bvh_depth;i++)
- // stack[i]=0;
+ /*
+ for(int i=0;i<bvh_depth;i++)
+ stack[i]=0;
+ */
int level=0;
@@ -855,7 +859,7 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vec
if (Geometry::segment_intersects_segment_2d(p_begin,p_end,a,b,&res)) {
- float nd = n.dot(res);
+ real_t nd = n.dot(res);
if (nd<d) {
d=nd;
@@ -1077,8 +1081,10 @@ void ConcavePolygonShape2DSW::cull(const Rect2& p_local_aabb,Callback p_callback
};
- //for(int i=0;i<bvh_depth;i++)
- // stack[i]=0;
+ /*
+ for(int i=0;i<bvh_depth;i++)
+ stack[i]=0;
+ */
int level=0;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index 9160d064ef..c04cdfa456 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -35,8 +35,8 @@
/*
SHAPE_LINE, ///< plane:"plane"
-SHAPE_SEGMENT, ///< float:"length"
-SHAPE_CIRCLE, ///< float:"radius"
+SHAPE_SEGMENT, ///< real_t:"length"
+SHAPE_CIRCLE, ///< real_t:"radius"
SHAPE_RECTANGLE, ///< vec3:"extents"
SHAPE_CONVEX_POLYGON, ///< array of planes:"planes"
SHAPE_CONCAVE_POLYGON, ///< Vector2 array:"triangles" , or Dictionary with "indices" (int array) and "triangles" (Vector2 array)
@@ -86,7 +86,7 @@ public:
virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const=0;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const=0;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const=0;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const=0;
virtual void set_data(const Variant& p_data)=0;
virtual Variant get_data() const=0;
@@ -150,7 +150,7 @@ _FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_n
real_t mina,maxa;\
real_t minb,maxb;\
Transform2D ofsb=p_transform;\
- ofsb.translate(p_cast);\
+ ofsb.elements[2]+=p_cast;\
project_range(p_normal,p_transform,mina,maxa);\
project_range(p_normal,ofsb,minb,maxb); \
r_min=MIN(mina,minb);\
@@ -175,7 +175,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -218,7 +218,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -266,7 +266,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -304,7 +304,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -344,7 +344,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -432,7 +432,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -440,7 +440,7 @@ public:
_FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const {
// no matter the angle, the box is mirrored anyway
Vector2 n=p_transform.basis_xform_inv(p_normal).normalized();
- float h = (n.y > 0) ? height : -height;
+ real_t h = (n.y > 0) ? height : -height;
n *= radius;
n.y += h * 0.5;
@@ -495,7 +495,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const;
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
@@ -506,7 +506,7 @@ public:
r_min = r_max = p_normal.dot(p_transform.xform(points[0].pos));
for(int i=1;i<point_count;i++) {
- float d = p_normal.dot(p_transform.xform(points[i].pos));
+ real_t d = p_normal.dot(p_transform.xform(points[i].pos));
if (d>r_max)
r_max=d;
if (d<r_min)
@@ -584,7 +584,7 @@ public:
virtual bool contains_point(const Vector2& p_point) const;
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
- virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const { return 0; }
+ virtual real_t get_moment_of_inertia(real_t p_mass,const Size2& p_scale) const { return 0; }
virtual void set_data(const Variant& p_data);
virtual Variant get_data() const;
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 2c7b099b36..9bced50061 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -190,7 +190,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2& p_from, const Vec
}
-int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,real_t p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
if (p_result_max<=0)
return 0;
@@ -237,7 +237,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Trans
-bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,real_t p_margin,real_t &p_closest_safe,real_t &p_closest_unsafe, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
@@ -248,13 +248,15 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transfor
aabb=aabb.merge(Rect2(aabb.pos+p_motion,aabb.size)); //motion
aabb=aabb.grow(p_margin);
- //if (p_motion!=Vector2())
- // print_line(p_motion);
+ /*
+ if (p_motion!=Vector2())
+ print_line(p_motion);
+ */
int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,Space2DSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results);
- float best_safe=1;
- float best_unsafe=1;
+ real_t best_safe=1;
+ real_t best_unsafe=1;
for(int i=0;i<amount;i++) {
@@ -303,13 +305,13 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transfor
//just do kinematic solving
- float low=0;
- float hi=1;
+ real_t low=0;
+ real_t hi=1;
Vector2 mnormal=p_motion.normalized();
for(int i=0;i<8;i++) { //steps should be customizable..
- float ofs = (low+hi)*0.5;
+ real_t ofs = (low+hi)*0.5;
Vector2 sep=mnormal; //important optimization for this to work fast enough
bool collided = CollisionSolver2DSW::solve(shape,p_xform,p_motion*ofs,col_obj->get_shape(shape_idx),col_obj_xform,Vector2(),NULL,NULL,&sep,p_margin);
@@ -362,7 +364,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transfor
}
-bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,real_t p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
if (p_result_max<=0)
@@ -434,9 +436,9 @@ struct _RestCallbackData2D {
int best_shape;
Vector2 best_contact;
Vector2 best_normal;
- float best_len;
+ real_t best_len;
Vector2 valid_dir;
- float valid_depth;
+ real_t valid_depth;
};
static void _rest_cbk_result(const Vector2& p_point_A,const Vector2& p_point_B,void *p_userdata) {
@@ -456,7 +458,7 @@ static void _rest_cbk_result(const Vector2& p_point_A,const Vector2& p_point_B,v
}
Vector2 contact_rel = p_point_B - p_point_A;
- float len = contact_rel.length();
+ real_t len = contact_rel.length();
if (len <= rd->best_len)
return;
@@ -471,7 +473,7 @@ static void _rest_cbk_result(const Vector2& p_point_A,const Vector2& p_point_B,v
}
-bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
+bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,real_t p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) {
Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
@@ -592,7 +594,7 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb) {
return amount;
}
-bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result) {
+bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, real_t p_margin, Physics2DServer::MotionResult *r_result) {
//give me back regular physics engine logic
//this is madness
@@ -620,6 +622,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D body_transform = p_from;
+
{
//STEP 1, FREE BODY IF STUCK
@@ -643,6 +646,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool collided=false;
+
int amount = _cull_aabb_for_body(p_body,body_aabb);
for(int j=0;j<p_body->get_shape_count();j++) {
@@ -661,8 +665,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
Vector2 cdir = body->get_one_way_collision_direction();
- //if (cdir!=Vector2() && p_motion.dot(cdir)<0)
- // continue;
+ /*
+ if (cdir!=Vector2() && p_motion.dot(cdir)<0)
+ continue;
+ */
cbk.valid_dir=cdir;
cbk.valid_depth=body->get_one_way_collision_max_depth();
@@ -678,11 +684,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
- if (!collided)
+ if (!collided) {
break;
+ }
Vector2 recover_motion;
+
for(int i=0;i<cbk.amount;i++) {
Vector2 a = sr[i*2+0];
@@ -690,19 +698,18 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
#if 0
Vector2 rel = b-a;
- float d = rel.length();
+ real_t d = rel.length();
if (d==0)
continue;
Vector2 n = rel/d;
- float traveled = n.dot(recover_motion);
+ real_t traveled = n.dot(recover_motion);
a+=n*traveled;
+ real_t d = a.distance_to(b);
+ if (d<margin)
+ continue;
#endif
- // float d = a.distance_to(b);
-
- //if (d<margin)
- /// continue;
recover_motion+=(b-a)*0.4;
}
@@ -711,7 +718,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
break;
}
- body_transform.translate(recover_motion);
+ body_transform.elements[2]+=recover_motion;
body_aabb.pos+=recover_motion;
recover_attempts--;
@@ -721,8 +728,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
- float safe = 1.0;
- float unsafe = 1.0;
+ real_t safe = 1.0;
+ real_t unsafe = 1.0;
int best_shape=-1;
{
@@ -744,8 +751,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool stuck=false;
- float best_safe=1;
- float best_unsafe=1;
+ real_t best_safe=1;
+ real_t best_unsafe=1;
for(int i=0;i<amount;i++) {
@@ -777,13 +784,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
//just do kinematic solving
- float low=0;
- float hi=1;
+ real_t low=0;
+ real_t hi=1;
Vector2 mnormal=p_motion.normalized();
for(int i=0;i<8;i++) { //steps should be customizable..
- float ofs = (low+hi)*0.5;
+ real_t ofs = (low+hi)*0.5;
Vector2 sep=mnormal; //important optimization for this to work fast enough
bool collided = CollisionSolver2DSW::solve(body_shape,body_shape_xform,p_motion*ofs,col_obj->get_shape(shape_idx),col_obj_xform,Vector2(),NULL,NULL,&sep,0);
@@ -860,7 +867,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
//it collided, let's get the rest info in unsafe advance
Transform2D ugt = body_transform;
- ugt.translate(p_motion*unsafe);
+ ugt.elements[2]+=p_motion*unsafe;
_RestCallbackData2D rcd;
rcd.best_len=0;
@@ -972,7 +979,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (collide_character)
mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+ //print_line("motion: "+p_motion+" margin: "+rtos(margin));
//print_line("margin: "+rtos(margin));
do {
@@ -997,10 +1004,12 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Vector2 a = sr[i*2+0];
Vector2 b = sr[i*2+1];
- float d = a.distance_to(b);
+ real_t d = a.distance_to(b);
- //if (d<margin)
- /// continue;
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.4;
}
@@ -1019,8 +1028,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
//move second
- float safe = 1.0;
- float unsafe = 1.0;
+ real_t safe = 1.0;
+ real_t unsafe = 1.0;
int best_shape=-1;
for(int i=0;i<get_shape_count();i++) {
@@ -1028,7 +1037,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (is_shape_set_as_trigger(i))
continue;
- float lsafe,lunsafe;
+ 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) {
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 5dee3dea5a..071aa7bdfb 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -37,7 +37,7 @@
#include "area_pair_2d_sw.h"
#include "broad_phase_2d_sw.h"
#include "collision_object_2d_sw.h"
-#include "globals.h"
+#include "global_config.h"
class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState {
@@ -49,10 +49,10 @@ public:
virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION, bool p_pick_point=false);
virtual bool intersect_ray(const Vector2& p_from, const Vector2& p_to,RayResult &r_result,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- virtual int intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- virtual bool cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- virtual bool collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
- virtual bool rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ virtual int intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,real_t p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ virtual bool cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& 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_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ virtual bool collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,real_t p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
+ virtual bool rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,real_t p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION);
Physics2DDirectSpaceStateSW();
};
@@ -106,9 +106,9 @@ private:
CollisionObject2DSW *intersection_query_results[INTERSECTION_QUERY_MAX];
int intersection_query_subindex_results[INTERSECTION_QUERY_MAX];
- float body_linear_velocity_sleep_treshold;
- float body_angular_velocity_sleep_treshold;
- float body_time_to_sleep;
+ real_t body_linear_velocity_sleep_treshold;
+ real_t body_angular_velocity_sleep_treshold;
+ real_t body_time_to_sleep;
bool locked;
@@ -185,7 +185,7 @@ public:
int get_collision_pairs() const { return collision_pairs; }
- bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result);
+ bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, real_t p_margin, Physics2DServer::MotionResult *r_result);
void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); }
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index 05c0bf0516..355cc25a69 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -56,7 +56,7 @@ void Step2DSW::_populate_island(Body2DSW* p_body,Body2DSW** p_island,Constraint2
}
}
-bool Step2DSW::_setup_island(Constraint2DSW *p_island,float p_delta) {
+bool Step2DSW::_setup_island(Constraint2DSW *p_island,real_t p_delta) {
Constraint2DSW *ci=p_island;
Constraint2DSW *prev_ci=NULL;
@@ -81,7 +81,7 @@ bool Step2DSW::_setup_island(Constraint2DSW *p_island,float p_delta) {
return removed_root;
}
-void Step2DSW::_solve_island(Constraint2DSW *p_island,int p_iterations,float p_delta){
+void Step2DSW::_solve_island(Constraint2DSW *p_island,int p_iterations,real_t p_delta){
for(int i=0;i<p_iterations;i++) {
@@ -94,7 +94,7 @@ void Step2DSW::_solve_island(Constraint2DSW *p_island,int p_iterations,float p_d
}
}
-void Step2DSW::_check_suspend(Body2DSW *p_island,float p_delta) {
+void Step2DSW::_check_suspend(Body2DSW *p_island,real_t p_delta) {
bool can_sleep=true;
@@ -132,7 +132,7 @@ void Step2DSW::_check_suspend(Body2DSW *p_island,float p_delta) {
}
}
-void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) {
+void Step2DSW::step(Space2DSW* p_space,real_t p_delta,int p_iterations) {
p_space->lock(); // can't access space during this
@@ -216,7 +216,7 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) {
p_space->area_remove_from_moved_list((SelfList<Area2DSW>*)aml.first()); //faster to remove here
}
-// print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
+ //print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();
diff --git a/servers/physics_2d/step_2d_sw.h b/servers/physics_2d/step_2d_sw.h
index 917d69e7f1..0896e1016d 100644
--- a/servers/physics_2d/step_2d_sw.h
+++ b/servers/physics_2d/step_2d_sw.h
@@ -36,12 +36,12 @@ class Step2DSW {
uint64_t _step;
void _populate_island(Body2DSW* p_body,Body2DSW** p_island,Constraint2DSW **p_constraint_island);
- bool _setup_island(Constraint2DSW *p_island,float p_delta);
- void _solve_island(Constraint2DSW *p_island,int p_iterations,float p_delta);
- void _check_suspend(Body2DSW *p_island,float p_delta);
+ bool _setup_island(Constraint2DSW *p_island,real_t p_delta);
+ void _solve_island(Constraint2DSW *p_island,int p_iterations,real_t p_delta);
+ void _check_suspend(Body2DSW *p_island,real_t p_delta);
public:
- void step(Space2DSW* p_space,float p_delta,int p_iterations);
+ void step(Space2DSW* p_space,real_t p_delta,int p_iterations);
Step2DSW();
};
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index c175c04ee9..bdbe85612f 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -73,40 +73,40 @@ Physics2DServer * Physics2DServer::get_singleton() {
void Physics2DDirectBodyState::_bind_methods() {
- ClassDB::bind_method(_MD("get_total_gravity"),&Physics2DDirectBodyState::get_total_gravity);
- ClassDB::bind_method(_MD("get_total_linear_damp"),&Physics2DDirectBodyState::get_total_linear_damp);
- ClassDB::bind_method(_MD("get_total_angular_damp"),&Physics2DDirectBodyState::get_total_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_total_gravity"),&Physics2DDirectBodyState::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"),&Physics2DDirectBodyState::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"),&Physics2DDirectBodyState::get_total_angular_damp);
- ClassDB::bind_method(_MD("get_inverse_mass"),&Physics2DDirectBodyState::get_inverse_mass);
- ClassDB::bind_method(_MD("get_inverse_inertia"),&Physics2DDirectBodyState::get_inverse_inertia);
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"),&Physics2DDirectBodyState::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"),&Physics2DDirectBodyState::get_inverse_inertia);
- ClassDB::bind_method(_MD("set_linear_velocity","velocity"),&Physics2DDirectBodyState::set_linear_velocity);
- ClassDB::bind_method(_MD("get_linear_velocity"),&Physics2DDirectBodyState::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity","velocity"),&Physics2DDirectBodyState::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"),&Physics2DDirectBodyState::get_linear_velocity);
- ClassDB::bind_method(_MD("set_angular_velocity","velocity"),&Physics2DDirectBodyState::set_angular_velocity);
- ClassDB::bind_method(_MD("get_angular_velocity"),&Physics2DDirectBodyState::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity","velocity"),&Physics2DDirectBodyState::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"),&Physics2DDirectBodyState::get_angular_velocity);
- ClassDB::bind_method(_MD("set_transform","transform"),&Physics2DDirectBodyState::set_transform);
- ClassDB::bind_method(_MD("get_transform"),&Physics2DDirectBodyState::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","transform"),&Physics2DDirectBodyState::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"),&Physics2DDirectBodyState::get_transform);
- ClassDB::bind_method(_MD("set_sleep_state","enabled"),&Physics2DDirectBodyState::set_sleep_state);
- ClassDB::bind_method(_MD("is_sleeping"),&Physics2DDirectBodyState::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleep_state","enabled"),&Physics2DDirectBodyState::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"),&Physics2DDirectBodyState::is_sleeping);
- ClassDB::bind_method(_MD("get_contact_count"),&Physics2DDirectBodyState::get_contact_count);
+ ClassDB::bind_method(D_METHOD("get_contact_count"),&Physics2DDirectBodyState::get_contact_count);
- ClassDB::bind_method(_MD("get_contact_local_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_local_pos);
- ClassDB::bind_method(_MD("get_contact_local_normal","contact_idx"),&Physics2DDirectBodyState::get_contact_local_normal);
- ClassDB::bind_method(_MD("get_contact_local_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_local_shape);
- ClassDB::bind_method(_MD("get_contact_collider","contact_idx"),&Physics2DDirectBodyState::get_contact_collider);
- ClassDB::bind_method(_MD("get_contact_collider_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_pos);
- ClassDB::bind_method(_MD("get_contact_collider_id","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_id);
- ClassDB::bind_method(_MD("get_contact_collider_object","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_object);
- ClassDB::bind_method(_MD("get_contact_collider_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_shape);
- ClassDB::bind_method(_MD("get_contact_collider_shape_metadata:Variant","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_shape_metadata);
- ClassDB::bind_method(_MD("get_contact_collider_velocity_at_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_velocity_at_pos);
- ClassDB::bind_method(_MD("get_step"),&Physics2DDirectBodyState::get_step);
- ClassDB::bind_method(_MD("integrate_forces"),&Physics2DDirectBodyState::integrate_forces);
- ClassDB::bind_method(_MD("get_space_state:Physics2DDirectSpaceState"),&Physics2DDirectBodyState::get_space_state);
+ ClassDB::bind_method(D_METHOD("get_contact_local_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_local_pos);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal","contact_idx"),&Physics2DDirectBodyState::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider","contact_idx"),&Physics2DDirectBodyState::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_pos);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata:Variant","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_shape_metadata);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_pos","contact_idx"),&Physics2DDirectBodyState::get_contact_collider_velocity_at_pos);
+ ClassDB::bind_method(D_METHOD("get_step"),&Physics2DDirectBodyState::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"),&Physics2DDirectBodyState::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state:Physics2DDirectSpaceState"),&Physics2DDirectBodyState::get_space_state);
}
@@ -179,7 +179,7 @@ int Physics2DShapeQueryParameters::get_object_type_mask() const{
}
void Physics2DShapeQueryParameters::set_exclude(const Vector<RID>& p_exclude) {
- exclude.clear();;
+ exclude.clear();
for(int i=0;i<p_exclude.size();i++)
exclude.insert(p_exclude[i]);
@@ -198,27 +198,27 @@ Vector<RID> Physics2DShapeQueryParameters::get_exclude() const{
void Physics2DShapeQueryParameters::_bind_methods() {
- ClassDB::bind_method(_MD("set_shape","shape:Shape2D"),&Physics2DShapeQueryParameters::set_shape);
- ClassDB::bind_method(_MD("set_shape_rid","shape"),&Physics2DShapeQueryParameters::set_shape_rid);
- ClassDB::bind_method(_MD("get_shape_rid"),&Physics2DShapeQueryParameters::get_shape_rid);
+ ClassDB::bind_method(D_METHOD("set_shape","shape:Shape2D"),&Physics2DShapeQueryParameters::set_shape);
+ ClassDB::bind_method(D_METHOD("set_shape_rid","shape"),&Physics2DShapeQueryParameters::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"),&Physics2DShapeQueryParameters::get_shape_rid);
- ClassDB::bind_method(_MD("set_transform","transform"),&Physics2DShapeQueryParameters::set_transform);
- ClassDB::bind_method(_MD("get_transform"),&Physics2DShapeQueryParameters::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","transform"),&Physics2DShapeQueryParameters::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"),&Physics2DShapeQueryParameters::get_transform);
- ClassDB::bind_method(_MD("set_motion","motion"),&Physics2DShapeQueryParameters::set_motion);
- ClassDB::bind_method(_MD("get_motion"),&Physics2DShapeQueryParameters::get_motion);
+ ClassDB::bind_method(D_METHOD("set_motion","motion"),&Physics2DShapeQueryParameters::set_motion);
+ ClassDB::bind_method(D_METHOD("get_motion"),&Physics2DShapeQueryParameters::get_motion);
- ClassDB::bind_method(_MD("set_margin","margin"),&Physics2DShapeQueryParameters::set_margin);
- ClassDB::bind_method(_MD("get_margin"),&Physics2DShapeQueryParameters::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin","margin"),&Physics2DShapeQueryParameters::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"),&Physics2DShapeQueryParameters::get_margin);
- ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Physics2DShapeQueryParameters::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&Physics2DShapeQueryParameters::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","layer_mask"),&Physics2DShapeQueryParameters::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&Physics2DShapeQueryParameters::get_layer_mask);
- ClassDB::bind_method(_MD("set_object_type_mask","object_type_mask"),&Physics2DShapeQueryParameters::set_object_type_mask);
- ClassDB::bind_method(_MD("get_object_type_mask"),&Physics2DShapeQueryParameters::get_object_type_mask);
+ ClassDB::bind_method(D_METHOD("set_object_type_mask","object_type_mask"),&Physics2DShapeQueryParameters::set_object_type_mask);
+ ClassDB::bind_method(D_METHOD("get_object_type_mask"),&Physics2DShapeQueryParameters::get_object_type_mask);
- ClassDB::bind_method(_MD("set_exclude","exclude"),&Physics2DShapeQueryParameters::set_exclude);
- ClassDB::bind_method(_MD("get_exclude"),&Physics2DShapeQueryParameters::get_exclude);
+ ClassDB::bind_method(D_METHOD("set_exclude","exclude"),&Physics2DShapeQueryParameters::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"),&Physics2DShapeQueryParameters::get_exclude);
}
@@ -366,13 +366,13 @@ Physics2DDirectSpaceState::Physics2DDirectSpaceState() {
void Physics2DDirectSpaceState::_bind_methods() {
- ClassDB::bind_method(_MD("intersect_point","point","max_results","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_point,DEFVAL(32),DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
- ClassDB::bind_method(_MD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
- ClassDB::bind_method(_MD("intersect_shape","shape:Physics2DShapeQueryParameters","max_results"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(32));
- ClassDB::bind_method(_MD("cast_motion","shape:Physics2DShapeQueryParameters"),&Physics2DDirectSpaceState::_cast_motion);
- ClassDB::bind_method(_MD("collide_shape","shape:Physics2DShapeQueryParameters","max_results"),&Physics2DDirectSpaceState::_collide_shape,DEFVAL(32));
- ClassDB::bind_method(_MD("get_rest_info","shape:Physics2DShapeQueryParameters"),&Physics2DDirectSpaceState::_get_rest_info);
- //ClassDB::bind_method(_MD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("intersect_point","point","max_results","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_point,DEFVAL(32),DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
+ ClassDB::bind_method(D_METHOD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&Physics2DDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
+ ClassDB::bind_method(D_METHOD("intersect_shape","shape:Physics2DShapeQueryParameters","max_results"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion","shape:Physics2DShapeQueryParameters"),&Physics2DDirectSpaceState::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape","shape:Physics2DShapeQueryParameters","max_results"),&Physics2DDirectSpaceState::_collide_shape,DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info","shape:Physics2DShapeQueryParameters"),&Physics2DDirectSpaceState::_get_rest_info);
+ //ClassDB::bind_method(D_METHOD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
BIND_CONSTANT( TYPE_MASK_STATIC_BODY );
BIND_CONSTANT( TYPE_MASK_KINEMATIC_BODY );
@@ -412,11 +412,11 @@ Physics2DShapeQueryResult::Physics2DShapeQueryResult() {
void Physics2DShapeQueryResult::_bind_methods() {
- ClassDB::bind_method(_MD("get_result_count"),&Physics2DShapeQueryResult::get_result_count);
- ClassDB::bind_method(_MD("get_result_rid","idx"),&Physics2DShapeQueryResult::get_result_rid);
- ClassDB::bind_method(_MD("get_result_object_id","idx"),&Physics2DShapeQueryResult::get_result_object_id);
- ClassDB::bind_method(_MD("get_result_object","idx"),&Physics2DShapeQueryResult::get_result_object);
- ClassDB::bind_method(_MD("get_result_object_shape","idx"),&Physics2DShapeQueryResult::get_result_object_shape);
+ ClassDB::bind_method(D_METHOD("get_result_count"),&Physics2DShapeQueryResult::get_result_count);
+ ClassDB::bind_method(D_METHOD("get_result_rid","idx"),&Physics2DShapeQueryResult::get_result_rid);
+ ClassDB::bind_method(D_METHOD("get_result_object_id","idx"),&Physics2DShapeQueryResult::get_result_object_id);
+ ClassDB::bind_method(D_METHOD("get_result_object","idx"),&Physics2DShapeQueryResult::get_result_object);
+ ClassDB::bind_method(D_METHOD("get_result_object_shape","idx"),&Physics2DShapeQueryResult::get_result_object_shape);
}
@@ -468,16 +468,16 @@ int Physics2DTestMotionResult::get_collider_shape() const{
void Physics2DTestMotionResult::_bind_methods() {
- //ClassDB::bind_method(_MD("is_colliding"),&Physics2DTestMotionResult::is_colliding);
- ClassDB::bind_method(_MD("get_motion"),&Physics2DTestMotionResult::get_motion);
- ClassDB::bind_method(_MD("get_motion_remainder"),&Physics2DTestMotionResult::get_motion_remainder);
- ClassDB::bind_method(_MD("get_collision_point"),&Physics2DTestMotionResult::get_collision_point);
- ClassDB::bind_method(_MD("get_collision_normal"),&Physics2DTestMotionResult::get_collision_normal);
- ClassDB::bind_method(_MD("get_collider_velocity"),&Physics2DTestMotionResult::get_collider_velocity);
- ClassDB::bind_method(_MD("get_collider_id"),&Physics2DTestMotionResult::get_collider_id);
- ClassDB::bind_method(_MD("get_collider_rid"),&Physics2DTestMotionResult::get_collider_rid);
- ClassDB::bind_method(_MD("get_collider"),&Physics2DTestMotionResult::get_collider);
- ClassDB::bind_method(_MD("get_collider_shape"),&Physics2DTestMotionResult::get_collider_shape);
+ //ClassDB::bind_method(D_METHOD("is_colliding"),&Physics2DTestMotionResult::is_colliding);
+ ClassDB::bind_method(D_METHOD("get_motion"),&Physics2DTestMotionResult::get_motion);
+ ClassDB::bind_method(D_METHOD("get_motion_remainder"),&Physics2DTestMotionResult::get_motion_remainder);
+ ClassDB::bind_method(D_METHOD("get_collision_point"),&Physics2DTestMotionResult::get_collision_point);
+ ClassDB::bind_method(D_METHOD("get_collision_normal"),&Physics2DTestMotionResult::get_collision_normal);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"),&Physics2DTestMotionResult::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_id"),&Physics2DTestMotionResult::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"),&Physics2DTestMotionResult::get_collider_rid);
+ ClassDB::bind_method(D_METHOD("get_collider"),&Physics2DTestMotionResult::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"),&Physics2DTestMotionResult::get_collider_shape);
}
@@ -504,147 +504,147 @@ bool Physics2DServer::_body_test_motion(RID p_body,const Transform2D& p_from,con
void Physics2DServer::_bind_methods() {
- ClassDB::bind_method(_MD("shape_create","type"),&Physics2DServer::shape_create);
- ClassDB::bind_method(_MD("shape_set_data","shape","data"),&Physics2DServer::shape_set_data);
+ ClassDB::bind_method(D_METHOD("shape_create","type"),&Physics2DServer::shape_create);
+ ClassDB::bind_method(D_METHOD("shape_set_data","shape","data"),&Physics2DServer::shape_set_data);
- ClassDB::bind_method(_MD("shape_get_type","shape"),&Physics2DServer::shape_get_type);
- ClassDB::bind_method(_MD("shape_get_data","shape"),&Physics2DServer::shape_get_data);
+ ClassDB::bind_method(D_METHOD("shape_get_type","shape"),&Physics2DServer::shape_get_type);
+ ClassDB::bind_method(D_METHOD("shape_get_data","shape"),&Physics2DServer::shape_get_data);
- ClassDB::bind_method(_MD("space_create"),&Physics2DServer::space_create);
- ClassDB::bind_method(_MD("space_set_active","space","active"),&Physics2DServer::space_set_active);
- ClassDB::bind_method(_MD("space_is_active","space"),&Physics2DServer::space_is_active);
- ClassDB::bind_method(_MD("space_set_param","space","param","value"),&Physics2DServer::space_set_param);
- ClassDB::bind_method(_MD("space_get_param","space","param"),&Physics2DServer::space_get_param);
- ClassDB::bind_method(_MD("space_get_direct_state:Physics2DDirectSpaceState","space"),&Physics2DServer::space_get_direct_state);
+ ClassDB::bind_method(D_METHOD("space_create"),&Physics2DServer::space_create);
+ ClassDB::bind_method(D_METHOD("space_set_active","space","active"),&Physics2DServer::space_set_active);
+ ClassDB::bind_method(D_METHOD("space_is_active","space"),&Physics2DServer::space_is_active);
+ ClassDB::bind_method(D_METHOD("space_set_param","space","param","value"),&Physics2DServer::space_set_param);
+ ClassDB::bind_method(D_METHOD("space_get_param","space","param"),&Physics2DServer::space_get_param);
+ ClassDB::bind_method(D_METHOD("space_get_direct_state:Physics2DDirectSpaceState","space"),&Physics2DServer::space_get_direct_state);
- ClassDB::bind_method(_MD("area_create"),&Physics2DServer::area_create);
- ClassDB::bind_method(_MD("area_set_space","area","space"),&Physics2DServer::area_set_space);
- ClassDB::bind_method(_MD("area_get_space","area"),&Physics2DServer::area_get_space);
+ ClassDB::bind_method(D_METHOD("area_create"),&Physics2DServer::area_create);
+ ClassDB::bind_method(D_METHOD("area_set_space","area","space"),&Physics2DServer::area_set_space);
+ ClassDB::bind_method(D_METHOD("area_get_space","area"),&Physics2DServer::area_get_space);
- ClassDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&Physics2DServer::area_set_space_override_mode);
- ClassDB::bind_method(_MD("area_get_space_override_mode","area"),&Physics2DServer::area_get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_set_space_override_mode","area","mode"),&Physics2DServer::area_set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_get_space_override_mode","area"),&Physics2DServer::area_get_space_override_mode);
- ClassDB::bind_method(_MD("area_add_shape","area","shape","transform"),&Physics2DServer::area_add_shape,DEFVAL(Transform2D()));
- ClassDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&Physics2DServer::area_set_shape);
- ClassDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&Physics2DServer::area_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_add_shape","area","shape","transform"),&Physics2DServer::area_add_shape,DEFVAL(Transform2D()));
+ ClassDB::bind_method(D_METHOD("area_set_shape","area","shape_idx","shape"),&Physics2DServer::area_set_shape);
+ ClassDB::bind_method(D_METHOD("area_set_shape_transform","area","shape_idx","transform"),&Physics2DServer::area_set_shape_transform);
- ClassDB::bind_method(_MD("area_get_shape_count","area"),&Physics2DServer::area_get_shape_count);
- ClassDB::bind_method(_MD("area_get_shape","area","shape_idx"),&Physics2DServer::area_get_shape);
- ClassDB::bind_method(_MD("area_get_shape_transform","area","shape_idx"),&Physics2DServer::area_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_get_shape_count","area"),&Physics2DServer::area_get_shape_count);
+ ClassDB::bind_method(D_METHOD("area_get_shape","area","shape_idx"),&Physics2DServer::area_get_shape);
+ ClassDB::bind_method(D_METHOD("area_get_shape_transform","area","shape_idx"),&Physics2DServer::area_get_shape_transform);
- ClassDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
- ClassDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);
+ ClassDB::bind_method(D_METHOD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
+ ClassDB::bind_method(D_METHOD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);
- ClassDB::bind_method(_MD("area_set_layer_mask","area","mask"),&Physics2DServer::area_set_layer_mask);
- ClassDB::bind_method(_MD("area_set_collision_mask","area","mask"),&Physics2DServer::area_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("area_set_layer_mask","area","mask"),&Physics2DServer::area_set_layer_mask);
+ ClassDB::bind_method(D_METHOD("area_set_collision_mask","area","mask"),&Physics2DServer::area_set_collision_mask);
- ClassDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_set_param);
- ClassDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform);
+ ClassDB::bind_method(D_METHOD("area_set_param","area","param","value"),&Physics2DServer::area_set_param);
+ ClassDB::bind_method(D_METHOD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform);
- ClassDB::bind_method(_MD("area_get_param","area","param"),&Physics2DServer::area_get_param);
- ClassDB::bind_method(_MD("area_get_transform","area"),&Physics2DServer::area_get_transform);
+ ClassDB::bind_method(D_METHOD("area_get_param","area","param"),&Physics2DServer::area_get_param);
+ ClassDB::bind_method(D_METHOD("area_get_transform","area"),&Physics2DServer::area_get_transform);
- ClassDB::bind_method(_MD("area_attach_object_instance_ID","area","id"),&Physics2DServer::area_attach_object_instance_ID);
- ClassDB::bind_method(_MD("area_get_object_instance_ID","area"),&Physics2DServer::area_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_ID","area","id"),&Physics2DServer::area_attach_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_ID","area"),&Physics2DServer::area_get_object_instance_ID);
- ClassDB::bind_method(_MD("area_set_monitor_callback","area","receiver","method"),&Physics2DServer::area_set_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_monitor_callback","area","receiver","method"),&Physics2DServer::area_set_monitor_callback);
- ClassDB::bind_method(_MD("body_create","mode","init_sleeping"),&Physics2DServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("body_create","mode","init_sleeping"),&Physics2DServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
- ClassDB::bind_method(_MD("body_set_space","body","space"),&Physics2DServer::body_set_space);
- ClassDB::bind_method(_MD("body_get_space","body"),&Physics2DServer::body_get_space);
+ ClassDB::bind_method(D_METHOD("body_set_space","body","space"),&Physics2DServer::body_set_space);
+ ClassDB::bind_method(D_METHOD("body_get_space","body"),&Physics2DServer::body_get_space);
- ClassDB::bind_method(_MD("body_set_mode","body","mode"),&Physics2DServer::body_set_mode);
- ClassDB::bind_method(_MD("body_get_mode","body"),&Physics2DServer::body_get_mode);
+ ClassDB::bind_method(D_METHOD("body_set_mode","body","mode"),&Physics2DServer::body_set_mode);
+ ClassDB::bind_method(D_METHOD("body_get_mode","body"),&Physics2DServer::body_get_mode);
- ClassDB::bind_method(_MD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Transform2D()));
- ClassDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&Physics2DServer::body_set_shape);
- ClassDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&Physics2DServer::body_set_shape_transform);
- ClassDB::bind_method(_MD("body_set_shape_metadata","body","shape_idx","metadata"),&Physics2DServer::body_set_shape_metadata);
+ ClassDB::bind_method(D_METHOD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Transform2D()));
+ ClassDB::bind_method(D_METHOD("body_set_shape","body","shape_idx","shape"),&Physics2DServer::body_set_shape);
+ ClassDB::bind_method(D_METHOD("body_set_shape_transform","body","shape_idx","transform"),&Physics2DServer::body_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_set_shape_metadata","body","shape_idx","metadata"),&Physics2DServer::body_set_shape_metadata);
- ClassDB::bind_method(_MD("body_get_shape_count","body"),&Physics2DServer::body_get_shape_count);
- ClassDB::bind_method(_MD("body_get_shape","body","shape_idx"),&Physics2DServer::body_get_shape);
- ClassDB::bind_method(_MD("body_get_shape_transform","body","shape_idx"),&Physics2DServer::body_get_shape_transform);
- ClassDB::bind_method(_MD("body_get_shape_metadata","body","shape_idx"),&Physics2DServer::body_get_shape_metadata);
+ ClassDB::bind_method(D_METHOD("body_get_shape_count","body"),&Physics2DServer::body_get_shape_count);
+ ClassDB::bind_method(D_METHOD("body_get_shape","body","shape_idx"),&Physics2DServer::body_get_shape);
+ ClassDB::bind_method(D_METHOD("body_get_shape_transform","body","shape_idx"),&Physics2DServer::body_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_get_shape_metadata","body","shape_idx"),&Physics2DServer::body_get_shape_metadata);
- ClassDB::bind_method(_MD("body_remove_shape","body","shape_idx"),&Physics2DServer::body_remove_shape);
- ClassDB::bind_method(_MD("body_clear_shapes","body"),&Physics2DServer::body_clear_shapes);
+ ClassDB::bind_method(D_METHOD("body_remove_shape","body","shape_idx"),&Physics2DServer::body_remove_shape);
+ ClassDB::bind_method(D_METHOD("body_clear_shapes","body"),&Physics2DServer::body_clear_shapes);
- ClassDB::bind_method(_MD("body_set_shape_as_trigger","body","shape_idx","enable"),&Physics2DServer::body_set_shape_as_trigger);
- ClassDB::bind_method(_MD("body_is_shape_set_as_trigger","body","shape_idx"),&Physics2DServer::body_is_shape_set_as_trigger);
+ ClassDB::bind_method(D_METHOD("body_set_shape_as_trigger","body","shape_idx","enable"),&Physics2DServer::body_set_shape_as_trigger);
+ ClassDB::bind_method(D_METHOD("body_is_shape_set_as_trigger","body","shape_idx"),&Physics2DServer::body_is_shape_set_as_trigger);
- ClassDB::bind_method(_MD("body_attach_object_instance_ID","body","id"),&Physics2DServer::body_attach_object_instance_ID);
- ClassDB::bind_method(_MD("body_get_object_instance_ID","body"),&Physics2DServer::body_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_ID","body","id"),&Physics2DServer::body_attach_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_ID","body"),&Physics2DServer::body_get_object_instance_ID);
- ClassDB::bind_method(_MD("body_set_continuous_collision_detection_mode","body","mode"),&Physics2DServer::body_set_continuous_collision_detection_mode);
- ClassDB::bind_method(_MD("body_get_continuous_collision_detection_mode","body"),&Physics2DServer::body_get_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode","body","mode"),&Physics2DServer::body_set_continuous_collision_detection_mode);
+ ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode","body"),&Physics2DServer::body_get_continuous_collision_detection_mode);
- ClassDB::bind_method(_MD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask);
- ClassDB::bind_method(_MD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask);
+ ClassDB::bind_method(D_METHOD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask);
+ ClassDB::bind_method(D_METHOD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask);
- ClassDB::bind_method(_MD("body_set_collision_mask","body","mask"),&Physics2DServer::body_set_collision_mask);
- ClassDB::bind_method(_MD("body_get_collision_mask","body"),&Physics2DServer::body_get_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_set_collision_mask","body","mask"),&Physics2DServer::body_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_get_collision_mask","body"),&Physics2DServer::body_get_collision_mask);
- ClassDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
- ClassDB::bind_method(_MD("body_get_param","body","param"),&Physics2DServer::body_get_param);
+ ClassDB::bind_method(D_METHOD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
+ ClassDB::bind_method(D_METHOD("body_get_param","body","param"),&Physics2DServer::body_get_param);
- ClassDB::bind_method(_MD("body_set_state","body","state","value"),&Physics2DServer::body_set_state);
- ClassDB::bind_method(_MD("body_get_state","body","state"),&Physics2DServer::body_get_state);
+ ClassDB::bind_method(D_METHOD("body_set_state","body","state","value"),&Physics2DServer::body_set_state);
+ ClassDB::bind_method(D_METHOD("body_get_state","body","state"),&Physics2DServer::body_get_state);
- ClassDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&Physics2DServer::body_apply_impulse);
- ClassDB::bind_method(_MD("body_add_force","body","offset","force"),&Physics2DServer::body_add_force);
- ClassDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&Physics2DServer::body_set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("body_apply_impulse","body","pos","impulse"),&Physics2DServer::body_apply_impulse);
+ ClassDB::bind_method(D_METHOD("body_add_force","body","offset","force"),&Physics2DServer::body_add_force);
+ ClassDB::bind_method(D_METHOD("body_set_axis_velocity","body","axis_velocity"),&Physics2DServer::body_set_axis_velocity);
- ClassDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&Physics2DServer::body_add_collision_exception);
- ClassDB::bind_method(_MD("body_remove_collision_exception","body","excepted_body"),&Physics2DServer::body_remove_collision_exception);
-// virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
+ ClassDB::bind_method(D_METHOD("body_add_collision_exception","body","excepted_body"),&Physics2DServer::body_add_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_remove_collision_exception","body","excepted_body"),&Physics2DServer::body_remove_collision_exception);
+ //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
- ClassDB::bind_method(_MD("body_set_max_contacts_reported","body","amount"),&Physics2DServer::body_set_max_contacts_reported);
- ClassDB::bind_method(_MD("body_get_max_contacts_reported","body"),&Physics2DServer::body_get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported","body","amount"),&Physics2DServer::body_set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported","body"),&Physics2DServer::body_get_max_contacts_reported);
- ClassDB::bind_method(_MD("body_set_one_way_collision_direction","body","normal"),&Physics2DServer::body_set_one_way_collision_direction);
- ClassDB::bind_method(_MD("body_get_one_way_collision_direction","body"),&Physics2DServer::body_get_one_way_collision_direction);
+ ClassDB::bind_method(D_METHOD("body_set_one_way_collision_direction","body","normal"),&Physics2DServer::body_set_one_way_collision_direction);
+ ClassDB::bind_method(D_METHOD("body_get_one_way_collision_direction","body"),&Physics2DServer::body_get_one_way_collision_direction);
- ClassDB::bind_method(_MD("body_set_one_way_collision_max_depth","body","depth"),&Physics2DServer::body_set_one_way_collision_max_depth);
- ClassDB::bind_method(_MD("body_get_one_way_collision_max_depth","body"),&Physics2DServer::body_get_one_way_collision_max_depth);
+ ClassDB::bind_method(D_METHOD("body_set_one_way_collision_max_depth","body","depth"),&Physics2DServer::body_set_one_way_collision_max_depth);
+ ClassDB::bind_method(D_METHOD("body_get_one_way_collision_max_depth","body"),&Physics2DServer::body_get_one_way_collision_max_depth);
- ClassDB::bind_method(_MD("body_set_omit_force_integration","body","enable"),&Physics2DServer::body_set_omit_force_integration);
- ClassDB::bind_method(_MD("body_is_omitting_force_integration","body"),&Physics2DServer::body_is_omitting_force_integration);
+ ClassDB::bind_method(D_METHOD("body_set_omit_force_integration","body","enable"),&Physics2DServer::body_set_omit_force_integration);
+ ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration","body"),&Physics2DServer::body_is_omitting_force_integration);
- ClassDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method","userdata"),&Physics2DServer::body_set_force_integration_callback,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_set_force_integration_callback","body","receiver","method","userdata"),&Physics2DServer::body_set_force_integration_callback,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("body_test_motion","body","from","motion","margin","result:Physics2DTestMotionResult"),&Physics2DServer::_body_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_test_motion","body","from","motion","margin","result:Physics2DTestMotionResult"),&Physics2DServer::_body_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
/* JOINT API */
- ClassDB::bind_method(_MD("joint_set_param","joint","param","value"),&Physics2DServer::joint_set_param);
- ClassDB::bind_method(_MD("joint_get_param","joint","param"),&Physics2DServer::joint_get_param);
+ ClassDB::bind_method(D_METHOD("joint_set_param","joint","param","value"),&Physics2DServer::joint_set_param);
+ ClassDB::bind_method(D_METHOD("joint_get_param","joint","param"),&Physics2DServer::joint_get_param);
- ClassDB::bind_method(_MD("pin_joint_create","anchor","body_a","body_b"),&Physics2DServer::pin_joint_create,DEFVAL(RID()));
- ClassDB::bind_method(_MD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&Physics2DServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
- ClassDB::bind_method(_MD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&Physics2DServer::damped_spring_joint_create,DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("pin_joint_create","anchor","body_a","body_b"),&Physics2DServer::pin_joint_create,DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&Physics2DServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&Physics2DServer::damped_spring_joint_create,DEFVAL(RID()));
- ClassDB::bind_method(_MD("damped_string_joint_set_param","joint","param","value"),&Physics2DServer::damped_string_joint_set_param);
- ClassDB::bind_method(_MD("damped_string_joint_get_param","joint","param"),&Physics2DServer::damped_string_joint_get_param);
+ ClassDB::bind_method(D_METHOD("damped_string_joint_set_param","joint","param","value"),&Physics2DServer::damped_string_joint_set_param);
+ ClassDB::bind_method(D_METHOD("damped_string_joint_get_param","joint","param"),&Physics2DServer::damped_string_joint_get_param);
- ClassDB::bind_method(_MD("joint_get_type","joint"),&Physics2DServer::joint_get_type);
+ ClassDB::bind_method(D_METHOD("joint_get_type","joint"),&Physics2DServer::joint_get_type);
- ClassDB::bind_method(_MD("free_rid","rid"),&Physics2DServer::free);
+ ClassDB::bind_method(D_METHOD("free_rid","rid"),&Physics2DServer::free);
- ClassDB::bind_method(_MD("set_active","active"),&Physics2DServer::set_active);
+ ClassDB::bind_method(D_METHOD("set_active","active"),&Physics2DServer::set_active);
- ClassDB::bind_method(_MD("get_process_info","process_info"),&Physics2DServer::get_process_info);
+ ClassDB::bind_method(D_METHOD("get_process_info","process_info"),&Physics2DServer::get_process_info);
-// ClassDB::bind_method(_MD("init"),&Physics2DServer::init);
-// ClassDB::bind_method(_MD("step"),&Physics2DServer::step);
-// ClassDB::bind_method(_MD("sync"),&Physics2DServer::sync);
- //ClassDB::bind_method(_MD("flush_queries"),&Physics2DServer::flush_queries);
+ //ClassDB::bind_method(D_METHOD("init"),&Physics2DServer::init);
+ //ClassDB::bind_method(D_METHOD("step"),&Physics2DServer::step);
+ //ClassDB::bind_method(D_METHOD("sync"),&Physics2DServer::sync);
+ //ClassDB::bind_method(D_METHOD("flush_queries"),&Physics2DServer::flush_queries);
BIND_CONSTANT( SPACE_PARAM_CONTACT_RECYCLE_RADIUS );
BIND_CONSTANT( SPACE_PARAM_CONTACT_MAX_SEPARATION );
@@ -710,8 +710,8 @@ void Physics2DServer::_bind_methods() {
BIND_CONSTANT( CCD_MODE_CAST_RAY );
BIND_CONSTANT( CCD_MODE_CAST_SHAPE );
-// BIND_CONSTANT( TYPE_BODY );
-// BIND_CONSTANT( TYPE_AREA );
+ //BIND_CONSTANT( TYPE_BODY );
+ //BIND_CONSTANT( TYPE_AREA );
BIND_CONSTANT( AREA_BODY_ADDED );
BIND_CONSTANT( AREA_BODY_REMOVED );
diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp
index 8f57fcfbdb..e76bfd113c 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server.cpp
@@ -74,46 +74,46 @@ PhysicsServer * PhysicsServer::get_singleton() {
void PhysicsDirectBodyState::_bind_methods() {
- ClassDB::bind_method(_MD("get_total_gravity"),&PhysicsDirectBodyState::get_total_gravity);
- ClassDB::bind_method(_MD("get_total_linear_damp"),&PhysicsDirectBodyState::get_total_linear_damp);
- ClassDB::bind_method(_MD("get_total_angular_damp"),&PhysicsDirectBodyState::get_total_angular_damp);
+ ClassDB::bind_method(D_METHOD("get_total_gravity"),&PhysicsDirectBodyState::get_total_gravity);
+ ClassDB::bind_method(D_METHOD("get_total_linear_damp"),&PhysicsDirectBodyState::get_total_linear_damp);
+ ClassDB::bind_method(D_METHOD("get_total_angular_damp"),&PhysicsDirectBodyState::get_total_angular_damp);
- ClassDB::bind_method(_MD("get_center_of_mass"),&PhysicsDirectBodyState::get_center_of_mass);
- ClassDB::bind_method(_MD("get_principal_inetria_axes"),&PhysicsDirectBodyState::get_principal_inertia_axes);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass"),&PhysicsDirectBodyState::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_principal_inetria_axes"),&PhysicsDirectBodyState::get_principal_inertia_axes);
- ClassDB::bind_method(_MD("get_inverse_mass"),&PhysicsDirectBodyState::get_inverse_mass);
- ClassDB::bind_method(_MD("get_inverse_inertia"),&PhysicsDirectBodyState::get_inverse_inertia);
+ ClassDB::bind_method(D_METHOD("get_inverse_mass"),&PhysicsDirectBodyState::get_inverse_mass);
+ ClassDB::bind_method(D_METHOD("get_inverse_inertia"),&PhysicsDirectBodyState::get_inverse_inertia);
- ClassDB::bind_method(_MD("set_linear_velocity","velocity"),&PhysicsDirectBodyState::set_linear_velocity);
- ClassDB::bind_method(_MD("get_linear_velocity"),&PhysicsDirectBodyState::get_linear_velocity);
+ ClassDB::bind_method(D_METHOD("set_linear_velocity","velocity"),&PhysicsDirectBodyState::set_linear_velocity);
+ ClassDB::bind_method(D_METHOD("get_linear_velocity"),&PhysicsDirectBodyState::get_linear_velocity);
- ClassDB::bind_method(_MD("set_angular_velocity","velocity"),&PhysicsDirectBodyState::set_angular_velocity);
- ClassDB::bind_method(_MD("get_angular_velocity"),&PhysicsDirectBodyState::get_angular_velocity);
+ ClassDB::bind_method(D_METHOD("set_angular_velocity","velocity"),&PhysicsDirectBodyState::set_angular_velocity);
+ ClassDB::bind_method(D_METHOD("get_angular_velocity"),&PhysicsDirectBodyState::get_angular_velocity);
- ClassDB::bind_method(_MD("set_transform","transform"),&PhysicsDirectBodyState::set_transform);
- ClassDB::bind_method(_MD("get_transform"),&PhysicsDirectBodyState::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","transform"),&PhysicsDirectBodyState::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"),&PhysicsDirectBodyState::get_transform);
- ClassDB::bind_method(_MD("add_force","force","pos"),&PhysicsDirectBodyState::add_force);
- ClassDB::bind_method(_MD("apply_impulse","pos","j"),&PhysicsDirectBodyState::apply_impulse);
- ClassDB::bind_method(_MD("apply_torqe_impulse","j"),&PhysicsDirectBodyState::apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("add_force","force","pos"),&PhysicsDirectBodyState::add_force);
+ ClassDB::bind_method(D_METHOD("apply_impulse","pos","j"),&PhysicsDirectBodyState::apply_impulse);
+ ClassDB::bind_method(D_METHOD("apply_torqe_impulse","j"),&PhysicsDirectBodyState::apply_torque_impulse);
- ClassDB::bind_method(_MD("set_sleep_state","enabled"),&PhysicsDirectBodyState::set_sleep_state);
- ClassDB::bind_method(_MD("is_sleeping"),&PhysicsDirectBodyState::is_sleeping);
+ ClassDB::bind_method(D_METHOD("set_sleep_state","enabled"),&PhysicsDirectBodyState::set_sleep_state);
+ ClassDB::bind_method(D_METHOD("is_sleeping"),&PhysicsDirectBodyState::is_sleeping);
- ClassDB::bind_method(_MD("get_contact_count"),&PhysicsDirectBodyState::get_contact_count);
+ ClassDB::bind_method(D_METHOD("get_contact_count"),&PhysicsDirectBodyState::get_contact_count);
- ClassDB::bind_method(_MD("get_contact_local_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_local_pos);
- ClassDB::bind_method(_MD("get_contact_local_normal","contact_idx"),&PhysicsDirectBodyState::get_contact_local_normal);
- ClassDB::bind_method(_MD("get_contact_local_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_local_shape);
- ClassDB::bind_method(_MD("get_contact_collider","contact_idx"),&PhysicsDirectBodyState::get_contact_collider);
- ClassDB::bind_method(_MD("get_contact_collider_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_pos);
- ClassDB::bind_method(_MD("get_contact_collider_id","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_id);
- ClassDB::bind_method(_MD("get_contact_collider_object","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_object);
- ClassDB::bind_method(_MD("get_contact_collider_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_shape);
- ClassDB::bind_method(_MD("get_contact_collider_velocity_at_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_velocity_at_pos);
- ClassDB::bind_method(_MD("get_step"),&PhysicsDirectBodyState::get_step);
- ClassDB::bind_method(_MD("integrate_forces"),&PhysicsDirectBodyState::integrate_forces);
- ClassDB::bind_method(_MD("get_space_state:PhysicsDirectSpaceState"),&PhysicsDirectBodyState::get_space_state);
+ ClassDB::bind_method(D_METHOD("get_contact_local_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_local_pos);
+ ClassDB::bind_method(D_METHOD("get_contact_local_normal","contact_idx"),&PhysicsDirectBodyState::get_contact_local_normal);
+ ClassDB::bind_method(D_METHOD("get_contact_local_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_local_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider","contact_idx"),&PhysicsDirectBodyState::get_contact_collider);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_pos);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_id","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_id);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_object","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_object);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_shape","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_pos","contact_idx"),&PhysicsDirectBodyState::get_contact_collider_velocity_at_pos);
+ ClassDB::bind_method(D_METHOD("get_step"),&PhysicsDirectBodyState::get_step);
+ ClassDB::bind_method(D_METHOD("integrate_forces"),&PhysicsDirectBodyState::integrate_forces);
+ ClassDB::bind_method(D_METHOD("get_space_state:PhysicsDirectSpaceState"),&PhysicsDirectBodyState::get_space_state);
}
@@ -178,7 +178,7 @@ int PhysicsShapeQueryParameters::get_object_type_mask() const{
}
void PhysicsShapeQueryParameters::set_exclude(const Vector<RID>& p_exclude) {
- exclude.clear();;
+ exclude.clear();
for(int i=0;i<p_exclude.size();i++)
exclude.insert(p_exclude[i]);
@@ -197,24 +197,24 @@ Vector<RID> PhysicsShapeQueryParameters::get_exclude() const{
void PhysicsShapeQueryParameters::_bind_methods() {
- ClassDB::bind_method(_MD("set_shape","shape:Shape"),&PhysicsShapeQueryParameters::set_shape);
- ClassDB::bind_method(_MD("set_shape_rid","shape"),&PhysicsShapeQueryParameters::set_shape_rid);
- ClassDB::bind_method(_MD("get_shape_rid"),&PhysicsShapeQueryParameters::get_shape_rid);
+ ClassDB::bind_method(D_METHOD("set_shape","shape:Shape"),&PhysicsShapeQueryParameters::set_shape);
+ ClassDB::bind_method(D_METHOD("set_shape_rid","shape"),&PhysicsShapeQueryParameters::set_shape_rid);
+ ClassDB::bind_method(D_METHOD("get_shape_rid"),&PhysicsShapeQueryParameters::get_shape_rid);
- ClassDB::bind_method(_MD("set_transform","transform"),&PhysicsShapeQueryParameters::set_transform);
- ClassDB::bind_method(_MD("get_transform"),&PhysicsShapeQueryParameters::get_transform);
+ ClassDB::bind_method(D_METHOD("set_transform","transform"),&PhysicsShapeQueryParameters::set_transform);
+ ClassDB::bind_method(D_METHOD("get_transform"),&PhysicsShapeQueryParameters::get_transform);
- ClassDB::bind_method(_MD("set_margin","margin"),&PhysicsShapeQueryParameters::set_margin);
- ClassDB::bind_method(_MD("get_margin"),&PhysicsShapeQueryParameters::get_margin);
+ ClassDB::bind_method(D_METHOD("set_margin","margin"),&PhysicsShapeQueryParameters::set_margin);
+ ClassDB::bind_method(D_METHOD("get_margin"),&PhysicsShapeQueryParameters::get_margin);
- ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&PhysicsShapeQueryParameters::set_layer_mask);
- ClassDB::bind_method(_MD("get_layer_mask"),&PhysicsShapeQueryParameters::get_layer_mask);
+ ClassDB::bind_method(D_METHOD("set_layer_mask","layer_mask"),&PhysicsShapeQueryParameters::set_layer_mask);
+ ClassDB::bind_method(D_METHOD("get_layer_mask"),&PhysicsShapeQueryParameters::get_layer_mask);
- ClassDB::bind_method(_MD("set_object_type_mask","object_type_mask"),&PhysicsShapeQueryParameters::set_object_type_mask);
- ClassDB::bind_method(_MD("get_object_type_mask"),&PhysicsShapeQueryParameters::get_object_type_mask);
+ ClassDB::bind_method(D_METHOD("set_object_type_mask","object_type_mask"),&PhysicsShapeQueryParameters::set_object_type_mask);
+ ClassDB::bind_method(D_METHOD("get_object_type_mask"),&PhysicsShapeQueryParameters::get_object_type_mask);
- ClassDB::bind_method(_MD("set_exclude","exclude"),&PhysicsShapeQueryParameters::set_exclude);
- ClassDB::bind_method(_MD("get_exclude"),&PhysicsShapeQueryParameters::get_exclude);
+ ClassDB::bind_method(D_METHOD("set_exclude","exclude"),&PhysicsShapeQueryParameters::set_exclude);
+ ClassDB::bind_method(D_METHOD("get_exclude"),&PhysicsShapeQueryParameters::get_exclude);
}
@@ -363,14 +363,14 @@ PhysicsDirectSpaceState::PhysicsDirectSpaceState() {
void PhysicsDirectSpaceState::_bind_methods() {
-// ClassDB::bind_method(_MD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
-// ClassDB::bind_method(_MD("intersect_shape:PhysicsShapeQueryResult","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
+ //ClassDB::bind_method(D_METHOD("intersect_shape:PhysicsShapeQueryResult","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
- ClassDB::bind_method(_MD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
- ClassDB::bind_method(_MD("intersect_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(32));
- ClassDB::bind_method(_MD("cast_motion","shape:PhysicsShapeQueryParameters","motion"),&PhysicsDirectSpaceState::_cast_motion);
- ClassDB::bind_method(_MD("collide_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_collide_shape,DEFVAL(32));
- ClassDB::bind_method(_MD("get_rest_info","shape:PhysicsShapeQueryParameters"),&PhysicsDirectSpaceState::_get_rest_info);
+ ClassDB::bind_method(D_METHOD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
+ ClassDB::bind_method(D_METHOD("intersect_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("cast_motion","shape:PhysicsShapeQueryParameters","motion"),&PhysicsDirectSpaceState::_cast_motion);
+ ClassDB::bind_method(D_METHOD("collide_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_collide_shape,DEFVAL(32));
+ ClassDB::bind_method(D_METHOD("get_rest_info","shape:PhysicsShapeQueryParameters"),&PhysicsDirectSpaceState::_get_rest_info);
BIND_CONSTANT( TYPE_MASK_STATIC_BODY );
@@ -411,11 +411,11 @@ PhysicsShapeQueryResult::PhysicsShapeQueryResult() {
void PhysicsShapeQueryResult::_bind_methods() {
- ClassDB::bind_method(_MD("get_result_count"),&PhysicsShapeQueryResult::get_result_count);
- ClassDB::bind_method(_MD("get_result_rid","idx"),&PhysicsShapeQueryResult::get_result_rid);
- ClassDB::bind_method(_MD("get_result_object_id","idx"),&PhysicsShapeQueryResult::get_result_object_id);
- ClassDB::bind_method(_MD("get_result_object","idx"),&PhysicsShapeQueryResult::get_result_object);
- ClassDB::bind_method(_MD("get_result_object_shape","idx"),&PhysicsShapeQueryResult::get_result_object_shape);
+ ClassDB::bind_method(D_METHOD("get_result_count"),&PhysicsShapeQueryResult::get_result_count);
+ ClassDB::bind_method(D_METHOD("get_result_rid","idx"),&PhysicsShapeQueryResult::get_result_rid);
+ ClassDB::bind_method(D_METHOD("get_result_object_id","idx"),&PhysicsShapeQueryResult::get_result_object_id);
+ ClassDB::bind_method(D_METHOD("get_result_object","idx"),&PhysicsShapeQueryResult::get_result_object);
+ ClassDB::bind_method(D_METHOD("get_result_object_shape","idx"),&PhysicsShapeQueryResult::get_result_object_shape);
}
@@ -429,118 +429,118 @@ void PhysicsShapeQueryResult::_bind_methods() {
void PhysicsServer::_bind_methods() {
- ClassDB::bind_method(_MD("shape_create","type"),&PhysicsServer::shape_create);
- ClassDB::bind_method(_MD("shape_set_data","shape","data"),&PhysicsServer::shape_set_data);
+ ClassDB::bind_method(D_METHOD("shape_create","type"),&PhysicsServer::shape_create);
+ ClassDB::bind_method(D_METHOD("shape_set_data","shape","data"),&PhysicsServer::shape_set_data);
- ClassDB::bind_method(_MD("shape_get_type","shape"),&PhysicsServer::shape_get_type);
- ClassDB::bind_method(_MD("shape_get_data","shape"),&PhysicsServer::shape_get_data);
+ ClassDB::bind_method(D_METHOD("shape_get_type","shape"),&PhysicsServer::shape_get_type);
+ ClassDB::bind_method(D_METHOD("shape_get_data","shape"),&PhysicsServer::shape_get_data);
- ClassDB::bind_method(_MD("space_create"),&PhysicsServer::space_create);
- ClassDB::bind_method(_MD("space_set_active","space","active"),&PhysicsServer::space_set_active);
- ClassDB::bind_method(_MD("space_is_active","space"),&PhysicsServer::space_is_active);
- ClassDB::bind_method(_MD("space_set_param","space","param","value"),&PhysicsServer::space_set_param);
- ClassDB::bind_method(_MD("space_get_param","space","param"),&PhysicsServer::space_get_param);
- ClassDB::bind_method(_MD("space_get_direct_state:PhysicsDirectSpaceState","space"),&PhysicsServer::space_get_direct_state);
+ ClassDB::bind_method(D_METHOD("space_create"),&PhysicsServer::space_create);
+ ClassDB::bind_method(D_METHOD("space_set_active","space","active"),&PhysicsServer::space_set_active);
+ ClassDB::bind_method(D_METHOD("space_is_active","space"),&PhysicsServer::space_is_active);
+ ClassDB::bind_method(D_METHOD("space_set_param","space","param","value"),&PhysicsServer::space_set_param);
+ ClassDB::bind_method(D_METHOD("space_get_param","space","param"),&PhysicsServer::space_get_param);
+ ClassDB::bind_method(D_METHOD("space_get_direct_state:PhysicsDirectSpaceState","space"),&PhysicsServer::space_get_direct_state);
- ClassDB::bind_method(_MD("area_create"),&PhysicsServer::area_create);
- ClassDB::bind_method(_MD("area_set_space","area","space"),&PhysicsServer::area_set_space);
- ClassDB::bind_method(_MD("area_get_space","area"),&PhysicsServer::area_get_space);
+ ClassDB::bind_method(D_METHOD("area_create"),&PhysicsServer::area_create);
+ ClassDB::bind_method(D_METHOD("area_set_space","area","space"),&PhysicsServer::area_set_space);
+ ClassDB::bind_method(D_METHOD("area_get_space","area"),&PhysicsServer::area_get_space);
- ClassDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&PhysicsServer::area_set_space_override_mode);
- ClassDB::bind_method(_MD("area_get_space_override_mode","area"),&PhysicsServer::area_get_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_set_space_override_mode","area","mode"),&PhysicsServer::area_set_space_override_mode);
+ ClassDB::bind_method(D_METHOD("area_get_space_override_mode","area"),&PhysicsServer::area_get_space_override_mode);
- ClassDB::bind_method(_MD("area_add_shape","area","shape","transform"),&PhysicsServer::area_add_shape,DEFVAL(Transform()));
- ClassDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&PhysicsServer::area_set_shape);
- ClassDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&PhysicsServer::area_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_add_shape","area","shape","transform"),&PhysicsServer::area_add_shape,DEFVAL(Transform()));
+ ClassDB::bind_method(D_METHOD("area_set_shape","area","shape_idx","shape"),&PhysicsServer::area_set_shape);
+ ClassDB::bind_method(D_METHOD("area_set_shape_transform","area","shape_idx","transform"),&PhysicsServer::area_set_shape_transform);
- ClassDB::bind_method(_MD("area_get_shape_count","area"),&PhysicsServer::area_get_shape_count);
- ClassDB::bind_method(_MD("area_get_shape","area","shape_idx"),&PhysicsServer::area_get_shape);
- ClassDB::bind_method(_MD("area_get_shape_transform","area","shape_idx"),&PhysicsServer::area_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("area_get_shape_count","area"),&PhysicsServer::area_get_shape_count);
+ ClassDB::bind_method(D_METHOD("area_get_shape","area","shape_idx"),&PhysicsServer::area_get_shape);
+ ClassDB::bind_method(D_METHOD("area_get_shape_transform","area","shape_idx"),&PhysicsServer::area_get_shape_transform);
- ClassDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&PhysicsServer::area_remove_shape);
- ClassDB::bind_method(_MD("area_clear_shapes","area"),&PhysicsServer::area_clear_shapes);
+ ClassDB::bind_method(D_METHOD("area_remove_shape","area","shape_idx"),&PhysicsServer::area_remove_shape);
+ ClassDB::bind_method(D_METHOD("area_clear_shapes","area"),&PhysicsServer::area_clear_shapes);
- ClassDB::bind_method(_MD("area_set_layer_mask","area","mask"),&PhysicsServer::area_set_layer_mask);
- ClassDB::bind_method(_MD("area_set_collision_mask","area","mask"),&PhysicsServer::area_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("area_set_layer_mask","area","mask"),&PhysicsServer::area_set_layer_mask);
+ ClassDB::bind_method(D_METHOD("area_set_collision_mask","area","mask"),&PhysicsServer::area_set_collision_mask);
- ClassDB::bind_method(_MD("area_set_param","area","param","value"),&PhysicsServer::area_set_param);
- ClassDB::bind_method(_MD("area_set_transform","area","transform"),&PhysicsServer::area_set_transform);
+ ClassDB::bind_method(D_METHOD("area_set_param","area","param","value"),&PhysicsServer::area_set_param);
+ ClassDB::bind_method(D_METHOD("area_set_transform","area","transform"),&PhysicsServer::area_set_transform);
- ClassDB::bind_method(_MD("area_get_param","area","param"),&PhysicsServer::area_get_param);
- ClassDB::bind_method(_MD("area_get_transform","area"),&PhysicsServer::area_get_transform);
+ ClassDB::bind_method(D_METHOD("area_get_param","area","param"),&PhysicsServer::area_get_param);
+ ClassDB::bind_method(D_METHOD("area_get_transform","area"),&PhysicsServer::area_get_transform);
- ClassDB::bind_method(_MD("area_attach_object_instance_ID","area","id"),&PhysicsServer::area_attach_object_instance_ID);
- ClassDB::bind_method(_MD("area_get_object_instance_ID","area"),&PhysicsServer::area_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_attach_object_instance_ID","area","id"),&PhysicsServer::area_attach_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("area_get_object_instance_ID","area"),&PhysicsServer::area_get_object_instance_ID);
- ClassDB::bind_method(_MD("area_set_monitor_callback","area","receiver","method"),&PhysicsServer::area_set_monitor_callback);
+ ClassDB::bind_method(D_METHOD("area_set_monitor_callback","area","receiver","method"),&PhysicsServer::area_set_monitor_callback);
- ClassDB::bind_method(_MD("area_set_ray_pickable","area","enable"),&PhysicsServer::area_set_ray_pickable);
- ClassDB::bind_method(_MD("area_is_ray_pickable","area"),&PhysicsServer::area_is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("area_set_ray_pickable","area","enable"),&PhysicsServer::area_set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("area_is_ray_pickable","area"),&PhysicsServer::area_is_ray_pickable);
- ClassDB::bind_method(_MD("body_create","mode","init_sleeping"),&PhysicsServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("body_create","mode","init_sleeping"),&PhysicsServer::body_create,DEFVAL(BODY_MODE_RIGID),DEFVAL(false));
- ClassDB::bind_method(_MD("body_set_space","body","space"),&PhysicsServer::body_set_space);
- ClassDB::bind_method(_MD("body_get_space","body"),&PhysicsServer::body_get_space);
+ ClassDB::bind_method(D_METHOD("body_set_space","body","space"),&PhysicsServer::body_set_space);
+ ClassDB::bind_method(D_METHOD("body_get_space","body"),&PhysicsServer::body_get_space);
- ClassDB::bind_method(_MD("body_set_mode","body","mode"),&PhysicsServer::body_set_mode);
- ClassDB::bind_method(_MD("body_get_mode","body"),&PhysicsServer::body_get_mode);
+ ClassDB::bind_method(D_METHOD("body_set_mode","body","mode"),&PhysicsServer::body_set_mode);
+ ClassDB::bind_method(D_METHOD("body_get_mode","body"),&PhysicsServer::body_get_mode);
- ClassDB::bind_method(_MD("body_set_layer_mask","body","mask"),&PhysicsServer::body_set_layer_mask);
- ClassDB::bind_method(_MD("body_get_layer_mask","body"),&PhysicsServer::body_get_layer_mask);
+ ClassDB::bind_method(D_METHOD("body_set_layer_mask","body","mask"),&PhysicsServer::body_set_layer_mask);
+ ClassDB::bind_method(D_METHOD("body_get_layer_mask","body"),&PhysicsServer::body_get_layer_mask);
- ClassDB::bind_method(_MD("body_set_collision_mask","body","mask"),&PhysicsServer::body_set_collision_mask);
- ClassDB::bind_method(_MD("body_get_collision_mask","body"),&PhysicsServer::body_get_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_set_collision_mask","body","mask"),&PhysicsServer::body_set_collision_mask);
+ ClassDB::bind_method(D_METHOD("body_get_collision_mask","body"),&PhysicsServer::body_get_collision_mask);
- ClassDB::bind_method(_MD("body_add_shape","body","shape","transform"),&PhysicsServer::body_add_shape,DEFVAL(Transform()));
- ClassDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&PhysicsServer::body_set_shape);
- ClassDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&PhysicsServer::body_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_add_shape","body","shape","transform"),&PhysicsServer::body_add_shape,DEFVAL(Transform()));
+ ClassDB::bind_method(D_METHOD("body_set_shape","body","shape_idx","shape"),&PhysicsServer::body_set_shape);
+ ClassDB::bind_method(D_METHOD("body_set_shape_transform","body","shape_idx","transform"),&PhysicsServer::body_set_shape_transform);
- ClassDB::bind_method(_MD("body_get_shape_count","body"),&PhysicsServer::body_get_shape_count);
- ClassDB::bind_method(_MD("body_get_shape","body","shape_idx"),&PhysicsServer::body_get_shape);
- ClassDB::bind_method(_MD("body_get_shape_transform","body","shape_idx"),&PhysicsServer::body_get_shape_transform);
+ ClassDB::bind_method(D_METHOD("body_get_shape_count","body"),&PhysicsServer::body_get_shape_count);
+ ClassDB::bind_method(D_METHOD("body_get_shape","body","shape_idx"),&PhysicsServer::body_get_shape);
+ ClassDB::bind_method(D_METHOD("body_get_shape_transform","body","shape_idx"),&PhysicsServer::body_get_shape_transform);
- ClassDB::bind_method(_MD("body_remove_shape","body","shape_idx"),&PhysicsServer::body_remove_shape);
- ClassDB::bind_method(_MD("body_clear_shapes","body"),&PhysicsServer::body_clear_shapes);
+ ClassDB::bind_method(D_METHOD("body_remove_shape","body","shape_idx"),&PhysicsServer::body_remove_shape);
+ ClassDB::bind_method(D_METHOD("body_clear_shapes","body"),&PhysicsServer::body_clear_shapes);
- ClassDB::bind_method(_MD("body_attach_object_instance_ID","body","id"),&PhysicsServer::body_attach_object_instance_ID);
- ClassDB::bind_method(_MD("body_get_object_instance_ID","body"),&PhysicsServer::body_get_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_attach_object_instance_ID","body","id"),&PhysicsServer::body_attach_object_instance_ID);
+ ClassDB::bind_method(D_METHOD("body_get_object_instance_ID","body"),&PhysicsServer::body_get_object_instance_ID);
- ClassDB::bind_method(_MD("body_set_enable_continuous_collision_detection","body","enable"),&PhysicsServer::body_set_enable_continuous_collision_detection);
- ClassDB::bind_method(_MD("body_is_continuous_collision_detection_enabled","body"),&PhysicsServer::body_is_continuous_collision_detection_enabled);
+ ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection","body","enable"),&PhysicsServer::body_set_enable_continuous_collision_detection);
+ ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled","body"),&PhysicsServer::body_is_continuous_collision_detection_enabled);
- //ClassDB::bind_method(_MD("body_set_user_flags","flags""),&PhysicsServer::body_set_shape,DEFVAL(Transform));
- //ClassDB::bind_method(_MD("body_get_user_flags","body","shape_idx","shape"),&PhysicsServer::body_get_shape);
+ //ClassDB::bind_method(D_METHOD("body_set_user_flags","flags""),&PhysicsServer::body_set_shape,DEFVAL(Transform));
+ //ClassDB::bind_method(D_METHOD("body_get_user_flags","body","shape_idx","shape"),&PhysicsServer::body_get_shape);
- ClassDB::bind_method(_MD("body_set_param","body","param","value"),&PhysicsServer::body_set_param);
- ClassDB::bind_method(_MD("body_get_param","body","param"),&PhysicsServer::body_get_param);
+ ClassDB::bind_method(D_METHOD("body_set_param","body","param","value"),&PhysicsServer::body_set_param);
+ ClassDB::bind_method(D_METHOD("body_get_param","body","param"),&PhysicsServer::body_get_param);
- ClassDB::bind_method(_MD("body_set_state","body","state","value"),&PhysicsServer::body_set_state);
- ClassDB::bind_method(_MD("body_get_state","body","state"),&PhysicsServer::body_get_state);
+ ClassDB::bind_method(D_METHOD("body_set_state","body","state","value"),&PhysicsServer::body_set_state);
+ ClassDB::bind_method(D_METHOD("body_get_state","body","state"),&PhysicsServer::body_get_state);
- ClassDB::bind_method(_MD("body_apply_impulse","body","pos","impulse"),&PhysicsServer::body_apply_impulse);
- ClassDB::bind_method(_MD("body_apply_torque_impulse","body","impulse"),&PhysicsServer::body_apply_torque_impulse);
- ClassDB::bind_method(_MD("body_set_axis_velocity","body","axis_velocity"),&PhysicsServer::body_set_axis_velocity);
+ ClassDB::bind_method(D_METHOD("body_apply_impulse","body","pos","impulse"),&PhysicsServer::body_apply_impulse);
+ ClassDB::bind_method(D_METHOD("body_apply_torque_impulse","body","impulse"),&PhysicsServer::body_apply_torque_impulse);
+ ClassDB::bind_method(D_METHOD("body_set_axis_velocity","body","axis_velocity"),&PhysicsServer::body_set_axis_velocity);
- ClassDB::bind_method(_MD("body_set_axis_lock","body","axis"),&PhysicsServer::body_set_axis_lock);
- ClassDB::bind_method(_MD("body_get_axis_lock","body"),&PhysicsServer::body_get_axis_lock);
+ ClassDB::bind_method(D_METHOD("body_set_axis_lock","body","axis"),&PhysicsServer::body_set_axis_lock);
+ ClassDB::bind_method(D_METHOD("body_get_axis_lock","body"),&PhysicsServer::body_get_axis_lock);
- ClassDB::bind_method(_MD("body_add_collision_exception","body","excepted_body"),&PhysicsServer::body_add_collision_exception);
- ClassDB::bind_method(_MD("body_remove_collision_exception","body","excepted_body"),&PhysicsServer::body_remove_collision_exception);
-// virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
+ ClassDB::bind_method(D_METHOD("body_add_collision_exception","body","excepted_body"),&PhysicsServer::body_add_collision_exception);
+ ClassDB::bind_method(D_METHOD("body_remove_collision_exception","body","excepted_body"),&PhysicsServer::body_remove_collision_exception);
+ //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0;
- ClassDB::bind_method(_MD("body_set_max_contacts_reported","body","amount"),&PhysicsServer::body_set_max_contacts_reported);
- ClassDB::bind_method(_MD("body_get_max_contacts_reported","body"),&PhysicsServer::body_get_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported","body","amount"),&PhysicsServer::body_set_max_contacts_reported);
+ ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported","body"),&PhysicsServer::body_get_max_contacts_reported);
- ClassDB::bind_method(_MD("body_set_omit_force_integration","body","enable"),&PhysicsServer::body_set_omit_force_integration);
- ClassDB::bind_method(_MD("body_is_omitting_force_integration","body"),&PhysicsServer::body_is_omitting_force_integration);
+ ClassDB::bind_method(D_METHOD("body_set_omit_force_integration","body","enable"),&PhysicsServer::body_set_omit_force_integration);
+ ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration","body"),&PhysicsServer::body_is_omitting_force_integration);
- ClassDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method","userdata"),&PhysicsServer::body_set_force_integration_callback,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_set_force_integration_callback","body","receiver","method","userdata"),&PhysicsServer::body_set_force_integration_callback,DEFVAL(Variant()));
- ClassDB::bind_method(_MD("body_set_ray_pickable","body","enable"),&PhysicsServer::body_set_ray_pickable);
- ClassDB::bind_method(_MD("body_is_ray_pickable","body"),&PhysicsServer::body_is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("body_set_ray_pickable","body","enable"),&PhysicsServer::body_set_ray_pickable);
+ ClassDB::bind_method(D_METHOD("body_is_ray_pickable","body"),&PhysicsServer::body_is_ray_pickable);
/* JOINT API */
@@ -550,15 +550,15 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT( JOINT_CONE_TWIST );
BIND_CONSTANT( JOINT_6DOF );
- ClassDB::bind_method(_MD("joint_create_pin","body_A","local_A","body_B","local_B"),&PhysicsServer::joint_create_pin);
- ClassDB::bind_method(_MD("pin_joint_set_param","joint","param","value"),&PhysicsServer::pin_joint_set_param);
- ClassDB::bind_method(_MD("pin_joint_get_param","joint","param"),&PhysicsServer::pin_joint_get_param);
+ ClassDB::bind_method(D_METHOD("joint_create_pin","body_A","local_A","body_B","local_B"),&PhysicsServer::joint_create_pin);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_param","joint","param","value"),&PhysicsServer::pin_joint_set_param);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_param","joint","param"),&PhysicsServer::pin_joint_get_param);
- ClassDB::bind_method(_MD("pin_joint_set_local_A","joint","local_A"),&PhysicsServer::pin_joint_set_local_A);
- ClassDB::bind_method(_MD("pin_joint_get_local_A","joint"),&PhysicsServer::pin_joint_get_local_A);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_A","joint","local_A"),&PhysicsServer::pin_joint_set_local_A);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_A","joint"),&PhysicsServer::pin_joint_get_local_A);
- ClassDB::bind_method(_MD("pin_joint_set_local_B","joint","local_B"),&PhysicsServer::pin_joint_set_local_B);
- ClassDB::bind_method(_MD("pin_joint_get_local_B","joint"),&PhysicsServer::pin_joint_get_local_B);
+ ClassDB::bind_method(D_METHOD("pin_joint_set_local_B","joint","local_B"),&PhysicsServer::pin_joint_set_local_B);
+ ClassDB::bind_method(D_METHOD("pin_joint_get_local_B","joint"),&PhysicsServer::pin_joint_get_local_B);
BIND_CONSTANT(PIN_JOINT_BIAS );
BIND_CONSTANT(PIN_JOINT_DAMPING );
@@ -576,18 +576,18 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT);
BIND_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR);
- ClassDB::bind_method(_MD("joint_create_hinge","body_A","hinge_A","body_B","hinge_B"),&PhysicsServer::joint_create_hinge);
+ ClassDB::bind_method(D_METHOD("joint_create_hinge","body_A","hinge_A","body_B","hinge_B"),&PhysicsServer::joint_create_hinge);
- ClassDB::bind_method(_MD("hinge_joint_set_param","joint","param","value"),&PhysicsServer::hinge_joint_set_param);
- ClassDB::bind_method(_MD("hinge_joint_get_param","joint","param"),&PhysicsServer::hinge_joint_get_param);
+ ClassDB::bind_method(D_METHOD("hinge_joint_set_param","joint","param","value"),&PhysicsServer::hinge_joint_set_param);
+ ClassDB::bind_method(D_METHOD("hinge_joint_get_param","joint","param"),&PhysicsServer::hinge_joint_get_param);
- ClassDB::bind_method(_MD("hinge_joint_set_flag","joint","flag","enabled"),&PhysicsServer::hinge_joint_set_flag);
- ClassDB::bind_method(_MD("hinge_joint_get_flag","joint","flag"),&PhysicsServer::hinge_joint_get_flag);
+ ClassDB::bind_method(D_METHOD("hinge_joint_set_flag","joint","flag","enabled"),&PhysicsServer::hinge_joint_set_flag);
+ ClassDB::bind_method(D_METHOD("hinge_joint_get_flag","joint","flag"),&PhysicsServer::hinge_joint_get_flag);
- ClassDB::bind_method(_MD("joint_create_slider","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_slider);
+ ClassDB::bind_method(D_METHOD("joint_create_slider","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_slider);
- ClassDB::bind_method(_MD("slider_joint_set_param","joint","param","value"),&PhysicsServer::slider_joint_set_param);
- ClassDB::bind_method(_MD("slider_joint_get_param","joint","param"),&PhysicsServer::slider_joint_get_param);
+ ClassDB::bind_method(D_METHOD("slider_joint_set_param","joint","param","value"),&PhysicsServer::slider_joint_set_param);
+ ClassDB::bind_method(D_METHOD("slider_joint_get_param","joint","param"),&PhysicsServer::slider_joint_get_param);
BIND_CONSTANT( SLIDER_JOINT_LINEAR_LIMIT_UPPER );
BIND_CONSTANT( SLIDER_JOINT_LINEAR_LIMIT_LOWER );
@@ -615,10 +615,10 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT( SLIDER_JOINT_MAX );
- ClassDB::bind_method(_MD("joint_create_cone_twist","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_cone_twist);
+ ClassDB::bind_method(D_METHOD("joint_create_cone_twist","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_cone_twist);
- ClassDB::bind_method(_MD("cone_twist_joint_set_param","joint","param","value"),&PhysicsServer::cone_twist_joint_set_param);
- ClassDB::bind_method(_MD("cone_twist_joint_get_param","joint","param"),&PhysicsServer::cone_twist_joint_get_param);
+ ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param","joint","param","value"),&PhysicsServer::cone_twist_joint_set_param);
+ ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param","joint","param"),&PhysicsServer::cone_twist_joint_get_param);
BIND_CONSTANT( CONE_TWIST_JOINT_SWING_SPAN );
BIND_CONSTANT( CONE_TWIST_JOINT_TWIST_SPAN );
@@ -647,44 +647,44 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT( G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT );
BIND_CONSTANT( G6DOF_JOINT_FLAG_ENABLE_MOTOR );
- ClassDB::bind_method(_MD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
+ ClassDB::bind_method(D_METHOD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
- ClassDB::bind_method(_MD("joint_set_solver_priority","joint","priority"),&PhysicsServer::joint_set_solver_priority);
- ClassDB::bind_method(_MD("joint_get_solver_priority","joint"),&PhysicsServer::joint_get_solver_priority);
+ ClassDB::bind_method(D_METHOD("joint_set_solver_priority","joint","priority"),&PhysicsServer::joint_set_solver_priority);
+ ClassDB::bind_method(D_METHOD("joint_get_solver_priority","joint"),&PhysicsServer::joint_get_solver_priority);
- ClassDB::bind_method(_MD("joint_create_generic_6dof","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_generic_6dof);
+ ClassDB::bind_method(D_METHOD("joint_create_generic_6dof","body_A","local_ref_A","body_B","local_ref_B"),&PhysicsServer::joint_create_generic_6dof);
- ClassDB::bind_method(_MD("generic_6dof_joint_set_param","joint","axis","param","value"),&PhysicsServer::generic_6dof_joint_set_param);
- ClassDB::bind_method(_MD("generic_6dof_joint_get_param","joint","axis","param"),&PhysicsServer::generic_6dof_joint_get_param);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param","joint","axis","param","value"),&PhysicsServer::generic_6dof_joint_set_param);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param","joint","axis","param"),&PhysicsServer::generic_6dof_joint_get_param);
- ClassDB::bind_method(_MD("generic_6dof_joint_set_flag","joint","axis","flag","enable"),&PhysicsServer::generic_6dof_joint_set_flag);
- ClassDB::bind_method(_MD("generic_6dof_joint_get_flag","joint","axis","flag"),&PhysicsServer::generic_6dof_joint_get_flag);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag","joint","axis","flag","enable"),&PhysicsServer::generic_6dof_joint_set_flag);
+ ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag","joint","axis","flag"),&PhysicsServer::generic_6dof_joint_get_flag);
/*
- ClassDB::bind_method(_MD("joint_set_param","joint","param","value"),&PhysicsServer::joint_set_param);
- ClassDB::bind_method(_MD("joint_get_param","joint","param"),&PhysicsServer::joint_get_param);
+ ClassDB::bind_method(D_METHOD("joint_set_param","joint","param","value"),&PhysicsServer::joint_set_param);
+ ClassDB::bind_method(D_METHOD("joint_get_param","joint","param"),&PhysicsServer::joint_get_param);
- ClassDB::bind_method(_MD("pin_joint_create","anchor","body_a","body_b"),&PhysicsServer::pin_joint_create,DEFVAL(RID()));
- ClassDB::bind_method(_MD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&PhysicsServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
- ClassDB::bind_method(_MD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&PhysicsServer::damped_spring_joint_create,DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("pin_joint_create","anchor","body_a","body_b"),&PhysicsServer::pin_joint_create,DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("groove_joint_create","groove1_a","groove2_a","anchor_b","body_a","body_b"),&PhysicsServer::groove_joint_create,DEFVAL(RID()),DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("damped_spring_joint_create","anchor_a","anchor_b","body_a","body_b"),&PhysicsServer::damped_spring_joint_create,DEFVAL(RID()));
- ClassDB::bind_method(_MD("damped_string_joint_set_param","joint","param","value"),&PhysicsServer::damped_string_joint_set_param,DEFVAL(RID()));
- ClassDB::bind_method(_MD("damped_string_joint_get_param","joint","param"),&PhysicsServer::damped_string_joint_get_param);
+ ClassDB::bind_method(D_METHOD("damped_string_joint_set_param","joint","param","value"),&PhysicsServer::damped_string_joint_set_param,DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("damped_string_joint_get_param","joint","param"),&PhysicsServer::damped_string_joint_get_param);
- ClassDB::bind_method(_MD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
+ ClassDB::bind_method(D_METHOD("joint_get_type","joint"),&PhysicsServer::joint_get_type);
*/
- ClassDB::bind_method(_MD("free_rid","rid"),&PhysicsServer::free);
+ ClassDB::bind_method(D_METHOD("free_rid","rid"),&PhysicsServer::free);
- ClassDB::bind_method(_MD("set_active","active"),&PhysicsServer::set_active);
+ ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsServer::set_active);
-// ClassDB::bind_method(_MD("init"),&PhysicsServer::init);
-// ClassDB::bind_method(_MD("step"),&PhysicsServer::step);
-// ClassDB::bind_method(_MD("sync"),&PhysicsServer::sync);
- //ClassDB::bind_method(_MD("flush_queries"),&PhysicsServer::flush_queries);
+ //ClassDB::bind_method(D_METHOD("init"),&PhysicsServer::init);
+ //ClassDB::bind_method(D_METHOD("step"),&PhysicsServer::step);
+ //ClassDB::bind_method(D_METHOD("sync"),&PhysicsServer::sync);
+ //ClassDB::bind_method(D_METHOD("flush_queries"),&PhysicsServer::flush_queries);
- ClassDB::bind_method(_MD("get_process_info","process_info"),&PhysicsServer::get_process_info);
+ ClassDB::bind_method(D_METHOD("get_process_info","process_info"),&PhysicsServer::get_process_info);
BIND_CONSTANT( SHAPE_PLANE );
BIND_CONSTANT( SHAPE_RAY );
@@ -739,8 +739,8 @@ void PhysicsServer::_bind_methods() {
BIND_CONSTANT( DAMPED_STRING_STIFFNESS );
BIND_CONSTANT( DAMPED_STRING_DAMPING );
*/
-// BIND_CONSTANT( TYPE_BODY );
-// BIND_CONSTANT( TYPE_AREA );
+ //BIND_CONSTANT( TYPE_BODY );
+ //BIND_CONSTANT( TYPE_AREA );
BIND_CONSTANT( AREA_BODY_ADDED );
BIND_CONSTANT( AREA_BODY_REMOVED );
diff --git a/servers/physics_server.h b/servers/physics_server.h
index d57ca93d92..653959be45 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -135,8 +135,8 @@ class PhysicsDirectSpaceState : public Object {
GDCLASS( PhysicsDirectSpaceState, Object );
-// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
-// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
+ //Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
+ //Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
public:
enum ObjectTypeMask {
diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp
index 9a98890a26..0d0619e880 100644
--- a/servers/register_server_types.cpp
+++ b/servers/register_server_types.cpp
@@ -27,16 +27,30 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_server_types.h"
-#include "globals.h"
+#include "global_config.h"
#include "visual_server.h"
#include "audio_server.h"
#include "physics_server.h"
#include "physics_2d_server.h"
-#include "spatial_sound_server.h"
-#include "spatial_sound_2d_server.h"
#include "script_debugger_remote.h"
#include "visual/shader_types.h"
+#include "audio/audio_stream.h"
+#include "audio/audio_effect.h"
+#include "audio/effects/audio_effect_amplify.h"
+#include "audio/effects/audio_effect_reverb.h"
+#include "audio/effects/audio_effect_filter.h"
+#include "audio/effects/audio_effect_eq.h"
+#include "audio/effects/audio_effect_distortion.h"
+#include "audio/effects/audio_effect_stereo_enhance.h"
+#include "audio/effects/audio_effect_panner.h"
+#include "audio/effects/audio_effect_chorus.h"
+#include "audio/effects/audio_effect_delay.h"
+#include "audio/effects/audio_effect_compressor.h"
+#include "audio/effects/audio_effect_limiter.h"
+#include "audio/effects/audio_effect_pitch_shift.h"
+#include "audio/effects/audio_effect_phaser.h"
+
static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsage>* r_usage) {
List<VS::TextureInfo> tinfo;
@@ -65,11 +79,45 @@ void register_server_types() {
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()) );
- GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("SpatialSoundServer",SpatialSoundServer::get_singleton()) );
- GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("SpatialSound2DServer",SpatialSound2DServer::get_singleton()) );
shader_types = memnew( ShaderTypes );
+ ClassDB::register_virtual_class<AudioStream>();
+ ClassDB::register_virtual_class<AudioStreamPlayback>();
+ ClassDB::register_virtual_class<AudioEffect>();
+ ClassDB::register_class<AudioBusLayout>();
+
+ {
+ //audio effects
+ ClassDB::register_class<AudioEffectAmplify>();
+
+ ClassDB::register_class<AudioEffectReverb>();
+
+ ClassDB::register_class<AudioEffectLowPassFilter>();
+ ClassDB::register_class<AudioEffectHighPassFilter>();
+ ClassDB::register_class<AudioEffectBandPassFilter>();
+ ClassDB::register_class<AudioEffectNotchFilter>();
+ ClassDB::register_class<AudioEffectBandLimitFilter>();
+ ClassDB::register_class<AudioEffectLowShelfFilter>();
+ ClassDB::register_class<AudioEffectHighShelfFilter>();
+
+ ClassDB::register_class<AudioEffectEQ6>();
+ ClassDB::register_class<AudioEffectEQ10>();
+ ClassDB::register_class<AudioEffectEQ21>();
+
+ ClassDB::register_class<AudioEffectDistortion>();
+
+ ClassDB::register_class<AudioEffectStereoEnhance>();
+
+ ClassDB::register_class<AudioEffectPanner>();
+ ClassDB::register_class<AudioEffectChorus>();
+ ClassDB::register_class<AudioEffectDelay>();
+ ClassDB::register_class<AudioEffectCompressor>();
+ ClassDB::register_class<AudioEffectLimiter>();
+ ClassDB::register_class<AudioEffectPitchShift>();
+ ClassDB::register_class<AudioEffectPhaser>();
+ }
+
ClassDB::register_virtual_class<Physics2DDirectBodyState>();
ClassDB::register_virtual_class<Physics2DDirectSpaceState>();
diff --git a/servers/spatial_sound/spatial_sound_server_sw.cpp b/servers/spatial_sound/spatial_sound_server_sw.cpp
deleted file mode 100644
index ccde73561f..0000000000
--- a/servers/spatial_sound/spatial_sound_server_sw.cpp
+++ /dev/null
@@ -1,1071 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_server_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_sound_server_sw.h"
-#include "os/os.h"
-#include "servers/audio/audio_filter_sw.h"
-
-
-
-int SpatialSoundServerSW::InternalAudioStream::get_channel_count() const {
-
- return AudioServer::get_singleton()->get_default_channel_count();
-}
-
-void SpatialSoundServerSW::InternalAudioStream::set_mix_rate(int p_rate) {
-
-
-}
-
-void SpatialSoundServerSW::InternalAudioStream::update() {
-
- owner->_update_sources();
-}
-
-bool SpatialSoundServerSW::InternalAudioStream::mix(int32_t *p_buffer,int p_frames) {
-
- return owner->internal_buffer_mix(p_buffer,p_frames);
-}
-
-void SpatialSoundServerSW::_update_sources() {
-
- _THREAD_SAFE_METHOD_
- for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) {
-
- Source *s=E->get();
- ERR_CONTINUE(!s->stream);
- s->stream->update();
- }
-}
-
-
-SpatialSoundServerSW::Room::Room() {
-
-// params[ROOM_PARAM_SPEED_OF_SOUND]=343.0;
- params[ROOM_PARAM_SPEED_OF_SOUND_SCALE]=1;
- params[ROOM_PARAM_DOPPLER_FACTOR]=1.0;
- params[ROOM_PARAM_PITCH_SCALE]=1.0;
- params[ROOM_PARAM_VOLUME_SCALE_DB]=0;
- params[ROOM_PARAM_REVERB_SEND]=0;
- params[ROOM_PARAM_CHORUS_SEND]=0;
- params[ROOM_PARAM_ATTENUATION_SCALE]=1.0;
- params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]=5000;
- params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0;
- params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]=1.0;
- params[ROOM_PARAM_ATTENUATION_REVERB_SCALE]=0.0;
- override_other_sources=false;
- reverb=ROOM_REVERB_HALL;
- octree_id=0;
- level=-1;
-
-
-}
-
-
-SpatialSoundServerSW::Source::Source() {
-
- params[SOURCE_PARAM_VOLUME_DB]=0.0;
- params[SOURCE_PARAM_PITCH_SCALE]=1.0;
- params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]=100;
- params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
- params[SOURCE_PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled
- params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation
- stream=NULL;
- voices.resize(1);
- last_voice=0;
-}
-
-SpatialSoundServerSW::Source::Voice::Voice() {
-
- active=false;
- restart=false;
- pitch_scale=1.0;
- volume_scale=0.0;
- voice_rid=AudioServer::get_singleton()->voice_create();
-
-}
-SpatialSoundServerSW::Source::Voice::~Voice() {
-
- AudioServer::get_singleton()->free(voice_rid);
-}
-
-
-SpatialSoundServerSW::Listener::Listener() {
-
- params[LISTENER_PARAM_VOLUME_SCALE_DB]=0.0;
- params[LISTENER_PARAM_PITCH_SCALE]=1.0;
- params[LISTENER_PARAM_ATTENUATION_SCALE]=1.0;
- params[LISTENER_PARAM_RECEPTION_CONE_DEGREES]=60.0;
- params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB]=-6; // minus six decibels
-
-}
-
-/* SPACE */
-RID SpatialSoundServerSW::space_create() {
-
- Space* space = memnew( Space );
- RID space_rid = space_owner.make_rid(space);
- space->default_room=room_create();
- room_set_space(space->default_room,space_rid);
- return space_rid;
-}
-
-/* ROOM */
-
-RID SpatialSoundServerSW::room_create() {
-
- Room *room = memnew( Room );
- return room_owner.make_rid(room);
-}
-
-void SpatialSoundServerSW::room_set_space(RID p_room,RID p_space) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
-
- if (room->space.is_valid()) {
-
- Space *space = space_owner.get(room->space);
- space->rooms.erase(p_room);
- space->octree.erase(room->octree_id);
- //room->octree_id=0;
- }
-
- room->space=RID();
-
- if (p_space.is_valid()) {
-
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND(!space);
- space->rooms.insert(p_room);
- room->octree_id=space->octree.create(room,Rect3());
- //set bounds
- Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb();
- space->octree.move(room->octree_id,room->transform.xform(aabb));
- room->space=p_space;
- }
-
-
-}
-
-RID SpatialSoundServerSW::room_get_space(RID p_room) const {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,RID());
-
-
- return room->space;
-}
-
-
-
-void SpatialSoundServerSW::room_set_bounds(RID p_room, const BSP_Tree& p_bounds) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
-
- room->bounds=p_bounds;
-
- if (!room->space.is_valid())
- return;
-
- Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb();
- Space* space = space_owner.get(room->space);
- ERR_FAIL_COND(!space);
-
- space->octree.move(room->octree_id,room->transform.xform(aabb));
-
-}
-BSP_Tree SpatialSoundServerSW::room_get_bounds(RID p_room) const {
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,BSP_Tree());
-
- return room->bounds;
-}
-
-void SpatialSoundServerSW::room_set_transform(RID p_room, const Transform& p_transform) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->transform=p_transform;
- room->inverse_transform=p_transform.affine_inverse(); // needs to be done to unscale BSP properly
-
- if (!room->space.is_valid())
- return;
-
- if (!room->bounds.is_empty()) {
-
- Space* space = space_owner.get(room->space);
- ERR_FAIL_COND(!space);
-
- space->octree.move(room->octree_id,room->transform.xform(room->bounds.get_aabb()));
- }
-}
-
-Transform SpatialSoundServerSW::room_get_transform(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,Transform());
- return room->transform;
-}
-
-
-void SpatialSoundServerSW::room_set_param(RID p_room, RoomParam p_param, float p_value) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- ERR_FAIL_INDEX(p_param,ROOM_PARAM_MAX);
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->params[p_param]=p_value;
-
-}
-float SpatialSoundServerSW::room_get_param(RID p_room, RoomParam p_param) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- ERR_FAIL_INDEX_V(p_param,ROOM_PARAM_MAX,0);
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,0);
- return room->params[p_param];
-}
-
-void SpatialSoundServerSW::room_set_level(RID p_room, int p_level) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->level =p_level;
-
-}
-
-int SpatialSoundServerSW::room_get_level(RID p_room) const {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,0);
- return room->level;
-
-}
-
-
-void SpatialSoundServerSW::room_set_reverb(RID p_room, RoomReverb p_reverb) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->reverb=p_reverb;
-
-}
-SpatialSoundServerSW::RoomReverb SpatialSoundServerSW::room_get_reverb(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,ROOM_REVERB_SMALL);
- return room->reverb;
-}
-
-//useful for underwater or rooms with very strange conditions
-void SpatialSoundServerSW::room_set_force_params_to_all_sources(RID p_room, bool p_force) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->override_other_sources=p_force;
-
-}
-bool SpatialSoundServerSW::room_is_forcing_params_to_all_sources(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,false);
- return room->override_other_sources;
-}
-
-/* SOURCE */
-
-RID SpatialSoundServerSW::source_create(RID p_space) {
-
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND_V(!space,RID());
-
- Source *source = memnew( Source );
- source->space=p_space;
- RID source_rid = source_owner.make_rid(source);
- space->sources.insert(source_rid);
-
- return source_rid;
-}
-
-
-void SpatialSoundServerSW::source_set_polyphony(RID p_source,int p_voice_count) {
-
-
- ERR_FAIL_COND(p_voice_count<=0); // more than 32 is too much, change this if you really need more
- if (p_voice_count>32) {
-
- ERR_PRINT("Voices will be clipped to 32");
- p_voice_count=32;
- }
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
-
- if (p_voice_count<source->voices.size()) {
-
- for(int i=p_voice_count;i<source->voices.size();i++) {
- active_voices.erase(ActiveVoice(source,i)); //erase from active voices
- }
- }
- source->voices.resize(p_voice_count);
-
-}
-
-int SpatialSoundServerSW::source_get_polyphony(RID p_source) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,-1);
- return source->voices.size();
-
-}
-
-void SpatialSoundServerSW::source_set_transform(RID p_source, const Transform& p_transform) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- source->transform=p_transform;
- source->transform.orthonormalize();
-}
-Transform SpatialSoundServerSW::source_get_transform(RID p_source) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,Transform());
- return source->transform;
-}
-
-void SpatialSoundServerSW::source_set_param(RID p_source, SourceParam p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,SOURCE_PARAM_MAX);
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- source->params[p_param]=p_value;
-
-}
-float SpatialSoundServerSW::source_get_param(RID p_source, SourceParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,SOURCE_PARAM_MAX,0);
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,0);
- return source->params[p_param];
-
-
-}
-
-void SpatialSoundServerSW::source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- AudioServer::get_singleton()->lock();
- source->stream=p_stream;
- _THREAD_SAFE_METHOD_
-
- if (!p_stream) {
- streaming_sources.erase(source);
- active_voices.erase(ActiveVoice(source,VOICE_IS_STREAM));
- } else {
- streaming_sources.insert(source);
- active_voices.insert(ActiveVoice(source,VOICE_IS_STREAM));
- zeromem(source->stream_data.filter_state,sizeof(Source::StreamData::FilterState)*4); //reset filter for safetyness
- p_stream->set_mix_rate(AudioServer::get_singleton()->get_default_mix_rate());
- }
-
- AudioServer::get_singleton()->unlock();
-
-} //null to unset
-
-SpatialSoundServer::SourceVoiceID SpatialSoundServerSW::source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,SOURCE_INVALID_VOICE);
-
- int to_play=0;
-
- if (p_voice==SOURCE_NEXT_VOICE) {
- to_play=source->last_voice+1;
- if (to_play>=source->voices.size())
- to_play=0;
-
- } else
- to_play=p_voice;
-
- ERR_FAIL_INDEX_V(to_play,source->voices.size(),SOURCE_INVALID_VOICE);
-
- source->voices[to_play].restart=true;
- source->voices[to_play].sample_rid=p_sample;
- source->voices[to_play].sample_mix_rate=p_mix_rate;
- source->voices[to_play].pitch_scale=1;
- source->voices[to_play].volume_scale=0;
- source->last_voice=to_play;
- active_voices.insert(ActiveVoice(source,to_play));
- return to_play;
-}
-
-/* VOICES */
-void SpatialSoundServerSW::source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- source->voices[p_voice].pitch_scale=p_pitch_scale;
-
-}
-void SpatialSoundServerSW::source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_db) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- source->voices[p_voice].volume_scale=p_db;
-
-}
-
-bool SpatialSoundServerSW::source_is_voice_active(RID p_source, SourceVoiceID p_voice) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,false);
- ERR_FAIL_INDEX_V(p_voice,source->voices.size(),false);
- return source->voices[p_voice].active || source->voices[p_voice].restart;
-
-}
-void SpatialSoundServerSW::source_stop_voice(RID p_source, SourceVoiceID p_voice) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- if (source->voices[p_voice].active) {
- AudioServer::get_singleton()->voice_stop(source->voices[p_voice].voice_rid);
- }
- source->voices[p_voice].active=false;
- source->voices[p_voice].restart=false;
- active_voices.erase(ActiveVoice(source,p_voice));
-}
-
-/* LISTENER */
-
-RID SpatialSoundServerSW::listener_create() {
-
- Listener *listener = memnew( Listener );
- RID listener_rid = listener_owner.make_rid(listener);
- return listener_rid;
-
-}
-
-void SpatialSoundServerSW::listener_set_space(RID p_listener,RID p_space) {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
-
- if (listener->space.is_valid()) {
-
- Space *lspace = space_owner.get(listener->space);
- ERR_FAIL_COND(!lspace);
- lspace->listeners.erase(p_listener);
- }
-
- listener->space=RID();
-
- if (p_space.is_valid()) {
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND(!space);
-
- listener->space=p_space;
- space->listeners.insert(p_listener);
- }
-
-}
-
-void SpatialSoundServerSW::listener_set_transform(RID p_listener, const Transform& p_transform) {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
- listener->transform=p_transform;
- listener->transform.orthonormalize(); //must be done..
-}
-Transform SpatialSoundServerSW::listener_get_transform(RID p_listener) const {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND_V(!listener,Transform());
- return listener->transform;
-}
-
-void SpatialSoundServerSW::listener_set_param(RID p_listener, ListenerParam p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,LISTENER_PARAM_MAX);
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
- listener->params[p_param]=p_value;
-}
-
-float SpatialSoundServerSW::listener_get_param(RID p_listener, ListenerParam p_param) const {
-
- ERR_FAIL_INDEX_V(p_param,LISTENER_PARAM_MAX,0);
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND_V(!listener,0);
- return listener->params[p_param];
-}
-
-
-/* MISC */
-
-void SpatialSoundServerSW::free(RID p_id) {
-
-
- if (space_owner.owns(p_id)) {
-
- Space *space = space_owner.get(p_id);
- free(space->default_room);
-
- while(space->listeners.size()) {
- listener_set_space(space->listeners.front()->get(),RID());
- }
- while(space->sources.size()) {
- free(space->sources.front()->get());
- }
- while(space->rooms.size()) {
- room_set_space(space->rooms.front()->get(),RID());
- }
- space_owner.free(p_id);
- memdelete(space);
-
- } else if (source_owner.owns(p_id)) {
-
- Source *source = source_owner.get(p_id);
- if (source->stream)
- source_set_audio_stream(p_id,NULL);
-
- Space *space = space_owner.get(source->space);
- ERR_FAIL_COND(!space);
- space->sources.erase(p_id);
- for(int i=0;i<source->voices.size();i++) {
- active_voices.erase(ActiveVoice(source,i));
- }
- source_owner.free(p_id);
- memdelete(source);
- } else if (listener_owner.owns(p_id)) {
-
- Listener *listener = listener_owner.get(p_id);
- if (listener->space.is_valid()) {
- Space *space = space_owner.get(listener->space);
- ERR_FAIL_COND(!space);
- space->listeners.erase(p_id);
- }
- listener_owner.free(p_id);
- memdelete(listener);
-
- } else if (room_owner.owns(p_id)) {
-
- Room *room = room_owner.get(p_id);
-
- if (room->space.is_valid()) {
- Space *space = space_owner.get(room->space);
- ERR_FAIL_COND(!space);
- space->octree.erase(room->octree_id);
- space->rooms.erase(p_id);
- }
- room_owner.free(p_id);
- memdelete(room);
- } else {
- ERR_PRINT("Attempt to free invalid ID") ;
- }
-
-}
-
-void SpatialSoundServerSW::_clean_up_owner(RID_OwnerBase *p_owner, const char *p_area) {
-
- List<RID> rids;
- p_owner->get_owned_list(&rids);
-
- for(List<RID>::Element *I=rids.front();I;I=I->next()) {
- if (OS::get_singleton()->is_stdout_verbose()) {
-
- print_line("Leaked RID ("+itos(I->get().get_id())+") of type "+String(p_area));
- }
- free(I->get());
- }
-}
-
-void SpatialSoundServerSW::init() {
-
- internal_buffer = memnew_arr(int32_t, INTERNAL_BUFFER_SIZE*INTERNAL_BUFFER_MAX_CHANNELS);
- internal_buffer_channels=AudioServer::get_singleton()->get_default_channel_count();
-
- internal_audio_stream = memnew( InternalAudioStream );
- internal_audio_stream->owner=this;
- internal_audio_stream_rid = AudioServer::get_singleton()->audio_stream_create(internal_audio_stream);
-
- AudioServer::get_singleton()->stream_set_active(internal_audio_stream_rid,true);
-
-}
-
-
-
-static float _get_attenuation(float cosine, float angle, float attenuation) {
-
-
- float listener_ang = Math::rad2deg(Math::acos(cosine))-angle;
-
- if (listener_ang>0 && angle<180.0) {
- listener_ang/=(180.0-angle);
- return Math::db2linear(Math::sin(listener_ang*(Math_PI/2.0))*attenuation);
- }
- return 1.0;
-}
-
-
-bool SpatialSoundServerSW::internal_buffer_mix(int32_t *p_buffer,int p_frames) {
-
- if (streaming_sources.size()==0)
- return false; //nothing to mix
-
-
- for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) {
-
- Source *s=E->get();
- ERR_CONTINUE(!s->stream);
-
- int channels = s->stream->get_channel_count();
- Source::StreamData &sd=s->stream_data;
-
- int todo=p_frames;
-
- AudioFilterSW filter;
- filter.set_sampling_rate(AudioServer::get_singleton()->get_default_mix_rate());
- filter.set_cutoff(sd.filter_cutoff);
- filter.set_gain(sd.filter_gain);
- filter.set_resonance(1);
- filter.set_mode(AudioFilterSW::HIGHSHELF);
- filter.set_stages(1);
- AudioFilterSW::Coeffs coefs;
- filter.prepare_coefficients(&coefs);
-
- int32_t in[4];
-#ifndef SPATIAL_SOUND_SERVER_NO_FILTER
-#define DO_FILTER(m_c)\
- {\
- float val = in[m_c];\
- float pre=val;\
- val = val*coefs.b0 + sd.filter_state[m_c].hb[0]*coefs.b1 + sd.filter_state[m_c].hb[1]*coefs.b2 + sd.filter_state[m_c].ha[0]*coefs.a1 + sd.filter_state[m_c].ha[1]*coefs.a2;\
- sd.filter_state[m_c].ha[1]=sd.filter_state[m_c].ha[0];\
- sd.filter_state[m_c].hb[1]=sd.filter_state[m_c].hb[0]; \
- sd.filter_state[m_c].hb[0]=pre;\
- sd.filter_state[m_c].ha[0]=val;\
- in[m_c]=Math::fast_ftoi(val);\
- }
-#else
-#define DO_FILTER(m_c)
-#endif
-
- while(todo) {
-
- int to_mix=MIN(todo,INTERNAL_BUFFER_SIZE);
-
- s->stream->mix(internal_buffer,to_mix);
-
- switch(internal_buffer_channels) {
-
- case 2: {
-
- float p = sd.panning.x*0.5+0.5;
- float panf[2]={ (1.0-p),p };
- panf[0]*=sd.volume;
- panf[1]*=sd.volume;
-
- int32_t pan[2]={Math::fast_ftoi(panf[0]*(1<<16)),Math::fast_ftoi(panf[1]*(1<<16))};
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[i];
- in[1]=internal_buffer[i];
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<1)+0];
- in[1]=internal_buffer[(i<<1)+1];
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=(internal_buffer[(i<<2)+0]+internal_buffer[(i<<2)+2])>>1;
- in[1]=(internal_buffer[(i<<2)+1]+internal_buffer[(i<<2)+3])>>1;
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
-
- } break;
-
- } break;
- case 4: {
-
- float xp = sd.panning.x*0.5+0.5;
- float yp = sd.panning.y*0.5+0.5;
- float panf[4]={ (1.0-xp)*(1.0-yp),(xp)*(1.0-yp),(1.0-xp)*(yp),(xp)*(yp) };
- panf[0]*=sd.volume;
- panf[1]*=sd.volume;
- panf[2]*=sd.volume;
- panf[3]*=sd.volume;
-
- int32_t pan[4]={
- Math::fast_ftoi(panf[0]*(1<<16)),
- Math::fast_ftoi(panf[1]*(1<<16)),
- Math::fast_ftoi(panf[2]*(1<<16)),
- Math::fast_ftoi(panf[3]*(1<<16))};
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[i];
- in[1]=internal_buffer[i];
- in[2]=internal_buffer[i];
- in[3]=internal_buffer[i];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<1)+0];
- in[1]=internal_buffer[(i<<1)+1];
- in[2]=internal_buffer[(i<<1)+0];
- in[3]=internal_buffer[(i<<1)+1];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<2)+0];
- in[1]=internal_buffer[(i<<2)+1];
- in[2]=internal_buffer[(i<<2)+2];
- in[3]=internal_buffer[(i<<2)+3];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
-
- } break;
-
- } break;
- case 6: {
-
-
- } break;
- }
- p_buffer+=to_mix*internal_buffer_channels;
- todo-=to_mix;
-
- }
-
- }
-
- return true;
-}
-
-void SpatialSoundServerSW::update(float p_delta) {
-
- List<ActiveVoice> to_disable;
-
-
- for(Set<ActiveVoice>::Element *E=active_voices.front();E;E=E->next()) {
-
- Source *source = E->get().source;
- int voice = E->get().voice;
-
- if (voice!=VOICE_IS_STREAM) {
- Source::Voice &v=source->voices[voice];
- ERR_CONTINUE(!v.active && !v.restart); // likely a bug...
- }
-
- //this could be optimized at some point... am not sure
- Space *space=space_owner.get(source->space);
- Room *room=room_owner.get(space->default_room);
- int max_level=-0x80000000;
- int rooms_culled = space->octree.cull_point(source->transform.origin,cull_rooms,MAX_CULL_ROOMS);
- for(int i=0;i<rooms_culled;i++) {
-
- Room *r=cull_rooms[i];
- ERR_CONTINUE( r->bounds.is_empty() ); // how did this happen??
- if (r->level<=max_level) //ignore optimization (level too low)
- continue;
- Vector3 local_point = r->inverse_transform.xform(source->transform.origin);
- if (!r->bounds.point_is_inside(local_point))
- continue;
- room=r;
- max_level=r->level;
-
- }
-
-
- //compute mixing weights (support for multiple listeners in the same output)
- float total_distance=0;
- for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) {
- Listener *listener=listener_owner.get(L->get());
- total_distance+=listener->transform.origin.distance_to(source->transform.origin);
- }
-
- //compute spatialization variables, weighted according to distance
- float volume_attenuation = 0.0;
- float air_absorption_hf_cutoff = 0.0;
- float air_absorption = 0.0;
- float pitch_scale=1.0;
- Vector3 panning;
-
-
- //print_line("listeners: "+itos(space->listeners.size()));
-
-
- for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) {
-
- Listener *listener=listener_owner.get(L->get());
-
- Vector3 rel_vector = listener->transform.xform_inv(source->transform.origin);
- Vector3 source_rel_vector = source->transform.xform_inv(listener->transform.origin).normalized();
- float distance=rel_vector.length();
- float weight = distance/total_distance;
- float pscale=1.0;
-
- float distance_scale=listener->params[LISTENER_PARAM_ATTENUATION_SCALE]*room->params[ROOM_PARAM_ATTENUATION_SCALE];
- float distance_min=source->params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]*distance_scale;
- float distance_max=source->params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]*distance_scale;
- float attenuation_exp=source->params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP];
- float attenuation=1;
-
- //print_line("DIST MIN: "+rtos(distance_min));
- //print_line("DIST MAX: "+rtos(distance_max));
- if (distance_max>0) {
- distance = CLAMP(distance,distance_min,distance_max);
- attenuation = Math::pow(1.0 - ((distance - distance_min)/(distance_max-distance_min)),CLAMP(attenuation_exp,0.001,16));
- }
-
- float hf_attenuation_cutoff = room->params[ROOM_PARAM_ATTENUATION_HF_CUTOFF];
- float hf_attenuation_exp = room->params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP];
- float hf_attenuation_floor = room->params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB];
- float absorption=Math::db2linear(Math::lerp(hf_attenuation_floor,0,Math::pow(attenuation,hf_attenuation_exp)));
-
- // source emission cone
-
- float emission_deg=source->params[SOURCE_PARAM_EMISSION_CONE_DEGREES];
- float emission_attdb=source->params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB];
- absorption*=_get_attenuation(source_rel_vector.dot(Vector3(0,0,-1)),emission_deg,emission_attdb);
-
- Vector3 vpanning=rel_vector.normalized();
-
- //listener stuff
-
- {
-
- // head cone
-
- float reception_deg=listener->params[LISTENER_PARAM_RECEPTION_CONE_DEGREES];
- float reception_attdb=listener->params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB];
-
- absorption*=_get_attenuation(vpanning.dot(Vector3(0,0,-1)),reception_deg,reception_attdb);
-
- // scale
-
- attenuation*=Math::db2linear(listener->params[LISTENER_PARAM_VOLUME_SCALE_DB]);
- pscale*=Math::db2linear(listener->params[LISTENER_PARAM_PITCH_SCALE]);
-
-
- }
-
-
-
-
- //add values
-
- volume_attenuation+=weight*attenuation; // plus other stuff i guess
- air_absorption+=weight*absorption;
- air_absorption_hf_cutoff+=weight*hf_attenuation_cutoff;
- panning+=vpanning*weight;
- //pitch_scale+=pscale*weight;
-
- }
-
- RoomReverb reverb_room;
- float reverb_send;
-
- /* APPLY ROOM SETTINGS */
-
- {
- pitch_scale*=room->params[ROOM_PARAM_PITCH_SCALE];
- volume_attenuation*=Math::db2linear(room->params[ROOM_PARAM_VOLUME_SCALE_DB]);
- reverb_room=room->reverb;
- reverb_send=Math::lerp(1.0,volume_attenuation,room->params[ROOM_PARAM_ATTENUATION_REVERB_SCALE])*room->params[ROOM_PARAM_REVERB_SEND];
-
- }
-
- /* UPDATE VOICE & STREAM */
-
-
-
- if (voice==VOICE_IS_STREAM) {
-
- //update voice!!
- source->stream_data.panning=panning;
- source->stream_data.volume=volume_attenuation*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]);
- source->stream_data.reverb=reverb_room;
- source->stream_data.reverb_send=reverb_send;
- source->stream_data.filter_gain=air_absorption;
- source->stream_data.filter_cutoff=air_absorption_hf_cutoff;
-
- if (!source->stream) //stream is gone bye bye
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
-
- } else if (voice>=0) {
- //update stream!!
- Source::Voice &v=source->voices[voice];
-
- if (v.restart)
- AudioServer::get_singleton()->voice_play(v.voice_rid,v.sample_rid);
-
- float volume_scale = Math::db2linear(v.volume_scale)*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]);
- float volume = volume_attenuation*volume_scale;
- reverb_send*=volume_scale;
- int mix_rate = v.sample_mix_rate*v.pitch_scale*pitch_scale*source->params[SOURCE_PARAM_PITCH_SCALE];
-
-
- if (mix_rate<=0) {
- ERR_PRINT("Invalid mix rate for voice (0) check for invalid pitch_scale param.");
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
- continue; //invalid mix rate, disabling
- }
- if (v.restart || v.last_volume!=volume)
- AudioServer::get_singleton()->voice_set_volume(v.voice_rid,volume);
- if (v.restart || v.last_mix_rate!=mix_rate)
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice_rid,mix_rate);
- if (v.restart || v.last_filter_gain!=air_absorption || v.last_filter_cutoff!=air_absorption_hf_cutoff)
- AudioServer::get_singleton()->voice_set_filter(v.voice_rid,AudioServer::FILTER_HIGH_SHELF,air_absorption_hf_cutoff,1.0,air_absorption);
- if (v.restart || v.last_panning!=panning)
- AudioServer::get_singleton()->voice_set_pan(v.voice_rid,panning.x,panning.y,panning.z);
- if (v.restart || v.last_reverb_room!=reverb_room || v.last_reverb_send!=reverb_send)
- AudioServer::get_singleton()->voice_set_reverb(v.voice_rid,AudioServer::ReverbRoomType(reverb_room),reverb_send);
-
- v.last_volume=volume;
- v.last_mix_rate=mix_rate;
- v.last_filter_gain=air_absorption;
- v.last_filter_cutoff=air_absorption_hf_cutoff;
- v.last_panning=panning;
- v.restart=false;
- v.active=true;
-
- if (!AudioServer::get_singleton()->voice_is_active(v.voice_rid))
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
- }
- }
-
- while(to_disable.size()) {
-
- ActiveVoice av = to_disable.front()->get();
- av.source->voices[av.voice].active=false;
- av.source->voices[av.voice].restart=false;
- active_voices.erase(av);
- to_disable.pop_front();
- }
-
-}
-void SpatialSoundServerSW::finish() {
-
- AudioServer::get_singleton()->free(internal_audio_stream_rid);
- memdelete(internal_audio_stream);
-
- _clean_up_owner(&source_owner,"Source");
- _clean_up_owner(&listener_owner,"Listener");
- _clean_up_owner(&room_owner,"Room");
- _clean_up_owner(&space_owner,"Space");
-
- memdelete_arr(internal_buffer);
-}
-
-SpatialSoundServerSW::SpatialSoundServerSW() {
-
-}
diff --git a/servers/spatial_sound/spatial_sound_server_sw.h b/servers/spatial_sound/spatial_sound_server_sw.h
deleted file mode 100644
index 901b781ac2..0000000000
--- a/servers/spatial_sound/spatial_sound_server_sw.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_server_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_SOUND_SERVER_SW_H
-#define SPATIAL_SOUND_SERVER_SW_H
-
-#include "servers/spatial_sound_server.h"
-#include "octree.h"
-#include "os/thread_safe.h"
-
-
-class SpatialSoundServerSW : public SpatialSoundServer {
-
- GDCLASS(SpatialSoundServerSW,SpatialSoundServer);
-
- _THREAD_SAFE_CLASS_
-
- enum {
- MAX_CULL_ROOMS=128,
- INTERNAL_BUFFER_SIZE=4096,
- INTERNAL_BUFFER_MAX_CHANNELS=4,
- VOICE_IS_STREAM=-1
-
- };
-
-
- struct InternalAudioStream : public AudioServer::AudioStream {
-
- ::SpatialSoundServerSW *owner;
- virtual int get_channel_count() const;
- virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
- virtual void update();
- };
-
- InternalAudioStream *internal_audio_stream;
- RID internal_audio_stream_rid;
- int32_t *internal_buffer;
- int internal_buffer_channels;
-
- bool internal_buffer_mix(int32_t *p_buffer,int p_frames);
-
- struct Room;
-
- struct Space : public RID_Data {
-
- RID default_room;
- Set<RID> rooms;
- Set<RID> sources;
- Set<RID> listeners;
-
- Octree<Room> octree;
- };
-
- mutable RID_Owner<Space> space_owner;
-
- struct Room : public RID_Data{
- RID space;
- Transform transform;
- Transform inverse_transform;
- BSP_Tree bounds;
- RoomReverb reverb;
- float params[ROOM_PARAM_MAX];
- bool override_other_sources;
- OctreeElementID octree_id;
- int level;
-
- Room();
- };
-
- mutable RID_Owner<Room> room_owner;
-
-
-
- struct Source : public RID_Data {
-
- struct Voice {
-
- RID voice_rid;
- RID sample_rid;
- bool active;
- bool restart;
- float pitch_scale;
- float volume_scale;
- int sample_mix_rate;
-
-
- float last_volume;
- float last_filter_gain;
- float last_filter_cutoff;
- Vector3 last_panning;
- int last_mix_rate;
- RoomReverb last_reverb_room;
- float last_reverb_send;
-
- Voice();
- ~Voice();
- };
-
- struct StreamData {
-
-
- Vector3 panning;
- RoomReverb reverb;
- float reverb_send;
- float volume;
- float filter_gain;
- float filter_cutoff;
-
- struct FilterState {
-
- float ha[2];
- float hb[2];
- } filter_state[4];
-
- StreamData() {
-
- reverb_send=0;
- reverb=ROOM_REVERB_HALL;
- volume=1.0;
- filter_gain=1;
- filter_cutoff=5000;
-
- }
- } stream_data;
-
- RID space;
- Transform transform;
- float params[SOURCE_PARAM_MAX];
- AudioServer::AudioStream *stream;
- Vector<Voice> voices;
- int last_voice;
-
- Source();
- };
-
- mutable RID_Owner<Source> source_owner;
-
- struct Listener : public RID_Data {
-
- RID space;
- Transform transform;
- float params[LISTENER_PARAM_MAX];
-
- Listener();
- };
-
- mutable RID_Owner<Listener> listener_owner;
-
- struct ActiveVoice {
-
- Source *source;
- int voice;
- bool operator<(const ActiveVoice& p_voice) const { return (voice==p_voice.voice)?(source<p_voice.source):(voice<p_voice.voice); }
- ActiveVoice(Source *p_source=NULL,int p_voice=0) { source=p_source; voice=p_voice; }
- };
-
- Room *cull_rooms[MAX_CULL_ROOMS];
-
- Set<Source*> streaming_sources;
- Set<ActiveVoice> active_voices;
-
- void _clean_up_owner(RID_OwnerBase *p_owner, const char *p_area);
- void _update_sources();
-
-public:
-
- /* SPACE */
- virtual RID space_create();
-
- /* ROOM */
-
- virtual RID room_create();
- virtual void room_set_space(RID p_room,RID p_space);
- virtual RID room_get_space(RID p_room) const;
-
- virtual void room_set_bounds(RID p_room, const BSP_Tree& p_bounds);
- virtual BSP_Tree room_get_bounds(RID p_room) const;
- virtual void room_set_transform(RID p_room, const Transform& p_transform);
- virtual Transform room_get_transform(RID p_room) const;
-
-
- virtual void room_set_param(RID p_room, RoomParam p_param, float p_value);
- virtual float room_get_param(RID p_room, RoomParam p_param) const;
-
- virtual void room_set_level(RID p_room, int p_level);
- virtual int room_get_level(RID p_room) const;
-
- virtual void room_set_reverb(RID p_room, RoomReverb p_reverb);
- virtual RoomReverb room_get_reverb(RID p_room) const;
-
- //useful for underwater or rooms with very strange conditions
- virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force);
- virtual bool room_is_forcing_params_to_all_sources(RID p_room) const;
-
- /* SOURCE */
-
- virtual RID source_create(RID p_space);
-
- virtual void source_set_polyphony(RID p_source,int p_voice_count);
- virtual int source_get_polyphony(RID p_source) const;
-
- virtual void source_set_transform(RID p_source, const Transform& p_transform);
- virtual Transform source_get_transform(RID p_source) const;
-
- virtual void source_set_param(RID p_source, SourceParam p_param, float p_value);
- virtual float source_get_param(RID p_source, SourceParam p_param) const;
-
- virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream); //null to unset
- virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE);
- /* VOICES */
- virtual void source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale);
- virtual void source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_volume);
-
- virtual bool source_is_voice_active(RID p_source, SourceVoiceID p_voice) const;
- virtual void source_stop_voice(RID p_source, SourceVoiceID p_voice);
-
- /* LISTENER */
-
- virtual RID listener_create();
- virtual void listener_set_space(RID p_listener, RID p_space);
-
- virtual void listener_set_transform(RID p_listener, const Transform& p_transform);
- virtual Transform listener_get_transform(RID p_listener) const;
-
- virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value);
- virtual float listener_get_param(RID p_listener, ListenerParam p_param) const;
-
-
- /* MISC */
-
- virtual void free(RID p_id);
-
- virtual void init();
- virtual void update(float p_delta);
- virtual void finish();
-
- SpatialSoundServerSW();
-};
-
-#endif // SPATIAL_SOUND_SERVER_SW_H
diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp
deleted file mode 100644
index 33e51eb262..0000000000
--- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_2d_server_sw.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_sound_2d_server_sw.h"
-
-#include "os/os.h"
-#include "servers/audio/audio_filter_sw.h"
-
-
-
-int SpatialSound2DServerSW::InternalAudioStream::get_channel_count() const {
-
- return AudioServer::get_singleton()->get_default_channel_count();
-}
-
-void SpatialSound2DServerSW::InternalAudioStream::set_mix_rate(int p_rate) {
-
-
-}
-
-void SpatialSound2DServerSW::InternalAudioStream::update() {
-
- owner->_update_sources();
-}
-
-bool SpatialSound2DServerSW::InternalAudioStream::mix(int32_t *p_buffer,int p_frames) {
-
- return owner->internal_buffer_mix(p_buffer,p_frames);
-}
-
-void SpatialSound2DServerSW::_update_sources() {
-
- _THREAD_SAFE_METHOD_
- for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) {
-
- Source *s=E->get();
- ERR_CONTINUE(!s->stream);
- s->stream->update();
- }
-}
-
-
-SpatialSound2DServerSW::Room::Room() {
-
-// params[ROOM_PARAM_SPEED_OF_SOUND]=343.0;
- params[ROOM_PARAM_PITCH_SCALE]=1.0;
- params[ROOM_PARAM_VOLUME_SCALE_DB]=0;
- params[ROOM_PARAM_REVERB_SEND]=0;
- params[ROOM_PARAM_CHORUS_SEND]=0;
- params[ROOM_PARAM_ATTENUATION_SCALE]=1.0;
- params[ROOM_PARAM_ATTENUATION_HF_CUTOFF]=5000;
- params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0;
- params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP]=1.0;
- params[ROOM_PARAM_ATTENUATION_REVERB_SCALE]=0.0;
- override_other_sources=false;
- reverb=ROOM_REVERB_HALL;
-// octree_id=0;
- level=-1;
-
-
-}
-
-
-SpatialSound2DServerSW::Source::Source() {
-
- params[SOURCE_PARAM_VOLUME_DB]=0.0;
- params[SOURCE_PARAM_PITCH_SCALE]=1.0;
- params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]=100;
- params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
- stream=NULL;
- voices.resize(1);
- last_voice=0;
-}
-
-SpatialSound2DServerSW::Source::Voice::Voice() {
-
- active=false;
- restart=false;
- pitch_scale=1.0;
- volume_scale=0.0;
- voice_rid=AudioServer::get_singleton()->voice_create();
-
-}
-SpatialSound2DServerSW::Source::Voice::~Voice() {
-
- AudioServer::get_singleton()->free(voice_rid);
-}
-
-
-SpatialSound2DServerSW::Listener::Listener() {
-
- params[LISTENER_PARAM_VOLUME_SCALE_DB]=0.0;
- params[LISTENER_PARAM_PITCH_SCALE]=1.0;
- params[LISTENER_PARAM_ATTENUATION_SCALE]=1.0;
- params[LISTENER_PARAM_PAN_RANGE]=128;
-
-}
-
-/* SPACE */
-RID SpatialSound2DServerSW::space_create() {
-
- Space* space = memnew( Space );
- RID space_rid = space_owner.make_rid(space);
- space->default_room=room_create();
- room_set_space(space->default_room,space_rid);
- return space_rid;
-}
-
-/* ROOM */
-
-RID SpatialSound2DServerSW::room_create() {
-
- Room *room = memnew( Room );
- return room_owner.make_rid(room);
-}
-
-void SpatialSound2DServerSW::room_set_space(RID p_room,RID p_space) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
-
- if (room->space.is_valid()) {
-
- Space *space = space_owner.get(room->space);
- space->rooms.erase(p_room);
-// space->octree.erase(room->octree_id);
- //room->octree_id=0;
- }
-
- room->space=RID();
-
- if (p_space.is_valid()) {
-
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND(!space);
- space->rooms.insert(p_room);
-// room->octree_id=space->octree.create(room,AABB());
- //set bounds
-// AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb();
- // space->octree.move(room->octree_id,room->transform.xform(aabb));
- room->space=p_space;
- }
-
-
-}
-
-RID SpatialSound2DServerSW::room_get_space(RID p_room) const {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,RID());
-
-
- return room->space;
-}
-
-
-
-void SpatialSound2DServerSW::room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
-
- room->bounds=p_bounds;
-
- if (!room->space.is_valid())
- return;
-
-// AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb();
-// Space* space = space_owner.get(room->space);
-// ERR_FAIL_COND(!space);
-
-// space->octree.move(room->octree_id,room->transform.xform(aabb));
-
-}
-PoolVector<Point2> SpatialSound2DServerSW::room_get_bounds(RID p_room) const {
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,PoolVector<Point2>());
-
- return room->bounds;
-}
-
-void SpatialSound2DServerSW::room_set_transform(RID p_room, const Transform2D& p_transform) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->transform=p_transform;
- room->inverse_transform=p_transform.affine_inverse(); // needs to be done to unscale BSP properly
-
- if (!room->space.is_valid())
- return;
-
- /*
- if (!room->bounds.is_empty()) {
-
- Space* space = space_owner.get(room->space);
- ERR_FAIL_COND(!space);
-
- //space->octree.move(room->octree_id,room->transform.xform(room->bounds.get_aabb()));
- }*/
-}
-
-Transform2D SpatialSound2DServerSW::room_get_transform(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,Transform2D());
- return room->transform;
-}
-
-
-void SpatialSound2DServerSW::room_set_param(RID p_room, RoomParam p_param, float p_value) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- ERR_FAIL_INDEX(p_param,ROOM_PARAM_MAX);
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->params[p_param]=p_value;
-
-}
-float SpatialSound2DServerSW::room_get_param(RID p_room, RoomParam p_param) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- ERR_FAIL_INDEX_V(p_param,ROOM_PARAM_MAX,0);
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,0);
- return room->params[p_param];
-}
-
-void SpatialSound2DServerSW::room_set_level(RID p_room, int p_level) {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->level =p_level;
-
-}
-
-int SpatialSound2DServerSW::room_get_level(RID p_room) const {
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,0);
- return room->level;
-
-}
-
-
-void SpatialSound2DServerSW::room_set_reverb(RID p_room, RoomReverb p_reverb) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->reverb=p_reverb;
-
-}
-SpatialSound2DServerSW::RoomReverb SpatialSound2DServerSW::room_get_reverb(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,ROOM_REVERB_SMALL);
- return room->reverb;
-}
-
-//useful for underwater or rooms with very strange conditions
-void SpatialSound2DServerSW::room_set_force_params_to_all_sources(RID p_room, bool p_force) {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND(!room);
- room->override_other_sources=p_force;
-
-}
-bool SpatialSound2DServerSW::room_is_forcing_params_to_all_sources(RID p_room) const {
-
- if (space_owner.owns(p_room))
- p_room=space_owner.get(p_room)->default_room;
-
- Room *room = room_owner.get(p_room);
- ERR_FAIL_COND_V(!room,false);
- return room->override_other_sources;
-}
-
-/* SOURCE */
-
-RID SpatialSound2DServerSW::source_create(RID p_space) {
-
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND_V(!space,RID());
-
- Source *source = memnew( Source );
- source->space=p_space;
- RID source_rid = source_owner.make_rid(source);
- space->sources.insert(source_rid);
-
- return source_rid;
-}
-
-
-void SpatialSound2DServerSW::source_set_polyphony(RID p_source,int p_voice_count) {
-
-
- ERR_FAIL_COND(p_voice_count<=0); // more than 32 is too much, change this if you really need more
- if (p_voice_count>32) {
-
- ERR_PRINT("Voices will be clipped to 32");
- p_voice_count=32;
- }
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
-
- if (p_voice_count<source->voices.size()) {
-
- for(int i=p_voice_count;i<source->voices.size();i++) {
- active_voices.erase(ActiveVoice(source,i)); //erase from active voices
- }
- }
- source->voices.resize(p_voice_count);
-
-}
-
-int SpatialSound2DServerSW::source_get_polyphony(RID p_source) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,-1);
- return source->voices.size();
-
-}
-
-void SpatialSound2DServerSW::source_set_transform(RID p_source, const Transform2D& p_transform) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- source->transform=p_transform;
- source->transform.orthonormalize();
-}
-Transform2D SpatialSound2DServerSW::source_get_transform(RID p_source) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,Transform2D());
- return source->transform;
-}
-
-void SpatialSound2DServerSW::source_set_param(RID p_source, SourceParam p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,SOURCE_PARAM_MAX);
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- source->params[p_param]=p_value;
-
-}
-float SpatialSound2DServerSW::source_get_param(RID p_source, SourceParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,SOURCE_PARAM_MAX,0);
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,0);
- return source->params[p_param];
-
-
-}
-
-void SpatialSound2DServerSW::source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- AudioServer::get_singleton()->lock();
- source->stream=p_stream;
- _THREAD_SAFE_METHOD_
-
- if (!p_stream) {
- streaming_sources.erase(source);
- active_voices.erase(ActiveVoice(source,VOICE_IS_STREAM));
- } else {
- streaming_sources.insert(source);
- active_voices.insert(ActiveVoice(source,VOICE_IS_STREAM));
- zeromem(source->stream_data.filter_state,sizeof(Source::StreamData::FilterState)*4); //reset filter for safetyness
- p_stream->set_mix_rate(AudioServer::get_singleton()->get_default_mix_rate());
- }
-
- AudioServer::get_singleton()->unlock();
-
-} //null to unset
-
-SpatialSound2DServer::SourceVoiceID SpatialSound2DServerSW::source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,SOURCE_INVALID_VOICE);
-
- int to_play=0;
-
- if (p_voice==SOURCE_NEXT_VOICE) {
- to_play=source->last_voice+1;
- if (to_play>=source->voices.size())
- to_play=0;
-
- } else
- to_play=p_voice;
-
- ERR_FAIL_INDEX_V(to_play,source->voices.size(),SOURCE_INVALID_VOICE);
-
- source->voices[to_play].restart=true;
- source->voices[to_play].sample_rid=p_sample;
- source->voices[to_play].sample_mix_rate=p_mix_rate;
- source->voices[to_play].pitch_scale=1;
- source->voices[to_play].volume_scale=0;
- source->last_voice=to_play;
- active_voices.insert(ActiveVoice(source,to_play));
- return to_play;
-}
-
-/* VOICES */
-void SpatialSound2DServerSW::source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- source->voices[p_voice].pitch_scale=p_pitch_scale;
-
-}
-void SpatialSound2DServerSW::source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_db) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- source->voices[p_voice].volume_scale=p_db;
-
-}
-
-bool SpatialSound2DServerSW::source_is_voice_active(RID p_source, SourceVoiceID p_voice) const {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND_V(!source,false);
- ERR_FAIL_INDEX_V(p_voice,source->voices.size(),false);
- return source->voices[p_voice].active || source->voices[p_voice].restart;
-
-}
-void SpatialSound2DServerSW::source_stop_voice(RID p_source, SourceVoiceID p_voice) {
-
- Source *source = source_owner.get(p_source);
- ERR_FAIL_COND(!source);
- ERR_FAIL_INDEX(p_voice,source->voices.size());
- if (source->voices[p_voice].active) {
- AudioServer::get_singleton()->voice_stop(source->voices[p_voice].voice_rid);
- }
- source->voices[p_voice].active=false;
- source->voices[p_voice].restart=false;
- active_voices.erase(ActiveVoice(source,p_voice));
-}
-
-/* LISTENER */
-
-RID SpatialSound2DServerSW::listener_create() {
-
- Listener *listener = memnew( Listener );
- RID listener_rid = listener_owner.make_rid(listener);
- return listener_rid;
-
-}
-
-void SpatialSound2DServerSW::listener_set_space(RID p_listener,RID p_space) {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
-
- if (listener->space.is_valid()) {
-
- Space *lspace = space_owner.get(listener->space);
- ERR_FAIL_COND(!lspace);
- lspace->listeners.erase(p_listener);
- }
-
- listener->space=RID();
-
- if (p_space.is_valid()) {
- Space *space = space_owner.get(p_space);
- ERR_FAIL_COND(!space);
-
- listener->space=p_space;
- space->listeners.insert(p_listener);
- }
-
-}
-
-void SpatialSound2DServerSW::listener_set_transform(RID p_listener, const Transform2D& p_transform) {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
- listener->transform=p_transform;
- listener->transform.orthonormalize(); //must be done..
-}
-Transform2D SpatialSound2DServerSW::listener_get_transform(RID p_listener) const {
-
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND_V(!listener,Transform2D());
- return listener->transform;
-}
-
-void SpatialSound2DServerSW::listener_set_param(RID p_listener, ListenerParam p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,LISTENER_PARAM_MAX);
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND(!listener);
- listener->params[p_param]=p_value;
-}
-
-float SpatialSound2DServerSW::listener_get_param(RID p_listener, ListenerParam p_param) const {
-
- ERR_FAIL_INDEX_V(p_param,LISTENER_PARAM_MAX,0);
- Listener *listener = listener_owner.get(p_listener);
- ERR_FAIL_COND_V(!listener,0);
- return listener->params[p_param];
-}
-
-
-/* MISC */
-
-void SpatialSound2DServerSW::free(RID p_id) {
-
-
- if (space_owner.owns(p_id)) {
-
- Space *space = space_owner.get(p_id);
- free(space->default_room);
-
- while(space->listeners.size()) {
- listener_set_space(space->listeners.front()->get(),RID());
- }
- while(space->sources.size()) {
- free(space->sources.front()->get());
- }
- while(space->rooms.size()) {
- room_set_space(space->rooms.front()->get(),RID());
- }
- space_owner.free(p_id);
- memdelete(space);
-
- } else if (source_owner.owns(p_id)) {
-
- Source *source = source_owner.get(p_id);
- if (source->stream)
- source_set_audio_stream(p_id,NULL);
-
- Space *space = space_owner.get(source->space);
- ERR_FAIL_COND(!space);
- space->sources.erase(p_id);
- for(int i=0;i<source->voices.size();i++) {
- active_voices.erase(ActiveVoice(source,i));
- }
- source_owner.free(p_id);
- memdelete(source);
- } else if (listener_owner.owns(p_id)) {
-
- Listener *listener = listener_owner.get(p_id);
- if (listener->space.is_valid()) {
- Space *space = space_owner.get(listener->space);
- ERR_FAIL_COND(!space);
- space->listeners.erase(p_id);
- }
- listener_owner.free(p_id);
- memdelete(listener);
-
- } else if (room_owner.owns(p_id)) {
-
- Room *room = room_owner.get(p_id);
-
- if (room->space.is_valid()) {
- Space *space = space_owner.get(room->space);
- ERR_FAIL_COND(!space);
-// space->octree.erase(room->octree_id);
- space->rooms.erase(p_id);
- }
- room_owner.free(p_id);
- memdelete(room);
- } else {
- ERR_PRINT("Attempt to free invalid ID") ;
- }
-
-}
-
-void SpatialSound2DServerSW::_clean_up_owner(RID_OwnerBase *p_owner, const char *p_area) {
-
- List<RID> rids;
- p_owner->get_owned_list(&rids);
-
- for(List<RID>::Element *I=rids.front();I;I=I->next()) {
- if (OS::get_singleton()->is_stdout_verbose()) {
-
- print_line("Leaked RID ("+itos(I->get().get_id())+") of type "+String(p_area));
- }
- free(I->get());
- }
-}
-
-void SpatialSound2DServerSW::init() {
-
- internal_buffer = memnew_arr(int32_t, INTERNAL_BUFFER_SIZE*INTERNAL_BUFFER_MAX_CHANNELS);
- internal_buffer_channels=AudioServer::get_singleton()->get_default_channel_count();
-
- internal_audio_stream = memnew( InternalAudioStream );
- internal_audio_stream->owner=this;
- internal_audio_stream_rid = AudioServer::get_singleton()->audio_stream_create(internal_audio_stream);
-
- AudioServer::get_singleton()->stream_set_active(internal_audio_stream_rid,true);
-
-}
-
-
-
-bool SpatialSound2DServerSW::internal_buffer_mix(int32_t *p_buffer,int p_frames) {
-
- if (streaming_sources.size()==0)
- return false; //nothing to mix
-
-
- for (Set<Source*>::Element *E=streaming_sources.front();E;E=E->next()) {
-
- Source *s=E->get();
- ERR_CONTINUE(!s->stream);
-
- int channels = s->stream->get_channel_count();
- Source::StreamData &sd=s->stream_data;
-
- int todo=p_frames;
-
- AudioFilterSW filter;
- filter.set_sampling_rate(AudioServer::get_singleton()->get_default_mix_rate());
- filter.set_cutoff(sd.filter_cutoff);
- filter.set_gain(sd.filter_gain);
- filter.set_resonance(1);
- filter.set_mode(AudioFilterSW::HIGHSHELF);
- filter.set_stages(1);
- AudioFilterSW::Coeffs coefs;
- filter.prepare_coefficients(&coefs);
-
- int32_t in[4];
-#ifndef SPATIAL_SOUND_SERVER_NO_FILTER
-#define DO_FILTER(m_c)\
- {\
- float val = in[m_c];\
- float pre=val;\
- val = val*coefs.b0 + sd.filter_state[m_c].hb[0]*coefs.b1 + sd.filter_state[m_c].hb[1]*coefs.b2 + sd.filter_state[m_c].ha[0]*coefs.a1 + sd.filter_state[m_c].ha[1]*coefs.a2;\
- sd.filter_state[m_c].ha[1]=sd.filter_state[m_c].ha[0];\
- sd.filter_state[m_c].hb[1]=sd.filter_state[m_c].hb[0]; \
- sd.filter_state[m_c].hb[0]=pre;\
- sd.filter_state[m_c].ha[0]=val;\
- in[m_c]=Math::fast_ftoi(val);\
- }
-#else
-#define DO_FILTER(m_c)
-#endif
-
- while(todo) {
-
- int to_mix=MIN(todo,INTERNAL_BUFFER_SIZE);
-
- s->stream->mix(internal_buffer,to_mix);
-
- switch(internal_buffer_channels) {
-
- case 2: {
-
- float p = sd.panning.x*0.5+0.5;
- float panf[2]={ (1.0-p),p };
- panf[0]*=sd.volume;
- panf[1]*=sd.volume;
-
- int32_t pan[2]={Math::fast_ftoi(panf[0]*(1<<16)),Math::fast_ftoi(panf[1]*(1<<16))};
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[i];
- in[1]=internal_buffer[i];
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<1)+0];
- in[1]=internal_buffer[(i<<1)+1];
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=(internal_buffer[(i<<2)+0]+internal_buffer[(i<<2)+2])>>1;
- in[1]=(internal_buffer[(i<<2)+1]+internal_buffer[(i<<2)+3])>>1;
- DO_FILTER(0);
- DO_FILTER(1);
- p_buffer[(i<<1)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<1)+1]=((in[1]>>16)*pan[1]);
- }
- } break;
-
- } break;
-
- } break;
- case 4: {
-
- float xp = sd.panning.x*0.5+0.5;
- float yp = sd.panning.y*0.5+0.5;
- float panf[4]={ (1.0-xp)*(1.0-yp),(xp)*(1.0-yp),(1.0-xp)*(yp),(xp)*(yp) };
- panf[0]*=sd.volume;
- panf[1]*=sd.volume;
- panf[2]*=sd.volume;
- panf[3]*=sd.volume;
-
- int32_t pan[4]={
- Math::fast_ftoi(panf[0]*(1<<16)),
- Math::fast_ftoi(panf[1]*(1<<16)),
- Math::fast_ftoi(panf[2]*(1<<16)),
- Math::fast_ftoi(panf[3]*(1<<16))};
-
- switch(channels) {
- case 1: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[i];
- in[1]=internal_buffer[i];
- in[2]=internal_buffer[i];
- in[3]=internal_buffer[i];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
- case 2: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<1)+0];
- in[1]=internal_buffer[(i<<1)+1];
- in[2]=internal_buffer[(i<<1)+0];
- in[3]=internal_buffer[(i<<1)+1];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
- case 4: {
-
- for(int i=0;i<to_mix;i++) {
-
- in[0]=internal_buffer[(i<<2)+0];
- in[1]=internal_buffer[(i<<2)+1];
- in[2]=internal_buffer[(i<<2)+2];
- in[3]=internal_buffer[(i<<2)+3];
- DO_FILTER(0);
- DO_FILTER(1);
- DO_FILTER(2);
- DO_FILTER(3);
- p_buffer[(i<<2)+0]=((in[0]>>16)*pan[0]);
- p_buffer[(i<<2)+1]=((in[1]>>16)*pan[1]);
- p_buffer[(i<<2)+2]=((in[2]>>16)*pan[2]);
- p_buffer[(i<<2)+3]=((in[3]>>16)*pan[3]);
- }
- } break;
-
- } break;
-
- } break;
- case 6: {
-
-
- } break;
- }
- p_buffer+=to_mix*internal_buffer_channels;
- todo-=to_mix;
-
- }
-
- }
-
- return true;
-}
-
-void SpatialSound2DServerSW::update(float p_delta) {
-
- List<ActiveVoice> to_disable;
-
- for(Set<ActiveVoice>::Element *E=active_voices.front();E;E=E->next()) {
-
- Source *source = E->get().source;
- int voice = E->get().voice;
-
- if (voice!=VOICE_IS_STREAM) {
- Source::Voice &v=source->voices[voice];
- ERR_CONTINUE(!v.active && !v.restart); // likely a bug...
- }
-
- //this could be optimized at some point... am not sure
- Space *space=space_owner.get(source->space);
- Room *room=room_owner.get(space->default_room);
-
- //compute mixing weights (support for multiple listeners in the same output)
- float total_distance=0;
- for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) {
- Listener *listener=listener_owner.get(L->get());
- float d = listener->transform.get_origin().distance_to(source->transform.get_origin());
- if (d==0)
- d=0.1;
- total_distance+=d;
- }
-
- //compute spatialization variables, weighted according to distance
- float volume_attenuation = 0.0;
- float air_absorption_hf_cutoff = 0.0;
- float air_absorption = 0.0;
- float pitch_scale=0.0;
- Vector2 panning;
-
- for(Set<RID>::Element *L=space->listeners.front();L;L=L->next()) {
-
- Listener *listener=listener_owner.get(L->get());
-
- Vector2 rel_vector = -listener->transform.xform_inv(source->transform.get_origin());
- //Vector2 source_rel_vector = source->transform.xform_inv(listener->transform.get_origin()).normalized();
- float distance=rel_vector.length();
- float weight = distance/total_distance;
- float pscale=1.0;
-
- float distance_scale=listener->params[LISTENER_PARAM_ATTENUATION_SCALE]*room->params[ROOM_PARAM_ATTENUATION_SCALE];
- float distance_min=source->params[SOURCE_PARAM_ATTENUATION_MIN_DISTANCE]*distance_scale;
- float distance_max=source->params[SOURCE_PARAM_ATTENUATION_MAX_DISTANCE]*distance_scale;
- float attenuation_exp=source->params[SOURCE_PARAM_ATTENUATION_DISTANCE_EXP];
- float attenuation=1;
-
- if (distance_max>0) {
- distance = CLAMP(distance,distance_min,distance_max);
- attenuation = Math::pow(1.0 - ((distance - distance_min)/(distance_max-distance_min)),CLAMP(attenuation_exp,0.001,16));
- }
-
- float hf_attenuation_cutoff = room->params[ROOM_PARAM_ATTENUATION_HF_CUTOFF];
- float hf_attenuation_exp = room->params[ROOM_PARAM_ATTENUATION_HF_RATIO_EXP];
- float hf_attenuation_floor = room->params[ROOM_PARAM_ATTENUATION_HF_FLOOR_DB];
- float absorption=Math::db2linear(Math::lerp(hf_attenuation_floor,0,Math::pow(attenuation,hf_attenuation_exp)));
-
- // source emission cone
-/* only for 3D
- float emission_deg=source->params[SOURCE_PARAM_EMISSION_CONE_DEGREES];
- float emission_attdb=source->params[SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB];
- absorption*=_get_attenuation(source_rel_vector.dot(Vector2(0,0,-1)),emission_deg,emission_attdb);
-*/
- Vector2 vpanning=rel_vector.normalized();
- if (distance < listener->params[LISTENER_PARAM_PAN_RANGE])
- vpanning*=distance/listener->params[LISTENER_PARAM_PAN_RANGE];
-
- //listener stuff
-
- {
-
- // head cone
-/* only for 3D
- float reception_deg=listener->params[LISTENER_PARAM_RECEPTION_CONE_DEGREES];
- float reception_attdb=listener->params[LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB];
-
- absorption*=_get_attenuation(vpanning.dot(Vector2(0,0,-1)),reception_deg,reception_attdb);
-*/
-
- // scale
-
- attenuation*=Math::db2linear(listener->params[LISTENER_PARAM_VOLUME_SCALE_DB]);
- pscale*=Math::db2linear(listener->params[LISTENER_PARAM_PITCH_SCALE]);
-
-
- }
-
-
-
-
- //add values
-
- volume_attenuation+=weight*attenuation; // plus other stuff i guess
- air_absorption+=weight*absorption;
- air_absorption_hf_cutoff+=weight*hf_attenuation_cutoff;
- panning+=vpanning*weight;
- pitch_scale+=pscale*weight;
-
- }
-
- RoomReverb reverb_room=ROOM_REVERB_HALL;
- float reverb_send=0;
-
- /* APPLY ROOM SETTINGS */
-
- {
- pitch_scale*=room->params[ROOM_PARAM_PITCH_SCALE];
- volume_attenuation*=Math::db2linear(room->params[ROOM_PARAM_VOLUME_SCALE_DB]);
- reverb_room=room->reverb;
- reverb_send=Math::lerp(1.0,volume_attenuation,room->params[ROOM_PARAM_ATTENUATION_REVERB_SCALE])*room->params[ROOM_PARAM_REVERB_SEND];
-
- }
-
- /* UPDATE VOICE & STREAM */
-
-
-
- if (voice==VOICE_IS_STREAM) {
-
- //update voice!!
- source->stream_data.panning=panning;
- source->stream_data.volume=volume_attenuation*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]);
- source->stream_data.reverb=reverb_room;
- source->stream_data.reverb_send=reverb_send;
- source->stream_data.filter_gain=air_absorption;
- source->stream_data.filter_cutoff=air_absorption_hf_cutoff;
-
- if (!source->stream) //stream is gone bye bye
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
-
- } else if (voice>=0) {
- //update stream!!
- Source::Voice &v=source->voices[voice];
-
- if (v.restart)
- AudioServer::get_singleton()->voice_play(v.voice_rid,v.sample_rid);
-
- float volume_scale = Math::db2linear(v.volume_scale)*Math::db2linear(source->params[SOURCE_PARAM_VOLUME_DB]);
- float volume = volume_attenuation*volume_scale;
- reverb_send*=volume_scale;
- int mix_rate = v.sample_mix_rate*v.pitch_scale*pitch_scale*source->params[SOURCE_PARAM_PITCH_SCALE];
-
-
- if (mix_rate<=0) {
-
- ERR_PRINT("Invalid mix rate for voice (0) check for invalid pitch_scale param.");
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
- continue; //invalid mix rate, disabling
- }
- if (v.restart || v.last_volume!=volume)
- AudioServer::get_singleton()->voice_set_volume(v.voice_rid,volume);
- if (v.restart || v.last_mix_rate!=mix_rate)
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice_rid,mix_rate);
- if (v.restart || v.last_filter_gain!=air_absorption || v.last_filter_cutoff!=air_absorption_hf_cutoff)
- AudioServer::get_singleton()->voice_set_filter(v.voice_rid,AudioServer::FILTER_HIGH_SHELF,air_absorption_hf_cutoff,1.0,air_absorption);
- if (v.restart || v.last_panning!=panning) {
- AudioServer::get_singleton()->voice_set_pan(v.voice_rid,-panning.x,panning.y,0);
- }
- if (v.restart || v.last_reverb_room!=reverb_room || v.last_reverb_send!=reverb_send)
- AudioServer::get_singleton()->voice_set_reverb(v.voice_rid,AudioServer::ReverbRoomType(reverb_room),reverb_send);
-
- v.last_volume=volume;
- v.last_mix_rate=mix_rate;
- v.last_filter_gain=air_absorption;
- v.last_filter_cutoff=air_absorption_hf_cutoff;
- v.last_panning=panning;
- v.last_reverb_room=reverb_room;
- v.last_reverb_send=reverb_send;
- v.restart=false;
- v.active=true;
-
- if (!AudioServer::get_singleton()->voice_is_active(v.voice_rid))
- to_disable.push_back(ActiveVoice(source,voice)); // oh well..
- }
- }
-
- while(to_disable.size()) {
-
- ActiveVoice av = to_disable.front()->get();
- av.source->voices[av.voice].active=false;
- av.source->voices[av.voice].restart=false;
- active_voices.erase(av);
- to_disable.pop_front();
- }
-
-}
-void SpatialSound2DServerSW::finish() {
-
- AudioServer::get_singleton()->free(internal_audio_stream_rid);
- memdelete(internal_audio_stream);
-
- _clean_up_owner(&source_owner,"Source");
- _clean_up_owner(&listener_owner,"Listener");
- _clean_up_owner(&room_owner,"Room");
- _clean_up_owner(&space_owner,"Space");
-
- memdelete_arr(internal_buffer);
-}
-
-SpatialSound2DServerSW::SpatialSound2DServerSW() {
-
-}
diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h
deleted file mode 100644
index 16d2c93e7d..0000000000
--- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_2d_server_sw.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_SOUND_2D_SERVER_SW_H
-#define SPATIAL_SOUND_2D_SERVER_SW_H
-
-#include "servers/spatial_sound_2d_server.h"
-
-#include "os/thread_safe.h"
-
-
-class SpatialSound2DServerSW : public SpatialSound2DServer {
-
- GDCLASS(SpatialSound2DServerSW,SpatialSound2DServer);
-
- _THREAD_SAFE_CLASS_
-
- enum {
- INTERNAL_BUFFER_SIZE=4096,
- INTERNAL_BUFFER_MAX_CHANNELS=4,
- VOICE_IS_STREAM=-1
-
- };
-
-
- struct InternalAudioStream : public AudioServer::AudioStream {
-
- ::SpatialSound2DServerSW *owner;
- virtual int get_channel_count() const;
- virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
- virtual void update();
- };
-
- InternalAudioStream *internal_audio_stream;
- RID internal_audio_stream_rid;
- int32_t *internal_buffer;
- int internal_buffer_channels;
-
- bool internal_buffer_mix(int32_t *p_buffer,int p_frames);
-
- struct Room;
-
- struct Space : public RID_Data {
-
- RID default_room;
- Set<RID> rooms;
- Set<RID> sources;
- Set<RID> listeners;
-
- //Octree<Room> octree;
- };
-
- mutable RID_Owner<Space> space_owner;
-
- struct Room : public RID_Data {
- RID space;
- Transform2D transform;
- Transform2D inverse_transform;
- PoolVector<Point2> bounds;
- RoomReverb reverb;
- float params[ROOM_PARAM_MAX];
- bool override_other_sources;
- //OctreeElementID octree_id;
- int level;
-
- Room();
- };
-
- mutable RID_Owner<Room> room_owner;
-
-
-
- struct Source : public RID_Data {
-
- struct Voice {
-
- RID voice_rid;
- RID sample_rid;
- bool active;
- bool restart;
- float pitch_scale;
- float volume_scale;
- int sample_mix_rate;
-
-
- float last_volume;
- float last_filter_gain;
- float last_filter_cutoff;
- Vector2 last_panning;
- int last_mix_rate;
- RoomReverb last_reverb_room;
- float last_reverb_send;
-
- Voice();
- ~Voice();
- };
-
- struct StreamData {
-
-
- Vector2 panning;
- RoomReverb reverb;
- float reverb_send;
- float volume;
- float filter_gain;
- float filter_cutoff;
-
- struct FilterState {
-
- float ha[2];
- float hb[2];
- } filter_state[4];
-
- StreamData() {
-
- reverb_send=0;
- reverb=ROOM_REVERB_HALL;
- volume=1.0;
- filter_gain=1;
- filter_cutoff=5000;
-
- }
- } stream_data;
-
- RID space;
- Transform2D transform;
- float params[SOURCE_PARAM_MAX];
- AudioServer::AudioStream *stream;
- Vector<Voice> voices;
- int last_voice;
-
- Source();
- };
-
- mutable RID_Owner<Source> source_owner;
-
- struct Listener : public RID_Data {
-
- RID space;
- Transform2D transform;
- float params[LISTENER_PARAM_MAX];
-
- Listener();
- };
-
- mutable RID_Owner<Listener> listener_owner;
-
- struct ActiveVoice {
-
- Source *source;
- int voice;
- bool operator<(const ActiveVoice& p_voice) const { return (voice==p_voice.voice)?(source<p_voice.source):(voice<p_voice.voice); }
- ActiveVoice(Source *p_source=NULL,int p_voice=0) { source=p_source; voice=p_voice; }
- };
-
-// Room *cull_rooms[MAX_CULL_ROOMS];
-
- Set<Source*> streaming_sources;
- Set<ActiveVoice> active_voices;
-
- void _clean_up_owner(RID_OwnerBase *p_owner, const char *p_area);
- void _update_sources();
-
-public:
-
- /* SPACE */
- virtual RID space_create();
-
- /* ROOM */
-
- virtual RID room_create();
- virtual void room_set_space(RID p_room,RID p_space);
- virtual RID room_get_space(RID p_room) const;
-
- virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds);
- virtual PoolVector<Point2> room_get_bounds(RID p_room) const;
- virtual void room_set_transform(RID p_room, const Transform2D& p_transform);
- virtual Transform2D room_get_transform(RID p_room) const;
-
-
- virtual void room_set_param(RID p_room, RoomParam p_param, float p_value);
- virtual float room_get_param(RID p_room, RoomParam p_param) const;
-
- virtual void room_set_level(RID p_room, int p_level);
- virtual int room_get_level(RID p_room) const;
-
- virtual void room_set_reverb(RID p_room, RoomReverb p_reverb);
- virtual RoomReverb room_get_reverb(RID p_room) const;
-
- //useful for underwater or rooms with very strange conditions
- virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force);
- virtual bool room_is_forcing_params_to_all_sources(RID p_room) const;
-
- /* SOURCE */
-
- virtual RID source_create(RID p_space);
-
- virtual void source_set_polyphony(RID p_source,int p_voice_count);
- virtual int source_get_polyphony(RID p_source) const;
-
- virtual void source_set_transform(RID p_source, const Transform2D& p_transform);
- virtual Transform2D source_get_transform(RID p_source) const;
-
- virtual void source_set_param(RID p_source, SourceParam p_param, float p_value);
- virtual float source_get_param(RID p_source, SourceParam p_param) const;
-
- virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream); //null to unset
- virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE);
- /* VOICES */
- virtual void source_voice_set_pitch_scale(RID p_source, SourceVoiceID p_voice, float p_pitch_scale);
- virtual void source_voice_set_volume_scale_db(RID p_source, SourceVoiceID p_voice, float p_volume);
-
- virtual bool source_is_voice_active(RID p_source, SourceVoiceID p_voice) const;
- virtual void source_stop_voice(RID p_source, SourceVoiceID p_voice);
-
- /* LISTENER */
-
- virtual RID listener_create();
- virtual void listener_set_space(RID p_listener, RID p_space);
-
- virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform);
- virtual Transform2D listener_get_transform(RID p_listener) const;
-
- virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value);
- virtual float listener_get_param(RID p_listener, ListenerParam p_param) const;
-
-
- /* MISC */
-
- virtual void free(RID p_id);
-
- virtual void init();
- virtual void update(float p_delta);
- virtual void finish();
-
- SpatialSound2DServerSW();
-};
-
-#endif // SPATIAL_SOUND_2D_SERVER_SW_H
diff --git a/servers/spatial_sound_2d_server.cpp b/servers/spatial_sound_2d_server.cpp
deleted file mode 100644
index 90f384ea2e..0000000000
--- a/servers/spatial_sound_2d_server.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_2d_server.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_sound_2d_server.h"
-
-SpatialSound2DServer *SpatialSound2DServer::singleton=NULL;
-
-
-SpatialSound2DServer *SpatialSound2DServer::get_singleton() {
-
- return singleton;
-}
-
-
-SpatialSound2DServer::SpatialSound2DServer() {
-
- ERR_FAIL_COND(singleton!=NULL);
- singleton=this;
-}
diff --git a/servers/spatial_sound_2d_server.h b/servers/spatial_sound_2d_server.h
deleted file mode 100644
index 331caf8198..0000000000
--- a/servers/spatial_sound_2d_server.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_2d_server.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_SOUND_2D_SERVER_H
-#define SPATIAL_SOUND_2D_SERVER_H
-
-#include "object.h"
-#include "bsp_tree.h"
-#include "servers/audio_server.h"
-
-class SpatialSound2DServer : public Object {
-
- GDCLASS(SpatialSound2DServer,Object);
- static SpatialSound2DServer *singleton;
-public:
-
-
- enum {
- SOURCE_INVALID_VOICE=-1,
- SOURCE_NEXT_VOICE=-2,
- };
-
- typedef int SourceVoiceID;
-
- /* SPACE */
- virtual RID space_create()=0;
-
- /* ROOM */
-
- virtual RID room_create()=0;
- virtual void room_set_space(RID p_room,RID p_space)=0;
- virtual RID room_get_space(RID p_room) const=0;
-
-
- virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds)=0;
- virtual PoolVector<Point2> room_get_bounds(RID p_room) const=0;
- virtual void room_set_transform(RID p_room, const Transform2D& p_transform)=0;
- virtual Transform2D room_get_transform(RID p_room) const=0;
-
- enum RoomParam {
- ROOM_PARAM_PITCH_SCALE,
- ROOM_PARAM_VOLUME_SCALE_DB,
- ROOM_PARAM_REVERB_SEND,
- ROOM_PARAM_CHORUS_SEND,
- ROOM_PARAM_ATTENUATION_SCALE,
- ROOM_PARAM_ATTENUATION_HF_CUTOFF,
- ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
- ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
- ROOM_PARAM_ATTENUATION_REVERB_SCALE,
- ROOM_PARAM_MAX
- };
-
- virtual void room_set_param(RID p_room, RoomParam p_param, float p_value)=0;
- virtual float room_get_param(RID p_room, RoomParam p_param) const=0;
-
- enum RoomReverb {
- ROOM_REVERB_SMALL,
- ROOM_REVERB_MEDIUM,
- ROOM_REVERB_LARGE,
- ROOM_REVERB_HALL
- };
-
- virtual void room_set_reverb(RID p_room, RoomReverb p_reverb)=0;
- virtual RoomReverb room_get_reverb(RID p_room) const=0;
-
- virtual void room_set_level(RID p_room, int p_level)=0;
- virtual int room_get_level(RID p_room) const=0;
-
- //useful for underwater or rooms with very strange conditions
- virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force)=0;
- virtual bool room_is_forcing_params_to_all_sources(RID p_room) const=0;
-
- /* SOURCE */
-
- virtual RID source_create(RID p_space)=0;
-
- virtual void source_set_transform(RID p_source, const Transform2D& p_transform)=0;
- virtual Transform2D source_get_transform(RID p_source) const=0;
-
- virtual void source_set_polyphony(RID p_source,int p_voice_count)=0;
- virtual int source_get_polyphony(RID p_source) const=0;
-
- enum SourceParam {
-
- SOURCE_PARAM_VOLUME_DB,
- SOURCE_PARAM_PITCH_SCALE,
- SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- SOURCE_PARAM_MAX
- };
-
- virtual void source_set_param(RID p_source, SourceParam p_param, float p_value)=0;
- virtual float source_get_param(RID p_source, SourceParam p_param) const=0;
-
- virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream)=0; //null to unset
- virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE)=0;
- //voices
- virtual void source_voice_set_pitch_scale(RID p_source,SourceVoiceID p_voice, float p_pitch_scale)=0;
- virtual void source_voice_set_volume_scale_db(RID p_source,SourceVoiceID p_voice, float p_volume_db)=0;
-
- virtual bool source_is_voice_active(RID p_source,SourceVoiceID p_voice) const=0;
- virtual void source_stop_voice(RID p_source,SourceVoiceID p_voice)=0;
-
- /* LISTENER */
-
- enum ListenerParam {
-
- LISTENER_PARAM_VOLUME_SCALE_DB,
- LISTENER_PARAM_PITCH_SCALE,
- LISTENER_PARAM_ATTENUATION_SCALE,
- LISTENER_PARAM_PAN_RANGE,
- LISTENER_PARAM_MAX
- };
-
- virtual RID listener_create()=0;
- virtual void listener_set_space(RID p_listener, RID p_space)=0;
-
- virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform)=0;
- virtual Transform2D listener_get_transform(RID p_listener) const=0;
-
- virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value)=0;
- virtual float listener_get_param(RID p_listener, ListenerParam p_param) const=0;
-
- /* MISC */
-
- virtual void free(RID p_id)=0;
-
- virtual void init()=0;
- virtual void update(float p_delta)=0;
- virtual void finish()=0;
-
- static SpatialSound2DServer *get_singleton();
-
- SpatialSound2DServer();
-
-};
-
-#endif // SPATIAL_SOUND_2D_SERVER_H
diff --git a/servers/spatial_sound_server.cpp b/servers/spatial_sound_server.cpp
deleted file mode 100644
index f49367d4c0..0000000000
--- a/servers/spatial_sound_server.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_server.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 "spatial_sound_server.h"
-
-SpatialSoundServer *SpatialSoundServer::singleton=NULL;
-
-
-SpatialSoundServer *SpatialSoundServer::get_singleton() {
-
- return singleton;
-}
-
-
-SpatialSoundServer::SpatialSoundServer() {
-
- ERR_FAIL_COND(singleton!=NULL);
- singleton=this;
-}
diff --git a/servers/spatial_sound_server.h b/servers/spatial_sound_server.h
deleted file mode 100644
index 69ef71c84f..0000000000
--- a/servers/spatial_sound_server.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*************************************************************************/
-/* spatial_sound_server.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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 SPATIAL_SOUND_SERVER_H
-#define SPATIAL_SOUND_SERVER_H
-
-#include "object.h"
-#include "bsp_tree.h"
-#include "servers/audio_server.h"
-
-class SpatialSoundServer : public Object {
- GDCLASS(SpatialSoundServer,Object);
-
- static SpatialSoundServer *singleton;
-public:
-
-
- enum {
- SOURCE_INVALID_VOICE=-1,
- SOURCE_NEXT_VOICE=-2,
- };
-
- typedef int SourceVoiceID;
-
- /* SPACE */
- virtual RID space_create()=0;
-
- /* ROOM */
-
- virtual RID room_create()=0;
- virtual void room_set_space(RID p_room,RID p_space)=0;
- virtual RID room_get_space(RID p_room) const=0;
-
-
- virtual void room_set_bounds(RID p_room, const BSP_Tree& p_bounds)=0;
- virtual BSP_Tree room_get_bounds(RID p_room) const=0;
- virtual void room_set_transform(RID p_room, const Transform& p_transform)=0;
- virtual Transform room_get_transform(RID p_room) const=0;
-
- enum RoomParam {
- ROOM_PARAM_SPEED_OF_SOUND_SCALE,
- ROOM_PARAM_DOPPLER_FACTOR,
- ROOM_PARAM_PITCH_SCALE,
- ROOM_PARAM_VOLUME_SCALE_DB,
- ROOM_PARAM_REVERB_SEND,
- ROOM_PARAM_CHORUS_SEND,
- ROOM_PARAM_ATTENUATION_SCALE,
- ROOM_PARAM_ATTENUATION_HF_CUTOFF,
- ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
- ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
- ROOM_PARAM_ATTENUATION_REVERB_SCALE,
- ROOM_PARAM_MAX
- };
-
- virtual void room_set_param(RID p_room, RoomParam p_param, float p_value)=0;
- virtual float room_get_param(RID p_room, RoomParam p_param) const=0;
-
- enum RoomReverb {
- ROOM_REVERB_SMALL,
- ROOM_REVERB_MEDIUM,
- ROOM_REVERB_LARGE,
- ROOM_REVERB_HALL
- };
-
- virtual void room_set_reverb(RID p_room, RoomReverb p_reverb)=0;
- virtual RoomReverb room_get_reverb(RID p_room) const=0;
-
- virtual void room_set_level(RID p_room, int p_level)=0;
- virtual int room_get_level(RID p_room) const=0;
-
- //useful for underwater or rooms with very strange conditions
- virtual void room_set_force_params_to_all_sources(RID p_room, bool p_force)=0;
- virtual bool room_is_forcing_params_to_all_sources(RID p_room) const=0;
-
- /* SOURCE */
-
- virtual RID source_create(RID p_space)=0;
-
- virtual void source_set_transform(RID p_source, const Transform& p_transform)=0;
- virtual Transform source_get_transform(RID p_source) const=0;
-
- virtual void source_set_polyphony(RID p_source,int p_voice_count)=0;
- virtual int source_get_polyphony(RID p_source) const=0;
-
- enum SourceParam {
-
- SOURCE_PARAM_VOLUME_DB,
- SOURCE_PARAM_PITCH_SCALE,
- SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- SOURCE_PARAM_EMISSION_CONE_DEGREES,
- SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB,
- SOURCE_PARAM_MAX
- };
-
- virtual void source_set_param(RID p_source, SourceParam p_param, float p_value)=0;
- virtual float source_get_param(RID p_source, SourceParam p_param) const=0;
-
- virtual void source_set_audio_stream(RID p_source, AudioServer::AudioStream *p_stream)=0; //null to unset
- virtual SourceVoiceID source_play_sample(RID p_source, RID p_sample, int p_mix_rate, int p_voice=SOURCE_NEXT_VOICE)=0;
- //voices
- virtual void source_voice_set_pitch_scale(RID p_source,SourceVoiceID p_voice, float p_pitch_scale)=0;
- virtual void source_voice_set_volume_scale_db(RID p_source,SourceVoiceID p_voice, float p_volume_db)=0;
-
- virtual bool source_is_voice_active(RID p_source,SourceVoiceID p_voice) const=0;
- virtual void source_stop_voice(RID p_source,SourceVoiceID p_voice)=0;
-
- /* LISTENER */
-
- enum ListenerParam {
-
- LISTENER_PARAM_VOLUME_SCALE_DB,
- LISTENER_PARAM_PITCH_SCALE,
- LISTENER_PARAM_ATTENUATION_SCALE,
- LISTENER_PARAM_RECEPTION_CONE_DEGREES,
- LISTENER_PARAM_RECEPTION_CONE_ATTENUATION_DB,
- LISTENER_PARAM_MAX
- };
-
- virtual RID listener_create()=0;
- virtual void listener_set_space(RID p_listener, RID p_space)=0;
-
- virtual void listener_set_transform(RID p_listener, const Transform& p_transform)=0;
- virtual Transform listener_get_transform(RID p_listener) const=0;
-
- virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value)=0;
- virtual float listener_get_param(RID p_listener, ListenerParam p_param) const=0;
-
- /* MISC */
-
- virtual void free(RID p_id)=0;
-
- virtual void init()=0;
- virtual void update(float p_delta)=0;
- virtual void finish()=0;
-
- static SpatialSoundServer *get_singleton();
-
- SpatialSoundServer();
-};
-
-#endif // SPATIAL_SOUND_SERVER_H
diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer.cpp
index 1adf2ee021..ba85f92e37 100644
--- a/servers/visual/rasterizer.cpp
+++ b/servers/visual/rasterizer.cpp
@@ -256,7 +256,7 @@ RID Rasterizer::_create_shader(const FixedSpatialMaterialShaderKey& p_key) {
vcode+="uniform float "+_fixed_material_point_size_name+";\n";
vcode+="POINT_SIZE="+_fixed_material_point_size_name+";\n";
-// vcode+="POINT_SIZE=10.0;\n";
+ //vcode+="POINT_SIZE=10.0;\n";
}
String lcode;
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 94a514e7c1..dd22986865 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -196,6 +196,8 @@ public:
virtual RID texture_create_radiance_cubemap(RID p_source,int p_resolution=-1) const=0;
+ virtual void texture_set_detect_3d_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata)=0;
+ virtual void texture_set_detect_srgb_callback(RID p_texture,VisualServer::TextureDetectCallback p_callback,void* p_userdata)=0;
virtual void textures_keep_original(bool p_enable)=0;
@@ -430,6 +432,12 @@ public:
virtual void gi_probe_set_energy(RID p_probe,float p_range)=0;
virtual float gi_probe_get_energy(RID p_probe) const=0;
+ 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_propagation(RID p_probe,float p_range)=0;
+ virtual float gi_probe_get_propagation(RID p_probe) const=0;
+
virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0;
virtual bool gi_probe_is_interior(RID p_probe) const=0;
@@ -512,6 +520,9 @@ public:
virtual VS::InstanceType get_base_type(RID p_rid) const=0;
virtual bool free(RID p_rid)=0;
+ virtual bool has_os_feature(const String& p_feature) const=0;
+
+ virtual void update_dirty_resources()=0;
static RasterizerStorage*base_signleton;
RasterizerStorage();
@@ -1226,7 +1237,7 @@ public:
virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0;
virtual RID multimesh_get_mesh(RID p_multimesh) const=0;
- virtual AABB multimesh_get_aabb(RID p_multimesh) const=0;;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const=0;
virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0;
virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0;
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index ea634e8f06..c680013efa 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -307,7 +307,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
} if (GETCHAR(0)=='*' && GETCHAR(1)=='/') {
char_idx+=2;
break;
- } if (GETCHAR(0)=='\n') {
+ } else if (GETCHAR(0)=='\n') {
tk_line++;
}
@@ -374,7 +374,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() {
char_idx++;
return _make_token(TK_OP_GREATER_EQUAL);
} else if (GETCHAR(0)=='<') {
- char_idx++;;
+ char_idx++;
if (GETCHAR(0)=='=') {
char_idx++;
return _make_token(TK_OP_ASSIGN_SHIFT_RIGHT);
@@ -1966,7 +1966,7 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode* p_block,const Map<Stri
return true;
}
- _set_tkpos(pos);;
+ _set_tkpos(pos);
while(true) {
@@ -2557,7 +2557,7 @@ ShaderLanguage::Node* ShaderLanguage::_parse_expression(BlockNode* p_block,const
} else if (l==2) {
member_type=DataType(dt-2);
} else if (l==3) {
- member_type=DataType(dt-1);;
+ member_type=DataType(dt-1);
} else if (l==4) {
member_type=dt;
} else {
@@ -2920,7 +2920,7 @@ ShaderLanguage::Node* ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha
ERR_FAIL_COND_V(op->arguments[0]->type!=Node::TYPE_VARIABLE,p_node);
VariableNode *vn = static_cast<VariableNode*>(op->arguments[0]);
- // StringName name=vn->name;
+ //StringName name=vn->name;
DataType base=get_scalar_type(op->get_datatype());
@@ -3241,7 +3241,7 @@ Error ShaderLanguage::_parse_shader(const Map< StringName, Map<StringName,DataTy
_set_error("void datatype not allowed here");
return ERR_PARSE_ERROR;
}
- if (!uniform && type<TYPE_FLOAT && type>TYPE_VEC4) {
+ if (!uniform && type<TYPE_FLOAT && type>TYPE_VEC4) { // FIXME: always false! should it be || instead?
_set_error("Invalid type for varying, only float,vec2,vec3,vec4 allowed.");
return ERR_PARSE_ERROR;
}
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h
index b5f843c114..4f8717088e 100644
--- a/servers/visual/shader_language.h
+++ b/servers/visual/shader_language.h
@@ -579,7 +579,7 @@ private:
public:
-// static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
+ //static void get_keyword_list(ShaderType p_type,List<String> *p_keywords);
void clear();
Error compile(const String& p_code,const Map< StringName, Map<StringName,DataType> > &p_functions,const Set<String>& p_render_modes);
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index d68c580442..f4031b711d 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -934,7 +934,7 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- int new_size = nearest_power_of_2(p_size);;
+ int new_size = nearest_power_of_2(p_size);
if (new_size==clight->shadow_buffer_size)
return;
@@ -1188,9 +1188,11 @@ bool VisualServerCanvas::free(RID p_rid) {
canvas_item->child_items[i]->parent=RID();
}
-// if (canvas_item->material) {
-// canvas_item->material->owners.erase(canvas_item);
-// }
+ /*
+ if (canvas_item->material) {
+ canvas_item->material->owners.erase(canvas_item);
+ }
+ */
canvas_item_owner.free( p_rid );
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 3262479c43..3a5ffda8f5 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "visual_server_raster.h"
#include "os/os.h"
-#include "globals.h"
+#include "global_config.h"
#include "default_mouse_cursor.xpm"
#include "sort.h"
#include "io/marshalls.h"
@@ -85,8 +85,10 @@ void VisualServerRaster::free( RID p_rid ){
void VisualServerRaster::draw(){
- //if (changes)
- // print_line("changes: "+itos(changes));
+ /*
+ if (changes)
+ print_line("changes: "+itos(changes));
+ */
changes=0;
@@ -121,6 +123,7 @@ void VisualServerRaster::finish(){
VSG::rasterizer->finalize();
}
+
/* STATUS INFORMATION */
@@ -154,6 +157,12 @@ RID VisualServerRaster::get_test_cube() {
return test_cube;
}
+
+bool VisualServerRaster::has_os_feature(const String& p_feature) const {
+
+ return VSG::storage->has_os_feature(p_feature);
+}
+
VisualServerRaster::VisualServerRaster() {
VSG::canvas = memnew( VisualServerCanvas);
@@ -181,7 +190,7 @@ BalloonAllocator<> *VisualServerRaster::OctreeAllocator::allocator=NULL;
#define VS_CHANGED\
changes++;\
-// print_line(__FUNCTION__);
+ //print_line(__FUNCTION__);
@@ -2928,7 +2937,7 @@ void VisualServerRaster::instance_geometry_set_flag(RID p_instance,InstanceFlags
Instance *instance = instance_owner.get( p_instance );
ERR_FAIL_COND( !instance );
-// ERR_FAIL_COND( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK) );
+ //ERR_FAIL_COND( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK) );
switch(p_flags) {
@@ -2980,7 +2989,7 @@ bool VisualServerRaster::instance_geometry_get_flag(RID p_instance,InstanceFlags
const Instance *instance = instance_owner.get( p_instance );
ERR_FAIL_COND_V( !instance, false );
-// ERR_FAIL_COND_V( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK), false );
+ //ERR_FAIL_COND_V( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK), false );
switch(p_flags) {
@@ -3335,8 +3344,10 @@ void VisualServerRaster::_update_instance(Instance *p_instance) {
} else {
- // if (new_aabb==p_instance->data.transformed_aabb)
- // return;
+ /*
+ if (new_aabb==p_instance->data.transformed_aabb)
+ return;
+ */
p_instance->scenario->octree.move(p_instance->octree_id,new_aabb);
}
@@ -4656,7 +4667,7 @@ void VisualServerRaster::_free_attached_instances(RID p_rid,bool p_free_scenario
void VisualServerRaster::custom_shade_model_set_shader(int p_model, RID p_shader) {
VS_CHANGED;
-// rasterizer->custom_shade_model_set_shader(p_model,p_shader);
+ //rasterizer->custom_shade_model_set_shader(p_model,p_shader);
}
RID VisualServerRaster::custom_shade_model_get_shader(int p_model) const {
@@ -4746,8 +4757,10 @@ void VisualServerRaster::free( RID p_rid ) {
BakedLightSampler *baked_light_sampler = baked_light_sampler_owner.get(p_rid);
ERR_FAIL_COND(!baked_light_sampler);
- //if (baked_light->data.octree_texture.is_valid())
- // rasterizer->free(baked_light->data.octree_texture);
+ /*
+ if (baked_light->data.octree_texture.is_valid())
+ rasterizer->free(baked_light->data.octree_texture);
+ */
baked_light_sampler_owner.free(p_rid);
memdelete(baked_light_sampler);
@@ -4766,7 +4779,7 @@ void VisualServerRaster::free( RID p_rid ) {
Viewport *viewport = viewport_owner.get( p_rid );
ERR_FAIL_COND(!viewport);
-// Viewport *parent=NULL;
+ //Viewport *parent=NULL;
rasterizer->free(viewport->viewport_data);
if (viewport->render_target.is_valid()) {
@@ -5105,7 +5118,7 @@ void VisualServerRaster::_light_instance_update_pssm_shadow(Instance *p_light,Sc
float distances[5];
float texsize=rasterizer->light_instance_get_shadow_size( p_light->light_info->instance );
-// float cull_min=p_cull_range.min;
+ //float cull_min=p_cull_range.min;
//float cull_max=p_cull_range.max;
@@ -6657,7 +6670,7 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
print_line("OTO: "+itos(p_scenario->octree.get_octant_count()));
-// print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
+ //print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
print_line("OTP: "+itos(p_scenario->octree.get_pair_count()));
*/
@@ -6761,7 +6774,7 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
if (light_cull_count<MAX_LIGHTS_CULLED) {
light_cull_result[light_cull_count++]=ins;
-// rasterizer->light_instance_set_active_hint(ins->light_info->instance);
+ //rasterizer->light_instance_set_active_hint(ins->light_info->instance);
{
//compute distance to camera using aabb support
Vector3 n = ins->data.transform.basis.xform_inv(cull_range.nearp.normal).normalized();
@@ -7284,7 +7297,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
ViewportRect desired_rect=p_viewport->rect;
ViewportRect old_rect = viewport_rect;
-// bool vpchanged=false;
+ //bool vpchanged=false;
// convert default expanding viewports to actual size
//if (desired_rect.x==0 && desired_rect.y==0 && desired_rect.width==0 && desired_rect.height==0) {
if (p_parent_w != 0 && p_parent_h != 0) {
@@ -7476,7 +7489,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
for (Map<Viewport::CanvasKey,Viewport::CanvasData*>::Element *E=canvas_map.front();E;E=E->next()) {
- // print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
+ //print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
//print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform);
Matrix32 xform = p_viewport->global_transform * E->get()->transform;
@@ -7508,7 +7521,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_
}
-// rasterizer->canvas_debug_viewport_shadows(lights_with_shadow);
+ //rasterizer->canvas_debug_viewport_shadows(lights_with_shadow);
}
//capture
@@ -7721,8 +7734,10 @@ void VisualServerRaster::sync() {
}
void VisualServerRaster::draw() {
- //if (changes)
- // print_line("changes: "+itos(changes));
+ /*
+ if (changes)
+ print_line("changes: "+itos(changes));
+ */
changes=0;
shadows_enabled=GLOBAL_DEF("render/shadows_enabled",true);
room_cull_enabled = GLOBAL_DEF("render/room_cull_enabled",true);
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 5c8105681a..7d547e1862 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -622,7 +622,8 @@ public:
BIND3(texture_set_size_override,RID,int,int)
BIND2RC(RID,texture_create_radiance_cubemap,RID,int)
-
+ BIND3(texture_set_detect_3d_callback,RID,TextureDetectCallback,void*)
+ BIND3(texture_set_detect_srgb_callback,RID,TextureDetectCallback,void*)
BIND2(texture_set_path,RID,const String&)
BIND1RC(String,texture_get_path,RID)
@@ -824,6 +825,12 @@ public:
BIND2(gi_probe_set_energy,RID,float)
BIND1RC(float,gi_probe_get_energy,RID)
+ BIND2(gi_probe_set_bias,RID,float)
+ BIND1RC(float,gi_probe_get_bias,RID)
+
+ BIND2(gi_probe_set_propagation,RID,float)
+ BIND1RC(float,gi_probe_get_propagation,RID)
+
BIND2(gi_probe_set_interior,RID,bool)
BIND1RC(bool,gi_probe_is_interior,RID)
@@ -1135,6 +1142,8 @@ public:
virtual bool has_feature(Features p_feature) const;
+ virtual bool has_os_feature(const String& p_feature) const;
+
VisualServerRaster();
~VisualServerRaster();
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 030796a22d..6f7b2e3aed 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -78,7 +78,7 @@ void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera,bool p_enabl
void* VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int) {
-// VisualServerScene *self = (VisualServerScene*)p_self;
+ //VisualServerScene *self = (VisualServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -204,7 +204,7 @@ void* VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance
}
void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int,void* udata) {
-// VisualServerScene *self = (VisualServerScene*)p_self;
+ //VisualServerScene *self = (VisualServerScene*)p_self;
Instance *A = p_A;
Instance *B = p_B;
@@ -1239,8 +1239,10 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
} else {
- // if (new_aabb==p_instance->data.transformed_aabb)
- // return;
+ /*
+ if (new_aabb==p_instance->data.transformed_aabb)
+ return;
+ */
p_instance->scenario->octree.move(p_instance->octree_id,new_aabb);
}
@@ -1554,9 +1556,11 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance,const
cull_count--;
SWAP(instance_shadow_cull_result[j],instance_shadow_cull_result[cull_count]);
j--;
+ continue;
}
+
instance->transformed_aabb.project_range_in_plane(Plane(z_vec,0),min,max);
if (max>z_max)
z_max=max;
@@ -1773,7 +1777,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
VSG::scene_render->set_scene_pass(render_pass);
-// rasterizer->set_camera(camera->transform, camera_matrix,ortho);
+ //rasterizer->set_camera(camera->transform, camera_matrix,ortho);
Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform);
@@ -1786,11 +1790,11 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
reflection_probe_cull_count=0;
-// light_samplers_culled=0;
+ //light_samplers_culled=0;
/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0));
print_line("OTO: "+itos(p_scenario->octree.get_octant_count()));
-// print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
+ //print_line("OTE: "+itos(p_scenario->octree.get_elem_count()));
print_line("OTP: "+itos(p_scenario->octree.get_pair_count()));
*/
@@ -2237,7 +2241,6 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform,const Came
bool redraw = VSG::scene_render->shadow_atlas_update_light(p_shadow_atlas,light->instance,coverage,light->last_version);
if (redraw) {
- print_line("redraw shadow");
//must redraw!
_light_instance_update_shadow(ins,p_cam_transform,p_cam_projection,p_cam_orthogonal,p_shadow_atlas,scenario);
}
@@ -2446,6 +2449,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
probe->dynamic.bake_dynamic_range=VSG::storage->gi_probe_get_dynamic_range(p_instance->base);
probe->dynamic.mipmaps_3d.clear();
+ probe->dynamic.propagate=VSG::storage->gi_probe_get_propagation(p_instance->base);
probe->dynamic.grid_size[0]=header->width;
probe->dynamic.grid_size[1]=header->height;
@@ -2940,14 +2944,12 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header,con
}
-void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data) {
+void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data,float p_propagate) {
//average light to upper level
- p_local_data[p_idx].energy[0]=0;
- p_local_data[p_idx].energy[1]=0;
- p_local_data[p_idx].energy[2]=0;
- int divisor=0;
+ float divisor=0;
+ float sum[3]={0.0,0.0,0.0};
for(int i=0;i<8;i++) {
@@ -2957,20 +2959,25 @@ void VisualServerScene::_bake_gi_downscale_light(int p_idx, int p_level, const G
continue;
if (p_level+1 < (int)p_header->cell_subdiv-1) {
- _bake_gi_downscale_light(child,p_level+1,p_cells,p_header,p_local_data);
+ _bake_gi_downscale_light(child,p_level+1,p_cells,p_header,p_local_data,p_propagate);
}
- p_local_data[p_idx].energy[0]+=p_local_data[child].energy[0];
- p_local_data[p_idx].energy[1]+=p_local_data[child].energy[1];
- p_local_data[p_idx].energy[2]+=p_local_data[child].energy[2];
- divisor++;
+ sum[0]+=p_local_data[child].energy[0];
+ sum[1]+=p_local_data[child].energy[1];
+ sum[2]+=p_local_data[child].energy[2];
+ divisor+=1.0;
}
+ divisor=Math::lerp((float)8.0,divisor,p_propagate);
+ sum[0]/=divisor;
+ sum[1]/=divisor;
+ sum[2]/=divisor;
+
//divide by eight for average
- p_local_data[p_idx].energy[0]/=divisor;
- p_local_data[p_idx].energy[1]/=divisor;
- p_local_data[p_idx].energy[2]/=divisor;
+ p_local_data[p_idx].energy[0]=Math::fast_ftoi(sum[0]);
+ p_local_data[p_idx].energy[1]=Math::fast_ftoi(sum[1]);
+ p_local_data[p_idx].energy[2]=Math::fast_ftoi(sum[2]);
}
@@ -3022,7 +3029,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
SWAP(probe_data->dynamic.light_cache_changes,probe_data->dynamic.light_cache);
//downscale to lower res levels
- _bake_gi_downscale_light(0,0,cells,header,local_data);
+ _bake_gi_downscale_light(0,0,cells,header,local_data,probe_data->dynamic.propagate);
//plot result to 3D texture!
@@ -3335,6 +3342,14 @@ void VisualServerScene::render_probes() {
force_lighting=true;
}
+ float propagate = VSG::storage->gi_probe_get_propagation(instance_probe->base);
+
+ if (probe->dynamic.propagate!=propagate) {
+ probe->dynamic.propagate=propagate;
+ force_lighting=true;
+ }
+
+
if (probe->invalid==false && probe->dynamic.enabled) {
switch(probe->dynamic.updating_stage) {
@@ -3375,7 +3390,7 @@ void VisualServerScene::render_probes() {
probe->dynamic.updating_stage=GI_UPDATE_STAGE_CHECK;
-// print_line("UPLOAD TIME: "+rtos((OS::get_singleton()->get_ticks_usec()-us)/1000000.0));
+ //print_line("UPLOAD TIME: "+rtos((OS::get_singleton()->get_ticks_usec()-us)/1000000.0));
} break;
}
@@ -3462,6 +3477,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
} else if (p_instance->base_type==VS::INSTANCE_MULTIMESH) {
RID mesh = VSG::storage->multimesh_get_mesh(p_instance->base);
if (mesh.is_valid()) {
+
bool cast_shadows=false;
int sc = VSG::storage->mesh_get_surface_count(mesh);
@@ -3478,6 +3494,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
cast_shadows=true;
break;
}
+
}
if (!cast_shadows) {
@@ -3525,6 +3542,8 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
void VisualServerScene::update_dirty_instances() {
+ VSG::storage->update_dirty_resources();
+
while(_instance_update_list.first()) {
_update_dirty_instance( _instance_update_list.first()->self() );
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index 1f7de3d005..f9a5dde1ac 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -445,6 +445,7 @@ public:
Vector< PoolVector<CompBlockS3TC> > mipmaps_s3tc; //for s3tc
int updating_stage;
+ float propagate;
int grid_size[3];
@@ -570,7 +571,7 @@ public:
void _gi_probe_fill_local_data(int p_idx,int p_level,int p_x,int p_y,int p_z,const GIProbeDataCell* p_cell,const GIProbeDataHeader *p_header,InstanceGIProbeData::LocalData *p_local_data,Vector<uint32_t> *prev_cell);
_FORCE_INLINE_ uint32_t _gi_bake_find_cell(const GIProbeDataCell *cells,int x,int y, int z,int p_cell_subdiv);
- void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data);
+ void _bake_gi_downscale_light(int p_idx, int p_level, const GIProbeDataCell* p_cells, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, float p_propagate);
void _bake_gi_probe_light(const GIProbeDataHeader *header,const GIProbeDataCell *cells,InstanceGIProbeData::LocalData *local_data,const uint32_t *leaves,int p_leaf_count, const InstanceGIProbeData::LightCache& light_cache,int p_sign);
void _bake_gi_probe(Instance *p_probe);
bool _check_gi_probe(Instance *p_gi_probe);
diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp
index 780335a7f4..d32c4dd6bf 100644
--- a/servers/visual/visual_server_viewport.cpp
+++ b/servers/visual/visual_server_viewport.cpp
@@ -2,7 +2,7 @@
#include "visual_server_global.h"
#include "visual_server_canvas.h"
#include "visual_server_scene.h"
-#include "globals.h"
+#include "global_config.h"
@@ -176,7 +176,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
light=light->shadows_next_ptr;
}
- // VSG::canvas_render->reset_canvas();
+ //VSG::canvas_render->reset_canvas();
}
VSG::rasterizer->restore_render_target();
@@ -196,7 +196,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get()->canvas);
- // print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
+ //print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
//print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform);
Transform2D xform = p_viewport->global_transform * E->get()->transform;
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 71f9c88f2a..5d231d208e 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_server.h"
-#include "globals.h"
+#include "global_config.h"
#include "method_bind_ext.inc"
VisualServer *VisualServer::singleton=NULL;
@@ -156,7 +156,7 @@ RID VisualServer::_make_test_cube() {
PoolVector<Vector3> uvs;
int vtx_idx=0;
-#define ADD_VTX(m_idx);\
+#define ADD_VTX(m_idx) \
vertices.push_back( face_points[m_idx] );\
normals.push_back( normal_points[m_idx] );\
tangents.push_back( normal_points[m_idx][1] );\
@@ -712,7 +712,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t
} break;
case VS::ARRAY_BONES: {
- ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER );
+ ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY && p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER );
PoolVector<int> array = p_arrays[ai];
@@ -1566,17 +1566,17 @@ Array VisualServer::mesh_surface_get_arrays(RID p_mesh,int p_surface) const {
void VisualServer::_bind_methods() {
- ClassDB::bind_method(_MD("texture_create"),&VisualServer::texture_create);
- ClassDB::bind_method(_MD("texture_create_from_image"),&VisualServer::texture_create_from_image,DEFVAL( TEXTURE_FLAGS_DEFAULT ) );
- //ClassDB::bind_method(_MD("texture_allocate"),&VisualServer::texture_allocate,DEFVAL( TEXTURE_FLAGS_DEFAULT ) );
- //ClassDB::bind_method(_MD("texture_set_data"),&VisualServer::texture_blit_rect,DEFVAL( CUBEMAP_LEFT ) );
- //ClassDB::bind_method(_MD("texture_get_rect"),&VisualServer::texture_get_rect );
- ClassDB::bind_method(_MD("texture_set_flags"),&VisualServer::texture_set_flags );
- ClassDB::bind_method(_MD("texture_get_flags"),&VisualServer::texture_get_flags );
- ClassDB::bind_method(_MD("texture_get_width"),&VisualServer::texture_get_width );
- ClassDB::bind_method(_MD("texture_get_height"),&VisualServer::texture_get_height );
+ 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_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(_MD("texture_set_shrink_all_x2_on_set_data","shrink"),&VisualServer::texture_set_shrink_all_x2_on_set_data );
+ ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data","shrink"),&VisualServer::texture_set_shrink_all_x2_on_set_data );
@@ -1675,7 +1675,7 @@ RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
VisualServer::VisualServer() {
-// ERR_FAIL_COND(singleton);
+ //ERR_FAIL_COND(singleton);
singleton=this;
}
diff --git a/servers/visual_server.h b/servers/visual_server.h
index cb4d87ce8a..08cf34a653 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -129,6 +129,11 @@ public:
virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable)=0;
+ typedef void (*TextureDetectCallback)(void*);
+
+ virtual void texture_set_detect_3d_callback(RID p_texture,TextureDetectCallback p_callback,void* p_userdata)=0;
+ virtual void texture_set_detect_srgb_callback(RID p_texture,TextureDetectCallback p_callback,void* p_userdata)=0;
+
struct TextureInfo {
RID texture;
Size2 size;
@@ -360,6 +365,7 @@ public:
LIGHT_PARAM_ATTENUATION,
LIGHT_PARAM_SPOT_ANGLE,
LIGHT_PARAM_SPOT_ATTENUATION,
+ LIGHT_PARAM_CONTACT_SHADOW_SIZE,
LIGHT_PARAM_SHADOW_MAX_DISTANCE,
LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
@@ -469,6 +475,12 @@ public:
virtual void gi_probe_set_energy(RID p_probe,float p_range)=0;
virtual float gi_probe_get_energy(RID p_probe) const=0;
+ 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_propagation(RID p_probe,float p_range)=0;
+ virtual float gi_probe_get_propagation(RID p_probe) const=0;
+
virtual void gi_probe_set_interior(RID p_probe,bool p_enable)=0;
virtual bool gi_probe_is_interior(RID p_probe) const=0;
@@ -706,7 +718,7 @@ public:
virtual RID instance_create2(RID p_base, RID p_scenario);
-// virtual RID instance_create(RID p_base,RID p_scenario)=0; // from can be mesh, light, area and portal so far.
+ //virtual RID instance_create(RID p_base,RID p_scenario)=0; // from can be mesh, light, area and portal so far.
virtual RID instance_create()=0; // from can be mesh, light, poly, area and portal so far.
virtual void instance_set_base(RID p_instance, RID p_base)=0; // from can be mesh, light, poly, area and portal so far.
@@ -938,6 +950,8 @@ public:
virtual bool has_feature(Features p_feature) const=0;
+ virtual bool has_os_feature(const String& p_feature) const=0;
+
VisualServer();
virtual ~VisualServer();
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 42642c09b7..8c2a3e6af3 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -1,6 +1,13 @@
# Third party libraries
+## certs
+
+- Upstream: ?
+
+TODO.
+
+
## enet
- Upstream: http://enet.bespin.org
@@ -18,6 +25,13 @@ for all platforms (especially UWP). Check the diff with the 1.3.13 tarball
before the next update.
+## fonts
+
+- Upstream: ?
+
+TODO.
+
+
## freetype
- Upstream: https://www.freetype.org
@@ -110,15 +124,15 @@ Files extracted from upstream source:
## libwebp
- Upstream: https://chromium.googlesource.com/webm/libwebp/
-- Version: 0.5.2
+- Version: 0.6.0
- License: BSD-3-Clause
Files extracted from upstream source:
-- `src/*` except from: .am and .in, files, extras/, `webp/extras.h`
+- `src/*` except from: .am, .rc and .in files
- AUTHORS, COPYING, PATENTS
-Important: The files `utils/bit_reader.{c,h}` have Godot-made
+Important: The files `utils/bit_reader_utils.{c,h}` have Godot-made
changes to ensure they build for Javascript/HTML5. Those
changes are marked with `// -- GODOT --` comments.
@@ -209,7 +223,7 @@ Files extracted from upstream source:
## zlib
- Upstream: http://www.zlib.net/
-- Version: 1.2.10
+- Version: 1.2.11
- License: zlib
Files extracted from upstream source:
diff --git a/tools/certs/ca-certificates.crt b/thirdparty/certs/ca-certificates.crt
index 862096d85a..862096d85a 100644
--- a/tools/certs/ca-certificates.crt
+++ b/thirdparty/certs/ca-certificates.crt
diff --git a/tools/editor_fonts/DroidSans.ttf b/thirdparty/fonts/DroidSans.ttf
index 767c63ad00..767c63ad00 100644
--- a/tools/editor_fonts/DroidSans.ttf
+++ b/thirdparty/fonts/DroidSans.ttf
Binary files differ
diff --git a/tools/editor_fonts/DroidSansArabic.ttf b/thirdparty/fonts/DroidSansArabic.ttf
index 660e2a9916..660e2a9916 100644
--- a/tools/editor_fonts/DroidSansArabic.ttf
+++ b/thirdparty/fonts/DroidSansArabic.ttf
Binary files differ
diff --git a/tools/editor_fonts/DroidSansFallback.ttf b/thirdparty/fonts/DroidSansFallback.ttf
index 206621fc6c..206621fc6c 100644
--- a/tools/editor_fonts/DroidSansFallback.ttf
+++ b/thirdparty/fonts/DroidSansFallback.ttf
Binary files differ
diff --git a/tools/editor_fonts/DroidSansHebrew.ttf b/thirdparty/fonts/DroidSansHebrew.ttf
index 8d77e3e4cf..8d77e3e4cf 100644
--- a/tools/editor_fonts/DroidSansHebrew.ttf
+++ b/thirdparty/fonts/DroidSansHebrew.ttf
Binary files differ
diff --git a/tools/editor_fonts/DroidSansJapanese.ttf b/thirdparty/fonts/DroidSansJapanese.ttf
index 412fa3de05..412fa3de05 100644
--- a/tools/editor_fonts/DroidSansJapanese.ttf
+++ b/thirdparty/fonts/DroidSansJapanese.ttf
Binary files differ
diff --git a/tools/editor_fonts/DroidSansThai.ttf b/thirdparty/fonts/DroidSansThai.ttf
index f849baeff9..f849baeff9 100644
--- a/tools/editor_fonts/DroidSansThai.ttf
+++ b/thirdparty/fonts/DroidSansThai.ttf
Binary files differ
diff --git a/tools/editor_fonts/LICENSE.DroidSans.txt b/thirdparty/fonts/LICENSE.DroidSans.txt
index 636f1e2975..636f1e2975 100644
--- a/tools/editor_fonts/LICENSE.DroidSans.txt
+++ b/thirdparty/fonts/LICENSE.DroidSans.txt
diff --git a/tools/editor_fonts/LICENSE.SourceCodePro.txt b/thirdparty/fonts/LICENSE.SourceCodePro.txt
index f430ee5dbe..f430ee5dbe 100644
--- a/tools/editor_fonts/LICENSE.SourceCodePro.txt
+++ b/thirdparty/fonts/LICENSE.SourceCodePro.txt
diff --git a/tools/editor_fonts/source_code_pro.otf b/thirdparty/fonts/source_code_pro.otf
index 4e3b9d0bcd..4e3b9d0bcd 100644
--- a/tools/editor_fonts/source_code_pro.otf
+++ b/thirdparty/fonts/source_code_pro.otf
Binary files differ
diff --git a/thirdparty/libwebp/dec/alpha.c b/thirdparty/libwebp/dec/alpha_dec.c
index d88f01d8de..83ffd4b609 100644
--- a/thirdparty/libwebp/dec/alpha.c
+++ b/thirdparty/libwebp/dec/alpha_dec.c
@@ -12,11 +12,11 @@
// Author: Skal (pascal.massimino@gmail.com)
#include <stdlib.h>
-#include "./alphai.h"
-#include "./vp8i.h"
-#include "./vp8li.h"
+#include "./alphai_dec.h"
+#include "./vp8i_dec.h"
+#include "./vp8li_dec.h"
#include "../dsp/dsp.h"
-#include "../utils/quant_levels_dec.h"
+#include "../utils/quant_levels_dec_utils.h"
#include "../utils/utils.h"
#include "../webp/format_constants.h"
diff --git a/thirdparty/libwebp/dec/alphai.h b/thirdparty/libwebp/dec/alphai_dec.h
index 69dd7c0f5d..561e8151ee 100644
--- a/thirdparty/libwebp/dec/alphai.h
+++ b/thirdparty/libwebp/dec/alphai_dec.h
@@ -14,8 +14,8 @@
#ifndef WEBP_DEC_ALPHAI_H_
#define WEBP_DEC_ALPHAI_H_
-#include "./webpi.h"
-#include "../utils/filters.h"
+#include "./webpi_dec.h"
+#include "../utils/filters_utils.h"
#ifdef __cplusplus
extern "C" {
diff --git a/thirdparty/libwebp/dec/buffer.c b/thirdparty/libwebp/dec/buffer_dec.c
index 547e69b434..c685fd5646 100644
--- a/thirdparty/libwebp/dec/buffer.c
+++ b/thirdparty/libwebp/dec/buffer_dec.c
@@ -13,8 +13,8 @@
#include <stdlib.h>
-#include "./vp8i.h"
-#include "./webpi.h"
+#include "./vp8i_dec.h"
+#include "./webpi_dec.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dec/common.h b/thirdparty/libwebp/dec/common_dec.h
index 6961e22470..6961e22470 100644
--- a/thirdparty/libwebp/dec/common.h
+++ b/thirdparty/libwebp/dec/common_dec.h
diff --git a/thirdparty/libwebp/dec/frame.c b/thirdparty/libwebp/dec/frame_dec.c
index 22d291d2cd..f91e27f7c8 100644
--- a/thirdparty/libwebp/dec/frame.c
+++ b/thirdparty/libwebp/dec/frame_dec.c
@@ -12,7 +12,7 @@
// Author: Skal (pascal.massimino@gmail.com)
#include <stdlib.h>
-#include "./vp8i.h"
+#include "./vp8i_dec.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
@@ -723,7 +723,7 @@ static int AllocateMemory(VP8Decoder* const dec) {
return VP8SetError(dec, VP8_STATUS_OUT_OF_MEMORY,
"no memory during frame initialization.");
}
- // down-cast is ok, thanks to WebPSafeAlloc() above.
+ // down-cast is ok, thanks to WebPSafeMalloc() above.
dec->mem_size_ = (size_t)needed;
}
diff --git a/thirdparty/libwebp/dec/idec.c b/thirdparty/libwebp/dec/idec_dec.c
index 8de131916e..78fb2e7186 100644
--- a/thirdparty/libwebp/dec/idec.c
+++ b/thirdparty/libwebp/dec/idec_dec.c
@@ -15,9 +15,9 @@
#include <string.h>
#include <stdlib.h>
-#include "./alphai.h"
-#include "./webpi.h"
-#include "./vp8i.h"
+#include "./alphai_dec.h"
+#include "./webpi_dec.h"
+#include "./vp8i_dec.h"
#include "../utils/utils.h"
// In append mode, buffer allocations increase as multiples of this value.
diff --git a/thirdparty/libwebp/dec/io.c b/thirdparty/libwebp/dec/io_dec.c
index 8d5c43f325..8bfab86959 100644
--- a/thirdparty/libwebp/dec/io.c
+++ b/thirdparty/libwebp/dec/io_dec.c
@@ -13,8 +13,8 @@
#include <assert.h>
#include <stdlib.h>
-#include "../dec/vp8i.h"
-#include "./webpi.h"
+#include "../dec/vp8i_dec.h"
+#include "./webpi_dec.h"
#include "../dsp/dsp.h"
#include "../dsp/yuv.h"
#include "../utils/utils.h"
@@ -256,7 +256,7 @@ static int Rescale(const uint8_t* src, int src_stride,
static int EmitRescaledYUV(const VP8Io* const io, WebPDecParams* const p) {
const int mb_h = io->mb_h;
const int uv_mb_h = (mb_h + 1) >> 1;
- WebPRescaler* const scaler = &p->scaler_y;
+ WebPRescaler* const scaler = p->scaler_y;
int num_lines_out = 0;
if (WebPIsAlphaMode(p->output->colorspace) && io->a != NULL) {
// Before rescaling, we premultiply the luma directly into the io->y
@@ -267,29 +267,28 @@ static int EmitRescaledYUV(const VP8Io* const io, WebPDecParams* const p) {
io->a, io->width, io->mb_w, mb_h, 0);
}
num_lines_out = Rescale(io->y, io->y_stride, mb_h, scaler);
- Rescale(io->u, io->uv_stride, uv_mb_h, &p->scaler_u);
- Rescale(io->v, io->uv_stride, uv_mb_h, &p->scaler_v);
+ Rescale(io->u, io->uv_stride, uv_mb_h, p->scaler_u);
+ Rescale(io->v, io->uv_stride, uv_mb_h, p->scaler_v);
return num_lines_out;
}
static int EmitRescaledAlphaYUV(const VP8Io* const io, WebPDecParams* const p,
int expected_num_lines_out) {
const WebPYUVABuffer* const buf = &p->output->u.YUVA;
+ uint8_t* const dst_a = buf->a + p->last_y * buf->a_stride;
if (io->a != NULL) {
- uint8_t* dst_y = buf->y + p->last_y * buf->y_stride;
- const uint8_t* src_a = buf->a + p->last_y * buf->a_stride;
- const int num_lines_out = Rescale(io->a, io->width, io->mb_h, &p->scaler_a);
- (void)expected_num_lines_out;
+ uint8_t* const dst_y = buf->y + p->last_y * buf->y_stride;
+ const int num_lines_out = Rescale(io->a, io->width, io->mb_h, p->scaler_a);
assert(expected_num_lines_out == num_lines_out);
if (num_lines_out > 0) { // unmultiply the Y
- WebPMultRows(dst_y, buf->y_stride, src_a, buf->a_stride,
- p->scaler_a.dst_width, num_lines_out, 1);
+ WebPMultRows(dst_y, buf->y_stride, dst_a, buf->a_stride,
+ p->scaler_a->dst_width, num_lines_out, 1);
}
} else if (buf->a != NULL) {
// the user requested alpha, but there is none, set it to opaque.
assert(p->last_y + expected_num_lines_out <= io->scaled_height);
- FillAlphaPlane(buf->a + p->last_y * buf->a_stride,
- io->scaled_width, expected_num_lines_out, buf->a_stride);
+ FillAlphaPlane(dst_a, io->scaled_width, expected_num_lines_out,
+ buf->a_stride);
}
return 0;
}
@@ -305,31 +304,42 @@ static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) {
const int uv_in_height = (io->mb_h + 1) >> 1;
const size_t work_size = 2 * out_width; // scratch memory for luma rescaler
const size_t uv_work_size = 2 * uv_out_width; // and for each u/v ones
- size_t tmp_size;
+ size_t tmp_size, rescaler_size;
rescaler_t* work;
+ WebPRescaler* scalers;
+ const int num_rescalers = has_alpha ? 4 : 3;
tmp_size = (work_size + 2 * uv_work_size) * sizeof(*work);
if (has_alpha) {
tmp_size += work_size * sizeof(*work);
}
- p->memory = WebPSafeMalloc(1ULL, tmp_size);
+ rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
+
+ p->memory = WebPSafeMalloc(1ULL, tmp_size + rescaler_size);
if (p->memory == NULL) {
return 0; // memory error
}
work = (rescaler_t*)p->memory;
- WebPRescalerInit(&p->scaler_y, io->mb_w, io->mb_h,
+
+ scalers = (WebPRescaler*)WEBP_ALIGN((const uint8_t*)work + tmp_size);
+ p->scaler_y = &scalers[0];
+ p->scaler_u = &scalers[1];
+ p->scaler_v = &scalers[2];
+ p->scaler_a = has_alpha ? &scalers[3] : NULL;
+
+ WebPRescalerInit(p->scaler_y, io->mb_w, io->mb_h,
buf->y, out_width, out_height, buf->y_stride, 1,
work);
- WebPRescalerInit(&p->scaler_u, uv_in_width, uv_in_height,
+ WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
buf->u, uv_out_width, uv_out_height, buf->u_stride, 1,
work + work_size);
- WebPRescalerInit(&p->scaler_v, uv_in_width, uv_in_height,
+ WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
buf->v, uv_out_width, uv_out_height, buf->v_stride, 1,
work + work_size + uv_work_size);
p->emit = EmitRescaledYUV;
if (has_alpha) {
- WebPRescalerInit(&p->scaler_a, io->mb_w, io->mb_h,
+ WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
buf->a, out_width, out_height, buf->a_stride, 1,
work + work_size + 2 * uv_work_size);
p->emit_alpha = EmitRescaledAlphaYUV;
@@ -349,15 +359,15 @@ static int ExportRGB(WebPDecParams* const p, int y_pos) {
int num_lines_out = 0;
// For RGB rescaling, because of the YUV420, current scan position
// U/V can be +1/-1 line from the Y one. Hence the double test.
- while (WebPRescalerHasPendingOutput(&p->scaler_y) &&
- WebPRescalerHasPendingOutput(&p->scaler_u)) {
+ while (WebPRescalerHasPendingOutput(p->scaler_y) &&
+ WebPRescalerHasPendingOutput(p->scaler_u)) {
assert(y_pos + num_lines_out < p->output->height);
- assert(p->scaler_u.y_accum == p->scaler_v.y_accum);
- WebPRescalerExportRow(&p->scaler_y);
- WebPRescalerExportRow(&p->scaler_u);
- WebPRescalerExportRow(&p->scaler_v);
- convert(p->scaler_y.dst, p->scaler_u.dst, p->scaler_v.dst,
- dst, p->scaler_y.dst_width);
+ assert(p->scaler_u->y_accum == p->scaler_v->y_accum);
+ WebPRescalerExportRow(p->scaler_y);
+ WebPRescalerExportRow(p->scaler_u);
+ WebPRescalerExportRow(p->scaler_v);
+ convert(p->scaler_y->dst, p->scaler_u->dst, p->scaler_v->dst,
+ dst, p->scaler_y->dst_width);
dst += buf->stride;
++num_lines_out;
}
@@ -371,15 +381,15 @@ static int EmitRescaledRGB(const VP8Io* const io, WebPDecParams* const p) {
int num_lines_out = 0;
while (j < mb_h) {
const int y_lines_in =
- WebPRescalerImport(&p->scaler_y, mb_h - j,
+ WebPRescalerImport(p->scaler_y, mb_h - j,
io->y + j * io->y_stride, io->y_stride);
j += y_lines_in;
- if (WebPRescaleNeededLines(&p->scaler_u, uv_mb_h - uv_j)) {
+ if (WebPRescaleNeededLines(p->scaler_u, uv_mb_h - uv_j)) {
const int u_lines_in =
- WebPRescalerImport(&p->scaler_u, uv_mb_h - uv_j,
+ WebPRescalerImport(p->scaler_u, uv_mb_h - uv_j,
io->u + uv_j * io->uv_stride, io->uv_stride);
const int v_lines_in =
- WebPRescalerImport(&p->scaler_v, uv_mb_h - uv_j,
+ WebPRescalerImport(p->scaler_v, uv_mb_h - uv_j,
io->v + uv_j * io->uv_stride, io->uv_stride);
(void)v_lines_in; // remove a gcc warning
assert(u_lines_in == v_lines_in);
@@ -400,13 +410,13 @@ static int ExportAlpha(WebPDecParams* const p, int y_pos, int max_lines_out) {
int num_lines_out = 0;
const int is_premult_alpha = WebPIsPremultipliedMode(colorspace);
uint32_t non_opaque = 0;
- const int width = p->scaler_a.dst_width;
+ const int width = p->scaler_a->dst_width;
- while (WebPRescalerHasPendingOutput(&p->scaler_a) &&
+ while (WebPRescalerHasPendingOutput(p->scaler_a) &&
num_lines_out < max_lines_out) {
assert(y_pos + num_lines_out < p->output->height);
- WebPRescalerExportRow(&p->scaler_a);
- non_opaque |= WebPDispatchAlpha(p->scaler_a.dst, 0, width, 1, dst, 0);
+ WebPRescalerExportRow(p->scaler_a);
+ non_opaque |= WebPDispatchAlpha(p->scaler_a->dst, 0, width, 1, dst, 0);
dst += buf->stride;
++num_lines_out;
}
@@ -428,18 +438,18 @@ static int ExportAlphaRGBA4444(WebPDecParams* const p, int y_pos,
#endif
int num_lines_out = 0;
const WEBP_CSP_MODE colorspace = p->output->colorspace;
- const int width = p->scaler_a.dst_width;
+ const int width = p->scaler_a->dst_width;
const int is_premult_alpha = WebPIsPremultipliedMode(colorspace);
uint32_t alpha_mask = 0x0f;
- while (WebPRescalerHasPendingOutput(&p->scaler_a) &&
+ while (WebPRescalerHasPendingOutput(p->scaler_a) &&
num_lines_out < max_lines_out) {
int i;
assert(y_pos + num_lines_out < p->output->height);
- WebPRescalerExportRow(&p->scaler_a);
+ WebPRescalerExportRow(p->scaler_a);
for (i = 0; i < width; ++i) {
// Fill in the alpha value (converted to 4 bits).
- const uint32_t alpha_value = p->scaler_a.dst[i] >> 4;
+ const uint32_t alpha_value = p->scaler_a->dst[i] >> 4;
alpha_dst[2 * i] = (alpha_dst[2 * i] & 0xf0) | alpha_value;
alpha_mask &= alpha_value;
}
@@ -455,7 +465,7 @@ static int ExportAlphaRGBA4444(WebPDecParams* const p, int y_pos,
static int EmitRescaledAlphaRGB(const VP8Io* const io, WebPDecParams* const p,
int expected_num_out_lines) {
if (io->a != NULL) {
- WebPRescaler* const scaler = &p->scaler_a;
+ WebPRescaler* const scaler = p->scaler_a;
int lines_left = expected_num_out_lines;
const int y_end = p->last_y + lines_left;
while (lines_left > 0) {
@@ -477,7 +487,9 @@ static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
const size_t work_size = 2 * out_width; // scratch memory for one rescaler
rescaler_t* work; // rescalers work area
uint8_t* tmp; // tmp storage for scaled YUV444 samples before RGB conversion
- size_t tmp_size1, tmp_size2, total_size;
+ size_t tmp_size1, tmp_size2, total_size, rescaler_size;
+ WebPRescaler* scalers;
+ const int num_rescalers = has_alpha ? 4 : 3;
tmp_size1 = 3 * work_size;
tmp_size2 = 3 * out_width;
@@ -486,26 +498,35 @@ static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
tmp_size2 += out_width;
}
total_size = tmp_size1 * sizeof(*work) + tmp_size2 * sizeof(*tmp);
- p->memory = WebPSafeMalloc(1ULL, total_size);
+ rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
+
+ p->memory = WebPSafeMalloc(1ULL, total_size + rescaler_size);
if (p->memory == NULL) {
return 0; // memory error
}
work = (rescaler_t*)p->memory;
tmp = (uint8_t*)(work + tmp_size1);
- WebPRescalerInit(&p->scaler_y, io->mb_w, io->mb_h,
+
+ scalers = (WebPRescaler*)WEBP_ALIGN((const uint8_t*)work + total_size);
+ p->scaler_y = &scalers[0];
+ p->scaler_u = &scalers[1];
+ p->scaler_v = &scalers[2];
+ p->scaler_a = has_alpha ? &scalers[3] : NULL;
+
+ WebPRescalerInit(p->scaler_y, io->mb_w, io->mb_h,
tmp + 0 * out_width, out_width, out_height, 0, 1,
work + 0 * work_size);
- WebPRescalerInit(&p->scaler_u, uv_in_width, uv_in_height,
+ WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
tmp + 1 * out_width, out_width, out_height, 0, 1,
work + 1 * work_size);
- WebPRescalerInit(&p->scaler_v, uv_in_width, uv_in_height,
+ WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
tmp + 2 * out_width, out_width, out_height, 0, 1,
work + 2 * work_size);
p->emit = EmitRescaledRGB;
WebPInitYUV444Converters();
if (has_alpha) {
- WebPRescalerInit(&p->scaler_a, io->mb_w, io->mb_h,
+ WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
tmp + 3 * out_width, out_width, out_height, 0, 1,
work + 3 * work_size);
p->emit_alpha = EmitRescaledAlphaRGB;
diff --git a/thirdparty/libwebp/dec/quant.c b/thirdparty/libwebp/dec/quant_dec.c
index 5b648f942c..14e3198946 100644
--- a/thirdparty/libwebp/dec/quant.c
+++ b/thirdparty/libwebp/dec/quant_dec.c
@@ -11,7 +11,7 @@
//
// Author: Skal (pascal.massimino@gmail.com)
-#include "./vp8i.h"
+#include "./vp8i_dec.h"
static WEBP_INLINE int clip(int v, int M) {
return v < 0 ? 0 : v > M ? M : v;
diff --git a/thirdparty/libwebp/dec/tree.c b/thirdparty/libwebp/dec/tree_dec.c
index c2007ea733..9e805f60f3 100644
--- a/thirdparty/libwebp/dec/tree.c
+++ b/thirdparty/libwebp/dec/tree_dec.c
@@ -11,10 +11,13 @@
//
// Author: Skal (pascal.massimino@gmail.com)
-#include "./vp8i.h"
-#include "../utils/bit_reader_inl.h"
+#include "./vp8i_dec.h"
+#include "../utils/bit_reader_inl_utils.h"
+#if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__)
+// using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then.
#define USE_GENERIC_TREE
+#endif
#ifdef USE_GENERIC_TREE
static const int8_t kYModesIntra4[18] = {
diff --git a/thirdparty/libwebp/dec/vp8.c b/thirdparty/libwebp/dec/vp8_dec.c
index 336680c38c..fad8d9cf35 100644
--- a/thirdparty/libwebp/dec/vp8.c
+++ b/thirdparty/libwebp/dec/vp8_dec.c
@@ -13,11 +13,11 @@
#include <stdlib.h>
-#include "./alphai.h"
-#include "./vp8i.h"
-#include "./vp8li.h"
-#include "./webpi.h"
-#include "../utils/bit_reader_inl.h"
+#include "./alphai_dec.h"
+#include "./vp8i_dec.h"
+#include "./vp8li_dec.h"
+#include "./webpi_dec.h"
+#include "../utils/bit_reader_inl_utils.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
@@ -27,6 +27,16 @@ int WebPGetDecoderVersion(void) {
}
//------------------------------------------------------------------------------
+// Signature and pointer-to-function for GetCoeffs() variants below.
+
+typedef int (*GetCoeffsFunc)(VP8BitReader* const br,
+ const VP8BandProbas* const prob[],
+ int ctx, const quant_t dq, int n, int16_t* out);
+static volatile GetCoeffsFunc GetCoeffs = NULL;
+
+static void InitGetCoeffs(void);
+
+//------------------------------------------------------------------------------
// VP8Decoder
static void SetOk(VP8Decoder* const dec) {
@@ -51,6 +61,7 @@ VP8Decoder* VP8New(void) {
WebPGetWorkerInterface()->Init(&dec->worker_);
dec->ready_ = 0;
dec->num_parts_minus_one_ = 0;
+ InitGetCoeffs();
}
return dec;
}
@@ -273,12 +284,14 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
frm_hdr->profile_ = (bits >> 1) & 7;
frm_hdr->show_ = (bits >> 4) & 1;
frm_hdr->partition_length_ = (bits >> 5);
- if (frm_hdr->profile_ > 3)
+ if (frm_hdr->profile_ > 3) {
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
"Incorrect keyframe parameters.");
- if (!frm_hdr->show_)
+ }
+ if (!frm_hdr->show_) {
return VP8SetError(dec, VP8_STATUS_UNSUPPORTED_FEATURE,
"Frame not displayable.");
+ }
buf += 3;
buf_size -= 3;
}
@@ -420,8 +433,9 @@ static int GetLargeValue(VP8BitReader* const br, const uint8_t* const p) {
}
// Returns the position of the last non-zero coeff plus one
-static int GetCoeffs(VP8BitReader* const br, const VP8BandProbas* const prob[],
- int ctx, const quant_t dq, int n, int16_t* out) {
+static int GetCoeffsFast(VP8BitReader* const br,
+ const VP8BandProbas* const prob[],
+ int ctx, const quant_t dq, int n, int16_t* out) {
const uint8_t* p = prob[n]->probas_[ctx];
for (; n < 16; ++n) {
if (!VP8GetBit(br, p[0])) {
@@ -447,6 +461,46 @@ static int GetCoeffs(VP8BitReader* const br, const VP8BandProbas* const prob[],
return 16;
}
+// This version of GetCoeffs() uses VP8GetBitAlt() which is an alternate version
+// of VP8GetBitAlt() targeting specific platforms.
+static int GetCoeffsAlt(VP8BitReader* const br,
+ const VP8BandProbas* const prob[],
+ int ctx, const quant_t dq, int n, int16_t* out) {
+ const uint8_t* p = prob[n]->probas_[ctx];
+ for (; n < 16; ++n) {
+ if (!VP8GetBitAlt(br, p[0])) {
+ return n; // previous coeff was last non-zero coeff
+ }
+ while (!VP8GetBitAlt(br, p[1])) { // sequence of zero coeffs
+ p = prob[++n]->probas_[0];
+ if (n == 16) return 16;
+ }
+ { // non zero coeff
+ const VP8ProbaArray* const p_ctx = &prob[n + 1]->probas_[0];
+ int v;
+ if (!VP8GetBitAlt(br, p[2])) {
+ v = 1;
+ p = p_ctx[1];
+ } else {
+ v = GetLargeValue(br, p);
+ p = p_ctx[2];
+ }
+ out[kZigzag[n]] = VP8GetSigned(br, v) * dq[n > 0];
+ }
+ }
+ return 16;
+}
+
+WEBP_TSAN_IGNORE_FUNCTION static void InitGetCoeffs(void) {
+ if (GetCoeffs == NULL) {
+ if (VP8GetCPUInfo != NULL && VP8GetCPUInfo(kSlowSSSE3)) {
+ GetCoeffs = GetCoeffsAlt;
+ } else {
+ GetCoeffs = GetCoeffsFast;
+ }
+ }
+}
+
static WEBP_INLINE uint32_t NzCodeBits(uint32_t nz_coeffs, int nz, int dc_nz) {
nz_coeffs <<= 2;
nz_coeffs |= (nz > 3) ? 3 : (nz > 1) ? 2 : dc_nz;
diff --git a/thirdparty/libwebp/dec/decode_vp8.h b/thirdparty/libwebp/dec/vp8_dec.h
index b9337bbec0..b9337bbec0 100644
--- a/thirdparty/libwebp/dec/decode_vp8.h
+++ b/thirdparty/libwebp/dec/vp8_dec.h
diff --git a/thirdparty/libwebp/dec/vp8i.h b/thirdparty/libwebp/dec/vp8i_dec.h
index 313d8a7b94..555853e8f8 100644
--- a/thirdparty/libwebp/dec/vp8i.h
+++ b/thirdparty/libwebp/dec/vp8i_dec.h
@@ -15,11 +15,11 @@
#define WEBP_DEC_VP8I_H_
#include <string.h> // for memcpy()
-#include "./common.h"
-#include "./vp8li.h"
-#include "../utils/bit_reader.h"
-#include "../utils/random.h"
-#include "../utils/thread.h"
+#include "./common_dec.h"
+#include "./vp8li_dec.h"
+#include "../utils/bit_reader_utils.h"
+#include "../utils/random_utils.h"
+#include "../utils/thread_utils.h"
#include "../dsp/dsp.h"
#ifdef __cplusplus
@@ -31,8 +31,8 @@ extern "C" {
// version numbers
#define DEC_MAJ_VERSION 0
-#define DEC_MIN_VERSION 5
-#define DEC_REV_VERSION 2
+#define DEC_MIN_VERSION 6
+#define DEC_REV_VERSION 0
// YUV-cache parameters. Cache is 32-bytes wide (= one cacheline).
// Constraints are: We need to store one 16x16 block of luma samples (y),
diff --git a/thirdparty/libwebp/dec/vp8l.c b/thirdparty/libwebp/dec/vp8l_dec.c
index cb2e3176b6..ef359a91f0 100644
--- a/thirdparty/libwebp/dec/vp8l.c
+++ b/thirdparty/libwebp/dec/vp8l_dec.c
@@ -14,13 +14,14 @@
#include <stdlib.h>
-#include "./alphai.h"
-#include "./vp8li.h"
+#include "./alphai_dec.h"
+#include "./vp8li_dec.h"
#include "../dsp/dsp.h"
#include "../dsp/lossless.h"
+#include "../dsp/lossless_common.h"
#include "../dsp/yuv.h"
-#include "../utils/endian_inl.h"
-#include "../utils/huffman.h"
+#include "../utils/endian_inl_utils.h"
+#include "../utils/huffman_utils.h"
#include "../utils/utils.h"
#define NUM_ARGB_CACHE_ROWS 16
@@ -547,11 +548,14 @@ static int EmitRescaledRowsRGBA(const VP8LDecoder* const dec,
uint8_t* const row_out = out + num_lines_out * out_stride;
const int lines_left = mb_h - num_lines_in;
const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left);
+ int lines_imported;
assert(needed_lines > 0 && needed_lines <= lines_left);
WebPMultARGBRows(row_in, in_stride,
dec->rescaler->src_width, needed_lines, 0);
- WebPRescalerImport(dec->rescaler, lines_left, row_in, in_stride);
- num_lines_in += needed_lines;
+ lines_imported =
+ WebPRescalerImport(dec->rescaler, lines_left, row_in, in_stride);
+ assert(lines_imported == needed_lines);
+ num_lines_in += lines_imported;
num_lines_out += Export(dec->rescaler, colorspace, out_stride, row_out);
}
return num_lines_out;
@@ -623,9 +627,12 @@ static int EmitRescaledRowsYUVA(const VP8LDecoder* const dec,
while (num_lines_in < mb_h) {
const int lines_left = mb_h - num_lines_in;
const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left);
+ int lines_imported;
WebPMultARGBRows(in, in_stride, dec->rescaler->src_width, needed_lines, 0);
- WebPRescalerImport(dec->rescaler, lines_left, in, in_stride);
- num_lines_in += needed_lines;
+ lines_imported =
+ WebPRescalerImport(dec->rescaler, lines_left, in, in_stride);
+ assert(lines_imported == needed_lines);
+ num_lines_in += lines_imported;
in += needed_lines * in_stride;
y_pos += ExportYUVA(dec, y_pos);
}
@@ -705,13 +712,15 @@ static void ApplyInverseTransforms(VP8LDecoder* const dec, int num_rows,
uint32_t* const rows_out = dec->argb_cache_;
// Inverse transforms.
- // TODO: most transforms only need to operate on the cropped region only.
- memcpy(rows_out, rows_in, cache_pixs * sizeof(*rows_out));
while (n-- > 0) {
VP8LTransform* const transform = &dec->transforms_[n];
VP8LInverseTransform(transform, start_row, end_row, rows_in, rows_out);
rows_in = rows_out;
}
+ if (rows_in != rows_out) {
+ // No transform called, hence just copy.
+ memcpy(rows_out, rows_in, cache_pixs * sizeof(*rows_out));
+ }
}
// Processes (transforms, scales & color-converts) the rows decoded after the
@@ -1210,8 +1219,9 @@ static int ExpandColorMap(int num_colors, VP8LTransform* const transform) {
// Equivalent to AddPixelEq(), on a byte-basis.
new_data[i] = (data[i] + new_data[i - 4]) & 0xff;
}
- for (; i < 4 * final_num_colors; ++i)
+ for (; i < 4 * final_num_colors; ++i) {
new_data[i] = 0; // black tail.
+ }
WebPSafeFree(transform->data_);
transform->data_ = new_color_map;
}
@@ -1482,9 +1492,8 @@ static void ExtractAlphaRows(VP8LDecoder* const dec, int last_row) {
const int cache_pixs = width * num_rows_to_process;
uint8_t* const dst = output + width * cur_row;
const uint32_t* const src = dec->argb_cache_;
- int i;
ApplyInverseTransforms(dec, num_rows_to_process, in);
- for (i = 0; i < cache_pixs; ++i) dst[i] = (src[i] >> 8) & 0xff;
+ WebPExtractGreen(src, dst, cache_pixs);
AlphaApplyFilter(alph_dec,
cur_row, cur_row + num_rows_to_process, dst, width);
num_rows -= num_rows_to_process;
@@ -1552,6 +1561,8 @@ int VP8LDecodeAlphaImageStream(ALPHDecoder* const alph_dec, int last_row) {
return 1; // done
}
+ if (!alph_dec->use_8b_decode_) WebPInitAlphaProcessing();
+
// Decode (with special row processing).
return alph_dec->use_8b_decode_ ?
DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_,
diff --git a/thirdparty/libwebp/dec/vp8li.h b/thirdparty/libwebp/dec/vp8li_dec.h
index 9313bdc0af..097a9d0589 100644
--- a/thirdparty/libwebp/dec/vp8li.h
+++ b/thirdparty/libwebp/dec/vp8li_dec.h
@@ -16,10 +16,10 @@
#define WEBP_DEC_VP8LI_H_
#include <string.h> // for memcpy()
-#include "./webpi.h"
-#include "../utils/bit_reader.h"
-#include "../utils/color_cache.h"
-#include "../utils/huffman.h"
+#include "./webpi_dec.h"
+#include "../utils/bit_reader_utils.h"
+#include "../utils/color_cache_utils.h"
+#include "../utils/huffman_utils.h"
#ifdef __cplusplus
extern "C" {
diff --git a/thirdparty/libwebp/dec/webp.c b/thirdparty/libwebp/dec/webp_dec.c
index d0b912f02f..a8e9c2c510 100644
--- a/thirdparty/libwebp/dec/webp.c
+++ b/thirdparty/libwebp/dec/webp_dec.c
@@ -13,9 +13,9 @@
#include <stdlib.h>
-#include "./vp8i.h"
-#include "./vp8li.h"
-#include "./webpi.h"
+#include "./vp8i_dec.h"
+#include "./vp8li_dec.h"
+#include "./webpi_dec.h"
#include "../utils/utils.h"
#include "../webp/mux_types.h" // ALPHA_FLAG
@@ -39,8 +39,8 @@
// 20..23 VP8X flags bit-map corresponding to the chunk-types present.
// 24..26 Width of the Canvas Image.
// 27..29 Height of the Canvas Image.
-// There can be extra chunks after the "VP8X" chunk (ICCP, FRGM, ANMF, VP8,
-// VP8L, XMP, EXIF ...)
+// There can be extra chunks after the "VP8X" chunk (ICCP, ANMF, VP8, VP8L,
+// XMP, EXIF ...)
// All sizes are in little-endian order.
// Note: chunk data size must be padded to multiple of 2 when written.
@@ -289,7 +289,6 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
int found_riff = 0;
int found_vp8x = 0;
int animation_present = 0;
- int fragments_present = 0;
const int have_all_data = (headers != NULL) ? headers->have_all_data : 0;
VP8StatusCode status;
@@ -318,7 +317,6 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
return status; // Wrong VP8X / insufficient data.
}
animation_present = !!(flags & ANIMATION_FLAG);
- fragments_present = !!(flags & FRAGMENTS_FLAG);
if (!found_riff && found_vp8x) {
// Note: This restriction may be removed in the future, if it becomes
// necessary to send VP8X chunk to the decoder.
@@ -330,8 +328,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
image_width = canvas_width;
image_height = canvas_height;
- if (found_vp8x && (animation_present || fragments_present) &&
- headers == NULL) {
+ if (found_vp8x && animation_present && headers == NULL) {
status = VP8_STATUS_OK;
goto ReturnWidthHeight; // Just return features from VP8X header.
}
@@ -362,7 +359,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
return VP8_STATUS_BITSTREAM_ERROR;
}
- if (format != NULL && !(animation_present || fragments_present)) {
+ if (format != NULL && !animation_present) {
*format = hdrs.is_lossless ? 2 : 1;
}
diff --git a/thirdparty/libwebp/dec/webpi.h b/thirdparty/libwebp/dec/webpi_dec.h
index 991b194c22..696abc1958 100644
--- a/thirdparty/libwebp/dec/webpi.h
+++ b/thirdparty/libwebp/dec/webpi_dec.h
@@ -18,8 +18,8 @@
extern "C" {
#endif
-#include "../utils/rescaler.h"
-#include "./decode_vp8.h"
+#include "../utils/rescaler_utils.h"
+#include "./vp8_dec.h"
//------------------------------------------------------------------------------
// WebPDecParams: Decoding output parameters. Transient internal object.
@@ -38,27 +38,18 @@ struct WebPDecParams {
int last_y; // coordinate of the line that was last output
const WebPDecoderOptions* options; // if not NULL, use alt decoding features
- // rescalers
- WebPRescaler scaler_y, scaler_u, scaler_v, scaler_a;
+
+ WebPRescaler* scaler_y, *scaler_u, *scaler_v, *scaler_a; // rescalers
void* memory; // overall scratch memory for the output work.
OutputFunc emit; // output RGB or YUV samples
OutputAlphaFunc emit_alpha; // output alpha channel
OutputRowFunc emit_alpha_row; // output one line of rescaled alpha values
-
- WebPDecBuffer* final_output; // In case the user supplied a slow-memory
- // output, we decode image in temporary buffer
- // (this::output) and copy it here.
- WebPDecBuffer tmp_buffer; // this::output will point to this one in case
- // of slow memory.
};
// Should be called first, before any use of the WebPDecParams object.
void WebPResetDecParams(WebPDecParams* const params);
-// Delete all memory (after an error occurred, for instance)
-void WebPFreeDecParams(WebPDecParams* const params);
-
//------------------------------------------------------------------------------
// Header parsing helpers
diff --git a/thirdparty/libwebp/demux/demux.c b/thirdparty/libwebp/demux/demux.c
index 1cb9bd5780..100eab8c01 100644
--- a/thirdparty/libwebp/demux/demux.c
+++ b/thirdparty/libwebp/demux/demux.c
@@ -25,7 +25,7 @@
#define DMUX_MAJ_VERSION 0
#define DMUX_MIN_VERSION 3
-#define DMUX_REV_VERSION 1
+#define DMUX_REV_VERSION 2
typedef struct {
size_t start_; // start location of the data
@@ -590,7 +590,6 @@ static int CheckFrameBounds(const Frame* const frame, int exact,
static int IsValidExtendedFormat(const WebPDemuxer* const dmux) {
const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG);
- const int is_fragmented = !!(dmux->feature_flags_ & FRAGMENTS_FLAG);
const Frame* f = dmux->frames_;
if (dmux->state_ == WEBP_DEMUX_PARSING_HEADER) return 1;
@@ -598,7 +597,7 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) {
if (dmux->canvas_width_ <= 0 || dmux->canvas_height_ <= 0) return 0;
if (dmux->loop_count_ < 0) return 0;
if (dmux->state_ == WEBP_DEMUX_DONE && dmux->frames_ == NULL) return 0;
- if (is_fragmented) return 0;
+ if (dmux->feature_flags_ & ~ALL_VALID_FLAGS) return 0; // invalid bitstream
while (f != NULL) {
const int cur_frame_set = f->frame_num_;
diff --git a/thirdparty/libwebp/dsp/alpha_processing.c b/thirdparty/libwebp/dsp/alpha_processing.c
index 1716cace8d..4b60e092be 100644
--- a/thirdparty/libwebp/dsp/alpha_processing.c
+++ b/thirdparty/libwebp/dsp/alpha_processing.c
@@ -284,9 +284,9 @@ static void ApplyAlphaMultiply_16b(uint8_t* rgba4444,
#endif
}
-static int DispatchAlpha(const uint8_t* alpha, int alpha_stride,
- int width, int height,
- uint8_t* dst, int dst_stride) {
+static int DispatchAlpha_C(const uint8_t* alpha, int alpha_stride,
+ int width, int height,
+ uint8_t* dst, int dst_stride) {
uint32_t alpha_mask = 0xff;
int i, j;
@@ -303,9 +303,9 @@ static int DispatchAlpha(const uint8_t* alpha, int alpha_stride,
return (alpha_mask != 0xff);
}
-static void DispatchAlphaToGreen(const uint8_t* alpha, int alpha_stride,
- int width, int height,
- uint32_t* dst, int dst_stride) {
+static void DispatchAlphaToGreen_C(const uint8_t* alpha, int alpha_stride,
+ int width, int height,
+ uint32_t* dst, int dst_stride) {
int i, j;
for (j = 0; j < height; ++j) {
for (i = 0; i < width; ++i) {
@@ -316,9 +316,9 @@ static void DispatchAlphaToGreen(const uint8_t* alpha, int alpha_stride,
}
}
-static int ExtractAlpha(const uint8_t* argb, int argb_stride,
- int width, int height,
- uint8_t* alpha, int alpha_stride) {
+static int ExtractAlpha_C(const uint8_t* argb, int argb_stride,
+ int width, int height,
+ uint8_t* alpha, int alpha_stride) {
uint8_t alpha_mask = 0xff;
int i, j;
@@ -334,11 +334,17 @@ static int ExtractAlpha(const uint8_t* argb, int argb_stride,
return (alpha_mask == 0xff);
}
+static void ExtractGreen_C(const uint32_t* argb, uint8_t* alpha, int size) {
+ int i;
+ for (i = 0; i < size; ++i) alpha[i] = argb[i] >> 8;
+}
+
void (*WebPApplyAlphaMultiply)(uint8_t*, int, int, int, int);
void (*WebPApplyAlphaMultiply4444)(uint8_t*, int, int, int);
int (*WebPDispatchAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
void (*WebPDispatchAlphaToGreen)(const uint8_t*, int, int, int, uint32_t*, int);
int (*WebPExtractAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
+void (*WebPExtractGreen)(const uint32_t* argb, uint8_t* alpha, int size);
//------------------------------------------------------------------------------
// Init function
@@ -346,6 +352,7 @@ int (*WebPExtractAlpha)(const uint8_t*, int, int, int, uint8_t*, int);
extern void WebPInitAlphaProcessingMIPSdspR2(void);
extern void WebPInitAlphaProcessingSSE2(void);
extern void WebPInitAlphaProcessingSSE41(void);
+extern void WebPInitAlphaProcessingNEON(void);
static volatile VP8CPUInfo alpha_processing_last_cpuinfo_used =
(VP8CPUInfo)&alpha_processing_last_cpuinfo_used;
@@ -357,9 +364,11 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void) {
WebPMultRow = WebPMultRowC;
WebPApplyAlphaMultiply = ApplyAlphaMultiply;
WebPApplyAlphaMultiply4444 = ApplyAlphaMultiply_16b;
- WebPDispatchAlpha = DispatchAlpha;
- WebPDispatchAlphaToGreen = DispatchAlphaToGreen;
- WebPExtractAlpha = ExtractAlpha;
+
+ WebPDispatchAlpha = DispatchAlpha_C;
+ WebPDispatchAlphaToGreen = DispatchAlphaToGreen_C;
+ WebPExtractAlpha = ExtractAlpha_C;
+ WebPExtractGreen = ExtractGreen_C;
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) {
@@ -373,6 +382,11 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void) {
#endif
}
#endif
+#if defined(WEBP_USE_NEON)
+ if (VP8GetCPUInfo(kNEON)) {
+ WebPInitAlphaProcessingNEON();
+ }
+#endif
#if defined(WEBP_USE_MIPS_DSP_R2)
if (VP8GetCPUInfo(kMIPSdspR2)) {
WebPInitAlphaProcessingMIPSdspR2();
diff --git a/thirdparty/libwebp/dsp/alpha_processing_neon.c b/thirdparty/libwebp/dsp/alpha_processing_neon.c
new file mode 100644
index 0000000000..606a401cf7
--- /dev/null
+++ b/thirdparty/libwebp/dsp/alpha_processing_neon.c
@@ -0,0 +1,191 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// Utilities for processing transparent channel, NEON version.
+//
+// Author: Skal (pascal.massimino@gmail.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_NEON)
+
+#include "./neon.h"
+
+//------------------------------------------------------------------------------
+
+#define MULTIPLIER(a) ((a) * 0x8081)
+#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
+
+#define MULTIPLY_BY_ALPHA(V, ALPHA, OTHER) do { \
+ const uint8x8_t alpha = (V).val[(ALPHA)]; \
+ const uint16x8_t r1 = vmull_u8((V).val[1], alpha); \
+ const uint16x8_t g1 = vmull_u8((V).val[2], alpha); \
+ const uint16x8_t b1 = vmull_u8((V).val[(OTHER)], alpha); \
+ /* we use: v / 255 = (v + 1 + (v >> 8)) >> 8 */ \
+ const uint16x8_t r2 = vsraq_n_u16(r1, r1, 8); \
+ const uint16x8_t g2 = vsraq_n_u16(g1, g1, 8); \
+ const uint16x8_t b2 = vsraq_n_u16(b1, b1, 8); \
+ const uint16x8_t r3 = vaddq_u16(r2, kOne); \
+ const uint16x8_t g3 = vaddq_u16(g2, kOne); \
+ const uint16x8_t b3 = vaddq_u16(b2, kOne); \
+ (V).val[1] = vshrn_n_u16(r3, 8); \
+ (V).val[2] = vshrn_n_u16(g3, 8); \
+ (V).val[(OTHER)] = vshrn_n_u16(b3, 8); \
+} while (0)
+
+static void ApplyAlphaMultiply_NEON(uint8_t* rgba, int alpha_first,
+ int w, int h, int stride) {
+ const uint16x8_t kOne = vdupq_n_u16(1u);
+ while (h-- > 0) {
+ uint32_t* const rgbx = (uint32_t*)rgba;
+ int i = 0;
+ if (alpha_first) {
+ for (; i + 8 <= w; i += 8) {
+ // load aaaa...|rrrr...|gggg...|bbbb...
+ uint8x8x4_t RGBX = vld4_u8((const uint8_t*)(rgbx + i));
+ MULTIPLY_BY_ALPHA(RGBX, 0, 3);
+ vst4_u8((uint8_t*)(rgbx + i), RGBX);
+ }
+ } else {
+ for (; i + 8 <= w; i += 8) {
+ uint8x8x4_t RGBX = vld4_u8((const uint8_t*)(rgbx + i));
+ MULTIPLY_BY_ALPHA(RGBX, 3, 0);
+ vst4_u8((uint8_t*)(rgbx + i), RGBX);
+ }
+ }
+ // Finish with left-overs.
+ for (; i < w; ++i) {
+ uint8_t* const rgb = rgba + (alpha_first ? 1 : 0);
+ const uint8_t* const alpha = rgba + (alpha_first ? 0 : 3);
+ const uint32_t a = alpha[4 * i];
+ if (a != 0xff) {
+ const uint32_t mult = MULTIPLIER(a);
+ rgb[4 * i + 0] = PREMULTIPLY(rgb[4 * i + 0], mult);
+ rgb[4 * i + 1] = PREMULTIPLY(rgb[4 * i + 1], mult);
+ rgb[4 * i + 2] = PREMULTIPLY(rgb[4 * i + 2], mult);
+ }
+ }
+ rgba += stride;
+ }
+}
+#undef MULTIPLY_BY_ALPHA
+#undef MULTIPLIER
+#undef PREMULTIPLY
+
+//------------------------------------------------------------------------------
+
+static int DispatchAlpha_NEON(const uint8_t* alpha, int alpha_stride,
+ int width, int height,
+ uint8_t* dst, int dst_stride) {
+ uint32_t alpha_mask = 0xffffffffu;
+ uint8x8_t mask8 = vdup_n_u8(0xff);
+ uint32_t tmp[2];
+ int i, j;
+ for (j = 0; j < height; ++j) {
+ // We don't know if alpha is first or last in dst[] (depending on rgbA/Argb
+ // mode). So we must be sure dst[4*i + 8 - 1] is writable for the store.
+ // Hence the test with 'width - 1' instead of just 'width'.
+ for (i = 0; i + 8 <= width - 1; i += 8) {
+ uint8x8x4_t rgbX = vld4_u8((const uint8_t*)(dst + 4 * i));
+ const uint8x8_t alphas = vld1_u8(alpha + i);
+ rgbX.val[0] = alphas;
+ vst4_u8((uint8_t*)(dst + 4 * i), rgbX);
+ mask8 = vand_u8(mask8, alphas);
+ }
+ for (; i < width; ++i) {
+ const uint32_t alpha_value = alpha[i];
+ dst[4 * i] = alpha_value;
+ alpha_mask &= alpha_value;
+ }
+ alpha += alpha_stride;
+ dst += dst_stride;
+ }
+ vst1_u8((uint8_t*)tmp, mask8);
+ alpha_mask &= tmp[0];
+ alpha_mask &= tmp[1];
+ return (alpha_mask != 0xffffffffu);
+}
+
+static void DispatchAlphaToGreen_NEON(const uint8_t* alpha, int alpha_stride,
+ int width, int height,
+ uint32_t* dst, int dst_stride) {
+ int i, j;
+ uint8x8x4_t greens; // leave A/R/B channels zero'd.
+ greens.val[0] = vdup_n_u8(0);
+ greens.val[2] = vdup_n_u8(0);
+ greens.val[3] = vdup_n_u8(0);
+ for (j = 0; j < height; ++j) {
+ for (i = 0; i + 8 <= width; i += 8) {
+ greens.val[1] = vld1_u8(alpha + i);
+ vst4_u8((uint8_t*)(dst + i), greens);
+ }
+ for (; i < width; ++i) dst[i] = alpha[i] << 8;
+ alpha += alpha_stride;
+ dst += dst_stride;
+ }
+}
+
+static int ExtractAlpha_NEON(const uint8_t* argb, int argb_stride,
+ int width, int height,
+ uint8_t* alpha, int alpha_stride) {
+ uint32_t alpha_mask = 0xffffffffu;
+ uint8x8_t mask8 = vdup_n_u8(0xff);
+ uint32_t tmp[2];
+ int i, j;
+ for (j = 0; j < height; ++j) {
+ // We don't know if alpha is first or last in dst[] (depending on rgbA/Argb
+ // mode). So we must be sure dst[4*i + 8 - 1] is writable for the store.
+ // Hence the test with 'width - 1' instead of just 'width'.
+ for (i = 0; i + 8 <= width - 1; i += 8) {
+ const uint8x8x4_t rgbX = vld4_u8((const uint8_t*)(argb + 4 * i));
+ const uint8x8_t alphas = rgbX.val[0];
+ vst1_u8((uint8_t*)(alpha + i), alphas);
+ mask8 = vand_u8(mask8, alphas);
+ }
+ for (; i < width; ++i) {
+ alpha[i] = argb[4 * i];
+ alpha_mask &= alpha[i];
+ }
+ argb += argb_stride;
+ alpha += alpha_stride;
+ }
+ vst1_u8((uint8_t*)tmp, mask8);
+ alpha_mask &= tmp[0];
+ alpha_mask &= tmp[1];
+ return (alpha_mask == 0xffffffffu);
+}
+
+static void ExtractGreen_NEON(const uint32_t* argb,
+ uint8_t* alpha, int size) {
+ int i;
+ for (i = 0; i + 16 <= size; i += 16) {
+ const uint8x16x4_t rgbX = vld4q_u8((const uint8_t*)(argb + i));
+ const uint8x16_t greens = rgbX.val[1];
+ vst1q_u8(alpha + i, greens);
+ }
+ for (; i < size; ++i) alpha[i] = (argb[i] >> 8) & 0xff;
+}
+
+//------------------------------------------------------------------------------
+
+extern void WebPInitAlphaProcessingNEON(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingNEON(void) {
+ WebPApplyAlphaMultiply = ApplyAlphaMultiply_NEON;
+ WebPDispatchAlpha = DispatchAlpha_NEON;
+ WebPDispatchAlphaToGreen = DispatchAlphaToGreen_NEON;
+ WebPExtractAlpha = ExtractAlpha_NEON;
+ WebPExtractGreen = ExtractGreen_NEON;
+}
+
+#else // !WEBP_USE_NEON
+
+WEBP_DSP_INIT_STUB(WebPInitAlphaProcessingNEON)
+
+#endif // WEBP_USE_NEON
diff --git a/thirdparty/libwebp/dsp/alpha_processing_sse2.c b/thirdparty/libwebp/dsp/alpha_processing_sse2.c
index 5acb481dcd..83dc559fac 100644
--- a/thirdparty/libwebp/dsp/alpha_processing_sse2.c
+++ b/thirdparty/libwebp/dsp/alpha_processing_sse2.c
@@ -150,46 +150,46 @@ static int ExtractAlpha(const uint8_t* argb, int argb_stride,
#define PREMULTIPLY(x, m) (((x) * (m)) >> 23)
// We can't use a 'const int' for the SHUFFLE value, because it has to be an
-// immediate in the _mm_shufflexx_epi16() instruction. We really a macro here.
-#define APPLY_ALPHA(RGBX, SHUFFLE, MASK, MULT) do { \
- const __m128i argb0 = _mm_loadl_epi64((__m128i*)&(RGBX)); \
- const __m128i argb1 = _mm_unpacklo_epi8(argb0, zero); \
- const __m128i alpha0 = _mm_and_si128(argb1, MASK); \
- const __m128i alpha1 = _mm_shufflelo_epi16(alpha0, SHUFFLE); \
- const __m128i alpha2 = _mm_shufflehi_epi16(alpha1, SHUFFLE); \
- /* alpha2 = [0 a0 a0 a0][0 a1 a1 a1] */ \
- const __m128i scale0 = _mm_mullo_epi16(alpha2, MULT); \
- const __m128i scale1 = _mm_mulhi_epu16(alpha2, MULT); \
- const __m128i argb2 = _mm_mulhi_epu16(argb1, scale0); \
- const __m128i argb3 = _mm_mullo_epi16(argb1, scale1); \
- const __m128i argb4 = _mm_adds_epu16(argb2, argb3); \
- const __m128i argb5 = _mm_srli_epi16(argb4, 7); \
- const __m128i argb6 = _mm_or_si128(argb5, alpha0); \
- const __m128i argb7 = _mm_packus_epi16(argb6, zero); \
- _mm_storel_epi64((__m128i*)&(RGBX), argb7); \
+// immediate in the _mm_shufflexx_epi16() instruction. We really need a macro.
+// We use: v / 255 = (v * 0x8081) >> 23, where v = alpha * {r,g,b} is a 16bit
+// value.
+#define APPLY_ALPHA(RGBX, SHUFFLE) do { \
+ const __m128i argb0 = _mm_loadu_si128((const __m128i*)&(RGBX)); \
+ const __m128i argb1_lo = _mm_unpacklo_epi8(argb0, zero); \
+ const __m128i argb1_hi = _mm_unpackhi_epi8(argb0, zero); \
+ const __m128i alpha0_lo = _mm_or_si128(argb1_lo, kMask); \
+ const __m128i alpha0_hi = _mm_or_si128(argb1_hi, kMask); \
+ const __m128i alpha1_lo = _mm_shufflelo_epi16(alpha0_lo, SHUFFLE); \
+ const __m128i alpha1_hi = _mm_shufflelo_epi16(alpha0_hi, SHUFFLE); \
+ const __m128i alpha2_lo = _mm_shufflehi_epi16(alpha1_lo, SHUFFLE); \
+ const __m128i alpha2_hi = _mm_shufflehi_epi16(alpha1_hi, SHUFFLE); \
+ /* alpha2 = [ff a0 a0 a0][ff a1 a1 a1] */ \
+ const __m128i A0_lo = _mm_mullo_epi16(alpha2_lo, argb1_lo); \
+ const __m128i A0_hi = _mm_mullo_epi16(alpha2_hi, argb1_hi); \
+ const __m128i A1_lo = _mm_mulhi_epu16(A0_lo, kMult); \
+ const __m128i A1_hi = _mm_mulhi_epu16(A0_hi, kMult); \
+ const __m128i A2_lo = _mm_srli_epi16(A1_lo, 7); \
+ const __m128i A2_hi = _mm_srli_epi16(A1_hi, 7); \
+ const __m128i A3 = _mm_packus_epi16(A2_lo, A2_hi); \
+ _mm_storeu_si128((__m128i*)&(RGBX), A3); \
} while (0)
-static void ApplyAlphaMultiply(uint8_t* rgba, int alpha_first,
- int w, int h, int stride) {
+static void ApplyAlphaMultiply_SSE2(uint8_t* rgba, int alpha_first,
+ int w, int h, int stride) {
const __m128i zero = _mm_setzero_si128();
- const int kSpan = 2;
- const int w2 = w & ~(kSpan - 1);
+ const __m128i kMult = _mm_set1_epi16(0x8081u);
+ const __m128i kMask = _mm_set_epi16(0, 0xff, 0xff, 0, 0, 0xff, 0xff, 0);
+ const int kSpan = 4;
while (h-- > 0) {
uint32_t* const rgbx = (uint32_t*)rgba;
int i;
if (!alpha_first) {
- const __m128i kMask = _mm_set_epi16(0xff, 0, 0, 0, 0xff, 0, 0, 0);
- const __m128i kMult =
- _mm_set_epi16(0, 0x8081, 0x8081, 0x8081, 0, 0x8081, 0x8081, 0x8081);
- for (i = 0; i < w2; i += kSpan) {
- APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(0, 3, 3, 3), kMask, kMult);
+ for (i = 0; i + kSpan <= w; i += kSpan) {
+ APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(2, 3, 3, 3));
}
} else {
- const __m128i kMask = _mm_set_epi16(0, 0, 0, 0xff, 0, 0, 0, 0xff);
- const __m128i kMult =
- _mm_set_epi16(0x8081, 0x8081, 0x8081, 0, 0x8081, 0x8081, 0x8081, 0);
- for (i = 0; i < w2; i += kSpan) {
- APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(0, 0, 0, 3), kMask, kMult);
+ for (i = 0; i + kSpan <= w; i += kSpan) {
+ APPLY_ALPHA(rgbx[i], _MM_SHUFFLE(0, 0, 0, 1));
}
}
// Finish with left-overs.
@@ -213,64 +213,51 @@ static void ApplyAlphaMultiply(uint8_t* rgba, int alpha_first,
// -----------------------------------------------------------------------------
// Apply alpha value to rows
-// We use: kINV255 = (1 << 24) / 255 = 0x010101
-// So: a * kINV255 = (a << 16) | [(a << 8) | a]
-// -> _mm_mulhi_epu16() takes care of the (a<<16) part,
-// and _mm_mullo_epu16(a * 0x0101,...) takes care of the "(a << 8) | a" one.
-
-static void MultARGBRow(uint32_t* const ptr, int width, int inverse) {
+static void MultARGBRow_SSE2(uint32_t* const ptr, int width, int inverse) {
int x = 0;
if (!inverse) {
const int kSpan = 2;
const __m128i zero = _mm_setzero_si128();
- const __m128i kRound =
- _mm_set_epi16(0, 1 << 7, 1 << 7, 1 << 7, 0, 1 << 7, 1 << 7, 1 << 7);
- const __m128i kMult =
- _mm_set_epi16(0, 0x0101, 0x0101, 0x0101, 0, 0x0101, 0x0101, 0x0101);
- const __m128i kOne64 = _mm_set_epi16(1u << 8, 0, 0, 0, 1u << 8, 0, 0, 0);
- const int w2 = width & ~(kSpan - 1);
- for (x = 0; x < w2; x += kSpan) {
- const __m128i argb0 = _mm_loadl_epi64((__m128i*)&ptr[x]);
- const __m128i argb1 = _mm_unpacklo_epi8(argb0, zero);
- const __m128i tmp0 = _mm_shufflelo_epi16(argb1, _MM_SHUFFLE(3, 3, 3, 3));
- const __m128i tmp1 = _mm_shufflehi_epi16(tmp0, _MM_SHUFFLE(3, 3, 3, 3));
- const __m128i tmp2 = _mm_srli_epi64(tmp1, 16);
- const __m128i scale0 = _mm_mullo_epi16(tmp1, kMult);
- const __m128i scale1 = _mm_or_si128(tmp2, kOne64);
- const __m128i argb2 = _mm_mulhi_epu16(argb1, scale0);
- const __m128i argb3 = _mm_mullo_epi16(argb1, scale1);
- const __m128i argb4 = _mm_adds_epu16(argb2, argb3);
- const __m128i argb5 = _mm_adds_epu16(argb4, kRound);
- const __m128i argb6 = _mm_srli_epi16(argb5, 8);
- const __m128i argb7 = _mm_packus_epi16(argb6, zero);
- _mm_storel_epi64((__m128i*)&ptr[x], argb7);
+ const __m128i k128 = _mm_set1_epi16(128);
+ const __m128i kMult = _mm_set1_epi16(0x0101);
+ const __m128i kMask = _mm_set_epi16(0, 0xff, 0, 0, 0, 0xff, 0, 0);
+ for (x = 0; x + kSpan <= width; x += kSpan) {
+ // To compute 'result = (int)(a * x / 255. + .5)', we use:
+ // tmp = a * v + 128, result = (tmp * 0x0101u) >> 16
+ const __m128i A0 = _mm_loadl_epi64((const __m128i*)&ptr[x]);
+ const __m128i A1 = _mm_unpacklo_epi8(A0, zero);
+ const __m128i A2 = _mm_or_si128(A1, kMask);
+ const __m128i A3 = _mm_shufflelo_epi16(A2, _MM_SHUFFLE(2, 3, 3, 3));
+ const __m128i A4 = _mm_shufflehi_epi16(A3, _MM_SHUFFLE(2, 3, 3, 3));
+ // here, A4 = [ff a0 a0 a0][ff a1 a1 a1]
+ const __m128i A5 = _mm_mullo_epi16(A4, A1);
+ const __m128i A6 = _mm_add_epi16(A5, k128);
+ const __m128i A7 = _mm_mulhi_epu16(A6, kMult);
+ const __m128i A10 = _mm_packus_epi16(A7, zero);
+ _mm_storel_epi64((__m128i*)&ptr[x], A10);
}
}
width -= x;
if (width > 0) WebPMultARGBRowC(ptr + x, width, inverse);
}
-static void MultRow(uint8_t* const ptr, const uint8_t* const alpha,
- int width, int inverse) {
+static void MultRow_SSE2(uint8_t* const ptr, const uint8_t* const alpha,
+ int width, int inverse) {
int x = 0;
if (!inverse) {
- const int kSpan = 8;
const __m128i zero = _mm_setzero_si128();
- const __m128i kRound = _mm_set1_epi16(1 << 7);
- const int w2 = width & ~(kSpan - 1);
- for (x = 0; x < w2; x += kSpan) {
+ const __m128i k128 = _mm_set1_epi16(128);
+ const __m128i kMult = _mm_set1_epi16(0x0101);
+ for (x = 0; x + 8 <= width; x += 8) {
const __m128i v0 = _mm_loadl_epi64((__m128i*)&ptr[x]);
+ const __m128i a0 = _mm_loadl_epi64((const __m128i*)&alpha[x]);
const __m128i v1 = _mm_unpacklo_epi8(v0, zero);
- const __m128i alpha0 = _mm_loadl_epi64((const __m128i*)&alpha[x]);
- const __m128i alpha1 = _mm_unpacklo_epi8(alpha0, zero);
- const __m128i alpha2 = _mm_unpacklo_epi8(alpha0, alpha0);
- const __m128i v2 = _mm_mulhi_epu16(v1, alpha2);
- const __m128i v3 = _mm_mullo_epi16(v1, alpha1);
- const __m128i v4 = _mm_adds_epu16(v2, v3);
- const __m128i v5 = _mm_adds_epu16(v4, kRound);
- const __m128i v6 = _mm_srli_epi16(v5, 8);
- const __m128i v7 = _mm_packus_epi16(v6, zero);
- _mm_storel_epi64((__m128i*)&ptr[x], v7);
+ const __m128i a1 = _mm_unpacklo_epi8(a0, zero);
+ const __m128i v2 = _mm_mullo_epi16(v1, a1);
+ const __m128i v3 = _mm_add_epi16(v2, k128);
+ const __m128i v4 = _mm_mulhi_epu16(v3, kMult);
+ const __m128i v5 = _mm_packus_epi16(v4, zero);
+ _mm_storel_epi64((__m128i*)&ptr[x], v5);
}
}
width -= x;
@@ -283,9 +270,9 @@ static void MultRow(uint8_t* const ptr, const uint8_t* const alpha,
extern void WebPInitAlphaProcessingSSE2(void);
WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessingSSE2(void) {
- WebPMultARGBRow = MultARGBRow;
- WebPMultRow = MultRow;
- WebPApplyAlphaMultiply = ApplyAlphaMultiply;
+ WebPMultARGBRow = MultARGBRow_SSE2;
+ WebPMultRow = MultRow_SSE2;
+ WebPApplyAlphaMultiply = ApplyAlphaMultiply_SSE2;
WebPDispatchAlpha = DispatchAlpha;
WebPDispatchAlphaToGreen = DispatchAlphaToGreen;
WebPExtractAlpha = ExtractAlpha;
diff --git a/thirdparty/libwebp/dsp/common_sse2.h b/thirdparty/libwebp/dsp/common_sse2.h
index 7cea13fb3c..995d7cf4ea 100644
--- a/thirdparty/libwebp/dsp/common_sse2.h
+++ b/thirdparty/libwebp/dsp/common_sse2.h
@@ -100,6 +100,91 @@ static WEBP_INLINE void VP8Transpose_2_4x4_16b(
// a03 a13 a23 a33 b03 b13 b23 b33
}
+//------------------------------------------------------------------------------
+// Channel mixing.
+
+// Function used several times in VP8PlanarTo24b.
+// It samples the in buffer as follows: one every two unsigned char is stored
+// at the beginning of the buffer, while the other half is stored at the end.
+#define VP8PlanarTo24bHelper(IN, OUT) \
+ do { \
+ const __m128i v_mask = _mm_set1_epi16(0x00ff); \
+ /* Take one every two upper 8b values.*/ \
+ (OUT##0) = _mm_packus_epi16(_mm_and_si128((IN##0), v_mask), \
+ _mm_and_si128((IN##1), v_mask)); \
+ (OUT##1) = _mm_packus_epi16(_mm_and_si128((IN##2), v_mask), \
+ _mm_and_si128((IN##3), v_mask)); \
+ (OUT##2) = _mm_packus_epi16(_mm_and_si128((IN##4), v_mask), \
+ _mm_and_si128((IN##5), v_mask)); \
+ /* Take one every two lower 8b values.*/ \
+ (OUT##3) = _mm_packus_epi16(_mm_srli_epi16((IN##0), 8), \
+ _mm_srli_epi16((IN##1), 8)); \
+ (OUT##4) = _mm_packus_epi16(_mm_srli_epi16((IN##2), 8), \
+ _mm_srli_epi16((IN##3), 8)); \
+ (OUT##5) = _mm_packus_epi16(_mm_srli_epi16((IN##4), 8), \
+ _mm_srli_epi16((IN##5), 8)); \
+ } while (0)
+
+// Pack the planar buffers
+// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
+// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
+static WEBP_INLINE void VP8PlanarTo24b(__m128i* const in0, __m128i* const in1,
+ __m128i* const in2, __m128i* const in3,
+ __m128i* const in4, __m128i* const in5) {
+ // The input is 6 registers of sixteen 8b but for the sake of explanation,
+ // let's take 6 registers of four 8b values.
+ // To pack, we will keep taking one every two 8b integer and move it
+ // around as follows:
+ // Input:
+ // r0r1r2r3 | r4r5r6r7 | g0g1g2g3 | g4g5g6g7 | b0b1b2b3 | b4b5b6b7
+ // Split the 6 registers in two sets of 3 registers: the first set as the even
+ // 8b bytes, the second the odd ones:
+ // r0r2r4r6 | g0g2g4g6 | b0b2b4b6 | r1r3r5r7 | g1g3g5g7 | b1b3b5b7
+ // Repeat the same permutations twice more:
+ // r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
+ // r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
+ __m128i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
+ VP8PlanarTo24bHelper(*in, tmp);
+ VP8PlanarTo24bHelper(tmp, *in);
+ VP8PlanarTo24bHelper(*in, tmp);
+ // We need to do it two more times than the example as we have sixteen bytes.
+ {
+ __m128i out0, out1, out2, out3, out4, out5;
+ VP8PlanarTo24bHelper(tmp, out);
+ VP8PlanarTo24bHelper(out, *in);
+ }
+}
+
+#undef VP8PlanarTo24bHelper
+
+// Convert four packed four-channel buffers like argbargbargbargb... into the
+// split channels aaaaa ... rrrr ... gggg .... bbbbb ......
+static WEBP_INLINE void VP8L32bToPlanar(__m128i* const in0,
+ __m128i* const in1,
+ __m128i* const in2,
+ __m128i* const in3) {
+ // Column-wise transpose.
+ const __m128i A0 = _mm_unpacklo_epi8(*in0, *in1);
+ const __m128i A1 = _mm_unpackhi_epi8(*in0, *in1);
+ const __m128i A2 = _mm_unpacklo_epi8(*in2, *in3);
+ const __m128i A3 = _mm_unpackhi_epi8(*in2, *in3);
+ const __m128i B0 = _mm_unpacklo_epi8(A0, A1);
+ const __m128i B1 = _mm_unpackhi_epi8(A0, A1);
+ const __m128i B2 = _mm_unpacklo_epi8(A2, A3);
+ const __m128i B3 = _mm_unpackhi_epi8(A2, A3);
+ // C0 = g7 g6 ... g1 g0 | b7 b6 ... b1 b0
+ // C1 = a7 a6 ... a1 a0 | r7 r6 ... r1 r0
+ const __m128i C0 = _mm_unpacklo_epi8(B0, B1);
+ const __m128i C1 = _mm_unpackhi_epi8(B0, B1);
+ const __m128i C2 = _mm_unpacklo_epi8(B2, B3);
+ const __m128i C3 = _mm_unpackhi_epi8(B2, B3);
+ // Gather the channels.
+ *in0 = _mm_unpackhi_epi64(C1, C3);
+ *in1 = _mm_unpacklo_epi64(C1, C3);
+ *in2 = _mm_unpackhi_epi64(C0, C2);
+ *in3 = _mm_unpacklo_epi64(C0, C2);
+}
+
#endif // WEBP_USE_SSE2
#ifdef __cplusplus
diff --git a/thirdparty/libwebp/dsp/cost.c b/thirdparty/libwebp/dsp/cost.c
index fe72d26e79..58ddea7248 100644
--- a/thirdparty/libwebp/dsp/cost.c
+++ b/thirdparty/libwebp/dsp/cost.c
@@ -10,7 +10,7 @@
// Author: Skal (pascal.massimino@gmail.com)
#include "./dsp.h"
-#include "../enc/cost.h"
+#include "../enc/cost_enc.h"
//------------------------------------------------------------------------------
// Boolean-cost cost table
diff --git a/thirdparty/libwebp/dsp/cost_mips32.c b/thirdparty/libwebp/dsp/cost_mips32.c
index d1e240e191..3102da877a 100644
--- a/thirdparty/libwebp/dsp/cost_mips32.c
+++ b/thirdparty/libwebp/dsp/cost_mips32.c
@@ -13,7 +13,7 @@
#if defined(WEBP_USE_MIPS32)
-#include "../enc/cost.h"
+#include "../enc/cost_enc.h"
static int GetResidualCost(int ctx0, const VP8Residual* const res) {
int temp0, temp1;
diff --git a/thirdparty/libwebp/dsp/cost_mips_dsp_r2.c b/thirdparty/libwebp/dsp/cost_mips_dsp_r2.c
index ce64067756..6ec8aeb610 100644
--- a/thirdparty/libwebp/dsp/cost_mips_dsp_r2.c
+++ b/thirdparty/libwebp/dsp/cost_mips_dsp_r2.c
@@ -13,7 +13,7 @@
#if defined(WEBP_USE_MIPS_DSP_R2)
-#include "../enc/cost.h"
+#include "../enc/cost_enc.h"
static int GetResidualCost(int ctx0, const VP8Residual* const res) {
int temp0, temp1;
diff --git a/thirdparty/libwebp/dsp/cost_sse2.c b/thirdparty/libwebp/dsp/cost_sse2.c
index 0cb1c1fa04..421d51fdd5 100644
--- a/thirdparty/libwebp/dsp/cost_sse2.c
+++ b/thirdparty/libwebp/dsp/cost_sse2.c
@@ -16,8 +16,8 @@
#if defined(WEBP_USE_SSE2)
#include <emmintrin.h>
-#include "../enc/cost.h"
-#include "../enc/vp8enci.h"
+#include "../enc/cost_enc.h"
+#include "../enc/vp8i_enc.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dsp/cpu.c b/thirdparty/libwebp/dsp/cpu.c
index cbb08db90a..b5583b6e9b 100644
--- a/thirdparty/libwebp/dsp/cpu.c
+++ b/thirdparty/libwebp/dsp/cpu.c
@@ -95,26 +95,62 @@ static WEBP_INLINE uint64_t xgetbv(void) {
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)
+
+// helper function for run-time detection of slow SSSE3 platforms
+static int CheckSlowModel(int info) {
+ // Table listing display models with longer latencies for the bsr instruction
+ // (ie 2 cycles vs 10/16 cycles) and some SSSE3 instructions like pshufb.
+ // Refer to Intel 64 and IA-32 Architectures Optimization Reference Manual.
+ static const uint8_t kSlowModels[] = {
+ 0x37, 0x4a, 0x4d, // Silvermont Microarchitecture
+ 0x1c, 0x26, 0x27 // Atom Microarchitecture
+ };
+ const uint32_t model = ((info & 0xf0000) >> 12) | ((info >> 4) & 0xf);
+ const uint32_t family = (info >> 8) & 0xf;
+ if (family == 0x06) {
+ size_t i;
+ for (i = 0; i < sizeof(kSlowModels) / sizeof(kSlowModels[0]); ++i) {
+ if (model == kSlowModels[i]) return 1;
+ }
+ }
+ return 0;
+}
+
static int x86CPUInfo(CPUFeature feature) {
int max_cpuid_value;
int cpu_info[4];
+ int is_intel = 0;
// get the highest feature value cpuid supports
GetCPUInfo(cpu_info, 0);
max_cpuid_value = cpu_info[0];
if (max_cpuid_value < 1) {
return 0;
+ } else {
+ const int VENDOR_ID_INTEL_EBX = 0x756e6547; // uneG
+ const int VENDOR_ID_INTEL_EDX = 0x49656e69; // Ieni
+ const int VENDOR_ID_INTEL_ECX = 0x6c65746e; // letn
+ is_intel = (cpu_info[1] == VENDOR_ID_INTEL_EBX &&
+ cpu_info[2] == VENDOR_ID_INTEL_ECX &&
+ cpu_info[3] == VENDOR_ID_INTEL_EDX); // genuine Intel?
}
GetCPUInfo(cpu_info, 1);
if (feature == kSSE2) {
- return 0 != (cpu_info[3] & 0x04000000);
+ return !!(cpu_info[3] & (1 << 26));
}
if (feature == kSSE3) {
- return 0 != (cpu_info[2] & 0x00000001);
+ return !!(cpu_info[2] & (1 << 0));
+ }
+ if (feature == kSlowSSSE3) {
+ if (is_intel && (cpu_info[2] & (1 << 0))) { // SSSE3?
+ return CheckSlowModel(cpu_info[0]);
+ }
+ return 0;
}
+
if (feature == kSSE4_1) {
- return 0 != (cpu_info[2] & 0x00080000);
+ return !!(cpu_info[2] & (1 << 19));
}
if (feature == kAVX) {
// bits 27 (OSXSAVE) & 28 (256-bit AVX)
@@ -126,7 +162,7 @@ static int x86CPUInfo(CPUFeature feature) {
if (feature == kAVX2) {
if (x86CPUInfo(kAVX) && max_cpuid_value >= 7) {
GetCPUInfo(cpu_info, 7);
- return ((cpu_info[1] & 0x00000020) == 0x00000020);
+ return !!(cpu_info[1] & (1 << 5));
}
}
return 0;
@@ -184,4 +220,3 @@ VP8CPUInfo VP8GetCPUInfo = mipsCPUInfo;
#else
VP8CPUInfo VP8GetCPUInfo = NULL;
#endif
-
diff --git a/thirdparty/libwebp/dsp/dec.c b/thirdparty/libwebp/dsp/dec.c
index 49bd16d976..007e985d8b 100644
--- a/thirdparty/libwebp/dsp/dec.c
+++ b/thirdparty/libwebp/dsp/dec.c
@@ -12,7 +12,7 @@
// Author: Skal (pascal.massimino@gmail.com)
#include "./dsp.h"
-#include "../dec/vp8i.h"
+#include "../dec/vp8i_dec.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dsp/dec_clip_tables.c b/thirdparty/libwebp/dsp/dec_clip_tables.c
index 3b6dde86ba..74ba34c0bb 100644
--- a/thirdparty/libwebp/dsp/dec_clip_tables.c
+++ b/thirdparty/libwebp/dsp/dec_clip_tables.c
@@ -63,7 +63,7 @@ static const uint8_t abs0[255 + 255 + 1] = {
0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
-static const int8_t sclip1[1020 + 1020 + 1] = {
+static const uint8_t sclip1[1020 + 1020 + 1] = {
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
@@ -236,7 +236,7 @@ static const int8_t sclip1[1020 + 1020 + 1] = {
0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
};
-static const int8_t sclip2[112 + 112 + 1] = {
+static const uint8_t sclip2[112 + 112 + 1] = {
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
@@ -339,8 +339,8 @@ static volatile int tables_ok = 0;
#endif
-const int8_t* const VP8ksclip1 = &sclip1[1020];
-const int8_t* const VP8ksclip2 = &sclip2[112];
+const int8_t* const VP8ksclip1 = (const int8_t*)&sclip1[1020];
+const int8_t* const VP8ksclip2 = (const int8_t*)&sclip2[112];
const uint8_t* const VP8kclip1 = &clip1[255];
const uint8_t* const VP8kabs0 = &abs0[255];
diff --git a/thirdparty/libwebp/dsp/dec_msa.c b/thirdparty/libwebp/dsp/dec_msa.c
index f76055cab0..8d9c98c3cf 100644
--- a/thirdparty/libwebp/dsp/dec_msa.c
+++ b/thirdparty/libwebp/dsp/dec_msa.c
@@ -154,6 +154,820 @@ static void TransformAC3(const int16_t* in, uint8_t* dst) {
}
//------------------------------------------------------------------------------
+// Edge filtering functions
+
+#define FLIP_SIGN2(in0, in1, out0, out1) { \
+ out0 = (v16i8)__msa_xori_b(in0, 0x80); \
+ out1 = (v16i8)__msa_xori_b(in1, 0x80); \
+}
+
+#define FLIP_SIGN4(in0, in1, in2, in3, out0, out1, out2, out3) { \
+ FLIP_SIGN2(in0, in1, out0, out1); \
+ FLIP_SIGN2(in2, in3, out2, out3); \
+}
+
+#define FILT_VAL(q0_m, p0_m, mask, filt) do { \
+ v16i8 q0_sub_p0; \
+ q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m); \
+ filt = __msa_adds_s_b(filt, q0_sub_p0); \
+ filt = __msa_adds_s_b(filt, q0_sub_p0); \
+ filt = __msa_adds_s_b(filt, q0_sub_p0); \
+ filt = filt & mask; \
+} while (0)
+
+#define FILT2(q_m, p_m, q, p) do { \
+ u_r = SRAI_H(temp1, 7); \
+ u_r = __msa_sat_s_h(u_r, 7); \
+ u_l = SRAI_H(temp3, 7); \
+ u_l = __msa_sat_s_h(u_l, 7); \
+ u = __msa_pckev_b((v16i8)u_l, (v16i8)u_r); \
+ q_m = __msa_subs_s_b(q_m, u); \
+ p_m = __msa_adds_s_b(p_m, u); \
+ q = __msa_xori_b((v16u8)q_m, 0x80); \
+ p = __msa_xori_b((v16u8)p_m, 0x80); \
+} while (0)
+
+#define LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev) do { \
+ v16i8 p1_m, p0_m, q0_m, q1_m; \
+ v16i8 filt, t1, t2; \
+ const v16i8 cnst4b = __msa_ldi_b(4); \
+ const v16i8 cnst3b = __msa_ldi_b(3); \
+ \
+ FLIP_SIGN4(p1, p0, q0, q1, p1_m, p0_m, q0_m, q1_m); \
+ filt = __msa_subs_s_b(p1_m, q1_m); \
+ filt = filt & hev; \
+ FILT_VAL(q0_m, p0_m, mask, filt); \
+ t1 = __msa_adds_s_b(filt, cnst4b); \
+ t1 = SRAI_B(t1, 3); \
+ t2 = __msa_adds_s_b(filt, cnst3b); \
+ t2 = SRAI_B(t2, 3); \
+ q0_m = __msa_subs_s_b(q0_m, t1); \
+ q0 = __msa_xori_b((v16u8)q0_m, 0x80); \
+ p0_m = __msa_adds_s_b(p0_m, t2); \
+ p0 = __msa_xori_b((v16u8)p0_m, 0x80); \
+ filt = __msa_srari_b(t1, 1); \
+ hev = __msa_xori_b(hev, 0xff); \
+ filt = filt & hev; \
+ q1_m = __msa_subs_s_b(q1_m, filt); \
+ q1 = __msa_xori_b((v16u8)q1_m, 0x80); \
+ p1_m = __msa_adds_s_b(p1_m, filt); \
+ p1 = __msa_xori_b((v16u8)p1_m, 0x80); \
+} while (0)
+
+#define LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev) do { \
+ v16i8 p2_m, p1_m, p0_m, q2_m, q1_m, q0_m; \
+ v16i8 u, filt, t1, t2, filt_sign; \
+ v8i16 filt_r, filt_l, u_r, u_l; \
+ v8i16 temp0, temp1, temp2, temp3; \
+ const v16i8 cnst4b = __msa_ldi_b(4); \
+ const v16i8 cnst3b = __msa_ldi_b(3); \
+ const v8i16 cnst9h = __msa_ldi_h(9); \
+ \
+ FLIP_SIGN4(p1, p0, q0, q1, p1_m, p0_m, q0_m, q1_m); \
+ filt = __msa_subs_s_b(p1_m, q1_m); \
+ FILT_VAL(q0_m, p0_m, mask, filt); \
+ FLIP_SIGN2(p2, q2, p2_m, q2_m); \
+ t2 = filt & hev; \
+ /* filt_val &= ~hev */ \
+ hev = __msa_xori_b(hev, 0xff); \
+ filt = filt & hev; \
+ t1 = __msa_adds_s_b(t2, cnst4b); \
+ t1 = SRAI_B(t1, 3); \
+ t2 = __msa_adds_s_b(t2, cnst3b); \
+ t2 = SRAI_B(t2, 3); \
+ q0_m = __msa_subs_s_b(q0_m, t1); \
+ p0_m = __msa_adds_s_b(p0_m, t2); \
+ filt_sign = __msa_clti_s_b(filt, 0); \
+ ILVRL_B2_SH(filt_sign, filt, filt_r, filt_l); \
+ /* update q2/p2 */ \
+ temp0 = filt_r * cnst9h; \
+ temp1 = ADDVI_H(temp0, 63); \
+ temp2 = filt_l * cnst9h; \
+ temp3 = ADDVI_H(temp2, 63); \
+ FILT2(q2_m, p2_m, q2, p2); \
+ /* update q1/p1 */ \
+ temp1 = temp1 + temp0; \
+ temp3 = temp3 + temp2; \
+ FILT2(q1_m, p1_m, q1, p1); \
+ /* update q0/p0 */ \
+ temp1 = temp1 + temp0; \
+ temp3 = temp3 + temp2; \
+ FILT2(q0_m, p0_m, q0, p0); \
+} while (0)
+
+#define LPF_MASK_HEV(p3_in, p2_in, p1_in, p0_in, \
+ q0_in, q1_in, q2_in, q3_in, \
+ limit_in, b_limit_in, thresh_in, \
+ hev_out, mask_out) do { \
+ v16u8 p3_asub_p2_m, p2_asub_p1_m, p1_asub_p0_m, q1_asub_q0_m; \
+ v16u8 p1_asub_q1_m, p0_asub_q0_m, q3_asub_q2_m, q2_asub_q1_m; \
+ v16u8 flat_out; \
+ \
+ /* absolute subtraction of pixel values */ \
+ p3_asub_p2_m = __msa_asub_u_b(p3_in, p2_in); \
+ p2_asub_p1_m = __msa_asub_u_b(p2_in, p1_in); \
+ p1_asub_p0_m = __msa_asub_u_b(p1_in, p0_in); \
+ q1_asub_q0_m = __msa_asub_u_b(q1_in, q0_in); \
+ q2_asub_q1_m = __msa_asub_u_b(q2_in, q1_in); \
+ q3_asub_q2_m = __msa_asub_u_b(q3_in, q2_in); \
+ p0_asub_q0_m = __msa_asub_u_b(p0_in, q0_in); \
+ p1_asub_q1_m = __msa_asub_u_b(p1_in, q1_in); \
+ /* calculation of hev */ \
+ flat_out = __msa_max_u_b(p1_asub_p0_m, q1_asub_q0_m); \
+ hev_out = (thresh_in < flat_out); \
+ /* calculation of mask */ \
+ p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p0_asub_q0_m); \
+ p1_asub_q1_m = SRAI_B(p1_asub_q1_m, 1); \
+ p0_asub_q0_m = __msa_adds_u_b(p0_asub_q0_m, p1_asub_q1_m); \
+ mask_out = (b_limit_in < p0_asub_q0_m); \
+ mask_out = __msa_max_u_b(flat_out, mask_out); \
+ p3_asub_p2_m = __msa_max_u_b(p3_asub_p2_m, p2_asub_p1_m); \
+ mask_out = __msa_max_u_b(p3_asub_p2_m, mask_out); \
+ q2_asub_q1_m = __msa_max_u_b(q2_asub_q1_m, q3_asub_q2_m); \
+ mask_out = __msa_max_u_b(q2_asub_q1_m, mask_out); \
+ mask_out = (limit_in < mask_out); \
+ mask_out = __msa_xori_b(mask_out, 0xff); \
+} while (0)
+
+#define ST6x1_UB(in0, in0_idx, in1, in1_idx, pdst, stride) do { \
+ const uint16_t tmp0_h = __msa_copy_s_h((v8i16)in1, in1_idx); \
+ const uint32_t tmp0_w = __msa_copy_s_w((v4i32)in0, in0_idx); \
+ SW(tmp0_w, pdst); \
+ SH(tmp0_h, pdst + stride); \
+} while (0)
+
+#define ST6x4_UB(in0, start_in0_idx, in1, start_in1_idx, pdst, stride) do { \
+ uint8_t* ptmp1 = (uint8_t*)pdst; \
+ ST6x1_UB(in0, start_in0_idx, in1, start_in1_idx, ptmp1, 4); \
+ ptmp1 += stride; \
+ ST6x1_UB(in0, start_in0_idx + 1, in1, start_in1_idx + 1, ptmp1, 4); \
+ ptmp1 += stride; \
+ ST6x1_UB(in0, start_in0_idx + 2, in1, start_in1_idx + 2, ptmp1, 4); \
+ ptmp1 += stride; \
+ ST6x1_UB(in0, start_in0_idx + 3, in1, start_in1_idx + 3, ptmp1, 4); \
+} while (0)
+
+#define LPF_SIMPLE_FILT(p1_in, p0_in, q0_in, q1_in, mask) do { \
+ v16i8 p1_m, p0_m, q0_m, q1_m, filt, filt1, filt2; \
+ const v16i8 cnst4b = __msa_ldi_b(4); \
+ const v16i8 cnst3b = __msa_ldi_b(3); \
+ \
+ FLIP_SIGN4(p1_in, p0_in, q0_in, q1_in, p1_m, p0_m, q0_m, q1_m); \
+ filt = __msa_subs_s_b(p1_m, q1_m); \
+ FILT_VAL(q0_m, p0_m, mask, filt); \
+ filt1 = __msa_adds_s_b(filt, cnst4b); \
+ filt1 = SRAI_B(filt1, 3); \
+ filt2 = __msa_adds_s_b(filt, cnst3b); \
+ filt2 = SRAI_B(filt2, 3); \
+ q0_m = __msa_subs_s_b(q0_m, filt1); \
+ p0_m = __msa_adds_s_b(p0_m, filt2); \
+ q0_in = __msa_xori_b((v16u8)q0_m, 0x80); \
+ p0_in = __msa_xori_b((v16u8)p0_m, 0x80); \
+} while (0)
+
+#define LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask) do { \
+ v16u8 p1_a_sub_q1, p0_a_sub_q0; \
+ \
+ p0_a_sub_q0 = __msa_asub_u_b(p0, q0); \
+ p1_a_sub_q1 = __msa_asub_u_b(p1, q1); \
+ p1_a_sub_q1 = (v16u8)__msa_srli_b((v16i8)p1_a_sub_q1, 1); \
+ p0_a_sub_q0 = __msa_adds_u_b(p0_a_sub_q0, p0_a_sub_q0); \
+ mask = __msa_adds_u_b(p0_a_sub_q0, p1_a_sub_q1); \
+ mask = (mask <= b_limit); \
+} while (0)
+
+static void VFilter16(uint8_t* src, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ uint8_t* ptemp = src - 4 * stride;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
+ v16u8 mask, hev;
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+
+ LD_UB8(ptemp, stride, p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
+ ptemp = src - 3 * stride;
+ ST_UB4(p2, p1, p0, q0, ptemp, stride);
+ ptemp += (4 * stride);
+ ST_UB2(q1, q2, ptemp, stride);
+}
+
+static void HFilter16(uint8_t* src, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ uint8_t* ptmp = src - 4;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
+ v16u8 mask, hev;
+ v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
+ v16u8 row9, row10, row11, row12, row13, row14, row15;
+ v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+
+ LD_UB8(ptmp, stride, row0, row1, row2, row3, row4, row5, row6, row7);
+ ptmp += (8 * stride);
+ LD_UB8(ptmp, stride, row8, row9, row10, row11, row12, row13, row14, row15);
+ TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
+ row8, row9, row10, row11, row12, row13, row14, row15,
+ p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
+ ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
+ ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
+ ILVRL_B2_SH(q2, q1, tmp2, tmp5);
+ ptmp = src - 3;
+ ST6x1_UB(tmp3, 0, tmp2, 0, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp3, 1, tmp2, 1, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp3, 2, tmp2, 2, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp3, 3, tmp2, 3, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp4, 0, tmp2, 4, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp4, 1, tmp2, 5, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp4, 2, tmp2, 6, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp4, 3, tmp2, 7, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp6, 0, tmp5, 0, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp6, 1, tmp5, 1, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp6, 2, tmp5, 2, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp6, 3, tmp5, 3, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp7, 0, tmp5, 4, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp7, 1, tmp5, 5, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp7, 2, tmp5, 6, ptmp, 4);
+ ptmp += stride;
+ ST6x1_UB(tmp7, 3, tmp5, 7, ptmp, 4);
+}
+
+// on three inner edges
+static void VFilterHorEdge16i(uint8_t* src, int stride,
+ int b_limit, int limit, int thresh) {
+ v16u8 mask, hev;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
+ const v16u8 thresh0 = (v16u8)__msa_fill_b(thresh);
+ const v16u8 b_limit0 = (v16u8)__msa_fill_b(b_limit);
+ const v16u8 limit0 = (v16u8)__msa_fill_b(limit);
+
+ LD_UB8((src - 4 * stride), stride, p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
+ hev, mask);
+ LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
+ ST_UB4(p1, p0, q0, q1, (src - 2 * stride), stride);
+}
+
+static void VFilter16i(uint8_t* src_y, int stride,
+ int b_limit, int limit, int thresh) {
+ VFilterHorEdge16i(src_y + 4 * stride, stride, b_limit, limit, thresh);
+ VFilterHorEdge16i(src_y + 8 * stride, stride, b_limit, limit, thresh);
+ VFilterHorEdge16i(src_y + 12 * stride, stride, b_limit, limit, thresh);
+}
+
+static void HFilterVertEdge16i(uint8_t* src, int stride,
+ int b_limit, int limit, int thresh) {
+ v16u8 mask, hev;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0;
+ v16u8 row0, row1, row2, row3, row4, row5, row6, row7;
+ v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
+ v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
+ const v16u8 thresh0 = (v16u8)__msa_fill_b(thresh);
+ const v16u8 b_limit0 = (v16u8)__msa_fill_b(b_limit);
+ const v16u8 limit0 = (v16u8)__msa_fill_b(limit);
+
+ LD_UB8(src - 4, stride, row0, row1, row2, row3, row4, row5, row6, row7);
+ LD_UB8(src - 4 + (8 * stride), stride,
+ row8, row9, row10, row11, row12, row13, row14, row15);
+ TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
+ row8, row9, row10, row11, row12, row13, row14, row15,
+ p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit0, b_limit0, thresh0,
+ hev, mask);
+ LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
+ ILVR_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp2, tmp3);
+ ILVL_B2_SH(p0, p1, q1, q0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp4, tmp5);
+ src -= 2;
+ ST4x8_UB(tmp2, tmp3, src, stride);
+ src += (8 * stride);
+ ST4x8_UB(tmp4, tmp5, src, stride);
+}
+
+static void HFilter16i(uint8_t* src_y, int stride,
+ int b_limit, int limit, int thresh) {
+ HFilterVertEdge16i(src_y + 4, stride, b_limit, limit, thresh);
+ HFilterVertEdge16i(src_y + 8, stride, b_limit, limit, thresh);
+ HFilterVertEdge16i(src_y + 12, stride, b_limit, limit, thresh);
+}
+
+// 8-pixels wide variants, for chroma filtering
+static void VFilter8(uint8_t* src_u, uint8_t* src_v, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ uint8_t* ptmp_src_u = src_u - 4 * stride;
+ uint8_t* ptmp_src_v = src_v - 4 * stride;
+ uint64_t p2_d, p1_d, p0_d, q0_d, q1_d, q2_d;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
+ v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
+ v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+
+ LD_UB8(ptmp_src_u, stride, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
+ LD_UB8(ptmp_src_v, stride, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
+ ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
+ ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
+ p2_d = __msa_copy_s_d((v2i64)p2, 0);
+ p1_d = __msa_copy_s_d((v2i64)p1, 0);
+ p0_d = __msa_copy_s_d((v2i64)p0, 0);
+ q0_d = __msa_copy_s_d((v2i64)q0, 0);
+ q1_d = __msa_copy_s_d((v2i64)q1, 0);
+ q2_d = __msa_copy_s_d((v2i64)q2, 0);
+ ptmp_src_u += stride;
+ SD4(p2_d, p1_d, p0_d, q0_d, ptmp_src_u, stride);
+ ptmp_src_u += (4 * stride);
+ SD(q1_d, ptmp_src_u);
+ ptmp_src_u += stride;
+ SD(q2_d, ptmp_src_u);
+ p2_d = __msa_copy_s_d((v2i64)p2, 1);
+ p1_d = __msa_copy_s_d((v2i64)p1, 1);
+ p0_d = __msa_copy_s_d((v2i64)p0, 1);
+ q0_d = __msa_copy_s_d((v2i64)q0, 1);
+ q1_d = __msa_copy_s_d((v2i64)q1, 1);
+ q2_d = __msa_copy_s_d((v2i64)q2, 1);
+ ptmp_src_v += stride;
+ SD4(p2_d, p1_d, p0_d, q0_d, ptmp_src_v, stride);
+ ptmp_src_v += (4 * stride);
+ SD(q1_d, ptmp_src_v);
+ ptmp_src_v += stride;
+ SD(q2_d, ptmp_src_v);
+}
+
+static void HFilter8(uint8_t* src_u, uint8_t* src_v, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ uint8_t* ptmp_src_u = src_u - 4;
+ uint8_t* ptmp_src_v = src_v - 4;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
+ v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
+ v16u8 row9, row10, row11, row12, row13, row14, row15;
+ v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+
+ LD_UB8(ptmp_src_u, stride, row0, row1, row2, row3, row4, row5, row6, row7);
+ LD_UB8(ptmp_src_v, stride,
+ row8, row9, row10, row11, row12, row13, row14, row15);
+ TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
+ row8, row9, row10, row11, row12, row13, row14, row15,
+ p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_MBFILTER(p2, p1, p0, q0, q1, q2, mask, hev);
+ ILVR_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp3, tmp4);
+ ILVL_B2_SH(p1, p2, q0, p0, tmp0, tmp1);
+ ILVRL_H2_SH(tmp1, tmp0, tmp6, tmp7);
+ ILVRL_B2_SH(q2, q1, tmp2, tmp5);
+ ptmp_src_u += 1;
+ ST6x4_UB(tmp3, 0, tmp2, 0, ptmp_src_u, stride);
+ ptmp_src_u += 4 * stride;
+ ST6x4_UB(tmp4, 0, tmp2, 4, ptmp_src_u, stride);
+ ptmp_src_v += 1;
+ ST6x4_UB(tmp6, 0, tmp5, 0, ptmp_src_v, stride);
+ ptmp_src_v += 4 * stride;
+ ST6x4_UB(tmp7, 0, tmp5, 4, ptmp_src_v, stride);
+}
+
+static void VFilter8i(uint8_t* src_u, uint8_t* src_v, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ uint64_t p1_d, p0_d, q0_d, q1_d;
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
+ v16u8 p3_u, p2_u, p1_u, p0_u, q3_u, q2_u, q1_u, q0_u;
+ v16u8 p3_v, p2_v, p1_v, p0_v, q3_v, q2_v, q1_v, q0_v;
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+
+ LD_UB8(src_u, stride, p3_u, p2_u, p1_u, p0_u, q0_u, q1_u, q2_u, q3_u);
+ src_u += (5 * stride);
+ LD_UB8(src_v, stride, p3_v, p2_v, p1_v, p0_v, q0_v, q1_v, q2_v, q3_v);
+ src_v += (5 * stride);
+ ILVR_D4_UB(p3_v, p3_u, p2_v, p2_u, p1_v, p1_u, p0_v, p0_u, p3, p2, p1, p0);
+ ILVR_D4_UB(q0_v, q0_u, q1_v, q1_u, q2_v, q2_u, q3_v, q3_u, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
+ p1_d = __msa_copy_s_d((v2i64)p1, 0);
+ p0_d = __msa_copy_s_d((v2i64)p0, 0);
+ q0_d = __msa_copy_s_d((v2i64)q0, 0);
+ q1_d = __msa_copy_s_d((v2i64)q1, 0);
+ SD4(q1_d, q0_d, p0_d, p1_d, src_u, -stride);
+ p1_d = __msa_copy_s_d((v2i64)p1, 1);
+ p0_d = __msa_copy_s_d((v2i64)p0, 1);
+ q0_d = __msa_copy_s_d((v2i64)q0, 1);
+ q1_d = __msa_copy_s_d((v2i64)q1, 1);
+ SD4(q1_d, q0_d, p0_d, p1_d, src_v, -stride);
+}
+
+static void HFilter8i(uint8_t* src_u, uint8_t* src_v, int stride,
+ int b_limit_in, int limit_in, int thresh_in) {
+ v16u8 p3, p2, p1, p0, q3, q2, q1, q0, mask, hev;
+ v16u8 row0, row1, row2, row3, row4, row5, row6, row7, row8;
+ v16u8 row9, row10, row11, row12, row13, row14, row15;
+ v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
+ const v16u8 thresh = (v16u8)__msa_fill_b(thresh_in);
+ const v16u8 limit = (v16u8)__msa_fill_b(limit_in);
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+
+ LD_UB8(src_u, stride, row0, row1, row2, row3, row4, row5, row6, row7);
+ LD_UB8(src_v, stride,
+ row8, row9, row10, row11, row12, row13, row14, row15);
+ TRANSPOSE16x8_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
+ row8, row9, row10, row11, row12, row13, row14, row15,
+ p3, p2, p1, p0, q0, q1, q2, q3);
+ LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
+ hev, mask);
+ LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev);
+ ILVR_B2_SW(p0, p1, q1, q0, tmp0, tmp1);
+ ILVRL_H2_SW(tmp1, tmp0, tmp2, tmp3);
+ ILVL_B2_SW(p0, p1, q1, q0, tmp0, tmp1);
+ ILVRL_H2_SW(tmp1, tmp0, tmp4, tmp5);
+ src_u += 2;
+ ST4x4_UB(tmp2, tmp2, 0, 1, 2, 3, src_u, stride);
+ src_u += 4 * stride;
+ ST4x4_UB(tmp3, tmp3, 0, 1, 2, 3, src_u, stride);
+ src_v += 2;
+ ST4x4_UB(tmp4, tmp4, 0, 1, 2, 3, src_v, stride);
+ src_v += 4 * stride;
+ ST4x4_UB(tmp5, tmp5, 0, 1, 2, 3, src_v, stride);
+}
+
+static void SimpleVFilter16(uint8_t* src, int stride, int b_limit_in) {
+ v16u8 p1, p0, q1, q0, mask;
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+
+ LD_UB4(src - 2 * stride, stride, p1, p0, q0, q1);
+ LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
+ LPF_SIMPLE_FILT(p1, p0, q0, q1, mask);
+ ST_UB2(p0, q0, src - stride, stride);
+}
+
+static void SimpleHFilter16(uint8_t* src, int stride, int b_limit_in) {
+ v16u8 p1, p0, q1, q0, mask, row0, row1, row2, row3, row4, row5, row6, row7;
+ v16u8 row8, row9, row10, row11, row12, row13, row14, row15;
+ v8i16 tmp0, tmp1;
+ const v16u8 b_limit = (v16u8)__msa_fill_b(b_limit_in);
+ uint8_t* ptemp_src = src - 2;
+
+ LD_UB8(ptemp_src, stride, row0, row1, row2, row3, row4, row5, row6, row7);
+ LD_UB8(ptemp_src + 8 * stride, stride,
+ row8, row9, row10, row11, row12, row13, row14, row15);
+ TRANSPOSE16x4_UB_UB(row0, row1, row2, row3, row4, row5, row6, row7,
+ row8, row9, row10, row11, row12, row13, row14, row15,
+ p1, p0, q0, q1);
+ LPF_SIMPLE_MASK(p1, p0, q0, q1, b_limit, mask);
+ LPF_SIMPLE_FILT(p1, p0, q0, q1, mask);
+ ILVRL_B2_SH(q0, p0, tmp1, tmp0);
+ ptemp_src += 1;
+ ST2x4_UB(tmp1, 0, ptemp_src, stride);
+ ptemp_src += 4 * stride;
+ ST2x4_UB(tmp1, 4, ptemp_src, stride);
+ ptemp_src += 4 * stride;
+ ST2x4_UB(tmp0, 0, ptemp_src, stride);
+ ptemp_src += 4 * stride;
+ ST2x4_UB(tmp0, 4, ptemp_src, stride);
+ ptemp_src += 4 * stride;
+}
+
+static void SimpleVFilter16i(uint8_t* src_y, int stride, int b_limit_in) {
+ SimpleVFilter16(src_y + 4 * stride, stride, b_limit_in);
+ SimpleVFilter16(src_y + 8 * stride, stride, b_limit_in);
+ SimpleVFilter16(src_y + 12 * stride, stride, b_limit_in);
+}
+
+static void SimpleHFilter16i(uint8_t* src_y, int stride, int b_limit_in) {
+ SimpleHFilter16(src_y + 4, stride, b_limit_in);
+ SimpleHFilter16(src_y + 8, stride, b_limit_in);
+ SimpleHFilter16(src_y + 12, stride, b_limit_in);
+}
+
+//------------------------------------------------------------------------------
+// Intra predictions
+//------------------------------------------------------------------------------
+
+// 4x4
+
+static void DC4(uint8_t* dst) { // DC
+ uint32_t dc = 4;
+ int i;
+ for (i = 0; i < 4; ++i) dc += dst[i - BPS] + dst[-1 + i * BPS];
+ dc >>= 3;
+ dc = dc | (dc << 8) | (dc << 16) | (dc << 24);
+ SW4(dc, dc, dc, dc, dst, BPS);
+}
+
+static void TM4(uint8_t* dst) {
+ const uint8_t* const ptemp = dst - BPS - 1;
+ v8i16 T, d, r0, r1, r2, r3;
+ const v16i8 zero = { 0 };
+ const v8i16 TL = (v8i16)__msa_fill_h(ptemp[0 * BPS]);
+ const v8i16 L0 = (v8i16)__msa_fill_h(ptemp[1 * BPS]);
+ const v8i16 L1 = (v8i16)__msa_fill_h(ptemp[2 * BPS]);
+ const v8i16 L2 = (v8i16)__msa_fill_h(ptemp[3 * BPS]);
+ const v8i16 L3 = (v8i16)__msa_fill_h(ptemp[4 * BPS]);
+ const v16u8 T1 = LD_UB(ptemp + 1);
+
+ T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
+ d = T - TL;
+ ADD4(d, L0, d, L1, d, L2, d, L3, r0, r1, r2, r3);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ PCKEV_ST4x4_UB(r0, r1, r2, r3, dst, BPS);
+}
+
+static void VE4(uint8_t* dst) { // vertical
+ const uint8_t* const ptop = dst - BPS - 1;
+ const uint32_t val0 = LW(ptop + 0);
+ const uint32_t val1 = LW(ptop + 4);
+ uint32_t out;
+ v16u8 A, B, C, AC, B2, R;
+
+ INSERT_W2_UB(val0, val1, A);
+ B = SLDI_UB(A, A, 1);
+ C = SLDI_UB(A, A, 2);
+ AC = __msa_ave_u_b(A, C);
+ B2 = __msa_ave_u_b(B, B);
+ R = __msa_aver_u_b(AC, B2);
+ out = __msa_copy_s_w((v4i32)R, 0);
+ SW4(out, out, out, out, dst, BPS);
+}
+
+static void RD4(uint8_t* dst) { // Down-right
+ const uint8_t* const ptop = dst - 1 - BPS;
+ uint32_t val0 = LW(ptop + 0);
+ uint32_t val1 = LW(ptop + 4);
+ uint32_t val2, val3;
+ v16u8 A, B, C, AC, B2, R, A1;
+
+ INSERT_W2_UB(val0, val1, A1);
+ A = SLDI_UB(A1, A1, 12);
+ A = (v16u8)__msa_insert_b((v16i8)A, 3, ptop[1 * BPS]);
+ A = (v16u8)__msa_insert_b((v16i8)A, 2, ptop[2 * BPS]);
+ A = (v16u8)__msa_insert_b((v16i8)A, 1, ptop[3 * BPS]);
+ A = (v16u8)__msa_insert_b((v16i8)A, 0, ptop[4 * BPS]);
+ B = SLDI_UB(A, A, 1);
+ C = SLDI_UB(A, A, 2);
+ AC = __msa_ave_u_b(A, C);
+ B2 = __msa_ave_u_b(B, B);
+ R = __msa_aver_u_b(AC, B2);
+ val3 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val2 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val1 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val0 = __msa_copy_s_w((v4i32)R, 0);
+ SW4(val0, val1, val2, val3, dst, BPS);
+}
+
+static void LD4(uint8_t* dst) { // Down-Left
+ const uint8_t* const ptop = dst - BPS;
+ uint32_t val0 = LW(ptop + 0);
+ uint32_t val1 = LW(ptop + 4);
+ uint32_t val2, val3;
+ v16u8 A, B, C, AC, B2, R;
+
+ INSERT_W2_UB(val0, val1, A);
+ B = SLDI_UB(A, A, 1);
+ C = SLDI_UB(A, A, 2);
+ C = (v16u8)__msa_insert_b((v16i8)C, 6, ptop[7]);
+ AC = __msa_ave_u_b(A, C);
+ B2 = __msa_ave_u_b(B, B);
+ R = __msa_aver_u_b(AC, B2);
+ val0 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val1 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val2 = __msa_copy_s_w((v4i32)R, 0);
+ R = SLDI_UB(R, R, 1);
+ val3 = __msa_copy_s_w((v4i32)R, 0);
+ SW4(val0, val1, val2, val3, dst, BPS);
+}
+
+// 16x16
+
+static void DC16(uint8_t* dst) { // DC
+ uint32_t dc = 16;
+ int i;
+ const v16u8 rtop = LD_UB(dst - BPS);
+ const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
+ v16u8 out;
+
+ for (i = 0; i < 16; ++i) {
+ dc += dst[-1 + i * BPS];
+ }
+ dc += HADD_UH_U32(dctop);
+ out = (v16u8)__msa_fill_b(dc >> 5);
+ ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
+}
+
+static void TM16(uint8_t* dst) {
+ int j;
+ v8i16 d1, d2;
+ const v16i8 zero = { 0 };
+ const v8i16 TL = (v8i16)__msa_fill_h(dst[-1 - BPS]);
+ const v16i8 T = LD_SB(dst - BPS);
+
+ ILVRL_B2_SH(zero, T, d1, d2);
+ SUB2(d1, TL, d2, TL, d1, d2);
+ for (j = 0; j < 16; j += 4) {
+ v16i8 t0, t1, t2, t3;
+ v8i16 r0, r1, r2, r3, r4, r5, r6, r7;
+ const v8i16 L0 = (v8i16)__msa_fill_h(dst[-1 + 0 * BPS]);
+ const v8i16 L1 = (v8i16)__msa_fill_h(dst[-1 + 1 * BPS]);
+ const v8i16 L2 = (v8i16)__msa_fill_h(dst[-1 + 2 * BPS]);
+ const v8i16 L3 = (v8i16)__msa_fill_h(dst[-1 + 3 * BPS]);
+ ADD4(d1, L0, d1, L1, d1, L2, d1, L3, r0, r1, r2, r3);
+ ADD4(d2, L0, d2, L1, d2, L2, d2, L3, r4, r5, r6, r7);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ CLIP_SH4_0_255(r4, r5, r6, r7);
+ PCKEV_B4_SB(r4, r0, r5, r1, r6, r2, r7, r3, t0, t1, t2, t3);
+ ST_SB4(t0, t1, t2, t3, dst, BPS);
+ dst += 4 * BPS;
+ }
+}
+
+static void VE16(uint8_t* dst) { // vertical
+ const v16u8 rtop = LD_UB(dst - BPS);
+ ST_UB8(rtop, rtop, rtop, rtop, rtop, rtop, rtop, rtop, dst, BPS);
+ ST_UB8(rtop, rtop, rtop, rtop, rtop, rtop, rtop, rtop, dst + 8 * BPS, BPS);
+}
+
+static void HE16(uint8_t* dst) { // horizontal
+ int j;
+ for (j = 16; j > 0; j -= 4) {
+ const v16u8 L0 = (v16u8)__msa_fill_b(dst[-1 + 0 * BPS]);
+ const v16u8 L1 = (v16u8)__msa_fill_b(dst[-1 + 1 * BPS]);
+ const v16u8 L2 = (v16u8)__msa_fill_b(dst[-1 + 2 * BPS]);
+ const v16u8 L3 = (v16u8)__msa_fill_b(dst[-1 + 3 * BPS]);
+ ST_UB4(L0, L1, L2, L3, dst, BPS);
+ dst += 4 * BPS;
+ }
+}
+
+static void DC16NoTop(uint8_t* dst) { // DC with top samples not available
+ int j;
+ uint32_t dc = 8;
+ v16u8 out;
+
+ for (j = 0; j < 16; ++j) {
+ dc += dst[-1 + j * BPS];
+ }
+ out = (v16u8)__msa_fill_b(dc >> 4);
+ ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
+}
+
+static void DC16NoLeft(uint8_t* dst) { // DC with left samples not available
+ uint32_t dc = 8;
+ const v16u8 rtop = LD_UB(dst - BPS);
+ const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
+ v16u8 out;
+
+ dc += HADD_UH_U32(dctop);
+ out = (v16u8)__msa_fill_b(dc >> 4);
+ ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
+}
+
+static void DC16NoTopLeft(uint8_t* dst) { // DC with nothing
+ const v16u8 out = (v16u8)__msa_fill_b(0x80);
+ ST_UB8(out, out, out, out, out, out, out, out, dst, BPS);
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS);
+}
+
+// Chroma
+
+#define STORE8x8(out, dst) do { \
+ SD4(out, out, out, out, dst + 0 * BPS, BPS); \
+ SD4(out, out, out, out, dst + 4 * BPS, BPS); \
+} while (0)
+
+static void DC8uv(uint8_t* dst) { // DC
+ uint32_t dc = 8;
+ int i;
+ uint64_t out;
+ const v16u8 rtop = LD_UB(dst - BPS);
+ const v8u16 temp0 = __msa_hadd_u_h(rtop, rtop);
+ const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0);
+ const v2u64 temp2 = __msa_hadd_u_d(temp1, temp1);
+ v16u8 dctemp;
+
+ for (i = 0; i < 8; ++i) {
+ dc += dst[-1 + i * BPS];
+ }
+ dc += __msa_copy_s_w((v4i32)temp2, 0);
+ dctemp = (v16u8)__msa_fill_b(dc >> 4);
+ out = __msa_copy_s_d((v2i64)dctemp, 0);
+ STORE8x8(out, dst);
+}
+
+static void TM8uv(uint8_t* dst) {
+ int j;
+ const v16i8 T1 = LD_SB(dst - BPS);
+ const v16i8 zero = { 0 };
+ const v8i16 T = (v8i16)__msa_ilvr_b(zero, T1);
+ const v8i16 TL = (v8i16)__msa_fill_h(dst[-1 - BPS]);
+ const v8i16 d = T - TL;
+
+ for (j = 0; j < 8; j += 4) {
+ v16i8 t0, t1;
+ v8i16 r0 = (v8i16)__msa_fill_h(dst[-1 + 0 * BPS]);
+ v8i16 r1 = (v8i16)__msa_fill_h(dst[-1 + 1 * BPS]);
+ v8i16 r2 = (v8i16)__msa_fill_h(dst[-1 + 2 * BPS]);
+ v8i16 r3 = (v8i16)__msa_fill_h(dst[-1 + 3 * BPS]);
+ ADD4(d, r0, d, r1, d, r2, d, r3, r0, r1, r2, r3);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ PCKEV_B2_SB(r1, r0, r3, r2, t0, t1);
+ ST4x4_UB(t0, t1, 0, 2, 0, 2, dst, BPS);
+ ST4x4_UB(t0, t1, 1, 3, 1, 3, dst + 4, BPS);
+ dst += 4 * BPS;
+ }
+}
+
+static void VE8uv(uint8_t* dst) { // vertical
+ const v16u8 rtop = LD_UB(dst - BPS);
+ const uint64_t out = __msa_copy_s_d((v2i64)rtop, 0);
+ STORE8x8(out, dst);
+}
+
+static void HE8uv(uint8_t* dst) { // horizontal
+ int j;
+ for (j = 0; j < 8; j += 4) {
+ const v16u8 L0 = (v16u8)__msa_fill_b(dst[-1 + 0 * BPS]);
+ const v16u8 L1 = (v16u8)__msa_fill_b(dst[-1 + 1 * BPS]);
+ const v16u8 L2 = (v16u8)__msa_fill_b(dst[-1 + 2 * BPS]);
+ const v16u8 L3 = (v16u8)__msa_fill_b(dst[-1 + 3 * BPS]);
+ const uint64_t out0 = __msa_copy_s_d((v2i64)L0, 0);
+ const uint64_t out1 = __msa_copy_s_d((v2i64)L1, 0);
+ const uint64_t out2 = __msa_copy_s_d((v2i64)L2, 0);
+ const uint64_t out3 = __msa_copy_s_d((v2i64)L3, 0);
+ SD4(out0, out1, out2, out3, dst, BPS);
+ dst += 4 * BPS;
+ }
+}
+
+static void DC8uvNoLeft(uint8_t* dst) { // DC with no left samples
+ const uint32_t dc = 4;
+ const v16u8 rtop = LD_UB(dst - BPS);
+ const v8u16 temp0 = __msa_hadd_u_h(rtop, rtop);
+ const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0);
+ const v2u64 temp2 = __msa_hadd_u_d(temp1, temp1);
+ const uint32_t sum_m = __msa_copy_s_w((v4i32)temp2, 0);
+ const v16u8 dcval = (v16u8)__msa_fill_b((dc + sum_m) >> 3);
+ const uint64_t out = __msa_copy_s_d((v2i64)dcval, 0);
+ STORE8x8(out, dst);
+}
+
+static void DC8uvNoTop(uint8_t* dst) { // DC with no top samples
+ uint32_t dc = 4;
+ int i;
+ uint64_t out;
+ v16u8 dctemp;
+
+ for (i = 0; i < 8; ++i) {
+ dc += dst[-1 + i * BPS];
+ }
+ dctemp = (v16u8)__msa_fill_b(dc >> 3);
+ out = __msa_copy_s_d((v2i64)dctemp, 0);
+ STORE8x8(out, dst);
+}
+
+static void DC8uvNoTopLeft(uint8_t* dst) { // DC with nothing
+ const uint64_t out = 0x8080808080808080ULL;
+ STORE8x8(out, dst);
+}
+
+//------------------------------------------------------------------------------
// Entry point
extern void VP8DspInitMSA(void);
@@ -163,6 +977,39 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8DspInitMSA(void) {
VP8Transform = TransformTwo;
VP8TransformDC = TransformDC;
VP8TransformAC3 = TransformAC3;
+
+ VP8VFilter16 = VFilter16;
+ VP8HFilter16 = HFilter16;
+ VP8VFilter16i = VFilter16i;
+ VP8HFilter16i = HFilter16i;
+ VP8VFilter8 = VFilter8;
+ VP8HFilter8 = HFilter8;
+ VP8VFilter8i = VFilter8i;
+ VP8HFilter8i = HFilter8i;
+ VP8SimpleVFilter16 = SimpleVFilter16;
+ VP8SimpleHFilter16 = SimpleHFilter16;
+ VP8SimpleVFilter16i = SimpleVFilter16i;
+ VP8SimpleHFilter16i = SimpleHFilter16i;
+
+ VP8PredLuma4[0] = DC4;
+ VP8PredLuma4[1] = TM4;
+ VP8PredLuma4[2] = VE4;
+ VP8PredLuma4[4] = RD4;
+ VP8PredLuma4[6] = LD4;
+ VP8PredLuma16[0] = DC16;
+ VP8PredLuma16[1] = TM16;
+ VP8PredLuma16[2] = VE16;
+ VP8PredLuma16[3] = HE16;
+ VP8PredLuma16[4] = DC16NoTop;
+ VP8PredLuma16[5] = DC16NoLeft;
+ VP8PredLuma16[6] = DC16NoTopLeft;
+ VP8PredChroma8[0] = DC8uv;
+ VP8PredChroma8[1] = TM8uv;
+ VP8PredChroma8[2] = VE8uv;
+ VP8PredChroma8[3] = HE8uv;
+ VP8PredChroma8[4] = DC8uvNoTop;
+ VP8PredChroma8[5] = DC8uvNoLeft;
+ VP8PredChroma8[6] = DC8uvNoTopLeft;
}
#else // !WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/dec_neon.c b/thirdparty/libwebp/dsp/dec_neon.c
index a63f43fe17..34796cf4a2 100644
--- a/thirdparty/libwebp/dsp/dec_neon.c
+++ b/thirdparty/libwebp/dsp/dec_neon.c
@@ -17,7 +17,7 @@
#if defined(WEBP_USE_NEON)
#include "./neon.h"
-#include "../dec/vp8i.h"
+#include "../dec/vp8i_dec.h"
//------------------------------------------------------------------------------
// NxM Loading functions
@@ -666,9 +666,8 @@ static uint8x16_t NeedsHev(const uint8x16_t p1, const uint8x16_t p0,
const uint8x16_t hev_thresh_v = vdupq_n_u8((uint8_t)hev_thresh);
const uint8x16_t a_p1_p0 = vabdq_u8(p1, p0); // abs(p1 - p0)
const uint8x16_t a_q1_q0 = vabdq_u8(q1, q0); // abs(q1 - q0)
- const uint8x16_t mask1 = vcgtq_u8(a_p1_p0, hev_thresh_v);
- const uint8x16_t mask2 = vcgtq_u8(a_q1_q0, hev_thresh_v);
- const uint8x16_t mask = vorrq_u8(mask1, mask2);
+ const uint8x16_t a_max = vmaxq_u8(a_p1_p0, a_q1_q0);
+ const uint8x16_t mask = vcgtq_u8(a_max, hev_thresh_v);
return mask;
}
@@ -756,24 +755,25 @@ static void ApplyFilter6(
const int8x16_t delta,
uint8x16_t* const op2, uint8x16_t* const op1, uint8x16_t* const op0,
uint8x16_t* const oq0, uint8x16_t* const oq1, uint8x16_t* const oq2) {
- const int16x8_t kCst63 = vdupq_n_s16(63);
- const int8x8_t kCst27 = vdup_n_s8(27);
- const int8x8_t kCst18 = vdup_n_s8(18);
- const int8x8_t kCst9 = vdup_n_s8(9);
+ // We have to compute: X = (9*a+63) >> 7, Y = (18*a+63)>>7, Z = (27*a+63) >> 7
+ // Turns out, there's a common sub-expression S=9 * a - 1 that can be used
+ // with the special vqrshrn_n_s16 rounding-shift-and-narrow instruction:
+ // X = (S + 64) >> 7, Y = (S + 32) >> 6, Z = (18 * a + S + 64) >> 7
const int8x8_t delta_lo = vget_low_s8(delta);
const int8x8_t delta_hi = vget_high_s8(delta);
- const int16x8_t s1_lo = vmlal_s8(kCst63, kCst27, delta_lo); // 63 + 27 * a
- const int16x8_t s1_hi = vmlal_s8(kCst63, kCst27, delta_hi); // 63 + 27 * a
- const int16x8_t s2_lo = vmlal_s8(kCst63, kCst18, delta_lo); // 63 + 18 * a
- const int16x8_t s2_hi = vmlal_s8(kCst63, kCst18, delta_hi); // 63 + 18 * a
- const int16x8_t s3_lo = vmlal_s8(kCst63, kCst9, delta_lo); // 63 + 9 * a
- const int16x8_t s3_hi = vmlal_s8(kCst63, kCst9, delta_hi); // 63 + 9 * a
- const int8x8_t a1_lo = vqshrn_n_s16(s1_lo, 7);
- const int8x8_t a1_hi = vqshrn_n_s16(s1_hi, 7);
- const int8x8_t a2_lo = vqshrn_n_s16(s2_lo, 7);
- const int8x8_t a2_hi = vqshrn_n_s16(s2_hi, 7);
- const int8x8_t a3_lo = vqshrn_n_s16(s3_lo, 7);
- const int8x8_t a3_hi = vqshrn_n_s16(s3_hi, 7);
+ const int8x8_t kCst9 = vdup_n_s8(9);
+ const int16x8_t kCstm1 = vdupq_n_s16(-1);
+ const int8x8_t kCst18 = vdup_n_s8(18);
+ const int16x8_t S_lo = vmlal_s8(kCstm1, kCst9, delta_lo); // S = 9 * a - 1
+ const int16x8_t S_hi = vmlal_s8(kCstm1, kCst9, delta_hi);
+ const int16x8_t Z_lo = vmlal_s8(S_lo, kCst18, delta_lo); // S + 18 * a
+ const int16x8_t Z_hi = vmlal_s8(S_hi, kCst18, delta_hi);
+ const int8x8_t a3_lo = vqrshrn_n_s16(S_lo, 7); // (9 * a + 63) >> 7
+ const int8x8_t a3_hi = vqrshrn_n_s16(S_hi, 7);
+ const int8x8_t a2_lo = vqrshrn_n_s16(S_lo, 6); // (9 * a + 31) >> 6
+ const int8x8_t a2_hi = vqrshrn_n_s16(S_hi, 6);
+ const int8x8_t a1_lo = vqrshrn_n_s16(Z_lo, 7); // (27 * a + 63) >> 7
+ const int8x8_t a1_hi = vqrshrn_n_s16(Z_hi, 7);
const int8x16_t a1 = vcombine_s8(a1_lo, a1_hi);
const int8x16_t a2 = vcombine_s8(a2_lo, a2_hi);
const int8x16_t a3 = vcombine_s8(a3_lo, a3_hi);
diff --git a/thirdparty/libwebp/dsp/dec_sse2.c b/thirdparty/libwebp/dsp/dec_sse2.c
index f0a8ddcaf3..411fb02768 100644
--- a/thirdparty/libwebp/dsp/dec_sse2.c
+++ b/thirdparty/libwebp/dsp/dec_sse2.c
@@ -22,7 +22,7 @@
#include <emmintrin.h>
#include "./common_sse2.h"
-#include "../dec/vp8i.h"
+#include "../dec/vp8i_dec.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
@@ -140,7 +140,7 @@ static void Transform(const int16_t* in, uint8_t* dst, int do_two) {
// Transpose the two 4x4.
VP8Transpose_2_4x4_16b(&shifted0, &shifted1, &shifted2, &shifted3, &T0, &T1,
- &T2, &T3);
+ &T2, &T3);
}
// Add inverse transform to 'dst' and store.
diff --git a/thirdparty/libwebp/dsp/dec_sse41.c b/thirdparty/libwebp/dsp/dec_sse41.c
index 8d6aed13e6..4e81ec4d80 100644
--- a/thirdparty/libwebp/dsp/dec_sse41.c
+++ b/thirdparty/libwebp/dsp/dec_sse41.c
@@ -16,7 +16,7 @@
#if defined(WEBP_USE_SSE41)
#include <smmintrin.h>
-#include "../dec/vp8i.h"
+#include "../dec/vp8i_dec.h"
#include "../utils/utils.h"
static void HE16(uint8_t* dst) { // horizontal
diff --git a/thirdparty/libwebp/dsp/dsp.h b/thirdparty/libwebp/dsp/dsp.h
index 1faac27b2b..813fed4a35 100644
--- a/thirdparty/libwebp/dsp/dsp.h
+++ b/thirdparty/libwebp/dsp/dsp.h
@@ -111,8 +111,7 @@ extern "C" {
#define WEBP_UBSAN_IGNORE_UNDEF
#define WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW
-#if !defined(WEBP_FORCE_ALIGNED) && defined(__clang__) && \
- defined(__has_attribute)
+#if defined(__clang__) && defined(__has_attribute)
#if __has_attribute(no_sanitize)
// This macro prevents the undefined behavior sanitizer from reporting
// failures. This is only meant to silence unaligned loads on platforms that
@@ -133,6 +132,7 @@ extern "C" {
typedef enum {
kSSE2,
kSSE3,
+ kSlowSSSE3, // special feature for slow SSSE3 architectures
kSSE4_1,
kAVX,
kAVX2,
@@ -185,6 +185,11 @@ typedef int (*VP8WMetric)(const uint8_t* pix, const uint8_t* ref,
// 4 by 4 symmetric matrix.
extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16;
+// Compute the average (DC) of four 4x4 blocks.
+// Each sub-4x4 block #i sum is stored in dc[i].
+typedef void (*VP8MeanMetric)(const uint8_t* ref, uint32_t dc[4]);
+extern VP8MeanMetric VP8Mean16x4;
+
typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst);
extern VP8BlockCopy VP8Copy4x4;
extern VP8BlockCopy VP8Copy16x8;
@@ -246,30 +251,37 @@ extern VP8GetResidualCostFunc VP8GetResidualCost;
void VP8EncDspCostInit(void);
//------------------------------------------------------------------------------
-// SSIM utils
+// SSIM / PSNR utils
// struct for accumulating statistical moments
typedef struct {
- double w; // sum(w_i) : sum of weights
- double xm, ym; // sum(w_i * x_i), sum(w_i * y_i)
- double xxm, xym, yym; // sum(w_i * x_i * x_i), etc.
+ uint32_t w; // sum(w_i) : sum of weights
+ uint32_t xm, ym; // sum(w_i * x_i), sum(w_i * y_i)
+ uint32_t xxm, xym, yym; // sum(w_i * x_i * x_i), etc.
} VP8DistoStats;
+// Compute the final SSIM value
+// The non-clipped version assumes stats->w = (2 * VP8_SSIM_KERNEL + 1)^2.
+double VP8SSIMFromStats(const VP8DistoStats* const stats);
+double VP8SSIMFromStatsClipped(const VP8DistoStats* const stats);
+
#define VP8_SSIM_KERNEL 3 // total size of the kernel: 2 * VP8_SSIM_KERNEL + 1
-typedef void (*VP8SSIMAccumulateClippedFunc)(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int xo, int yo, // center position
- int W, int H, // plane dimension
- VP8DistoStats* const stats);
+typedef double (*VP8SSIMGetClippedFunc)(const uint8_t* src1, int stride1,
+ const uint8_t* src2, int stride2,
+ int xo, int yo, // center position
+ int W, int H); // plane dimension
// This version is called with the guarantee that you can load 8 bytes and
// 8 rows at offset src1 and src2
-typedef void (*VP8SSIMAccumulateFunc)(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- VP8DistoStats* const stats);
+typedef double (*VP8SSIMGetFunc)(const uint8_t* src1, int stride1,
+ const uint8_t* src2, int stride2);
+
+extern VP8SSIMGetFunc VP8SSIMGet; // unclipped / unchecked
+extern VP8SSIMGetClippedFunc VP8SSIMGetClipped; // with clipping
-extern VP8SSIMAccumulateFunc VP8SSIMAccumulate; // unclipped / unchecked
-extern VP8SSIMAccumulateClippedFunc VP8SSIMAccumulateClipped; // with clipping
+typedef uint32_t (*VP8AccumulateSSEFunc)(const uint8_t* src1,
+ const uint8_t* src2, int len);
+extern VP8AccumulateSSEFunc VP8AccumulateSSE;
// must be called before using any of the above directly
void VP8SSIMDspInit(void);
@@ -416,6 +428,15 @@ extern void WebPConvertARGBToUV_C(const uint32_t* argb, uint8_t* u, uint8_t* v,
extern void WebPConvertRGBA32ToUV_C(const uint16_t* rgb,
uint8_t* u, uint8_t* v, int width);
+// utilities for accurate RGB->YUV conversion
+extern uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* src, const uint16_t* ref,
+ uint16_t* dst, int len);
+extern void (*WebPSharpYUVUpdateRGB)(const int16_t* src, const int16_t* ref,
+ int16_t* dst, int len);
+extern void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B,
+ int len,
+ const uint16_t* best_y, uint16_t* out);
+
// Must be called before using the above.
void WebPInitConvertARGBToYUV(void);
@@ -488,6 +509,10 @@ extern int (*WebPExtractAlpha)(const uint8_t* argb, int argb_stride,
int width, int height,
uint8_t* alpha, int alpha_stride);
+// Extract the green values from 32b values in argb[] and pack them into alpha[]
+// (this is the opposite of WebPDispatchAlphaToGreen).
+extern void (*WebPExtractGreen)(const uint32_t* argb, uint8_t* alpha, int size);
+
// Pre-Multiply operation transforms x into x * A / 255 (where x=Y,R,G or B).
// Un-Multiply operation transforms x into x * 255 / A.
diff --git a/thirdparty/libwebp/dsp/enc.c b/thirdparty/libwebp/dsp/enc.c
index db0e9e70ae..f31bc6de18 100644
--- a/thirdparty/libwebp/dsp/enc.c
+++ b/thirdparty/libwebp/dsp/enc.c
@@ -15,7 +15,7 @@
#include <stdlib.h> // for abs()
#include "./dsp.h"
-#include "../enc/vp8enci.h"
+#include "../enc/vp8i_enc.h"
static WEBP_INLINE uint8_t clip_8b(int v) {
return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255;
@@ -551,6 +551,20 @@ static int SSE4x4(const uint8_t* a, const uint8_t* b) {
return GetSSE(a, b, 4, 4);
}
+static void Mean16x4(const uint8_t* ref, uint32_t dc[4]) {
+ int k, x, y;
+ for (k = 0; k < 4; ++k) {
+ uint32_t avg = 0;
+ for (y = 0; y < 4; ++y) {
+ for (x = 0; x < 4; ++x) {
+ avg += ref[x + y * BPS];
+ }
+ }
+ dc[k] = avg;
+ ref += 4; // go to next 4x4 block.
+ }
+}
+
//------------------------------------------------------------------------------
// Texture distortion
//
@@ -656,32 +670,6 @@ static int Quantize2Blocks(int16_t in[32], int16_t out[32],
return nz;
}
-static int QuantizeBlockWHT(int16_t in[16], int16_t out[16],
- const VP8Matrix* const mtx) {
- int n, last = -1;
- for (n = 0; n < 16; ++n) {
- const int j = kZigzag[n];
- const int sign = (in[j] < 0);
- const uint32_t coeff = sign ? -in[j] : in[j];
- assert(mtx->sharpen_[j] == 0);
- if (coeff > mtx->zthresh_[j]) {
- const uint32_t Q = mtx->q_[j];
- const uint32_t iQ = mtx->iq_[j];
- const uint32_t B = mtx->bias_[j];
- int level = QUANTDIV(coeff, iQ, B);
- if (level > MAX_LEVEL) level = MAX_LEVEL;
- if (sign) level = -level;
- in[j] = level * (int)Q;
- out[n] = level;
- if (level) last = n;
- } else {
- out[n] = 0;
- in[j] = 0;
- }
- }
- return (last >= 0);
-}
-
//------------------------------------------------------------------------------
// Block copy
@@ -703,11 +691,51 @@ static void Copy16x8(const uint8_t* src, uint8_t* dst) {
}
//------------------------------------------------------------------------------
+// SSIM / PSNR
-static void SSIMAccumulateClipped(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int xo, int yo, int W, int H,
- VP8DistoStats* const stats) {
+// hat-shaped filter. Sum of coefficients is equal to 16.
+static const uint32_t kWeight[2 * VP8_SSIM_KERNEL + 1] = {
+ 1, 2, 3, 4, 3, 2, 1
+};
+static const uint32_t kWeightSum = 16 * 16; // sum{kWeight}^2
+
+static WEBP_INLINE double SSIMCalculation(
+ const VP8DistoStats* const stats, uint32_t N /*num samples*/) {
+ const uint32_t w2 = N * N;
+ const uint32_t C1 = 20 * w2;
+ const uint32_t C2 = 60 * w2;
+ const uint32_t C3 = 8 * 8 * w2; // 'dark' limit ~= 6
+ const uint64_t xmxm = (uint64_t)stats->xm * stats->xm;
+ const uint64_t ymym = (uint64_t)stats->ym * stats->ym;
+ if (xmxm + ymym >= C3) {
+ const int64_t xmym = (int64_t)stats->xm * stats->ym;
+ const int64_t sxy = (int64_t)stats->xym * N - xmym; // can be negative
+ const uint64_t sxx = (uint64_t)stats->xxm * N - xmxm;
+ const uint64_t syy = (uint64_t)stats->yym * N - ymym;
+ // we descale by 8 to prevent overflow during the fnum/fden multiply.
+ const uint64_t num_S = (2 * (uint64_t)(sxy < 0 ? 0 : sxy) + C2) >> 8;
+ const uint64_t den_S = (sxx + syy + C2) >> 8;
+ const uint64_t fnum = (2 * xmym + C1) * num_S;
+ const uint64_t fden = (xmxm + ymym + C1) * den_S;
+ const double r = (double)fnum / fden;
+ assert(r >= 0. && r <= 1.0);
+ return r;
+ }
+ return 1.; // area is too dark to contribute meaningfully
+}
+
+double VP8SSIMFromStats(const VP8DistoStats* const stats) {
+ return SSIMCalculation(stats, kWeightSum);
+}
+
+double VP8SSIMFromStatsClipped(const VP8DistoStats* const stats) {
+ return SSIMCalculation(stats, stats->w);
+}
+
+static double SSIMGetClipped_C(const uint8_t* src1, int stride1,
+ const uint8_t* src2, int stride2,
+ int xo, int yo, int W, int H) {
+ VP8DistoStats stats = { 0, 0, 0, 0, 0, 0 };
const int ymin = (yo - VP8_SSIM_KERNEL < 0) ? 0 : yo - VP8_SSIM_KERNEL;
const int ymax = (yo + VP8_SSIM_KERNEL > H - 1) ? H - 1
: yo + VP8_SSIM_KERNEL;
@@ -719,38 +747,61 @@ static void SSIMAccumulateClipped(const uint8_t* src1, int stride1,
src2 += ymin * stride2;
for (y = ymin; y <= ymax; ++y, src1 += stride1, src2 += stride2) {
for (x = xmin; x <= xmax; ++x) {
- const int s1 = src1[x];
- const int s2 = src2[x];
- stats->w += 1;
- stats->xm += s1;
- stats->ym += s2;
- stats->xxm += s1 * s1;
- stats->xym += s1 * s2;
- stats->yym += s2 * s2;
+ const uint32_t w = kWeight[VP8_SSIM_KERNEL + x - xo]
+ * kWeight[VP8_SSIM_KERNEL + y - yo];
+ const uint32_t s1 = src1[x];
+ const uint32_t s2 = src2[x];
+ stats.w += w;
+ stats.xm += w * s1;
+ stats.ym += w * s2;
+ stats.xxm += w * s1 * s1;
+ stats.xym += w * s1 * s2;
+ stats.yym += w * s2 * s2;
}
}
+ return VP8SSIMFromStatsClipped(&stats);
}
-static void SSIMAccumulate(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- VP8DistoStats* const stats) {
+static double SSIMGet_C(const uint8_t* src1, int stride1,
+ const uint8_t* src2, int stride2) {
+ VP8DistoStats stats = { 0, 0, 0, 0, 0, 0 };
int x, y;
for (y = 0; y <= 2 * VP8_SSIM_KERNEL; ++y, src1 += stride1, src2 += stride2) {
for (x = 0; x <= 2 * VP8_SSIM_KERNEL; ++x) {
- const int s1 = src1[x];
- const int s2 = src2[x];
- stats->w += 1;
- stats->xm += s1;
- stats->ym += s2;
- stats->xxm += s1 * s1;
- stats->xym += s1 * s2;
- stats->yym += s2 * s2;
+ const uint32_t w = kWeight[x] * kWeight[y];
+ const uint32_t s1 = src1[x];
+ const uint32_t s2 = src2[x];
+ stats.xm += w * s1;
+ stats.ym += w * s2;
+ stats.xxm += w * s1 * s1;
+ stats.xym += w * s1 * s2;
+ stats.yym += w * s2 * s2;
}
}
+ return VP8SSIMFromStats(&stats);
+}
+
+//------------------------------------------------------------------------------
+
+static uint32_t AccumulateSSE(const uint8_t* src1,
+ const uint8_t* src2, int len) {
+ int i;
+ uint32_t sse2 = 0;
+ assert(len <= 65535); // to ensure that accumulation fits within uint32_t
+ for (i = 0; i < len; ++i) {
+ const int32_t diff = src1[i] - src2[i];
+ sse2 += diff * diff;
+ }
+ return sse2;
}
-VP8SSIMAccumulateFunc VP8SSIMAccumulate;
-VP8SSIMAccumulateClippedFunc VP8SSIMAccumulateClipped;
+//------------------------------------------------------------------------------
+
+VP8SSIMGetFunc VP8SSIMGet;
+VP8SSIMGetClippedFunc VP8SSIMGetClipped;
+VP8AccumulateSSEFunc VP8AccumulateSSE;
+
+extern void VP8SSIMDspInitSSE2(void);
static volatile VP8CPUInfo ssim_last_cpuinfo_used =
(VP8CPUInfo)&ssim_last_cpuinfo_used;
@@ -758,8 +809,17 @@ static volatile VP8CPUInfo ssim_last_cpuinfo_used =
WEBP_TSAN_IGNORE_FUNCTION void VP8SSIMDspInit(void) {
if (ssim_last_cpuinfo_used == VP8GetCPUInfo) return;
- VP8SSIMAccumulate = SSIMAccumulate;
- VP8SSIMAccumulateClipped = SSIMAccumulateClipped;
+ VP8SSIMGetClipped = SSIMGetClipped_C;
+ VP8SSIMGet = SSIMGet_C;
+
+ VP8AccumulateSSE = AccumulateSSE;
+ if (VP8GetCPUInfo != NULL) {
+#if defined(WEBP_USE_SSE2)
+ if (VP8GetCPUInfo(kSSE2)) {
+ VP8SSIMDspInitSSE2();
+ }
+#endif
+ }
ssim_last_cpuinfo_used = VP8GetCPUInfo;
}
@@ -783,6 +843,7 @@ VP8Metric VP8SSE16x8;
VP8Metric VP8SSE4x4;
VP8WMetric VP8TDisto4x4;
VP8WMetric VP8TDisto16x16;
+VP8MeanMetric VP8Mean16x4;
VP8QuantizeBlock VP8EncQuantizeBlock;
VP8Quantize2Blocks VP8EncQuantize2Blocks;
VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT;
@@ -795,6 +856,7 @@ extern void VP8EncDspInitAVX2(void);
extern void VP8EncDspInitNEON(void);
extern void VP8EncDspInitMIPS32(void);
extern void VP8EncDspInitMIPSdspR2(void);
+extern void VP8EncDspInitMSA(void);
static volatile VP8CPUInfo enc_last_cpuinfo_used =
(VP8CPUInfo)&enc_last_cpuinfo_used;
@@ -820,9 +882,10 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInit(void) {
VP8SSE4x4 = SSE4x4;
VP8TDisto4x4 = Disto4x4;
VP8TDisto16x16 = Disto16x16;
+ VP8Mean16x4 = Mean16x4;
VP8EncQuantizeBlock = QuantizeBlock;
VP8EncQuantize2Blocks = Quantize2Blocks;
- VP8EncQuantizeBlockWHT = QuantizeBlockWHT;
+ VP8EncQuantizeBlockWHT = QuantizeBlock;
VP8Copy4x4 = Copy4x4;
VP8Copy16x8 = Copy16x8;
@@ -858,6 +921,11 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInit(void) {
VP8EncDspInitMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ VP8EncDspInitMSA();
+ }
+#endif
}
enc_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/thirdparty/libwebp/dsp/enc_mips32.c b/thirdparty/libwebp/dsp/enc_mips32.c
index fd10143de9..752b14daf6 100644
--- a/thirdparty/libwebp/dsp/enc_mips32.c
+++ b/thirdparty/libwebp/dsp/enc_mips32.c
@@ -18,8 +18,8 @@
#if defined(WEBP_USE_MIPS32)
#include "./mips_macro.h"
-#include "../enc/vp8enci.h"
-#include "../enc/cost.h"
+#include "../enc/vp8i_enc.h"
+#include "../enc/cost_enc.h"
static const int kC1 = 20091 + (1 << 16);
static const int kC2 = 35468;
diff --git a/thirdparty/libwebp/dsp/enc_mips_dsp_r2.c b/thirdparty/libwebp/dsp/enc_mips_dsp_r2.c
index 7ab96f6800..6c8c1c6acd 100644
--- a/thirdparty/libwebp/dsp/enc_mips_dsp_r2.c
+++ b/thirdparty/libwebp/dsp/enc_mips_dsp_r2.c
@@ -17,8 +17,8 @@
#if defined(WEBP_USE_MIPS_DSP_R2)
#include "./mips_macro.h"
-#include "../enc/cost.h"
-#include "../enc/vp8enci.h"
+#include "../enc/cost_enc.h"
+#include "../enc/vp8i_enc.h"
static const int kC1 = 20091 + (1 << 16);
static const int kC2 = 35468;
diff --git a/thirdparty/libwebp/dsp/enc_msa.c b/thirdparty/libwebp/dsp/enc_msa.c
new file mode 100644
index 0000000000..909b46d5d9
--- /dev/null
+++ b/thirdparty/libwebp/dsp/enc_msa.c
@@ -0,0 +1,892 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA version of encoder dsp functions.
+//
+// Author: Prashant Patil (prashant.patil@imgtec.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include <stdlib.h>
+#include "./msa_macro.h"
+#include "../enc/vp8i_enc.h"
+
+//------------------------------------------------------------------------------
+// Transforms
+
+#define IDCT_1D_W(in0, in1, in2, in3, out0, out1, out2, out3) do { \
+ v4i32 a1_m, b1_m, c1_m, d1_m; \
+ const v4i32 cospi8sqrt2minus1 = __msa_fill_w(20091); \
+ const v4i32 sinpi8sqrt2 = __msa_fill_w(35468); \
+ v4i32 c_tmp1_m = in1 * sinpi8sqrt2; \
+ v4i32 c_tmp2_m = in3 * cospi8sqrt2minus1; \
+ v4i32 d_tmp1_m = in1 * cospi8sqrt2minus1; \
+ v4i32 d_tmp2_m = in3 * sinpi8sqrt2; \
+ \
+ ADDSUB2(in0, in2, a1_m, b1_m); \
+ SRAI_W2_SW(c_tmp1_m, c_tmp2_m, 16); \
+ c_tmp2_m = c_tmp2_m + in3; \
+ c1_m = c_tmp1_m - c_tmp2_m; \
+ SRAI_W2_SW(d_tmp1_m, d_tmp2_m, 16); \
+ d_tmp1_m = d_tmp1_m + in1; \
+ d1_m = d_tmp1_m + d_tmp2_m; \
+ BUTTERFLY_4(a1_m, b1_m, c1_m, d1_m, out0, out1, out2, out3); \
+} while (0)
+
+static WEBP_INLINE void ITransformOne(const uint8_t* ref, const int16_t* in,
+ uint8_t* dst) {
+ v8i16 input0, input1;
+ v4i32 in0, in1, in2, in3, hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3;
+ v4i32 res0, res1, res2, res3;
+ v16i8 dest0, dest1, dest2, dest3;
+ const v16i8 zero = { 0 };
+
+ LD_SH2(in, 8, input0, input1);
+ UNPCK_SH_SW(input0, in0, in1);
+ UNPCK_SH_SW(input1, in2, in3);
+ IDCT_1D_W(in0, in1, in2, in3, hz0, hz1, hz2, hz3);
+ TRANSPOSE4x4_SW_SW(hz0, hz1, hz2, hz3, hz0, hz1, hz2, hz3);
+ IDCT_1D_W(hz0, hz1, hz2, hz3, vt0, vt1, vt2, vt3);
+ SRARI_W4_SW(vt0, vt1, vt2, vt3, 3);
+ TRANSPOSE4x4_SW_SW(vt0, vt1, vt2, vt3, vt0, vt1, vt2, vt3);
+ LD_SB4(ref, BPS, dest0, dest1, dest2, dest3);
+ ILVR_B4_SW(zero, dest0, zero, dest1, zero, dest2, zero, dest3,
+ res0, res1, res2, res3);
+ ILVR_H4_SW(zero, res0, zero, res1, zero, res2, zero, res3,
+ res0, res1, res2, res3);
+ ADD4(res0, vt0, res1, vt1, res2, vt2, res3, vt3, res0, res1, res2, res3);
+ CLIP_SW4_0_255(res0, res1, res2, res3);
+ PCKEV_B2_SW(res0, res1, res2, res3, vt0, vt1);
+ res0 = (v4i32)__msa_pckev_b((v16i8)vt0, (v16i8)vt1);
+ ST4x4_UB(res0, res0, 3, 2, 1, 0, dst, BPS);
+}
+
+static void ITransform(const uint8_t* ref, const int16_t* in, uint8_t* dst,
+ int do_two) {
+ ITransformOne(ref, in, dst);
+ if (do_two) {
+ ITransformOne(ref + 4, in + 16, dst + 4);
+ }
+}
+
+static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) {
+ uint64_t out0, out1, out2, out3;
+ uint32_t in0, in1, in2, in3;
+ v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5;
+ v8i16 t0, t1, t2, t3;
+ v16u8 srcl0, srcl1, src0, src1;
+ const v8i16 mask0 = { 0, 4, 8, 12, 1, 5, 9, 13 };
+ const v8i16 mask1 = { 3, 7, 11, 15, 2, 6, 10, 14 };
+ const v8i16 mask2 = { 4, 0, 5, 1, 6, 2, 7, 3 };
+ const v8i16 mask3 = { 0, 4, 1, 5, 2, 6, 3, 7 };
+ const v8i16 cnst0 = { 2217, -5352, 2217, -5352, 2217, -5352, 2217, -5352 };
+ const v8i16 cnst1 = { 5352, 2217, 5352, 2217, 5352, 2217, 5352, 2217 };
+
+ LW4(src, BPS, in0, in1, in2, in3);
+ INSERT_W4_UB(in0, in1, in2, in3, src0);
+ LW4(ref, BPS, in0, in1, in2, in3);
+ INSERT_W4_UB(in0, in1, in2, in3, src1);
+ ILVRL_B2_UB(src0, src1, srcl0, srcl1);
+ HSUB_UB2_SH(srcl0, srcl1, t0, t1);
+ VSHF_H2_SH(t0, t1, t0, t1, mask0, mask1, t2, t3);
+ ADDSUB2(t2, t3, t0, t1);
+ t0 = SRLI_H(t0, 3);
+ VSHF_H2_SH(t0, t0, t1, t1, mask2, mask3, t3, t2);
+ tmp0 = __msa_hadd_s_w(t3, t3);
+ tmp2 = __msa_hsub_s_w(t3, t3);
+ FILL_W2_SW(1812, 937, tmp1, tmp3);
+ DPADD_SH2_SW(t2, t2, cnst0, cnst1, tmp3, tmp1);
+ SRAI_W2_SW(tmp1, tmp3, 9);
+ PCKEV_H2_SH(tmp1, tmp0, tmp3, tmp2, t0, t1);
+ VSHF_H2_SH(t0, t1, t0, t1, mask0, mask1, t2, t3);
+ ADDSUB2(t2, t3, t0, t1);
+ VSHF_H2_SH(t0, t0, t1, t1, mask2, mask3, t3, t2);
+ tmp0 = __msa_hadd_s_w(t3, t3);
+ tmp2 = __msa_hsub_s_w(t3, t3);
+ ADDVI_W2_SW(tmp0, 7, tmp2, 7, tmp0, tmp2);
+ SRAI_W2_SW(tmp0, tmp2, 4);
+ FILL_W2_SW(12000, 51000, tmp1, tmp3);
+ DPADD_SH2_SW(t2, t2, cnst0, cnst1, tmp3, tmp1);
+ SRAI_W2_SW(tmp1, tmp3, 16);
+ UNPCK_R_SH_SW(t1, tmp4);
+ tmp5 = __msa_ceqi_w(tmp4, 0);
+ tmp4 = (v4i32)__msa_nor_v((v16u8)tmp5, (v16u8)tmp5);
+ tmp5 = __msa_fill_w(1);
+ tmp5 = (v4i32)__msa_and_v((v16u8)tmp5, (v16u8)tmp4);
+ tmp1 += tmp5;
+ PCKEV_H2_SH(tmp1, tmp0, tmp3, tmp2, t0, t1);
+ out0 = __msa_copy_s_d((v2i64)t0, 0);
+ out1 = __msa_copy_s_d((v2i64)t0, 1);
+ out2 = __msa_copy_s_d((v2i64)t1, 0);
+ out3 = __msa_copy_s_d((v2i64)t1, 1);
+ SD4(out0, out1, out2, out3, out, 8);
+}
+
+static void FTransformWHT(const int16_t* in, int16_t* out) {
+ v8i16 in0 = { 0 };
+ v8i16 in1 = { 0 };
+ v8i16 tmp0, tmp1, tmp2, tmp3;
+ v8i16 out0, out1;
+ const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 };
+ const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 };
+ const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 };
+ const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 };
+
+ in0 = __msa_insert_h(in0, 0, in[ 0]);
+ in0 = __msa_insert_h(in0, 1, in[ 64]);
+ in0 = __msa_insert_h(in0, 2, in[128]);
+ in0 = __msa_insert_h(in0, 3, in[192]);
+ in0 = __msa_insert_h(in0, 4, in[ 16]);
+ in0 = __msa_insert_h(in0, 5, in[ 80]);
+ in0 = __msa_insert_h(in0, 6, in[144]);
+ in0 = __msa_insert_h(in0, 7, in[208]);
+ in1 = __msa_insert_h(in1, 0, in[ 48]);
+ in1 = __msa_insert_h(in1, 1, in[112]);
+ in1 = __msa_insert_h(in1, 2, in[176]);
+ in1 = __msa_insert_h(in1, 3, in[240]);
+ in1 = __msa_insert_h(in1, 4, in[ 32]);
+ in1 = __msa_insert_h(in1, 5, in[ 96]);
+ in1 = __msa_insert_h(in1, 6, in[160]);
+ in1 = __msa_insert_h(in1, 7, in[224]);
+ ADDSUB2(in0, in1, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
+ ADDSUB2(tmp2, tmp3, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
+ ADDSUB2(in0, in1, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
+ ADDSUB2(tmp2, tmp3, out0, out1);
+ SRAI_H2_SH(out0, out1, 1);
+ ST_SH2(out0, out1, out, 8);
+}
+
+static int TTransform(const uint8_t* in, const uint16_t* w) {
+ int sum;
+ uint32_t in0_m, in1_m, in2_m, in3_m;
+ v16i8 src0;
+ v8i16 in0, in1, tmp0, tmp1, tmp2, tmp3;
+ v4i32 dst0, dst1;
+ const v16i8 zero = { 0 };
+ const v8i16 mask0 = { 0, 1, 2, 3, 8, 9, 10, 11 };
+ const v8i16 mask1 = { 4, 5, 6, 7, 12, 13, 14, 15 };
+ const v8i16 mask2 = { 0, 4, 8, 12, 1, 5, 9, 13 };
+ const v8i16 mask3 = { 3, 7, 11, 15, 2, 6, 10, 14 };
+
+ LW4(in, BPS, in0_m, in1_m, in2_m, in3_m);
+ INSERT_W4_SB(in0_m, in1_m, in2_m, in3_m, src0);
+ ILVRL_B2_SH(zero, src0, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
+ ADDSUB2(in0, in1, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
+ ADDSUB2(tmp2, tmp3, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask2, mask3, in0, in1);
+ ADDSUB2(in0, in1, tmp0, tmp1);
+ VSHF_H2_SH(tmp0, tmp1, tmp0, tmp1, mask0, mask1, tmp2, tmp3);
+ ADDSUB2(tmp2, tmp3, tmp0, tmp1);
+ tmp0 = __msa_add_a_h(tmp0, (v8i16)zero);
+ tmp1 = __msa_add_a_h(tmp1, (v8i16)zero);
+ LD_SH2(w, 8, tmp2, tmp3);
+ DOTP_SH2_SW(tmp0, tmp1, tmp2, tmp3, dst0, dst1);
+ dst0 = dst0 + dst1;
+ sum = HADD_SW_S32(dst0);
+ return sum;
+}
+
+static int Disto4x4(const uint8_t* const a, const uint8_t* const b,
+ const uint16_t* const w) {
+ const int sum1 = TTransform(a, w);
+ const int sum2 = TTransform(b, w);
+ return abs(sum2 - sum1) >> 5;
+}
+
+static int Disto16x16(const uint8_t* const a, const uint8_t* const b,
+ const uint16_t* const w) {
+ int D = 0;
+ int x, y;
+ for (y = 0; y < 16 * BPS; y += 4 * BPS) {
+ for (x = 0; x < 16; x += 4) {
+ D += Disto4x4(a + x + y, b + x + y, w);
+ }
+ }
+ return D;
+}
+
+//------------------------------------------------------------------------------
+// Histogram
+
+static void CollectHistogram(const uint8_t* ref, const uint8_t* pred,
+ int start_block, int end_block,
+ VP8Histogram* const histo) {
+ int j;
+ int distribution[MAX_COEFF_THRESH + 1] = { 0 };
+ for (j = start_block; j < end_block; ++j) {
+ int16_t out[16];
+ VP8FTransform(ref + VP8DspScan[j], pred + VP8DspScan[j], out);
+ {
+ int k;
+ v8i16 coeff0, coeff1;
+ const v8i16 zero = { 0 };
+ const v8i16 max_coeff_thr = __msa_ldi_h(MAX_COEFF_THRESH);
+ LD_SH2(&out[0], 8, coeff0, coeff1);
+ coeff0 = __msa_add_a_h(coeff0, zero);
+ coeff1 = __msa_add_a_h(coeff1, zero);
+ SRAI_H2_SH(coeff0, coeff1, 3);
+ coeff0 = __msa_min_s_h(coeff0, max_coeff_thr);
+ coeff1 = __msa_min_s_h(coeff1, max_coeff_thr);
+ ST_SH2(coeff0, coeff1, &out[0], 8);
+ for (k = 0; k < 16; ++k) {
+ ++distribution[out[k]];
+ }
+ }
+ }
+ VP8SetHistogramData(distribution, histo);
+}
+
+//------------------------------------------------------------------------------
+// Intra predictions
+
+// luma 4x4 prediction
+
+#define DST(x, y) dst[(x) + (y) * BPS]
+#define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
+#define AVG2(a, b) (((a) + (b) + 1) >> 1)
+
+static WEBP_INLINE void VE4(uint8_t* dst, const uint8_t* top) { // vertical
+ const uint64_t val_m = LD(top - 1);
+ const v16u8 A = (v16u8)__msa_insert_d((v2i64)A, 0, val_m);
+ const v16u8 B = SLDI_UB(A, A, 1);
+ const v16u8 C = SLDI_UB(A, A, 2);
+ const v16u8 AC = __msa_ave_u_b(A, C);
+ const v16u8 B2 = __msa_ave_u_b(B, B);
+ const v16u8 R = __msa_aver_u_b(AC, B2);
+ const uint32_t out = __msa_copy_s_w((v4i32)R, 0);
+ SW4(out, out, out, out, dst, BPS);
+}
+
+static WEBP_INLINE void HE4(uint8_t* dst, const uint8_t* top) { // horizontal
+ const int X = top[-1];
+ const int I = top[-2];
+ const int J = top[-3];
+ const int K = top[-4];
+ const int L = top[-5];
+ WebPUint32ToMem(dst + 0 * BPS, 0x01010101U * AVG3(X, I, J));
+ WebPUint32ToMem(dst + 1 * BPS, 0x01010101U * AVG3(I, J, K));
+ WebPUint32ToMem(dst + 2 * BPS, 0x01010101U * AVG3(J, K, L));
+ WebPUint32ToMem(dst + 3 * BPS, 0x01010101U * AVG3(K, L, L));
+}
+
+static WEBP_INLINE void DC4(uint8_t* dst, const uint8_t* top) {
+ uint32_t dc = 4;
+ int i;
+ for (i = 0; i < 4; ++i) dc += top[i] + top[-5 + i];
+ dc >>= 3;
+ dc = dc | (dc << 8) | (dc << 16) | (dc << 24);
+ SW4(dc, dc, dc, dc, dst, BPS);
+}
+
+static WEBP_INLINE void RD4(uint8_t* dst, const uint8_t* top) {
+ const uint64_t val_m = LD(top - 5);
+ const v16u8 A1 = (v16u8)__msa_insert_d((v2i64)A1, 0, val_m);
+ const v16u8 A = (v16u8)__msa_insert_b((v16i8)A1, 8, top[3]);
+ const v16u8 B = SLDI_UB(A, A, 1);
+ const v16u8 C = SLDI_UB(A, A, 2);
+ const v16u8 AC = __msa_ave_u_b(A, C);
+ const v16u8 B2 = __msa_ave_u_b(B, B);
+ const v16u8 R0 = __msa_aver_u_b(AC, B2);
+ const v16u8 R1 = SLDI_UB(R0, R0, 1);
+ const v16u8 R2 = SLDI_UB(R1, R1, 1);
+ const v16u8 R3 = SLDI_UB(R2, R2, 1);
+ const uint32_t val0 = __msa_copy_s_w((v4i32)R0, 0);
+ const uint32_t val1 = __msa_copy_s_w((v4i32)R1, 0);
+ const uint32_t val2 = __msa_copy_s_w((v4i32)R2, 0);
+ const uint32_t val3 = __msa_copy_s_w((v4i32)R3, 0);
+ SW4(val3, val2, val1, val0, dst, BPS);
+}
+
+static WEBP_INLINE void LD4(uint8_t* dst, const uint8_t* top) {
+ const uint64_t val_m = LD(top);
+ const v16u8 A = (v16u8)__msa_insert_d((v2i64)A, 0, val_m);
+ const v16u8 B = SLDI_UB(A, A, 1);
+ const v16u8 C1 = SLDI_UB(A, A, 2);
+ const v16u8 C = (v16u8)__msa_insert_b((v16i8)C1, 6, top[7]);
+ const v16u8 AC = __msa_ave_u_b(A, C);
+ const v16u8 B2 = __msa_ave_u_b(B, B);
+ const v16u8 R0 = __msa_aver_u_b(AC, B2);
+ const v16u8 R1 = SLDI_UB(R0, R0, 1);
+ const v16u8 R2 = SLDI_UB(R1, R1, 1);
+ const v16u8 R3 = SLDI_UB(R2, R2, 1);
+ const uint32_t val0 = __msa_copy_s_w((v4i32)R0, 0);
+ const uint32_t val1 = __msa_copy_s_w((v4i32)R1, 0);
+ const uint32_t val2 = __msa_copy_s_w((v4i32)R2, 0);
+ const uint32_t val3 = __msa_copy_s_w((v4i32)R3, 0);
+ SW4(val0, val1, val2, val3, dst, BPS);
+}
+
+static WEBP_INLINE void VR4(uint8_t* dst, const uint8_t* top) {
+ const int X = top[-1];
+ const int I = top[-2];
+ const int J = top[-3];
+ const int K = top[-4];
+ const int A = top[0];
+ const int B = top[1];
+ const int C = top[2];
+ const int D = top[3];
+ DST(0, 0) = DST(1, 2) = AVG2(X, A);
+ DST(1, 0) = DST(2, 2) = AVG2(A, B);
+ DST(2, 0) = DST(3, 2) = AVG2(B, C);
+ DST(3, 0) = AVG2(C, D);
+ DST(0, 3) = AVG3(K, J, I);
+ DST(0, 2) = AVG3(J, I, X);
+ DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
+ DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
+ DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
+ DST(3, 1) = AVG3(B, C, D);
+}
+
+static WEBP_INLINE void VL4(uint8_t* dst, const uint8_t* top) {
+ const int A = top[0];
+ const int B = top[1];
+ const int C = top[2];
+ const int D = top[3];
+ const int E = top[4];
+ const int F = top[5];
+ const int G = top[6];
+ const int H = top[7];
+ DST(0, 0) = AVG2(A, B);
+ DST(1, 0) = DST(0, 2) = AVG2(B, C);
+ DST(2, 0) = DST(1, 2) = AVG2(C, D);
+ DST(3, 0) = DST(2, 2) = AVG2(D, E);
+ DST(0, 1) = AVG3(A, B, C);
+ DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
+ DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
+ DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
+ DST(3, 2) = AVG3(E, F, G);
+ DST(3, 3) = AVG3(F, G, H);
+}
+
+static WEBP_INLINE void HU4(uint8_t* dst, const uint8_t* top) {
+ const int I = top[-2];
+ const int J = top[-3];
+ const int K = top[-4];
+ const int L = top[-5];
+ DST(0, 0) = AVG2(I, J);
+ DST(2, 0) = DST(0, 1) = AVG2(J, K);
+ DST(2, 1) = DST(0, 2) = AVG2(K, L);
+ DST(1, 0) = AVG3(I, J, K);
+ DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
+ DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
+ DST(3, 2) = DST(2, 2) =
+ DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
+}
+
+static WEBP_INLINE void HD4(uint8_t* dst, const uint8_t* top) {
+ const int X = top[-1];
+ const int I = top[-2];
+ const int J = top[-3];
+ const int K = top[-4];
+ const int L = top[-5];
+ const int A = top[0];
+ const int B = top[1];
+ const int C = top[2];
+ DST(0, 0) = DST(2, 1) = AVG2(I, X);
+ DST(0, 1) = DST(2, 2) = AVG2(J, I);
+ DST(0, 2) = DST(2, 3) = AVG2(K, J);
+ DST(0, 3) = AVG2(L, K);
+ DST(3, 0) = AVG3(A, B, C);
+ DST(2, 0) = AVG3(X, A, B);
+ DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
+ DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
+ DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
+ DST(1, 3) = AVG3(L, K, J);
+}
+
+static WEBP_INLINE void TM4(uint8_t* dst, const uint8_t* top) {
+ const v16i8 zero = { 0 };
+ const v8i16 TL = (v8i16)__msa_fill_h(top[-1]);
+ const v8i16 L0 = (v8i16)__msa_fill_h(top[-2]);
+ const v8i16 L1 = (v8i16)__msa_fill_h(top[-3]);
+ const v8i16 L2 = (v8i16)__msa_fill_h(top[-4]);
+ const v8i16 L3 = (v8i16)__msa_fill_h(top[-5]);
+ const v16u8 T1 = LD_UB(top);
+ const v8i16 T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
+ const v8i16 d = T - TL;
+ v8i16 r0, r1, r2, r3;
+ ADD4(d, L0, d, L1, d, L2, d, L3, r0, r1, r2, r3);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ PCKEV_ST4x4_UB(r0, r1, r2, r3, dst, BPS);
+}
+
+#undef DST
+#undef AVG3
+#undef AVG2
+
+static void Intra4Preds(uint8_t* dst, const uint8_t* top) {
+ DC4(I4DC4 + dst, top);
+ TM4(I4TM4 + dst, top);
+ VE4(I4VE4 + dst, top);
+ HE4(I4HE4 + dst, top);
+ RD4(I4RD4 + dst, top);
+ VR4(I4VR4 + dst, top);
+ LD4(I4LD4 + dst, top);
+ VL4(I4VL4 + dst, top);
+ HD4(I4HD4 + dst, top);
+ HU4(I4HU4 + dst, top);
+}
+
+// luma 16x16 prediction
+
+#define STORE16x16(out, dst) do { \
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 0 * BPS, BPS); \
+ ST_UB8(out, out, out, out, out, out, out, out, dst + 8 * BPS, BPS); \
+} while (0)
+
+static WEBP_INLINE void VerticalPred16x16(uint8_t* dst, const uint8_t* top) {
+ if (top != NULL) {
+ const v16u8 out = LD_UB(top);
+ STORE16x16(out, dst);
+ } else {
+ const v16u8 out = (v16u8)__msa_fill_b(0x7f);
+ STORE16x16(out, dst);
+ }
+}
+
+static WEBP_INLINE void HorizontalPred16x16(uint8_t* dst,
+ const uint8_t* left) {
+ if (left != NULL) {
+ int j;
+ for (j = 0; j < 16; j += 4) {
+ const v16u8 L0 = (v16u8)__msa_fill_b(left[0]);
+ const v16u8 L1 = (v16u8)__msa_fill_b(left[1]);
+ const v16u8 L2 = (v16u8)__msa_fill_b(left[2]);
+ const v16u8 L3 = (v16u8)__msa_fill_b(left[3]);
+ ST_UB4(L0, L1, L2, L3, dst, BPS);
+ dst += 4 * BPS;
+ left += 4;
+ }
+ } else {
+ const v16u8 out = (v16u8)__msa_fill_b(0x81);
+ STORE16x16(out, dst);
+ }
+}
+
+static WEBP_INLINE void TrueMotion16x16(uint8_t* dst, const uint8_t* left,
+ const uint8_t* top) {
+ if (left != NULL) {
+ if (top != NULL) {
+ int j;
+ v8i16 d1, d2;
+ const v16i8 zero = { 0 };
+ const v8i16 TL = (v8i16)__msa_fill_h(left[-1]);
+ const v16u8 T = LD_UB(top);
+ ILVRL_B2_SH(zero, T, d1, d2);
+ SUB2(d1, TL, d2, TL, d1, d2);
+ for (j = 0; j < 16; j += 4) {
+ v16i8 t0, t1, t2, t3;
+ v8i16 r0, r1, r2, r3, r4, r5, r6, r7;
+ const v8i16 L0 = (v8i16)__msa_fill_h(left[j + 0]);
+ const v8i16 L1 = (v8i16)__msa_fill_h(left[j + 1]);
+ const v8i16 L2 = (v8i16)__msa_fill_h(left[j + 2]);
+ const v8i16 L3 = (v8i16)__msa_fill_h(left[j + 3]);
+ ADD4(d1, L0, d1, L1, d1, L2, d1, L3, r0, r1, r2, r3);
+ ADD4(d2, L0, d2, L1, d2, L2, d2, L3, r4, r5, r6, r7);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ CLIP_SH4_0_255(r4, r5, r6, r7);
+ PCKEV_B4_SB(r4, r0, r5, r1, r6, r2, r7, r3, t0, t1, t2, t3);
+ ST_SB4(t0, t1, t2, t3, dst, BPS);
+ dst += 4 * BPS;
+ }
+ } else {
+ HorizontalPred16x16(dst, left);
+ }
+ } else {
+ if (top != NULL) {
+ VerticalPred16x16(dst, top);
+ } else {
+ const v16u8 out = (v16u8)__msa_fill_b(0x81);
+ STORE16x16(out, dst);
+ }
+ }
+}
+
+static WEBP_INLINE void DCMode16x16(uint8_t* dst, const uint8_t* left,
+ const uint8_t* top) {
+ int DC;
+ v16u8 out;
+ if (top != NULL && left != NULL) {
+ const v16u8 rtop = LD_UB(top);
+ const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
+ const v16u8 rleft = LD_UB(left);
+ const v8u16 dcleft = __msa_hadd_u_h(rleft, rleft);
+ const v8u16 dctemp = dctop + dcleft;
+ DC = HADD_UH_U32(dctemp);
+ DC = (DC + 16) >> 5;
+ } else if (left != NULL) { // left but no top
+ const v16u8 rleft = LD_UB(left);
+ const v8u16 dcleft = __msa_hadd_u_h(rleft, rleft);
+ DC = HADD_UH_U32(dcleft);
+ DC = (DC + DC + 16) >> 5;
+ } else if (top != NULL) { // top but no left
+ const v16u8 rtop = LD_UB(top);
+ const v8u16 dctop = __msa_hadd_u_h(rtop, rtop);
+ DC = HADD_UH_U32(dctop);
+ DC = (DC + DC + 16) >> 5;
+ } else { // no top, no left, nothing.
+ DC = 0x80;
+ }
+ out = (v16u8)__msa_fill_b(DC);
+ STORE16x16(out, dst);
+}
+
+static void Intra16Preds(uint8_t* dst,
+ const uint8_t* left, const uint8_t* top) {
+ DCMode16x16(I16DC16 + dst, left, top);
+ VerticalPred16x16(I16VE16 + dst, top);
+ HorizontalPred16x16(I16HE16 + dst, left);
+ TrueMotion16x16(I16TM16 + dst, left, top);
+}
+
+// Chroma 8x8 prediction
+
+#define CALC_DC8(in, out) do { \
+ const v8u16 temp0 = __msa_hadd_u_h(in, in); \
+ const v4u32 temp1 = __msa_hadd_u_w(temp0, temp0); \
+ const v2i64 temp2 = (v2i64)__msa_hadd_u_d(temp1, temp1); \
+ const v2i64 temp3 = __msa_splati_d(temp2, 1); \
+ const v2i64 temp4 = temp3 + temp2; \
+ const v16i8 temp5 = (v16i8)__msa_srari_d(temp4, 4); \
+ const v2i64 temp6 = (v2i64)__msa_splati_b(temp5, 0); \
+ out = __msa_copy_s_d(temp6, 0); \
+} while (0)
+
+#define STORE8x8(out, dst) do { \
+ SD4(out, out, out, out, dst + 0 * BPS, BPS); \
+ SD4(out, out, out, out, dst + 4 * BPS, BPS); \
+} while (0)
+
+static WEBP_INLINE void VerticalPred8x8(uint8_t* dst, const uint8_t* top) {
+ if (top != NULL) {
+ const uint64_t out = LD(top);
+ STORE8x8(out, dst);
+ } else {
+ const uint64_t out = 0x7f7f7f7f7f7f7f7fULL;
+ STORE8x8(out, dst);
+ }
+}
+
+static WEBP_INLINE void HorizontalPred8x8(uint8_t* dst, const uint8_t* left) {
+ if (left != NULL) {
+ int j;
+ for (j = 0; j < 8; j += 4) {
+ const v16u8 L0 = (v16u8)__msa_fill_b(left[0]);
+ const v16u8 L1 = (v16u8)__msa_fill_b(left[1]);
+ const v16u8 L2 = (v16u8)__msa_fill_b(left[2]);
+ const v16u8 L3 = (v16u8)__msa_fill_b(left[3]);
+ const uint64_t out0 = __msa_copy_s_d((v2i64)L0, 0);
+ const uint64_t out1 = __msa_copy_s_d((v2i64)L1, 0);
+ const uint64_t out2 = __msa_copy_s_d((v2i64)L2, 0);
+ const uint64_t out3 = __msa_copy_s_d((v2i64)L3, 0);
+ SD4(out0, out1, out2, out3, dst, BPS);
+ dst += 4 * BPS;
+ left += 4;
+ }
+ } else {
+ const uint64_t out = 0x8181818181818181ULL;
+ STORE8x8(out, dst);
+ }
+}
+
+static WEBP_INLINE void TrueMotion8x8(uint8_t* dst, const uint8_t* left,
+ const uint8_t* top) {
+ if (left != NULL) {
+ if (top != NULL) {
+ int j;
+ const v8i16 TL = (v8i16)__msa_fill_h(left[-1]);
+ const v16u8 T1 = LD_UB(top);
+ const v16i8 zero = { 0 };
+ const v8i16 T = (v8i16)__msa_ilvr_b(zero, (v16i8)T1);
+ const v8i16 d = T - TL;
+ for (j = 0; j < 8; j += 4) {
+ uint64_t out0, out1, out2, out3;
+ v16i8 t0, t1;
+ v8i16 r0 = (v8i16)__msa_fill_h(left[j + 0]);
+ v8i16 r1 = (v8i16)__msa_fill_h(left[j + 1]);
+ v8i16 r2 = (v8i16)__msa_fill_h(left[j + 2]);
+ v8i16 r3 = (v8i16)__msa_fill_h(left[j + 3]);
+ ADD4(d, r0, d, r1, d, r2, d, r3, r0, r1, r2, r3);
+ CLIP_SH4_0_255(r0, r1, r2, r3);
+ PCKEV_B2_SB(r1, r0, r3, r2, t0, t1);
+ out0 = __msa_copy_s_d((v2i64)t0, 0);
+ out1 = __msa_copy_s_d((v2i64)t0, 1);
+ out2 = __msa_copy_s_d((v2i64)t1, 0);
+ out3 = __msa_copy_s_d((v2i64)t1, 1);
+ SD4(out0, out1, out2, out3, dst, BPS);
+ dst += 4 * BPS;
+ }
+ } else {
+ HorizontalPred8x8(dst, left);
+ }
+ } else {
+ if (top != NULL) {
+ VerticalPred8x8(dst, top);
+ } else {
+ const uint64_t out = 0x8181818181818181ULL;
+ STORE8x8(out, dst);
+ }
+ }
+}
+
+static WEBP_INLINE void DCMode8x8(uint8_t* dst, const uint8_t* left,
+ const uint8_t* top) {
+ uint64_t out;
+ v16u8 src;
+ if (top != NULL && left != NULL) {
+ const uint64_t left_m = LD(left);
+ const uint64_t top_m = LD(top);
+ INSERT_D2_UB(left_m, top_m, src);
+ CALC_DC8(src, out);
+ } else if (left != NULL) { // left but no top
+ const uint64_t left_m = LD(left);
+ INSERT_D2_UB(left_m, left_m, src);
+ CALC_DC8(src, out);
+ } else if (top != NULL) { // top but no left
+ const uint64_t top_m = LD(top);
+ INSERT_D2_UB(top_m, top_m, src);
+ CALC_DC8(src, out);
+ } else { // no top, no left, nothing.
+ src = (v16u8)__msa_fill_b(0x80);
+ out = __msa_copy_s_d((v2i64)src, 0);
+ }
+ STORE8x8(out, dst);
+}
+
+static void IntraChromaPreds(uint8_t* dst, const uint8_t* left,
+ const uint8_t* top) {
+ // U block
+ DCMode8x8(C8DC8 + dst, left, top);
+ VerticalPred8x8(C8VE8 + dst, top);
+ HorizontalPred8x8(C8HE8 + dst, left);
+ TrueMotion8x8(C8TM8 + dst, left, top);
+ // V block
+ dst += 8;
+ if (top != NULL) top += 8;
+ if (left != NULL) left += 16;
+ DCMode8x8(C8DC8 + dst, left, top);
+ VerticalPred8x8(C8VE8 + dst, top);
+ HorizontalPred8x8(C8HE8 + dst, left);
+ TrueMotion8x8(C8TM8 + dst, left, top);
+}
+
+//------------------------------------------------------------------------------
+// Metric
+
+#define PACK_DOTP_UB4_SW(in0, in1, in2, in3, out0, out1, out2, out3) do { \
+ v16u8 tmp0, tmp1; \
+ v8i16 tmp2, tmp3; \
+ ILVRL_B2_UB(in0, in1, tmp0, tmp1); \
+ HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
+ DOTP_SH2_SW(tmp2, tmp3, tmp2, tmp3, out0, out1); \
+ ILVRL_B2_UB(in2, in3, tmp0, tmp1); \
+ HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
+ DOTP_SH2_SW(tmp2, tmp3, tmp2, tmp3, out2, out3); \
+} while (0)
+
+#define PACK_DPADD_UB4_SW(in0, in1, in2, in3, out0, out1, out2, out3) do { \
+ v16u8 tmp0, tmp1; \
+ v8i16 tmp2, tmp3; \
+ ILVRL_B2_UB(in0, in1, tmp0, tmp1); \
+ HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
+ DPADD_SH2_SW(tmp2, tmp3, tmp2, tmp3, out0, out1); \
+ ILVRL_B2_UB(in2, in3, tmp0, tmp1); \
+ HSUB_UB2_SH(tmp0, tmp1, tmp2, tmp3); \
+ DPADD_SH2_SW(tmp2, tmp3, tmp2, tmp3, out2, out3); \
+} while (0)
+
+static int SSE16x16(const uint8_t* a, const uint8_t* b) {
+ uint32_t sum;
+ v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
+ v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
+ v4i32 out0, out1, out2, out3;
+
+ LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
+ LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
+ PACK_DOTP_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
+ a += 8 * BPS;
+ b += 8 * BPS;
+ LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
+ LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
+ PACK_DPADD_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
+ out0 += out1;
+ out2 += out3;
+ out0 += out2;
+ sum = HADD_SW_S32(out0);
+ return sum;
+}
+
+static int SSE16x8(const uint8_t* a, const uint8_t* b) {
+ uint32_t sum;
+ v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
+ v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
+ v4i32 out0, out1, out2, out3;
+
+ LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
+ LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
+ PACK_DOTP_UB4_SW(src0, ref0, src1, ref1, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src2, ref2, src3, ref3, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src4, ref4, src5, ref5, out0, out1, out2, out3);
+ PACK_DPADD_UB4_SW(src6, ref6, src7, ref7, out0, out1, out2, out3);
+ out0 += out1;
+ out2 += out3;
+ out0 += out2;
+ sum = HADD_SW_S32(out0);
+ return sum;
+}
+
+static int SSE8x8(const uint8_t* a, const uint8_t* b) {
+ uint32_t sum;
+ v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
+ v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
+ v16u8 t0, t1, t2, t3;
+ v4i32 out0, out1, out2, out3;
+
+ LD_UB8(a, BPS, src0, src1, src2, src3, src4, src5, src6, src7);
+ LD_UB8(b, BPS, ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7);
+ ILVR_B4_UB(src0, src1, src2, src3, ref0, ref1, ref2, ref3, t0, t1, t2, t3);
+ PACK_DOTP_UB4_SW(t0, t2, t1, t3, out0, out1, out2, out3);
+ ILVR_B4_UB(src4, src5, src6, src7, ref4, ref5, ref6, ref7, t0, t1, t2, t3);
+ PACK_DPADD_UB4_SW(t0, t2, t1, t3, out0, out1, out2, out3);
+ out0 += out1;
+ out2 += out3;
+ out0 += out2;
+ sum = HADD_SW_S32(out0);
+ return sum;
+}
+
+static int SSE4x4(const uint8_t* a, const uint8_t* b) {
+ uint32_t sum = 0;
+ uint32_t src0, src1, src2, src3, ref0, ref1, ref2, ref3;
+ v16u8 src, ref, tmp0, tmp1;
+ v8i16 diff0, diff1;
+ v4i32 out0, out1;
+
+ LW4(a, BPS, src0, src1, src2, src3);
+ LW4(b, BPS, ref0, ref1, ref2, ref3);
+ INSERT_W4_UB(src0, src1, src2, src3, src);
+ INSERT_W4_UB(ref0, ref1, ref2, ref3, ref);
+ ILVRL_B2_UB(src, ref, tmp0, tmp1);
+ HSUB_UB2_SH(tmp0, tmp1, diff0, diff1);
+ DOTP_SH2_SW(diff0, diff1, diff0, diff1, out0, out1);
+ out0 += out1;
+ sum = HADD_SW_S32(out0);
+ return sum;
+}
+
+//------------------------------------------------------------------------------
+// Quantization
+
+static int QuantizeBlock(int16_t in[16], int16_t out[16],
+ const VP8Matrix* const mtx) {
+ int sum;
+ v8i16 in0, in1, sh0, sh1, out0, out1;
+ v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, sign0, sign1;
+ v4i32 s0, s1, s2, s3, b0, b1, b2, b3, t0, t1, t2, t3;
+ const v8i16 zero = { 0 };
+ const v8i16 zigzag0 = { 0, 1, 4, 8, 5, 2, 3, 6 };
+ const v8i16 zigzag1 = { 9, 12, 13, 10, 7, 11, 14, 15 };
+ const v8i16 maxlevel = __msa_fill_h(MAX_LEVEL);
+
+ LD_SH2(&in[0], 8, in0, in1);
+ LD_SH2(&mtx->sharpen_[0], 8, sh0, sh1);
+ tmp4 = __msa_add_a_h(in0, zero);
+ tmp5 = __msa_add_a_h(in1, zero);
+ ILVRL_H2_SH(sh0, tmp4, tmp0, tmp1);
+ ILVRL_H2_SH(sh1, tmp5, tmp2, tmp3);
+ HADD_SH4_SW(tmp0, tmp1, tmp2, tmp3, s0, s1, s2, s3);
+ sign0 = (in0 < zero);
+ sign1 = (in1 < zero); // sign
+ LD_SH2(&mtx->iq_[0], 8, tmp0, tmp1); // iq
+ ILVRL_H2_SW(zero, tmp0, t0, t1);
+ ILVRL_H2_SW(zero, tmp1, t2, t3);
+ LD_SW4(&mtx->bias_[0], 4, b0, b1, b2, b3); // bias
+ MUL4(t0, s0, t1, s1, t2, s2, t3, s3, t0, t1, t2, t3);
+ ADD4(b0, t0, b1, t1, b2, t2, b3, t3, b0, b1, b2, b3);
+ SRAI_W4_SW(b0, b1, b2, b3, 17);
+ PCKEV_H2_SH(b1, b0, b3, b2, tmp2, tmp3);
+ tmp0 = (tmp2 > maxlevel);
+ tmp1 = (tmp3 > maxlevel);
+ tmp2 = (v8i16)__msa_bmnz_v((v16u8)tmp2, (v16u8)maxlevel, (v16u8)tmp0);
+ tmp3 = (v8i16)__msa_bmnz_v((v16u8)tmp3, (v16u8)maxlevel, (v16u8)tmp1);
+ SUB2(0, tmp2, 0, tmp3, tmp0, tmp1);
+ tmp2 = (v8i16)__msa_bmnz_v((v16u8)tmp2, (v16u8)tmp0, (v16u8)sign0);
+ tmp3 = (v8i16)__msa_bmnz_v((v16u8)tmp3, (v16u8)tmp1, (v16u8)sign1);
+ LD_SW4(&mtx->zthresh_[0], 4, t0, t1, t2, t3); // zthresh
+ t0 = (s0 > t0);
+ t1 = (s1 > t1);
+ t2 = (s2 > t2);
+ t3 = (s3 > t3);
+ PCKEV_H2_SH(t1, t0, t3, t2, tmp0, tmp1);
+ tmp4 = (v8i16)__msa_bmnz_v((v16u8)zero, (v16u8)tmp2, (v16u8)tmp0);
+ tmp5 = (v8i16)__msa_bmnz_v((v16u8)zero, (v16u8)tmp3, (v16u8)tmp1);
+ LD_SH2(&mtx->q_[0], 8, tmp0, tmp1);
+ MUL2(tmp4, tmp0, tmp5, tmp1, in0, in1);
+ VSHF_H2_SH(tmp4, tmp5, tmp4, tmp5, zigzag0, zigzag1, out0, out1);
+ ST_SH2(in0, in1, &in[0], 8);
+ ST_SH2(out0, out1, &out[0], 8);
+ out0 = __msa_add_a_h(out0, out1);
+ sum = HADD_SH_S32(out0);
+ return (sum > 0);
+}
+
+static int Quantize2Blocks(int16_t in[32], int16_t out[32],
+ const VP8Matrix* const mtx) {
+ int nz;
+ nz = VP8EncQuantizeBlock(in + 0 * 16, out + 0 * 16, mtx) << 0;
+ nz |= VP8EncQuantizeBlock(in + 1 * 16, out + 1 * 16, mtx) << 1;
+ return nz;
+}
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void VP8EncDspInitMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitMSA(void) {
+ VP8ITransform = ITransform;
+ VP8FTransform = FTransform;
+ VP8FTransformWHT = FTransformWHT;
+
+ VP8TDisto4x4 = Disto4x4;
+ VP8TDisto16x16 = Disto16x16;
+ VP8CollectHistogram = CollectHistogram;
+
+ VP8EncPredLuma4 = Intra4Preds;
+ VP8EncPredLuma16 = Intra16Preds;
+ VP8EncPredChroma8 = IntraChromaPreds;
+
+ VP8SSE16x16 = SSE16x16;
+ VP8SSE16x8 = SSE16x8;
+ VP8SSE8x8 = SSE8x8;
+ VP8SSE4x4 = SSE4x4;
+
+ VP8EncQuantizeBlock = QuantizeBlock;
+ VP8EncQuantize2Blocks = Quantize2Blocks;
+ VP8EncQuantizeBlockWHT = QuantizeBlock;
+}
+
+#else // !WEBP_USE_MSA
+
+WEBP_DSP_INIT_STUB(VP8EncDspInitMSA)
+
+#endif // WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/enc_neon.c b/thirdparty/libwebp/dsp/enc_neon.c
index 46f6bf9a33..6a078d632d 100644
--- a/thirdparty/libwebp/dsp/enc_neon.c
+++ b/thirdparty/libwebp/dsp/enc_neon.c
@@ -18,7 +18,7 @@
#include <assert.h>
#include "./neon.h"
-#include "../enc/vp8enci.h"
+#include "../enc/vp8i_enc.h"
//------------------------------------------------------------------------------
// Transforms (Paragraph 14.4)
@@ -746,9 +746,14 @@ static WEBP_INLINE void AccumulateSSE16(const uint8_t* const a,
const uint8x16_t a0 = vld1q_u8(a);
const uint8x16_t b0 = vld1q_u8(b);
const uint8x16_t abs_diff = vabdq_u8(a0, b0);
- uint16x8_t prod = vmull_u8(vget_low_u8(abs_diff), vget_low_u8(abs_diff));
- prod = vmlal_u8(prod, vget_high_u8(abs_diff), vget_high_u8(abs_diff));
- *sum = vpadalq_u16(*sum, prod); // pair-wise add and accumulate
+ const uint16x8_t prod1 = vmull_u8(vget_low_u8(abs_diff),
+ vget_low_u8(abs_diff));
+ const uint16x8_t prod2 = vmull_u8(vget_high_u8(abs_diff),
+ vget_high_u8(abs_diff));
+ /* pair-wise adds and widen */
+ const uint32x4_t sum1 = vpaddlq_u16(prod1);
+ const uint32x4_t sum2 = vpaddlq_u16(prod2);
+ *sum = vaddq_u32(*sum, vaddq_u32(sum1, sum2));
}
// Horizontal sum of all four uint32_t values in 'sum'.
@@ -758,7 +763,7 @@ static int SumToInt(uint32x4_t sum) {
return (int)sum3;
}
-static int SSE16x16(const uint8_t* a, const uint8_t* b) {
+static int SSE16x16_NEON(const uint8_t* a, const uint8_t* b) {
uint32x4_t sum = vdupq_n_u32(0);
int y;
for (y = 0; y < 16; ++y) {
@@ -767,7 +772,7 @@ static int SSE16x16(const uint8_t* a, const uint8_t* b) {
return SumToInt(sum);
}
-static int SSE16x8(const uint8_t* a, const uint8_t* b) {
+static int SSE16x8_NEON(const uint8_t* a, const uint8_t* b) {
uint32x4_t sum = vdupq_n_u32(0);
int y;
for (y = 0; y < 8; ++y) {
@@ -776,7 +781,7 @@ static int SSE16x8(const uint8_t* a, const uint8_t* b) {
return SumToInt(sum);
}
-static int SSE8x8(const uint8_t* a, const uint8_t* b) {
+static int SSE8x8_NEON(const uint8_t* a, const uint8_t* b) {
uint32x4_t sum = vdupq_n_u32(0);
int y;
for (y = 0; y < 8; ++y) {
@@ -789,13 +794,18 @@ static int SSE8x8(const uint8_t* a, const uint8_t* b) {
return SumToInt(sum);
}
-static int SSE4x4(const uint8_t* a, const uint8_t* b) {
+static int SSE4x4_NEON(const uint8_t* a, const uint8_t* b) {
const uint8x16_t a0 = Load4x4(a);
const uint8x16_t b0 = Load4x4(b);
const uint8x16_t abs_diff = vabdq_u8(a0, b0);
- uint16x8_t prod = vmull_u8(vget_low_u8(abs_diff), vget_low_u8(abs_diff));
- prod = vmlal_u8(prod, vget_high_u8(abs_diff), vget_high_u8(abs_diff));
- return SumToInt(vpaddlq_u16(prod));
+ const uint16x8_t prod1 = vmull_u8(vget_low_u8(abs_diff),
+ vget_low_u8(abs_diff));
+ const uint16x8_t prod2 = vmull_u8(vget_high_u8(abs_diff),
+ vget_high_u8(abs_diff));
+ /* pair-wise adds and widen */
+ const uint32x4_t sum1 = vpaddlq_u16(prod1);
+ const uint32x4_t sum2 = vpaddlq_u16(prod2);
+ return SumToInt(vaddq_u32(sum1, sum2));
}
//------------------------------------------------------------------------------
@@ -903,10 +913,12 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitNEON(void) {
VP8TDisto4x4 = Disto4x4;
VP8TDisto16x16 = Disto16x16;
VP8CollectHistogram = CollectHistogram;
- VP8SSE16x16 = SSE16x16;
- VP8SSE16x8 = SSE16x8;
- VP8SSE8x8 = SSE8x8;
- VP8SSE4x4 = SSE4x4;
+
+ VP8SSE16x16 = SSE16x16_NEON;
+ VP8SSE16x8 = SSE16x8_NEON;
+ VP8SSE8x8 = SSE8x8_NEON;
+ VP8SSE4x4 = SSE4x4_NEON;
+
#if !defined(WORK_AROUND_GCC)
VP8EncQuantizeBlock = QuantizeBlock;
VP8EncQuantize2Blocks = Quantize2Blocks;
diff --git a/thirdparty/libwebp/dsp/enc_sse2.c b/thirdparty/libwebp/dsp/enc_sse2.c
index 4a2e3ce14f..2026a74c91 100644
--- a/thirdparty/libwebp/dsp/enc_sse2.c
+++ b/thirdparty/libwebp/dsp/enc_sse2.c
@@ -14,12 +14,13 @@
#include "./dsp.h"
#if defined(WEBP_USE_SSE2)
+#include <assert.h>
#include <stdlib.h> // for abs()
#include <emmintrin.h>
#include "./common_sse2.h"
-#include "../enc/cost.h"
-#include "../enc/vp8enci.h"
+#include "../enc/cost_enc.h"
+#include "../enc/vp8i_enc.h"
//------------------------------------------------------------------------------
// Transforms (Paragraph 14.4)
@@ -139,7 +140,7 @@ static void ITransform(const uint8_t* ref, const int16_t* in, uint8_t* dst,
// Transpose the two 4x4.
VP8Transpose_2_4x4_16b(&shifted0, &shifted1, &shifted2, &shifted3, &T0, &T1,
- &T2, &T3);
+ &T2, &T3);
}
// Add inverse transform to 'ref' and store.
@@ -250,25 +251,11 @@ static void FTransformPass2(const __m128i* const v01, const __m128i* const v32,
const __m128i k51000 = _mm_set1_epi32(51000);
// Same operations are done on the (0,3) and (1,2) pairs.
- // a0 = v0 + v3
- // a1 = v1 + v2
// a3 = v0 - v3
// a2 = v1 - v2
- const __m128i a01 = _mm_add_epi16(*v01, *v32);
const __m128i a32 = _mm_sub_epi16(*v01, *v32);
- const __m128i a11 = _mm_unpackhi_epi64(a01, a01);
const __m128i a22 = _mm_unpackhi_epi64(a32, a32);
- const __m128i a01_plus_7 = _mm_add_epi16(a01, seven);
- // d0 = (a0 + a1 + 7) >> 4;
- // d2 = (a0 - a1 + 7) >> 4;
- const __m128i c0 = _mm_add_epi16(a01_plus_7, a11);
- const __m128i c2 = _mm_sub_epi16(a01_plus_7, a11);
- const __m128i d0 = _mm_srai_epi16(c0, 4);
- const __m128i d2 = _mm_srai_epi16(c2, 4);
-
- // f1 = ((b3 * 5352 + b2 * 2217 + 12000) >> 16)
- // f3 = ((b3 * 2217 - b2 * 5352 + 51000) >> 16)
const __m128i b23 = _mm_unpacklo_epi16(a22, a32);
const __m128i c1 = _mm_madd_epi16(b23, k5352_2217);
const __m128i c3 = _mm_madd_epi16(b23, k2217_5352);
@@ -276,14 +263,28 @@ static void FTransformPass2(const __m128i* const v01, const __m128i* const v32,
const __m128i d3 = _mm_add_epi32(c3, k51000);
const __m128i e1 = _mm_srai_epi32(d1, 16);
const __m128i e3 = _mm_srai_epi32(d3, 16);
+ // f1 = ((b3 * 5352 + b2 * 2217 + 12000) >> 16)
+ // f3 = ((b3 * 2217 - b2 * 5352 + 51000) >> 16)
const __m128i f1 = _mm_packs_epi32(e1, e1);
const __m128i f3 = _mm_packs_epi32(e3, e3);
- // f1 = f1 + (a3 != 0);
+ // g1 = f1 + (a3 != 0);
// The compare will return (0xffff, 0) for (==0, !=0). To turn that into the
// desired (0, 1), we add one earlier through k12000_plus_one.
- // -> f1 = f1 + 1 - (a3 == 0)
+ // -> g1 = f1 + 1 - (a3 == 0)
const __m128i g1 = _mm_add_epi16(f1, _mm_cmpeq_epi16(a32, zero));
+ // a0 = v0 + v3
+ // a1 = v1 + v2
+ const __m128i a01 = _mm_add_epi16(*v01, *v32);
+ const __m128i a01_plus_7 = _mm_add_epi16(a01, seven);
+ const __m128i a11 = _mm_unpackhi_epi64(a01, a01);
+ const __m128i c0 = _mm_add_epi16(a01_plus_7, a11);
+ const __m128i c2 = _mm_sub_epi16(a01_plus_7, a11);
+ // d0 = (a0 + a1 + 7) >> 4;
+ // d2 = (a0 - a1 + 7) >> 4;
+ const __m128i d0 = _mm_srai_epi16(c0, 4);
+ const __m128i d2 = _mm_srai_epi16(c2, 4);
+
const __m128i d0_g1 = _mm_unpacklo_epi64(d0, g1);
const __m128i d2_f3 = _mm_unpacklo_epi64(d2, f3);
_mm_storeu_si128((__m128i*)&out[0], d0_g1);
@@ -1046,6 +1047,37 @@ static int SSE4x4(const uint8_t* a, const uint8_t* b) {
}
//------------------------------------------------------------------------------
+
+static void Mean16x4(const uint8_t* ref, uint32_t dc[4]) {
+ const __m128i mask = _mm_set1_epi16(0x00ff);
+ const __m128i a0 = _mm_loadu_si128((const __m128i*)&ref[BPS * 0]);
+ const __m128i a1 = _mm_loadu_si128((const __m128i*)&ref[BPS * 1]);
+ const __m128i a2 = _mm_loadu_si128((const __m128i*)&ref[BPS * 2]);
+ const __m128i a3 = _mm_loadu_si128((const __m128i*)&ref[BPS * 3]);
+ const __m128i b0 = _mm_srli_epi16(a0, 8); // hi byte
+ const __m128i b1 = _mm_srli_epi16(a1, 8);
+ const __m128i b2 = _mm_srli_epi16(a2, 8);
+ const __m128i b3 = _mm_srli_epi16(a3, 8);
+ const __m128i c0 = _mm_and_si128(a0, mask); // lo byte
+ const __m128i c1 = _mm_and_si128(a1, mask);
+ const __m128i c2 = _mm_and_si128(a2, mask);
+ const __m128i c3 = _mm_and_si128(a3, mask);
+ const __m128i d0 = _mm_add_epi32(b0, c0);
+ const __m128i d1 = _mm_add_epi32(b1, c1);
+ const __m128i d2 = _mm_add_epi32(b2, c2);
+ const __m128i d3 = _mm_add_epi32(b3, c3);
+ const __m128i e0 = _mm_add_epi32(d0, d1);
+ const __m128i e1 = _mm_add_epi32(d2, d3);
+ const __m128i f0 = _mm_add_epi32(e0, e1);
+ uint16_t tmp[8];
+ _mm_storeu_si128((__m128i*)tmp, f0);
+ dc[0] = tmp[0] + tmp[1];
+ dc[1] = tmp[2] + tmp[3];
+ dc[2] = tmp[4] + tmp[5];
+ dc[3] = tmp[6] + tmp[7];
+}
+
+//------------------------------------------------------------------------------
// Texture distortion
//
// We try to match the spectral content (weighted) between source and
@@ -1331,10 +1363,122 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspInitSSE2(void) {
VP8SSE4x4 = SSE4x4;
VP8TDisto4x4 = Disto4x4;
VP8TDisto16x16 = Disto16x16;
+ VP8Mean16x4 = Mean16x4;
+}
+
+//------------------------------------------------------------------------------
+// SSIM / PSNR entry point (TODO(skal): move to its own file later)
+
+static uint32_t AccumulateSSE_SSE2(const uint8_t* src1,
+ const uint8_t* src2, int len) {
+ int i = 0;
+ uint32_t sse2 = 0;
+ if (len >= 16) {
+ const int limit = len - 32;
+ int32_t tmp[4];
+ __m128i sum1;
+ __m128i sum = _mm_setzero_si128();
+ __m128i a0 = _mm_loadu_si128((const __m128i*)&src1[i]);
+ __m128i b0 = _mm_loadu_si128((const __m128i*)&src2[i]);
+ i += 16;
+ while (i <= limit) {
+ const __m128i a1 = _mm_loadu_si128((const __m128i*)&src1[i]);
+ const __m128i b1 = _mm_loadu_si128((const __m128i*)&src2[i]);
+ __m128i sum2;
+ i += 16;
+ SubtractAndAccumulate(a0, b0, &sum1);
+ sum = _mm_add_epi32(sum, sum1);
+ a0 = _mm_loadu_si128((const __m128i*)&src1[i]);
+ b0 = _mm_loadu_si128((const __m128i*)&src2[i]);
+ i += 16;
+ SubtractAndAccumulate(a1, b1, &sum2);
+ sum = _mm_add_epi32(sum, sum2);
+ }
+ SubtractAndAccumulate(a0, b0, &sum1);
+ sum = _mm_add_epi32(sum, sum1);
+ _mm_storeu_si128((__m128i*)tmp, sum);
+ sse2 += (tmp[3] + tmp[2] + tmp[1] + tmp[0]);
+ }
+
+ for (; i < len; ++i) {
+ const int32_t diff = src1[i] - src2[i];
+ sse2 += diff * diff;
+ }
+ return sse2;
+}
+
+static uint32_t HorizontalAdd16b(const __m128i* const m) {
+ uint16_t tmp[8];
+ const __m128i a = _mm_srli_si128(*m, 8);
+ const __m128i b = _mm_add_epi16(*m, a);
+ _mm_storeu_si128((__m128i*)tmp, b);
+ return (uint32_t)tmp[3] + tmp[2] + tmp[1] + tmp[0];
+}
+
+static uint32_t HorizontalAdd32b(const __m128i* const m) {
+ const __m128i a = _mm_srli_si128(*m, 8);
+ const __m128i b = _mm_add_epi32(*m, a);
+ const __m128i c = _mm_add_epi32(b, _mm_srli_si128(b, 4));
+ return (uint32_t)_mm_cvtsi128_si32(c);
+}
+
+static const uint16_t kWeight[] = { 1, 2, 3, 4, 3, 2, 1, 0 };
+
+#define ACCUMULATE_ROW(WEIGHT) do { \
+ /* compute row weight (Wx * Wy) */ \
+ const __m128i Wy = _mm_set1_epi16((WEIGHT)); \
+ const __m128i W = _mm_mullo_epi16(Wx, Wy); \
+ /* process 8 bytes at a time (7 bytes, actually) */ \
+ const __m128i a0 = _mm_loadl_epi64((const __m128i*)src1); \
+ const __m128i b0 = _mm_loadl_epi64((const __m128i*)src2); \
+ /* convert to 16b and multiply by weight */ \
+ const __m128i a1 = _mm_unpacklo_epi8(a0, zero); \
+ const __m128i b1 = _mm_unpacklo_epi8(b0, zero); \
+ const __m128i wa1 = _mm_mullo_epi16(a1, W); \
+ const __m128i wb1 = _mm_mullo_epi16(b1, W); \
+ /* accumulate */ \
+ xm = _mm_add_epi16(xm, wa1); \
+ ym = _mm_add_epi16(ym, wb1); \
+ xxm = _mm_add_epi32(xxm, _mm_madd_epi16(a1, wa1)); \
+ xym = _mm_add_epi32(xym, _mm_madd_epi16(a1, wb1)); \
+ yym = _mm_add_epi32(yym, _mm_madd_epi16(b1, wb1)); \
+ src1 += stride1; \
+ src2 += stride2; \
+} while (0)
+
+static double SSIMGet_SSE2(const uint8_t* src1, int stride1,
+ const uint8_t* src2, int stride2) {
+ VP8DistoStats stats;
+ const __m128i zero = _mm_setzero_si128();
+ __m128i xm = zero, ym = zero; // 16b accums
+ __m128i xxm = zero, yym = zero, xym = zero; // 32b accum
+ const __m128i Wx = _mm_loadu_si128((const __m128i*)kWeight);
+ assert(2 * VP8_SSIM_KERNEL + 1 == 7);
+ ACCUMULATE_ROW(1);
+ ACCUMULATE_ROW(2);
+ ACCUMULATE_ROW(3);
+ ACCUMULATE_ROW(4);
+ ACCUMULATE_ROW(3);
+ ACCUMULATE_ROW(2);
+ ACCUMULATE_ROW(1);
+ stats.xm = HorizontalAdd16b(&xm);
+ stats.ym = HorizontalAdd16b(&ym);
+ stats.xxm = HorizontalAdd32b(&xxm);
+ stats.xym = HorizontalAdd32b(&xym);
+ stats.yym = HorizontalAdd32b(&yym);
+ return VP8SSIMFromStats(&stats);
+}
+
+extern void VP8SSIMDspInitSSE2(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8SSIMDspInitSSE2(void) {
+ VP8AccumulateSSE = AccumulateSSE_SSE2;
+ VP8SSIMGet = SSIMGet_SSE2;
}
#else // !WEBP_USE_SSE2
WEBP_DSP_INIT_STUB(VP8EncDspInitSSE2)
+WEBP_DSP_INIT_STUB(VP8SSIMDspInitSSE2)
#endif // WEBP_USE_SSE2
diff --git a/thirdparty/libwebp/dsp/enc_sse41.c b/thirdparty/libwebp/dsp/enc_sse41.c
index a1783901a6..e32086d9fd 100644
--- a/thirdparty/libwebp/dsp/enc_sse41.c
+++ b/thirdparty/libwebp/dsp/enc_sse41.c
@@ -18,7 +18,7 @@
#include <stdlib.h> // for abs()
#include "./common_sse2.h"
-#include "../enc/vp8enci.h"
+#include "../enc/vp8i_enc.h"
//------------------------------------------------------------------------------
// Compute susceptibility based on DCT-coeff histograms.
diff --git a/thirdparty/libwebp/dsp/filters.c b/thirdparty/libwebp/dsp/filters.c
index 9f04faf0cb..65f34aad1f 100644
--- a/thirdparty/libwebp/dsp/filters.c
+++ b/thirdparty/libwebp/dsp/filters.c
@@ -227,6 +227,8 @@ WebPFilterFunc WebPFilters[WEBP_FILTER_LAST];
WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST];
extern void VP8FiltersInitMIPSdspR2(void);
+extern void VP8FiltersInitMSA(void);
+extern void VP8FiltersInitNEON(void);
extern void VP8FiltersInitSSE2(void);
static volatile VP8CPUInfo filters_last_cpuinfo_used =
@@ -251,11 +253,21 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInit(void) {
VP8FiltersInitSSE2();
}
#endif
+#if defined(WEBP_USE_NEON)
+ if (VP8GetCPUInfo(kNEON)) {
+ VP8FiltersInitNEON();
+ }
+#endif
#if defined(WEBP_USE_MIPS_DSP_R2)
if (VP8GetCPUInfo(kMIPSdspR2)) {
VP8FiltersInitMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ VP8FiltersInitMSA();
+ }
+#endif
}
filters_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/thirdparty/libwebp/dsp/filters_msa.c b/thirdparty/libwebp/dsp/filters_msa.c
new file mode 100644
index 0000000000..4b8922d0bc
--- /dev/null
+++ b/thirdparty/libwebp/dsp/filters_msa.c
@@ -0,0 +1,202 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA variant of alpha filters
+//
+// Author: Prashant Patil (prashant.patil@imgtec.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include "./msa_macro.h"
+
+#include <assert.h>
+
+static WEBP_INLINE void PredictLineInverse0(const uint8_t* src,
+ const uint8_t* pred,
+ uint8_t* dst, int length) {
+ v16u8 src0, pred0, dst0;
+ assert(length >= 0);
+ while (length >= 32) {
+ v16u8 src1, pred1, dst1;
+ LD_UB2(src, 16, src0, src1);
+ LD_UB2(pred, 16, pred0, pred1);
+ SUB2(src0, pred0, src1, pred1, dst0, dst1);
+ ST_UB2(dst0, dst1, dst, 16);
+ src += 32;
+ pred += 32;
+ dst += 32;
+ length -= 32;
+ }
+ if (length > 0) {
+ int i;
+ if (length >= 16) {
+ src0 = LD_UB(src);
+ pred0 = LD_UB(pred);
+ dst0 = src0 - pred0;
+ ST_UB(dst0, dst);
+ src += 16;
+ pred += 16;
+ dst += 16;
+ length -= 16;
+ }
+ for (i = 0; i < length; i++) {
+ dst[i] = src[i] - pred[i];
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+// Helpful macro.
+
+#define SANITY_CHECK(in, out) \
+ assert(in != NULL); \
+ assert(out != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width);
+
+//------------------------------------------------------------------------------
+// Horrizontal filter
+
+static void HorizontalFilter(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ const uint8_t* preds = data;
+ const uint8_t* in = data;
+ uint8_t* out = filtered_data;
+ int row = 1;
+ SANITY_CHECK(in, out);
+
+ // Leftmost pixel is the same as input for topmost scanline.
+ out[0] = in[0];
+ PredictLineInverse0(in + 1, preds, out + 1, width - 1);
+ preds += stride;
+ in += stride;
+ out += stride;
+ // Filter line-by-line.
+ while (row < height) {
+ // Leftmost pixel is predicted from above.
+ PredictLineInverse0(in, preds - stride, out, 1);
+ PredictLineInverse0(in + 1, preds, out + 1, width - 1);
+ ++row;
+ preds += stride;
+ in += stride;
+ out += stride;
+ }
+}
+
+//------------------------------------------------------------------------------
+// Gradient filter
+
+static WEBP_INLINE void PredictLineGradient(const uint8_t* pinput,
+ const uint8_t* ppred,
+ uint8_t* poutput, int stride,
+ int size) {
+ int w;
+ const v16i8 zero = { 0 };
+ while (size >= 16) {
+ v16u8 pred0, dst0;
+ v8i16 a0, a1, b0, b1, c0, c1;
+ const v16u8 tmp0 = LD_UB(ppred - 1);
+ const v16u8 tmp1 = LD_UB(ppred - stride);
+ const v16u8 tmp2 = LD_UB(ppred - stride - 1);
+ const v16u8 src0 = LD_UB(pinput);
+ ILVRL_B2_SH(zero, tmp0, a0, a1);
+ ILVRL_B2_SH(zero, tmp1, b0, b1);
+ ILVRL_B2_SH(zero, tmp2, c0, c1);
+ ADD2(a0, b0, a1, b1, a0, a1);
+ SUB2(a0, c0, a1, c1, a0, a1);
+ CLIP_SH2_0_255(a0, a1);
+ pred0 = (v16u8)__msa_pckev_b((v16i8)a1, (v16i8)a0);
+ dst0 = src0 - pred0;
+ ST_UB(dst0, poutput);
+ ppred += 16;
+ pinput += 16;
+ poutput += 16;
+ size -= 16;
+ }
+ for (w = 0; w < size; ++w) {
+ const int pred = ppred[w - 1] + ppred[w - stride] - ppred[w - stride - 1];
+ poutput[w] = pinput[w] - (pred < 0 ? 0 : pred > 255 ? 255 : pred);
+ }
+}
+
+
+static void GradientFilter(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ const uint8_t* in = data;
+ const uint8_t* preds = data;
+ uint8_t* out = filtered_data;
+ int row = 1;
+ SANITY_CHECK(in, out);
+
+ // left prediction for top scan-line
+ out[0] = in[0];
+ PredictLineInverse0(in + 1, preds, out + 1, width - 1);
+ preds += stride;
+ in += stride;
+ out += stride;
+ // Filter line-by-line.
+ while (row < height) {
+ out[0] = in[0] - preds[- stride];
+ PredictLineGradient(preds + 1, in + 1, out + 1, stride, width - 1);
+ ++row;
+ preds += stride;
+ in += stride;
+ out += stride;
+ }
+}
+
+//------------------------------------------------------------------------------
+// Vertical filter
+
+static void VerticalFilter(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ const uint8_t* in = data;
+ const uint8_t* preds = data;
+ uint8_t* out = filtered_data;
+ int row = 1;
+ SANITY_CHECK(in, out);
+
+ // Very first top-left pixel is copied.
+ out[0] = in[0];
+ // Rest of top scan-line is left-predicted.
+ PredictLineInverse0(in + 1, preds, out + 1, width - 1);
+ in += stride;
+ out += stride;
+
+ // Filter line-by-line.
+ while (row < height) {
+ PredictLineInverse0(in, preds, out, width);
+ ++row;
+ preds += stride;
+ in += stride;
+ out += stride;
+ }
+}
+
+#undef SANITY_CHECK
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void VP8FiltersInitMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitMSA(void) {
+ WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter;
+ WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter;
+ WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter;
+}
+
+#else // !WEBP_USE_MSA
+
+WEBP_DSP_INIT_STUB(VP8FiltersInitMSA)
+
+#endif // WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/filters_neon.c b/thirdparty/libwebp/dsp/filters_neon.c
new file mode 100644
index 0000000000..4d6e50cc76
--- /dev/null
+++ b/thirdparty/libwebp/dsp/filters_neon.c
@@ -0,0 +1,327 @@
+// Copyright 2017 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// NEON variant of alpha filters
+//
+// Author: Skal (pascal.massimino@gmail.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_NEON)
+
+#include <assert.h>
+#include "./neon.h"
+
+//------------------------------------------------------------------------------
+// Helpful macros.
+
+# define SANITY_CHECK(in, out) \
+ assert(in != NULL); \
+ assert(out != NULL); \
+ assert(width > 0); \
+ assert(height > 0); \
+ assert(stride >= width); \
+ assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
+ (void)height; // Silence unused warning.
+
+// load eight u8 and widen to s16
+#define U8_TO_S16(A) vreinterpretq_s16_u16(vmovl_u8(A))
+#define LOAD_U8_TO_S16(A) U8_TO_S16(vld1_u8(A))
+
+// shift left or right by N byte, inserting zeros
+#define SHIFT_RIGHT_N_Q(A, N) vextq_u8((A), zero, (N))
+#define SHIFT_LEFT_N_Q(A, N) vextq_u8(zero, (A), (16 - (N)) % 16)
+
+// rotate left by N bytes
+#define ROTATE_LEFT_N(A, N) vext_u8((A), (A), (N))
+// rotate right by N bytes
+#define ROTATE_RIGHT_N(A, N) vext_u8((A), (A), (8 - (N)) % 8)
+
+static void PredictLine_NEON(const uint8_t* src, const uint8_t* pred,
+ uint8_t* dst, int length) {
+ int i;
+ assert(length >= 0);
+ for (i = 0; i + 16 <= length; i += 16) {
+ const uint8x16_t A = vld1q_u8(&src[i]);
+ const uint8x16_t B = vld1q_u8(&pred[i]);
+ const uint8x16_t C = vsubq_u8(A, B);
+ vst1q_u8(&dst[i], C);
+ }
+ for (; i < length; ++i) dst[i] = src[i] - pred[i];
+}
+
+// Special case for left-based prediction (when preds==dst-1 or preds==src-1).
+static void PredictLineLeft_NEON(const uint8_t* src, uint8_t* dst, int length) {
+ PredictLine_NEON(src, src - 1, dst, length);
+}
+
+//------------------------------------------------------------------------------
+// Horizontal filter.
+
+static WEBP_INLINE void DoHorizontalFilter_NEON(const uint8_t* in,
+ int width, int height,
+ int stride,
+ int row, int num_rows,
+ uint8_t* out) {
+ const size_t start_offset = row * stride;
+ const int last_row = row + num_rows;
+ SANITY_CHECK(in, out);
+ in += start_offset;
+ out += start_offset;
+
+ if (row == 0) {
+ // Leftmost pixel is the same as input for topmost scanline.
+ out[0] = in[0];
+ PredictLineLeft_NEON(in + 1, out + 1, width - 1);
+ row = 1;
+ in += stride;
+ out += stride;
+ }
+
+ // Filter line-by-line.
+ while (row < last_row) {
+ // Leftmost pixel is predicted from above.
+ out[0] = in[0] - in[-stride];
+ PredictLineLeft_NEON(in + 1, out + 1, width - 1);
+ ++row;
+ in += stride;
+ out += stride;
+ }
+}
+
+static void HorizontalFilter_NEON(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ DoHorizontalFilter_NEON(data, width, height, stride, 0, height,
+ filtered_data);
+}
+
+//------------------------------------------------------------------------------
+// Vertical filter.
+
+static WEBP_INLINE void DoVerticalFilter_NEON(const uint8_t* in,
+ int width, int height, int stride,
+ int row, int num_rows,
+ uint8_t* out) {
+ const size_t start_offset = row * stride;
+ const int last_row = row + num_rows;
+ SANITY_CHECK(in, out);
+ in += start_offset;
+ out += start_offset;
+
+ if (row == 0) {
+ // Very first top-left pixel is copied.
+ out[0] = in[0];
+ // Rest of top scan-line is left-predicted.
+ PredictLineLeft_NEON(in + 1, out + 1, width - 1);
+ row = 1;
+ in += stride;
+ out += stride;
+ }
+
+ // Filter line-by-line.
+ while (row < last_row) {
+ PredictLine_NEON(in, in - stride, out, width);
+ ++row;
+ in += stride;
+ out += stride;
+ }
+}
+
+static void VerticalFilter_NEON(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ DoVerticalFilter_NEON(data, width, height, stride, 0, height,
+ filtered_data);
+}
+
+//------------------------------------------------------------------------------
+// Gradient filter.
+
+static WEBP_INLINE int GradientPredictor_C(uint8_t a, uint8_t b, uint8_t c) {
+ const int g = a + b - c;
+ return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit
+}
+
+static void GradientPredictDirect_NEON(const uint8_t* const row,
+ const uint8_t* const top,
+ uint8_t* const out, int length) {
+ int i;
+ for (i = 0; i + 8 <= length; i += 8) {
+ const uint8x8_t A = vld1_u8(&row[i - 1]);
+ const uint8x8_t B = vld1_u8(&top[i + 0]);
+ const int16x8_t C = vreinterpretq_s16_u16(vaddl_u8(A, B));
+ const int16x8_t D = LOAD_U8_TO_S16(&top[i - 1]);
+ const uint8x8_t E = vqmovun_s16(vsubq_s16(C, D));
+ const uint8x8_t F = vld1_u8(&row[i + 0]);
+ vst1_u8(&out[i], vsub_u8(F, E));
+ }
+ for (; i < length; ++i) {
+ out[i] = row[i] - GradientPredictor_C(row[i - 1], top[i], top[i - 1]);
+ }
+}
+
+static WEBP_INLINE void DoGradientFilter_NEON(const uint8_t* in,
+ int width, int height,
+ int stride,
+ int row, int num_rows,
+ uint8_t* out) {
+ const size_t start_offset = row * stride;
+ const int last_row = row + num_rows;
+ SANITY_CHECK(in, out);
+ in += start_offset;
+ out += start_offset;
+
+ // left prediction for top scan-line
+ if (row == 0) {
+ out[0] = in[0];
+ PredictLineLeft_NEON(in + 1, out + 1, width - 1);
+ row = 1;
+ in += stride;
+ out += stride;
+ }
+
+ // Filter line-by-line.
+ while (row < last_row) {
+ out[0] = in[0] - in[-stride];
+ GradientPredictDirect_NEON(in + 1, in + 1 - stride, out + 1, width - 1);
+ ++row;
+ in += stride;
+ out += stride;
+ }
+}
+
+static void GradientFilter_NEON(const uint8_t* data, int width, int height,
+ int stride, uint8_t* filtered_data) {
+ DoGradientFilter_NEON(data, width, height, stride, 0, height,
+ filtered_data);
+}
+
+#undef SANITY_CHECK
+
+//------------------------------------------------------------------------------
+// Inverse transforms
+
+static void HorizontalUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
+ uint8_t* out, int width) {
+ int i;
+ const uint8x16_t zero = vdupq_n_u8(0);
+ uint8x16_t last;
+ out[0] = in[0] + (prev == NULL ? 0 : prev[0]);
+ if (width <= 1) return;
+ last = vsetq_lane_u8(out[0], zero, 0);
+ for (i = 1; i + 16 <= width; i += 16) {
+ const uint8x16_t A0 = vld1q_u8(&in[i]);
+ const uint8x16_t A1 = vaddq_u8(A0, last);
+ const uint8x16_t A2 = SHIFT_LEFT_N_Q(A1, 1);
+ const uint8x16_t A3 = vaddq_u8(A1, A2);
+ const uint8x16_t A4 = SHIFT_LEFT_N_Q(A3, 2);
+ const uint8x16_t A5 = vaddq_u8(A3, A4);
+ const uint8x16_t A6 = SHIFT_LEFT_N_Q(A5, 4);
+ const uint8x16_t A7 = vaddq_u8(A5, A6);
+ const uint8x16_t A8 = SHIFT_LEFT_N_Q(A7, 8);
+ const uint8x16_t A9 = vaddq_u8(A7, A8);
+ vst1q_u8(&out[i], A9);
+ last = SHIFT_RIGHT_N_Q(A9, 15);
+ }
+ for (; i < width; ++i) out[i] = in[i] + out[i - 1];
+}
+
+static void VerticalUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
+ uint8_t* out, int width) {
+ if (prev == NULL) {
+ HorizontalUnfilter_NEON(NULL, in, out, width);
+ } else {
+ int i;
+ assert(width >= 0);
+ for (i = 0; i + 16 <= width; i += 16) {
+ const uint8x16_t A = vld1q_u8(&in[i]);
+ const uint8x16_t B = vld1q_u8(&prev[i]);
+ const uint8x16_t C = vaddq_u8(A, B);
+ vst1q_u8(&out[i], C);
+ }
+ for (; i < width; ++i) out[i] = in[i] + prev[i];
+ }
+}
+
+// GradientUnfilter_NEON is correct but slower than the C-version,
+// at least on ARM64. For armv7, it's a wash.
+// So best is to disable it for now, but keep the idea around...
+// #define USE_GRADIENT_UNFILTER
+
+#if defined(USE_GRADIENT_UNFILTER)
+#define GRAD_PROCESS_LANE(L) do { \
+ const uint8x8_t tmp1 = ROTATE_RIGHT_N(pred, 1); /* rotate predictor in */ \
+ const int16x8_t tmp2 = vaddq_s16(BC, U8_TO_S16(tmp1)); \
+ const uint8x8_t delta = vqmovun_s16(tmp2); \
+ pred = vadd_u8(D, delta); \
+ out = vext_u8(out, ROTATE_LEFT_N(pred, (L)), 1); \
+} while (0)
+
+static void GradientPredictInverse_NEON(const uint8_t* const in,
+ const uint8_t* const top,
+ uint8_t* const row, int length) {
+ if (length > 0) {
+ int i;
+ uint8x8_t pred = vdup_n_u8(row[-1]); // left sample
+ uint8x8_t out = vdup_n_u8(0);
+ for (i = 0; i + 8 <= length; i += 8) {
+ const int16x8_t B = LOAD_U8_TO_S16(&top[i + 0]);
+ const int16x8_t C = LOAD_U8_TO_S16(&top[i - 1]);
+ const int16x8_t BC = vsubq_s16(B, C); // unclipped gradient basis B - C
+ const uint8x8_t D = vld1_u8(&in[i]); // base input
+ GRAD_PROCESS_LANE(0);
+ GRAD_PROCESS_LANE(1);
+ GRAD_PROCESS_LANE(2);
+ GRAD_PROCESS_LANE(3);
+ GRAD_PROCESS_LANE(4);
+ GRAD_PROCESS_LANE(5);
+ GRAD_PROCESS_LANE(6);
+ GRAD_PROCESS_LANE(7);
+ vst1_u8(&row[i], out);
+ }
+ for (; i < length; ++i) {
+ row[i] = in[i] + GradientPredictor_C(row[i - 1], top[i], top[i - 1]);
+ }
+ }
+}
+#undef GRAD_PROCESS_LANE
+
+static void GradientUnfilter_NEON(const uint8_t* prev, const uint8_t* in,
+ uint8_t* out, int width) {
+ if (prev == NULL) {
+ HorizontalUnfilter_NEON(NULL, in, out, width);
+ } else {
+ out[0] = in[0] + prev[0]; // predict from above
+ GradientPredictInverse_NEON(in + 1, prev + 1, out + 1, width - 1);
+ }
+}
+
+#endif // USE_GRADIENT_UNFILTER
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void VP8FiltersInitNEON(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8FiltersInitNEON(void) {
+ WebPUnfilters[WEBP_FILTER_HORIZONTAL] = HorizontalUnfilter_NEON;
+ WebPUnfilters[WEBP_FILTER_VERTICAL] = VerticalUnfilter_NEON;
+#if defined(USE_GRADIENT_UNFILTER)
+ WebPUnfilters[WEBP_FILTER_GRADIENT] = GradientUnfilter_NEON;
+#endif
+
+ WebPFilters[WEBP_FILTER_HORIZONTAL] = HorizontalFilter_NEON;
+ WebPFilters[WEBP_FILTER_VERTICAL] = VerticalFilter_NEON;
+ WebPFilters[WEBP_FILTER_GRADIENT] = GradientFilter_NEON;
+}
+
+#else // !WEBP_USE_NEON
+
+WEBP_DSP_INIT_STUB(VP8FiltersInitNEON)
+
+#endif // WEBP_USE_NEON
diff --git a/thirdparty/libwebp/dsp/lossless.c b/thirdparty/libwebp/dsp/lossless.c
index af913efccb..20d18f6ecd 100644
--- a/thirdparty/libwebp/dsp/lossless.c
+++ b/thirdparty/libwebp/dsp/lossless.c
@@ -17,20 +17,16 @@
#include <math.h>
#include <stdlib.h>
-#include "../dec/vp8li.h"
-#include "../utils/endian_inl.h"
+#include "../dec/vp8li_dec.h"
+#include "../utils/endian_inl_utils.h"
#include "./lossless.h"
+#include "./lossless_common.h"
#define MAX_DIFF_COST (1e30f)
//------------------------------------------------------------------------------
// Image transforms.
-// In-place sum of each component with mod 256.
-static WEBP_INLINE void AddPixelsEq(uint32_t* a, uint32_t b) {
- *a = VP8LAddPixels(*a, b);
-}
-
static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
return (((a0 ^ a1) & 0xfefefefeu) >> 1) + (a0 & a1);
}
@@ -171,21 +167,41 @@ static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
return pred;
}
+GENERATE_PREDICTOR_ADD(Predictor0, PredictorAdd0)
+static void PredictorAdd1(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint32_t left = out[-1];
+ for (i = 0; i < num_pixels; ++i) {
+ out[i] = left = VP8LAddPixels(in[i], left);
+ }
+ (void)upper;
+}
+GENERATE_PREDICTOR_ADD(Predictor2, PredictorAdd2)
+GENERATE_PREDICTOR_ADD(Predictor3, PredictorAdd3)
+GENERATE_PREDICTOR_ADD(Predictor4, PredictorAdd4)
+GENERATE_PREDICTOR_ADD(Predictor5, PredictorAdd5)
+GENERATE_PREDICTOR_ADD(Predictor6, PredictorAdd6)
+GENERATE_PREDICTOR_ADD(Predictor7, PredictorAdd7)
+GENERATE_PREDICTOR_ADD(Predictor8, PredictorAdd8)
+GENERATE_PREDICTOR_ADD(Predictor9, PredictorAdd9)
+GENERATE_PREDICTOR_ADD(Predictor10, PredictorAdd10)
+GENERATE_PREDICTOR_ADD(Predictor11, PredictorAdd11)
+GENERATE_PREDICTOR_ADD(Predictor12, PredictorAdd12)
+GENERATE_PREDICTOR_ADD(Predictor13, PredictorAdd13)
+
//------------------------------------------------------------------------------
// Inverse prediction.
static void PredictorInverseTransform(const VP8LTransform* const transform,
- int y_start, int y_end, uint32_t* data) {
+ int y_start, int y_end,
+ const uint32_t* in, uint32_t* out) {
const int width = transform->xsize_;
if (y_start == 0) { // First Row follows the L (mode=1) mode.
- int x;
- const uint32_t pred0 = Predictor0(data[-1], NULL);
- AddPixelsEq(data, pred0);
- for (x = 1; x < width; ++x) {
- const uint32_t pred1 = Predictor1(data[x - 1], NULL);
- AddPixelsEq(data + x, pred1);
- }
- data += width;
+ PredictorAdd0(in, NULL, 1, out);
+ PredictorAdd1(in + 1, NULL, width - 1, out + 1);
+ in += width;
+ out += width;
++y_start;
}
@@ -193,36 +209,26 @@ static void PredictorInverseTransform(const VP8LTransform* const transform,
int y = y_start;
const int tile_width = 1 << transform->bits_;
const int mask = tile_width - 1;
- const int safe_width = width & ~mask;
const int tiles_per_row = VP8LSubSampleSize(width, transform->bits_);
const uint32_t* pred_mode_base =
transform->data_ + (y >> transform->bits_) * tiles_per_row;
while (y < y_end) {
- const uint32_t pred2 = Predictor2(data[-1], data - width);
const uint32_t* pred_mode_src = pred_mode_base;
- VP8LPredictorFunc pred_func;
int x = 1;
- int t = 1;
// First pixel follows the T (mode=2) mode.
- AddPixelsEq(data, pred2);
+ PredictorAdd2(in, out - width, 1, out);
// .. the rest:
- while (x < safe_width) {
- pred_func = VP8LPredictors[((*pred_mode_src++) >> 8) & 0xf];
- for (; t < tile_width; ++t, ++x) {
- const uint32_t pred = pred_func(data[x - 1], data + x - width);
- AddPixelsEq(data + x, pred);
- }
- t = 0;
- }
- if (x < width) {
- pred_func = VP8LPredictors[((*pred_mode_src++) >> 8) & 0xf];
- for (; x < width; ++x) {
- const uint32_t pred = pred_func(data[x - 1], data + x - width);
- AddPixelsEq(data + x, pred);
- }
+ while (x < width) {
+ const VP8LPredictorAddSubFunc pred_func =
+ VP8LPredictorsAdd[((*pred_mode_src++) >> 8) & 0xf];
+ int x_end = (x & ~mask) + tile_width;
+ if (x_end > width) x_end = width;
+ pred_func(in + x, out + x - width, x_end - x, out + x);
+ x = x_end;
}
- data += width;
+ in += width;
+ out += width;
++y;
if ((y & mask) == 0) { // Use the same mask, since tiles are squares.
pred_mode_base += tiles_per_row;
@@ -233,21 +239,22 @@ static void PredictorInverseTransform(const VP8LTransform* const transform,
// Add green to blue and red channels (i.e. perform the inverse transform of
// 'subtract green').
-void VP8LAddGreenToBlueAndRed_C(uint32_t* data, int num_pixels) {
+void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
int i;
for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = data[i];
+ const uint32_t argb = src[i];
const uint32_t green = ((argb >> 8) & 0xff);
uint32_t red_blue = (argb & 0x00ff00ffu);
red_blue += (green << 16) | green;
red_blue &= 0x00ff00ffu;
- data[i] = (argb & 0xff00ff00u) | red_blue;
+ dst[i] = (argb & 0xff00ff00u) | red_blue;
}
}
-static WEBP_INLINE uint32_t ColorTransformDelta(int8_t color_pred,
- int8_t color) {
- return (uint32_t)((int)(color_pred) * color) >> 5;
+static WEBP_INLINE int ColorTransformDelta(int8_t color_pred,
+ int8_t color) {
+ return ((int)color_pred * color) >> 5;
}
static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
@@ -257,27 +264,29 @@ static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
m->red_to_blue_ = (color_code >> 16) & 0xff;
}
-void VP8LTransformColorInverse_C(const VP8LMultipliers* const m, uint32_t* data,
- int num_pixels) {
+void VP8LTransformColorInverse_C(const VP8LMultipliers* const m,
+ const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
int i;
for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = data[i];
+ const uint32_t argb = src[i];
const uint32_t green = argb >> 8;
const uint32_t red = argb >> 16;
- uint32_t new_red = red;
- uint32_t new_blue = argb;
+ int new_red = red;
+ int new_blue = argb;
new_red += ColorTransformDelta(m->green_to_red_, green);
new_red &= 0xff;
new_blue += ColorTransformDelta(m->green_to_blue_, green);
new_blue += ColorTransformDelta(m->red_to_blue_, new_red);
new_blue &= 0xff;
- data[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
+ dst[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
}
}
// Color space inverse transform.
static void ColorSpaceInverseTransform(const VP8LTransform* const transform,
- int y_start, int y_end, uint32_t* data) {
+ int y_start, int y_end,
+ const uint32_t* src, uint32_t* dst) {
const int width = transform->xsize_;
const int tile_width = 1 << transform->bits_;
const int mask = tile_width - 1;
@@ -291,17 +300,19 @@ static void ColorSpaceInverseTransform(const VP8LTransform* const transform,
while (y < y_end) {
const uint32_t* pred = pred_row;
VP8LMultipliers m = { 0, 0, 0 };
- const uint32_t* const data_safe_end = data + safe_width;
- const uint32_t* const data_end = data + width;
- while (data < data_safe_end) {
+ const uint32_t* const src_safe_end = src + safe_width;
+ const uint32_t* const src_end = src + width;
+ while (src < src_safe_end) {
ColorCodeToMultipliers(*pred++, &m);
- VP8LTransformColorInverse(&m, data, tile_width);
- data += tile_width;
+ VP8LTransformColorInverse(&m, src, tile_width, dst);
+ src += tile_width;
+ dst += tile_width;
}
- if (data < data_end) { // Left-overs using C-version.
+ if (src < src_end) { // Left-overs using C-version.
ColorCodeToMultipliers(*pred++, &m);
- VP8LTransformColorInverse(&m, data, remaining_width);
- data += remaining_width;
+ VP8LTransformColorInverse(&m, src, remaining_width, dst);
+ src += remaining_width;
+ dst += remaining_width;
}
++y;
if ((y & mask) == 0) pred_row += tiles_per_row;
@@ -366,10 +377,10 @@ void VP8LInverseTransform(const VP8LTransform* const transform,
assert(row_end <= transform->ysize_);
switch (transform->type_) {
case SUBTRACT_GREEN:
- VP8LAddGreenToBlueAndRed(out, (row_end - row_start) * width);
+ VP8LAddGreenToBlueAndRed(in, (row_end - row_start) * width, out);
break;
case PREDICTOR_TRANSFORM:
- PredictorInverseTransform(transform, row_start, row_end, out);
+ PredictorInverseTransform(transform, row_start, row_end, in, out);
if (row_end != transform->ysize_) {
// The last predicted row in this iteration will be the top-pred row
// for the first row in next iteration.
@@ -378,7 +389,7 @@ void VP8LInverseTransform(const VP8LTransform* const transform,
}
break;
case CROSS_COLOR_TRANSFORM:
- ColorSpaceInverseTransform(transform, row_start, row_end, out);
+ ColorSpaceInverseTransform(transform, row_start, row_end, in, out);
break;
case COLOR_INDEXING_TRANSFORM:
if (in == out && transform->bits_ > 0) {
@@ -555,10 +566,15 @@ void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
//------------------------------------------------------------------------------
-VP8LProcessBlueAndRedFunc VP8LAddGreenToBlueAndRed;
+VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed;
+VP8LPredictorAddSubFunc VP8LPredictorsAdd[16];
VP8LPredictorFunc VP8LPredictors[16];
-VP8LTransformColorFunc VP8LTransformColorInverse;
+// exposed plain-C implementations
+VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16];
+VP8LPredictorFunc VP8LPredictors_C[16];
+
+VP8LTransformColorInverseFunc VP8LTransformColorInverse;
VP8LConvertFunc VP8LConvertBGRAToRGB;
VP8LConvertFunc VP8LConvertBGRAToRGBA;
@@ -572,29 +588,37 @@ VP8LMapAlphaFunc VP8LMapColor8b;
extern void VP8LDspInitSSE2(void);
extern void VP8LDspInitNEON(void);
extern void VP8LDspInitMIPSdspR2(void);
+extern void VP8LDspInitMSA(void);
static volatile VP8CPUInfo lossless_last_cpuinfo_used =
(VP8CPUInfo)&lossless_last_cpuinfo_used;
+#define COPY_PREDICTOR_ARRAY(IN, OUT) do { \
+ (OUT)[0] = IN##0; \
+ (OUT)[1] = IN##1; \
+ (OUT)[2] = IN##2; \
+ (OUT)[3] = IN##3; \
+ (OUT)[4] = IN##4; \
+ (OUT)[5] = IN##5; \
+ (OUT)[6] = IN##6; \
+ (OUT)[7] = IN##7; \
+ (OUT)[8] = IN##8; \
+ (OUT)[9] = IN##9; \
+ (OUT)[10] = IN##10; \
+ (OUT)[11] = IN##11; \
+ (OUT)[12] = IN##12; \
+ (OUT)[13] = IN##13; \
+ (OUT)[14] = IN##0; /* <- padding security sentinels*/ \
+ (OUT)[15] = IN##0; \
+} while (0);
+
WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInit(void) {
if (lossless_last_cpuinfo_used == VP8GetCPUInfo) return;
- VP8LPredictors[0] = Predictor0;
- VP8LPredictors[1] = Predictor1;
- VP8LPredictors[2] = Predictor2;
- VP8LPredictors[3] = Predictor3;
- VP8LPredictors[4] = Predictor4;
- VP8LPredictors[5] = Predictor5;
- VP8LPredictors[6] = Predictor6;
- VP8LPredictors[7] = Predictor7;
- VP8LPredictors[8] = Predictor8;
- VP8LPredictors[9] = Predictor9;
- VP8LPredictors[10] = Predictor10;
- VP8LPredictors[11] = Predictor11;
- VP8LPredictors[12] = Predictor12;
- VP8LPredictors[13] = Predictor13;
- VP8LPredictors[14] = Predictor0; // <- padding security sentinels
- VP8LPredictors[15] = Predictor0;
+ COPY_PREDICTOR_ARRAY(Predictor, VP8LPredictors)
+ COPY_PREDICTOR_ARRAY(Predictor, VP8LPredictors_C)
+ COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd)
+ COPY_PREDICTOR_ARRAY(PredictorAdd, VP8LPredictorsAdd_C)
VP8LAddGreenToBlueAndRed = VP8LAddGreenToBlueAndRed_C;
@@ -626,8 +650,14 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInit(void) {
VP8LDspInitMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ VP8LDspInitMSA();
+ }
+#endif
}
lossless_last_cpuinfo_used = VP8GetCPUInfo;
}
+#undef COPY_PREDICTOR_ARRAY
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dsp/lossless.h b/thirdparty/libwebp/dsp/lossless.h
index 9f0d7a25b7..352a54e509 100644
--- a/thirdparty/libwebp/dsp/lossless.h
+++ b/thirdparty/libwebp/dsp/lossless.h
@@ -18,7 +18,7 @@
#include "../webp/types.h"
#include "../webp/decode.h"
-#include "../enc/histogram.h"
+#include "../enc/histogram_enc.h"
#include "../utils/utils.h"
#ifdef __cplusplus
@@ -26,7 +26,7 @@ extern "C" {
#endif
#ifdef WEBP_EXPERIMENTAL_FEATURES
-#include "../enc/delta_palettization.h"
+#include "../enc/delta_palettization_enc.h"
#endif // WEBP_EXPERIMENTAL_FEATURES
//------------------------------------------------------------------------------
@@ -34,9 +34,17 @@ extern "C" {
typedef uint32_t (*VP8LPredictorFunc)(uint32_t left, const uint32_t* const top);
extern VP8LPredictorFunc VP8LPredictors[16];
-
-typedef void (*VP8LProcessBlueAndRedFunc)(uint32_t* argb_data, int num_pixels);
-extern VP8LProcessBlueAndRedFunc VP8LAddGreenToBlueAndRed;
+extern VP8LPredictorFunc VP8LPredictors_C[16];
+// These Add/Sub function expects upper[-1] and out[-1] to be readable.
+typedef void (*VP8LPredictorAddSubFunc)(const uint32_t* in,
+ const uint32_t* upper, int num_pixels,
+ uint32_t* out);
+extern VP8LPredictorAddSubFunc VP8LPredictorsAdd[16];
+extern VP8LPredictorAddSubFunc VP8LPredictorsAdd_C[16];
+
+typedef void (*VP8LProcessDecBlueAndRedFunc)(const uint32_t* src,
+ int num_pixels, uint32_t* dst);
+extern VP8LProcessDecBlueAndRedFunc VP8LAddGreenToBlueAndRed;
typedef struct {
// Note: the members are uint8_t, so that any negative values are
@@ -45,9 +53,10 @@ typedef struct {
uint8_t green_to_blue_;
uint8_t red_to_blue_;
} VP8LMultipliers;
-typedef void (*VP8LTransformColorFunc)(const VP8LMultipliers* const m,
- uint32_t* argb_data, int num_pixels);
-extern VP8LTransformColorFunc VP8LTransformColorInverse;
+typedef void (*VP8LTransformColorInverseFunc)(const VP8LMultipliers* const m,
+ const uint32_t* src,
+ int num_pixels, uint32_t* dst);
+extern VP8LTransformColorInverseFunc VP8LTransformColorInverse;
struct VP8LTransform; // Defined in dec/vp8li.h.
@@ -72,23 +81,6 @@ extern VP8LConvertFunc VP8LConvertBGRAToBGR;
void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
WEBP_CSP_MODE out_colorspace, uint8_t* const rgba);
-// color mapping related functions.
-static WEBP_INLINE uint32_t VP8GetARGBIndex(uint32_t idx) {
- return (idx >> 8) & 0xff;
-}
-
-static WEBP_INLINE uint8_t VP8GetAlphaIndex(uint8_t idx) {
- return idx;
-}
-
-static WEBP_INLINE uint32_t VP8GetARGBValue(uint32_t val) {
- return val;
-}
-
-static WEBP_INLINE uint8_t VP8GetAlphaValue(uint32_t val) {
- return (val >> 8) & 0xff;
-}
-
typedef void (*VP8LMapARGBFunc)(const uint32_t* src,
const uint32_t* const color_map,
uint32_t* dst, int y_start,
@@ -110,7 +102,8 @@ void VP8LColorIndexInverseTransformAlpha(
// Expose some C-only fallback functions
void VP8LTransformColorInverse_C(const VP8LMultipliers* const m,
- uint32_t* data, int num_pixels);
+ const uint32_t* src, int num_pixels,
+ uint32_t* dst);
void VP8LConvertBGRAToRGB_C(const uint32_t* src, int num_pixels, uint8_t* dst);
void VP8LConvertBGRAToRGBA_C(const uint32_t* src, int num_pixels, uint8_t* dst);
@@ -119,7 +112,8 @@ void VP8LConvertBGRAToRGBA4444_C(const uint32_t* src,
void VP8LConvertBGRAToRGB565_C(const uint32_t* src,
int num_pixels, uint8_t* dst);
void VP8LConvertBGRAToBGR_C(const uint32_t* src, int num_pixels, uint8_t* dst);
-void VP8LAddGreenToBlueAndRed_C(uint32_t* data, int num_pixels);
+void VP8LAddGreenToBlueAndRed_C(const uint32_t* src, int num_pixels,
+ uint32_t* dst);
// Must be called before calling any of the above methods.
void VP8LDspInit(void);
@@ -127,7 +121,10 @@ void VP8LDspInit(void);
//------------------------------------------------------------------------------
// Encoding
-extern VP8LProcessBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
+typedef void (*VP8LProcessEncBlueAndRedFunc)(uint32_t* dst, int num_pixels);
+extern VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
+typedef void (*VP8LTransformColorFunc)(const VP8LMultipliers* const m,
+ uint32_t* const dst, int num_pixels);
extern VP8LTransformColorFunc VP8LTransformColor;
typedef void (*VP8LCollectColorBlueTransformsFunc)(
const uint32_t* argb, int stride,
@@ -153,62 +150,8 @@ void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
int green_to_blue, int red_to_blue,
int histo[]);
-//------------------------------------------------------------------------------
-// Image transforms.
-
-void VP8LResidualImage(int width, int height, int bits, int low_effort,
- uint32_t* const argb, uint32_t* const argb_scratch,
- uint32_t* const image, int near_lossless, int exact,
- int used_subtract_green);
-
-void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
- uint32_t* const argb, uint32_t* image);
-
-//------------------------------------------------------------------------------
-// Misc methods.
-
-// Computes sampled size of 'size' when sampling using 'sampling bits'.
-static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size,
- uint32_t sampling_bits) {
- return (size + (1 << sampling_bits) - 1) >> sampling_bits;
-}
-
-// Converts near lossless quality into max number of bits shaved off.
-static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) {
- // 100 -> 0
- // 80..99 -> 1
- // 60..79 -> 2
- // 40..59 -> 3
- // 20..39 -> 4
- // 0..19 -> 5
- return 5 - near_lossless_quality / 20;
-}
-
-// -----------------------------------------------------------------------------
-// Faster logarithm for integers. Small values use a look-up table.
-
-// The threshold till approximate version of log_2 can be used.
-// Practically, we can get rid of the call to log() as the two values match to
-// very high degree (the ratio of these two is 0.99999x).
-// Keeping a high threshold for now.
-#define APPROX_LOG_WITH_CORRECTION_MAX 65536
-#define APPROX_LOG_MAX 4096
-#define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
-#define LOG_LOOKUP_IDX_MAX 256
-extern const float kLog2Table[LOG_LOOKUP_IDX_MAX];
-extern const float kSLog2Table[LOG_LOOKUP_IDX_MAX];
-typedef float (*VP8LFastLog2SlowFunc)(uint32_t v);
-
-extern VP8LFastLog2SlowFunc VP8LFastLog2Slow;
-extern VP8LFastLog2SlowFunc VP8LFastSLog2Slow;
-
-static WEBP_INLINE float VP8LFastLog2(uint32_t v) {
- return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v);
-}
-// Fast calculation of v * log2(v) for integer input.
-static WEBP_INLINE float VP8LFastSLog2(uint32_t v) {
- return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v);
-}
+extern VP8LPredictorAddSubFunc VP8LPredictorsSub[16];
+extern VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16];
// -----------------------------------------------------------------------------
// Huffman-cost related functions.
@@ -228,11 +171,6 @@ typedef struct { // small struct to hold counters
int streaks[2][2]; // [zero/non-zero][streak<3 / streak>=3]
} VP8LStreaks;
-typedef VP8LStreaks (*VP8LCostCombinedCountFunc)(const uint32_t* X,
- const uint32_t* Y, int length);
-
-extern VP8LCostCombinedCountFunc VP8LHuffmanCostCombinedCount;
-
typedef struct { // small struct to hold bit entropy results
double entropy; // entropy
uint32_t sum; // sum of the population
@@ -246,26 +184,20 @@ void VP8LBitEntropyInit(VP8LBitEntropy* const entropy);
// Get the combined symbol bit entropy and Huffman cost stats for the
// distributions 'X' and 'Y'. Those results can then be refined according to
// codec specific heuristics.
-void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
- const uint32_t* const Y, int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats);
+typedef void (*VP8LGetCombinedEntropyUnrefinedFunc)(
+ const uint32_t X[], const uint32_t Y[], int length,
+ VP8LBitEntropy* const bit_entropy, VP8LStreaks* const stats);
+extern VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
+
// Get the entropy for the distribution 'X'.
-void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats);
+typedef void (*VP8LGetEntropyUnrefinedFunc)(const uint32_t X[], int length,
+ VP8LBitEntropy* const bit_entropy,
+ VP8LStreaks* const stats);
+extern VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
void VP8LBitsEntropyUnrefined(const uint32_t* const array, int n,
VP8LBitEntropy* const entropy);
-typedef void (*GetEntropyUnrefinedHelperFunc)(uint32_t val, int i,
- uint32_t* const val_prev,
- int* const i_prev,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats);
-// Internal function used by VP8LGet*EntropyUnrefined.
-extern GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper;
-
typedef void (*VP8LHistogramAddFunc)(const VP8LHistogram* const a,
const VP8LHistogram* const b,
VP8LHistogram* const out);
@@ -279,86 +211,11 @@ typedef int (*VP8LVectorMismatchFunc)(const uint32_t* const array1,
// Returns the first index where array1 and array2 are different.
extern VP8LVectorMismatchFunc VP8LVectorMismatch;
-static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) {
- const int log_floor = BitsLog2Floor(n);
- if (n == (n & ~(n - 1))) // zero or a power of two.
- return log_floor;
- else
- return log_floor + 1;
-}
-
-// Splitting of distance and length codes into prefixes and
-// extra bits. The prefixes are encoded with an entropy code
-// while the extra bits are stored just as normal bits.
-static WEBP_INLINE void VP8LPrefixEncodeBitsNoLUT(int distance, int* const code,
- int* const extra_bits) {
- const int highest_bit = BitsLog2Floor(--distance);
- const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
- *extra_bits = highest_bit - 1;
- *code = 2 * highest_bit + second_highest_bit;
-}
-
-static WEBP_INLINE void VP8LPrefixEncodeNoLUT(int distance, int* const code,
- int* const extra_bits,
- int* const extra_bits_value) {
- const int highest_bit = BitsLog2Floor(--distance);
- const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
- *extra_bits = highest_bit - 1;
- *extra_bits_value = distance & ((1 << *extra_bits) - 1);
- *code = 2 * highest_bit + second_highest_bit;
-}
-
-#define PREFIX_LOOKUP_IDX_MAX 512
-typedef struct {
- int8_t code_;
- int8_t extra_bits_;
-} VP8LPrefixCode;
-
-// These tables are derived using VP8LPrefixEncodeNoLUT.
-extern const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX];
-extern const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX];
-static WEBP_INLINE void VP8LPrefixEncodeBits(int distance, int* const code,
- int* const extra_bits) {
- if (distance < PREFIX_LOOKUP_IDX_MAX) {
- const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
- *code = prefix_code.code_;
- *extra_bits = prefix_code.extra_bits_;
- } else {
- VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits);
- }
-}
-
-static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code,
- int* const extra_bits,
- int* const extra_bits_value) {
- if (distance < PREFIX_LOOKUP_IDX_MAX) {
- const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
- *code = prefix_code.code_;
- *extra_bits = prefix_code.extra_bits_;
- *extra_bits_value = kPrefixEncodeExtraBitsValue[distance];
- } else {
- VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value);
- }
-}
-
-// Sum of each component, mod 256.
-static WEBP_INLINE uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
- const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u);
- const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu);
- return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
-}
-
-// Difference of each component, mod 256.
-static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
- const uint32_t alpha_and_green =
- 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
- const uint32_t red_and_blue =
- 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu);
- return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
-}
-
-void VP8LBundleColorMap(const uint8_t* const row, int width,
- int xbits, uint32_t* const dst);
+typedef void (*VP8LBundleColorMapFunc)(const uint8_t* const row, int width,
+ int xbits, uint32_t* dst);
+extern VP8LBundleColorMapFunc VP8LBundleColorMap;
+void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits,
+ uint32_t* dst);
// Must be called before calling any of the above methods.
void VP8LEncDspInit(void);
diff --git a/thirdparty/libwebp/dsp/lossless_common.h b/thirdparty/libwebp/dsp/lossless_common.h
new file mode 100644
index 0000000000..c40f711208
--- /dev/null
+++ b/thirdparty/libwebp/dsp/lossless_common.h
@@ -0,0 +1,210 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// Image transforms and color space conversion methods for lossless decoder.
+//
+// Authors: Vikas Arora (vikaas.arora@gmail.com)
+// Jyrki Alakuijala (jyrki@google.com)
+// Vincent Rabaud (vrabaud@google.com)
+
+#ifndef WEBP_DSP_LOSSLESS_COMMON_H_
+#define WEBP_DSP_LOSSLESS_COMMON_H_
+
+#include "../webp/types.h"
+
+#include "../utils/utils.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------------
+// Decoding
+
+// color mapping related functions.
+static WEBP_INLINE uint32_t VP8GetARGBIndex(uint32_t idx) {
+ return (idx >> 8) & 0xff;
+}
+
+static WEBP_INLINE uint8_t VP8GetAlphaIndex(uint8_t idx) {
+ return idx;
+}
+
+static WEBP_INLINE uint32_t VP8GetARGBValue(uint32_t val) {
+ return val;
+}
+
+static WEBP_INLINE uint8_t VP8GetAlphaValue(uint32_t val) {
+ return (val >> 8) & 0xff;
+}
+
+//------------------------------------------------------------------------------
+// Misc methods.
+
+// Computes sampled size of 'size' when sampling using 'sampling bits'.
+static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size,
+ uint32_t sampling_bits) {
+ return (size + (1 << sampling_bits) - 1) >> sampling_bits;
+}
+
+// Converts near lossless quality into max number of bits shaved off.
+static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) {
+ // 100 -> 0
+ // 80..99 -> 1
+ // 60..79 -> 2
+ // 40..59 -> 3
+ // 20..39 -> 4
+ // 0..19 -> 5
+ return 5 - near_lossless_quality / 20;
+}
+
+// -----------------------------------------------------------------------------
+// Faster logarithm for integers. Small values use a look-up table.
+
+// The threshold till approximate version of log_2 can be used.
+// Practically, we can get rid of the call to log() as the two values match to
+// very high degree (the ratio of these two is 0.99999x).
+// Keeping a high threshold for now.
+#define APPROX_LOG_WITH_CORRECTION_MAX 65536
+#define APPROX_LOG_MAX 4096
+#define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
+#define LOG_LOOKUP_IDX_MAX 256
+extern const float kLog2Table[LOG_LOOKUP_IDX_MAX];
+extern const float kSLog2Table[LOG_LOOKUP_IDX_MAX];
+typedef float (*VP8LFastLog2SlowFunc)(uint32_t v);
+
+extern VP8LFastLog2SlowFunc VP8LFastLog2Slow;
+extern VP8LFastLog2SlowFunc VP8LFastSLog2Slow;
+
+static WEBP_INLINE float VP8LFastLog2(uint32_t v) {
+ return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v);
+}
+// Fast calculation of v * log2(v) for integer input.
+static WEBP_INLINE float VP8LFastSLog2(uint32_t v) {
+ return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v);
+}
+
+// -----------------------------------------------------------------------------
+// PrefixEncode()
+
+static WEBP_INLINE int VP8LBitsLog2Ceiling(uint32_t n) {
+ const int log_floor = BitsLog2Floor(n);
+ if (n == (n & ~(n - 1))) { // zero or a power of two.
+ return log_floor;
+ }
+ return log_floor + 1;
+}
+
+// Splitting of distance and length codes into prefixes and
+// extra bits. The prefixes are encoded with an entropy code
+// while the extra bits are stored just as normal bits.
+static WEBP_INLINE void VP8LPrefixEncodeBitsNoLUT(int distance, int* const code,
+ int* const extra_bits) {
+ const int highest_bit = BitsLog2Floor(--distance);
+ const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
+ *extra_bits = highest_bit - 1;
+ *code = 2 * highest_bit + second_highest_bit;
+}
+
+static WEBP_INLINE void VP8LPrefixEncodeNoLUT(int distance, int* const code,
+ int* const extra_bits,
+ int* const extra_bits_value) {
+ const int highest_bit = BitsLog2Floor(--distance);
+ const int second_highest_bit = (distance >> (highest_bit - 1)) & 1;
+ *extra_bits = highest_bit - 1;
+ *extra_bits_value = distance & ((1 << *extra_bits) - 1);
+ *code = 2 * highest_bit + second_highest_bit;
+}
+
+#define PREFIX_LOOKUP_IDX_MAX 512
+typedef struct {
+ int8_t code_;
+ int8_t extra_bits_;
+} VP8LPrefixCode;
+
+// These tables are derived using VP8LPrefixEncodeNoLUT.
+extern const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX];
+extern const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX];
+static WEBP_INLINE void VP8LPrefixEncodeBits(int distance, int* const code,
+ int* const extra_bits) {
+ if (distance < PREFIX_LOOKUP_IDX_MAX) {
+ const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
+ *code = prefix_code.code_;
+ *extra_bits = prefix_code.extra_bits_;
+ } else {
+ VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits);
+ }
+}
+
+static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code,
+ int* const extra_bits,
+ int* const extra_bits_value) {
+ if (distance < PREFIX_LOOKUP_IDX_MAX) {
+ const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance];
+ *code = prefix_code.code_;
+ *extra_bits = prefix_code.extra_bits_;
+ *extra_bits_value = kPrefixEncodeExtraBitsValue[distance];
+ } else {
+ VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value);
+ }
+}
+
+// Sum of each component, mod 256.
+static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
+uint32_t VP8LAddPixels(uint32_t a, uint32_t b) {
+ const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u);
+ const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu);
+ return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
+}
+
+// Difference of each component, mod 256.
+static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
+uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
+ const uint32_t alpha_and_green =
+ 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
+ const uint32_t red_and_blue =
+ 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu);
+ return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
+}
+
+//------------------------------------------------------------------------------
+// Transform-related functions use din both encoding and decoding.
+
+// Macros used to create a batch predictor that iteratively uses a
+// one-pixel predictor.
+
+// The predictor is added to the output pixel (which
+// is therefore considered as a residual) to get the final prediction.
+#define GENERATE_PREDICTOR_ADD(PREDICTOR, PREDICTOR_ADD) \
+static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int x; \
+ for (x = 0; x < num_pixels; ++x) { \
+ const uint32_t pred = (PREDICTOR)(out[x - 1], upper + x); \
+ out[x] = VP8LAddPixels(in[x], pred); \
+ } \
+}
+
+// It subtracts the prediction from the input pixel and stores the residual
+// in the output pixel.
+#define GENERATE_PREDICTOR_SUB(PREDICTOR, PREDICTOR_SUB) \
+static void PREDICTOR_SUB(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int x; \
+ for (x = 0; x < num_pixels; ++x) { \
+ const uint32_t pred = (PREDICTOR)(in[x - 1], upper + x); \
+ out[x] = VP8LSubPixels(in[x], pred); \
+ } \
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // WEBP_DSP_LOSSLESS_COMMON_H_
diff --git a/thirdparty/libwebp/dsp/lossless_enc.c b/thirdparty/libwebp/dsp/lossless_enc.c
index 256f6f5f8b..4e46fbab8b 100644
--- a/thirdparty/libwebp/dsp/lossless_enc.c
+++ b/thirdparty/libwebp/dsp/lossless_enc.c
@@ -17,16 +17,12 @@
#include <math.h>
#include <stdlib.h>
-#include "../dec/vp8li.h"
-#include "../utils/endian_inl.h"
+#include "../dec/vp8li_dec.h"
+#include "../utils/endian_inl_utils.h"
#include "./lossless.h"
+#include "./lossless_common.h"
#include "./yuv.h"
-#define MAX_DIFF_COST (1e30f)
-
-static const int kPredLowEffort = 11;
-static const uint32_t kMaskAlpha = 0xff000000;
-
// lookup table for small values of log2(int)
const float kLog2Table[LOG_LOOKUP_IDX_MAX] = {
0.0000000000000000f, 0.0000000000000000f,
@@ -380,26 +376,9 @@ static float FastLog2Slow(uint32_t v) {
}
}
-// Mostly used to reduce code size + readability
-static WEBP_INLINE int GetMin(int a, int b) { return (a > b) ? b : a; }
-static WEBP_INLINE int GetMax(int a, int b) { return (a < b) ? b : a; }
-
//------------------------------------------------------------------------------
// Methods to calculate Entropy (Shannon).
-static float PredictionCostSpatial(const int counts[256], int weight_0,
- double exp_val) {
- const int significant_symbols = 256 >> 4;
- const double exp_decay_factor = 0.6;
- double bits = weight_0 * counts[0];
- int i;
- for (i = 1; i < significant_symbols; ++i) {
- bits += exp_val * (counts[i] + counts[256 - i]);
- exp_val *= exp_decay_factor;
- }
- return (float)(-0.1 * bits);
-}
-
// Compute the combined Shanon's entropy for distribution {X} and {X+Y}
static float CombinedShannonEntropy(const int X[256], const int Y[256]) {
int i;
@@ -422,18 +401,6 @@ static float CombinedShannonEntropy(const int X[256], const int Y[256]) {
return (float)retval;
}
-static float PredictionCostSpatialHistogram(const int accumulated[4][256],
- const int tile[4][256]) {
- int i;
- double retval = 0;
- for (i = 0; i < 4; ++i) {
- const double kExpValue = 0.94;
- retval += PredictionCostSpatial(tile[i], 1, kExpValue);
- retval += VP8LCombinedShannonEntropy(tile[i], accumulated[i]);
- }
- return (float)retval;
-}
-
void VP8LBitEntropyInit(VP8LBitEntropy* const entropy) {
entropy->entropy = 0.;
entropy->sum = 0;
@@ -486,9 +453,9 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
*i_prev = i;
}
-void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats) {
+static void GetEntropyUnrefined(const uint32_t X[], int length,
+ VP8LBitEntropy* const bit_entropy,
+ VP8LStreaks* const stats) {
int i;
int i_prev = 0;
uint32_t x_prev = X[0];
@@ -499,18 +466,18 @@ void VP8LGetEntropyUnrefined(const uint32_t* const X, int length,
for (i = 1; i < length; ++i) {
const uint32_t x = X[i];
if (x != x_prev) {
- VP8LGetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
+ GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
}
}
- VP8LGetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
+ GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
}
-void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
- const uint32_t* const Y, int length,
- VP8LBitEntropy* const bit_entropy,
- VP8LStreaks* const stats) {
+static void GetCombinedEntropyUnrefined(const uint32_t X[], const uint32_t Y[],
+ int length,
+ VP8LBitEntropy* const bit_entropy,
+ VP8LStreaks* const stats) {
int i = 1;
int i_prev = 0;
uint32_t xy_prev = X[0] + Y[0];
@@ -521,439 +488,29 @@ void VP8LGetCombinedEntropyUnrefined(const uint32_t* const X,
for (i = 1; i < length; ++i) {
const uint32_t xy = X[i] + Y[i];
if (xy != xy_prev) {
- VP8LGetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy,
- stats);
+ GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
}
}
- VP8LGetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
+ GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
}
-static WEBP_INLINE void UpdateHisto(int histo_argb[4][256], uint32_t argb) {
- ++histo_argb[0][argb >> 24];
- ++histo_argb[1][(argb >> 16) & 0xff];
- ++histo_argb[2][(argb >> 8) & 0xff];
- ++histo_argb[3][argb & 0xff];
-}
-
//------------------------------------------------------------------------------
-static WEBP_INLINE uint32_t Predict(VP8LPredictorFunc pred_func,
- int x, int y,
- const uint32_t* current_row,
- const uint32_t* upper_row) {
- if (y == 0) {
- return (x == 0) ? ARGB_BLACK : current_row[x - 1]; // Left.
- } else if (x == 0) {
- return upper_row[x]; // Top.
- } else {
- return pred_func(current_row[x - 1], upper_row + x);
- }
-}
-
-static int MaxDiffBetweenPixels(uint32_t p1, uint32_t p2) {
- const int diff_a = abs((int)(p1 >> 24) - (int)(p2 >> 24));
- const int diff_r = abs((int)((p1 >> 16) & 0xff) - (int)((p2 >> 16) & 0xff));
- const int diff_g = abs((int)((p1 >> 8) & 0xff) - (int)((p2 >> 8) & 0xff));
- const int diff_b = abs((int)(p1 & 0xff) - (int)(p2 & 0xff));
- return GetMax(GetMax(diff_a, diff_r), GetMax(diff_g, diff_b));
-}
-
-static int MaxDiffAroundPixel(uint32_t current, uint32_t up, uint32_t down,
- uint32_t left, uint32_t right) {
- const int diff_up = MaxDiffBetweenPixels(current, up);
- const int diff_down = MaxDiffBetweenPixels(current, down);
- const int diff_left = MaxDiffBetweenPixels(current, left);
- const int diff_right = MaxDiffBetweenPixels(current, right);
- return GetMax(GetMax(diff_up, diff_down), GetMax(diff_left, diff_right));
-}
-
-static uint32_t AddGreenToBlueAndRed(uint32_t argb) {
- const uint32_t green = (argb >> 8) & 0xff;
- uint32_t red_blue = argb & 0x00ff00ffu;
- red_blue += (green << 16) | green;
- red_blue &= 0x00ff00ffu;
- return (argb & 0xff00ff00u) | red_blue;
-}
-
-static void MaxDiffsForRow(int width, int stride, const uint32_t* const argb,
- uint8_t* const max_diffs, int used_subtract_green) {
- uint32_t current, up, down, left, right;
- int x;
- if (width <= 2) return;
- current = argb[0];
- right = argb[1];
- if (used_subtract_green) {
- current = AddGreenToBlueAndRed(current);
- right = AddGreenToBlueAndRed(right);
- }
- // max_diffs[0] and max_diffs[width - 1] are never used.
- for (x = 1; x < width - 1; ++x) {
- up = argb[-stride + x];
- down = argb[stride + x];
- left = current;
- current = right;
- right = argb[x + 1];
- if (used_subtract_green) {
- up = AddGreenToBlueAndRed(up);
- down = AddGreenToBlueAndRed(down);
- right = AddGreenToBlueAndRed(right);
- }
- max_diffs[x] = MaxDiffAroundPixel(current, up, down, left, right);
- }
-}
-
-// Quantize the difference between the actual component value and its prediction
-// to a multiple of quantization, working modulo 256, taking care not to cross
-// a boundary (inclusive upper limit).
-static uint8_t NearLosslessComponent(uint8_t value, uint8_t predict,
- uint8_t boundary, int quantization) {
- const int residual = (value - predict) & 0xff;
- const int boundary_residual = (boundary - predict) & 0xff;
- const int lower = residual & ~(quantization - 1);
- const int upper = lower + quantization;
- // Resolve ties towards a value closer to the prediction (i.e. towards lower
- // if value comes after prediction and towards upper otherwise).
- const int bias = ((boundary - value) & 0xff) < boundary_residual;
- if (residual - lower < upper - residual + bias) {
- // lower is closer to residual than upper.
- if (residual > boundary_residual && lower <= boundary_residual) {
- // Halve quantization step to avoid crossing boundary. This midpoint is
- // on the same side of boundary as residual because midpoint >= residual
- // (since lower is closer than upper) and residual is above the boundary.
- return lower + (quantization >> 1);
- }
- return lower;
- } else {
- // upper is closer to residual than lower.
- if (residual <= boundary_residual && upper > boundary_residual) {
- // Halve quantization step to avoid crossing boundary. This midpoint is
- // on the same side of boundary as residual because midpoint <= residual
- // (since upper is closer than lower) and residual is below the boundary.
- return lower + (quantization >> 1);
- }
- return upper & 0xff;
- }
-}
-
-// Quantize every component of the difference between the actual pixel value and
-// its prediction to a multiple of a quantization (a power of 2, not larger than
-// max_quantization which is a power of 2, smaller than max_diff). Take care if
-// value and predict have undergone subtract green, which means that red and
-// blue are represented as offsets from green.
-static uint32_t NearLossless(uint32_t value, uint32_t predict,
- int max_quantization, int max_diff,
- int used_subtract_green) {
- int quantization;
- uint8_t new_green = 0;
- uint8_t green_diff = 0;
- uint8_t a, r, g, b;
- if (max_diff <= 2) {
- return VP8LSubPixels(value, predict);
- }
- quantization = max_quantization;
- while (quantization >= max_diff) {
- quantization >>= 1;
- }
- if ((value >> 24) == 0 || (value >> 24) == 0xff) {
- // Preserve transparency of fully transparent or fully opaque pixels.
- a = ((value >> 24) - (predict >> 24)) & 0xff;
- } else {
- a = NearLosslessComponent(value >> 24, predict >> 24, 0xff, quantization);
- }
- g = NearLosslessComponent((value >> 8) & 0xff, (predict >> 8) & 0xff, 0xff,
- quantization);
- if (used_subtract_green) {
- // The green offset will be added to red and blue components during decoding
- // to obtain the actual red and blue values.
- new_green = ((predict >> 8) + g) & 0xff;
- // The amount by which green has been adjusted during quantization. It is
- // subtracted from red and blue for compensation, to avoid accumulating two
- // quantization errors in them.
- green_diff = (new_green - (value >> 8)) & 0xff;
- }
- r = NearLosslessComponent(((value >> 16) - green_diff) & 0xff,
- (predict >> 16) & 0xff, 0xff - new_green,
- quantization);
- b = NearLosslessComponent((value - green_diff) & 0xff, predict & 0xff,
- 0xff - new_green, quantization);
- return ((uint32_t)a << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
-}
-
-// Returns the difference between the pixel and its prediction. In case of a
-// lossy encoding, updates the source image to avoid propagating the deviation
-// further to pixels which depend on the current pixel for their predictions.
-static WEBP_INLINE uint32_t GetResidual(int width, int height,
- uint32_t* const upper_row,
- uint32_t* const current_row,
- const uint8_t* const max_diffs,
- int mode, VP8LPredictorFunc pred_func,
- int x, int y, int max_quantization,
- int exact, int used_subtract_green) {
- const uint32_t predict = Predict(pred_func, x, y, current_row, upper_row);
- uint32_t residual;
- if (max_quantization == 1 || mode == 0 || y == 0 || y == height - 1 ||
- x == 0 || x == width - 1) {
- residual = VP8LSubPixels(current_row[x], predict);
- } else {
- residual = NearLossless(current_row[x], predict, max_quantization,
- max_diffs[x], used_subtract_green);
- // Update the source image.
- current_row[x] = VP8LAddPixels(predict, residual);
- // x is never 0 here so we do not need to update upper_row like below.
- }
- if (!exact && (current_row[x] & kMaskAlpha) == 0) {
- // If alpha is 0, cleanup RGB. We can choose the RGB values of the residual
- // for best compression. The prediction of alpha itself can be non-zero and
- // must be kept though. We choose RGB of the residual to be 0.
- residual &= kMaskAlpha;
- // Update the source image.
- current_row[x] = predict & ~kMaskAlpha;
- // The prediction for the rightmost pixel in a row uses the leftmost pixel
- // in that row as its top-right context pixel. Hence if we change the
- // leftmost pixel of current_row, the corresponding change must be applied
- // to upper_row as well where top-right context is being read from.
- if (x == 0 && y != 0) upper_row[width] = current_row[0];
- }
- return residual;
-}
-
-// Returns best predictor and updates the accumulated histogram.
-// If max_quantization > 1, assumes that near lossless processing will be
-// applied, quantizing residuals to multiples of quantization levels up to
-// max_quantization (the actual quantization level depends on smoothness near
-// the given pixel).
-static int GetBestPredictorForTile(int width, int height,
- int tile_x, int tile_y, int bits,
- int accumulated[4][256],
- uint32_t* const argb_scratch,
- const uint32_t* const argb,
- int max_quantization,
- int exact, int used_subtract_green) {
- const int kNumPredModes = 14;
- const int start_x = tile_x << bits;
- const int start_y = tile_y << bits;
- const int tile_size = 1 << bits;
- const int max_y = GetMin(tile_size, height - start_y);
- const int max_x = GetMin(tile_size, width - start_x);
- // Whether there exist columns just outside the tile.
- const int have_left = (start_x > 0);
- const int have_right = (max_x < width - start_x);
- // Position and size of the strip covering the tile and adjacent columns if
- // they exist.
- const int context_start_x = start_x - have_left;
- const int context_width = max_x + have_left + have_right;
- // The width of upper_row and current_row is one pixel larger than image width
- // to allow the top right pixel to point to the leftmost pixel of the next row
- // when at the right edge.
- uint32_t* upper_row = argb_scratch;
- uint32_t* current_row = upper_row + width + 1;
- uint8_t* const max_diffs = (uint8_t*)(current_row + width + 1);
- float best_diff = MAX_DIFF_COST;
- int best_mode = 0;
- int mode;
- int histo_stack_1[4][256];
- int histo_stack_2[4][256];
- // Need pointers to be able to swap arrays.
- int (*histo_argb)[256] = histo_stack_1;
- int (*best_histo)[256] = histo_stack_2;
- int i, j;
-
- for (mode = 0; mode < kNumPredModes; ++mode) {
- const VP8LPredictorFunc pred_func = VP8LPredictors[mode];
- float cur_diff;
- int relative_y;
- memset(histo_argb, 0, sizeof(histo_stack_1));
- if (start_y > 0) {
- // Read the row above the tile which will become the first upper_row.
- // Include a pixel to the left if it exists; include a pixel to the right
- // in all cases (wrapping to the leftmost pixel of the next row if it does
- // not exist).
- memcpy(current_row + context_start_x,
- argb + (start_y - 1) * width + context_start_x,
- sizeof(*argb) * (max_x + have_left + 1));
- }
- for (relative_y = 0; relative_y < max_y; ++relative_y) {
- const int y = start_y + relative_y;
- int relative_x;
- uint32_t* tmp = upper_row;
- upper_row = current_row;
- current_row = tmp;
- // Read current_row. Include a pixel to the left if it exists; include a
- // pixel to the right in all cases except at the bottom right corner of
- // the image (wrapping to the leftmost pixel of the next row if it does
- // not exist in the current row).
- memcpy(current_row + context_start_x,
- argb + y * width + context_start_x,
- sizeof(*argb) * (max_x + have_left + (y + 1 < height)));
- if (max_quantization > 1 && y >= 1 && y + 1 < height) {
- MaxDiffsForRow(context_width, width, argb + y * width + context_start_x,
- max_diffs + context_start_x, used_subtract_green);
- }
-
- for (relative_x = 0; relative_x < max_x; ++relative_x) {
- const int x = start_x + relative_x;
- UpdateHisto(histo_argb,
- GetResidual(width, height, upper_row, current_row,
- max_diffs, mode, pred_func, x, y,
- max_quantization, exact, used_subtract_green));
- }
- }
- cur_diff = PredictionCostSpatialHistogram(
- (const int (*)[256])accumulated, (const int (*)[256])histo_argb);
- if (cur_diff < best_diff) {
- int (*tmp)[256] = histo_argb;
- histo_argb = best_histo;
- best_histo = tmp;
- best_diff = cur_diff;
- best_mode = mode;
- }
- }
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 256; j++) {
- accumulated[i][j] += best_histo[i][j];
- }
- }
-
- return best_mode;
-}
-
-// Converts pixels of the image to residuals with respect to predictions.
-// If max_quantization > 1, applies near lossless processing, quantizing
-// residuals to multiples of quantization levels up to max_quantization
-// (the actual quantization level depends on smoothness near the given pixel).
-static void CopyImageWithPrediction(int width, int height,
- int bits, uint32_t* const modes,
- uint32_t* const argb_scratch,
- uint32_t* const argb,
- int low_effort, int max_quantization,
- int exact, int used_subtract_green) {
- const int tiles_per_row = VP8LSubSampleSize(width, bits);
- const int mask = (1 << bits) - 1;
- // The width of upper_row and current_row is one pixel larger than image width
- // to allow the top right pixel to point to the leftmost pixel of the next row
- // when at the right edge.
- uint32_t* upper_row = argb_scratch;
- uint32_t* current_row = upper_row + width + 1;
- uint8_t* current_max_diffs = (uint8_t*)(current_row + width + 1);
- uint8_t* lower_max_diffs = current_max_diffs + width;
- int y;
- int mode = 0;
- VP8LPredictorFunc pred_func = NULL;
-
- for (y = 0; y < height; ++y) {
- int x;
- uint32_t* const tmp32 = upper_row;
- upper_row = current_row;
- current_row = tmp32;
- memcpy(current_row, argb + y * width,
- sizeof(*argb) * (width + (y + 1 < height)));
-
- if (low_effort) {
- for (x = 0; x < width; ++x) {
- const uint32_t predict = Predict(VP8LPredictors[kPredLowEffort], x, y,
- current_row, upper_row);
- argb[y * width + x] = VP8LSubPixels(current_row[x], predict);
- }
- } else {
- if (max_quantization > 1) {
- // Compute max_diffs for the lower row now, because that needs the
- // contents of argb for the current row, which we will overwrite with
- // residuals before proceeding with the next row.
- uint8_t* const tmp8 = current_max_diffs;
- current_max_diffs = lower_max_diffs;
- lower_max_diffs = tmp8;
- if (y + 2 < height) {
- MaxDiffsForRow(width, width, argb + (y + 1) * width, lower_max_diffs,
- used_subtract_green);
- }
- }
- for (x = 0; x < width; ++x) {
- if ((x & mask) == 0) {
- mode = (modes[(y >> bits) * tiles_per_row + (x >> bits)] >> 8) & 0xff;
- pred_func = VP8LPredictors[mode];
- }
- argb[y * width + x] = GetResidual(
- width, height, upper_row, current_row, current_max_diffs, mode,
- pred_func, x, y, max_quantization, exact, used_subtract_green);
- }
- }
- }
-}
-
-// Finds the best predictor for each tile, and converts the image to residuals
-// with respect to predictions. If near_lossless_quality < 100, applies
-// near lossless processing, shaving off more bits of residuals for lower
-// qualities.
-void VP8LResidualImage(int width, int height, int bits, int low_effort,
- uint32_t* const argb, uint32_t* const argb_scratch,
- uint32_t* const image, int near_lossless_quality,
- int exact, int used_subtract_green) {
- const int tiles_per_row = VP8LSubSampleSize(width, bits);
- const int tiles_per_col = VP8LSubSampleSize(height, bits);
- int tile_y;
- int histo[4][256];
- const int max_quantization = 1 << VP8LNearLosslessBits(near_lossless_quality);
- if (low_effort) {
- int i;
- for (i = 0; i < tiles_per_row * tiles_per_col; ++i) {
- image[i] = ARGB_BLACK | (kPredLowEffort << 8);
- }
- } else {
- memset(histo, 0, sizeof(histo));
- for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) {
- int tile_x;
- for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) {
- const int pred = GetBestPredictorForTile(width, height, tile_x, tile_y,
- bits, histo, argb_scratch, argb, max_quantization, exact,
- used_subtract_green);
- image[tile_y * tiles_per_row + tile_x] = ARGB_BLACK | (pred << 8);
- }
- }
- }
-
- CopyImageWithPrediction(width, height, bits, image, argb_scratch, argb,
- low_effort, max_quantization, exact,
- used_subtract_green);
-}
-
void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels) {
int i;
for (i = 0; i < num_pixels; ++i) {
- const uint32_t argb = argb_data[i];
- const uint32_t green = (argb >> 8) & 0xff;
+ const int argb = argb_data[i];
+ const int green = (argb >> 8) & 0xff;
const uint32_t new_r = (((argb >> 16) & 0xff) - green) & 0xff;
- const uint32_t new_b = ((argb & 0xff) - green) & 0xff;
- argb_data[i] = (argb & 0xff00ff00) | (new_r << 16) | new_b;
+ const uint32_t new_b = (((argb >> 0) & 0xff) - green) & 0xff;
+ argb_data[i] = (argb & 0xff00ff00u) | (new_r << 16) | new_b;
}
}
-static WEBP_INLINE void MultipliersClear(VP8LMultipliers* const m) {
- m->green_to_red_ = 0;
- m->green_to_blue_ = 0;
- m->red_to_blue_ = 0;
-}
-
-static WEBP_INLINE uint32_t ColorTransformDelta(int8_t color_pred,
- int8_t color) {
- return (uint32_t)((int)(color_pred) * color) >> 5;
-}
-
-static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
- VP8LMultipliers* const m) {
- m->green_to_red_ = (color_code >> 0) & 0xff;
- m->green_to_blue_ = (color_code >> 8) & 0xff;
- m->red_to_blue_ = (color_code >> 16) & 0xff;
-}
-
-static WEBP_INLINE uint32_t MultipliersToColorCode(
- const VP8LMultipliers* const m) {
- return 0xff000000u |
- ((uint32_t)(m->red_to_blue_) << 16) |
- ((uint32_t)(m->green_to_blue_) << 8) |
- m->green_to_red_;
+static WEBP_INLINE int ColorTransformDelta(int8_t color_pred, int8_t color) {
+ return ((int)color_pred * color) >> 5;
}
void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,
@@ -963,8 +520,8 @@ void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,
const uint32_t argb = data[i];
const uint32_t green = argb >> 8;
const uint32_t red = argb >> 16;
- uint32_t new_red = red;
- uint32_t new_blue = argb;
+ int new_red = red;
+ int new_blue = argb;
new_red -= ColorTransformDelta(m->green_to_red_, green);
new_red &= 0xff;
new_blue -= ColorTransformDelta(m->green_to_blue_, green);
@@ -977,7 +534,7 @@ void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,
static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,
uint32_t argb) {
const uint32_t green = argb >> 8;
- uint32_t new_red = argb >> 16;
+ int new_red = argb >> 16;
new_red -= ColorTransformDelta(green_to_red, green);
return (new_red & 0xff);
}
@@ -993,15 +550,6 @@ static WEBP_INLINE uint8_t TransformColorBlue(uint8_t green_to_blue,
return (new_blue & 0xff);
}
-static float PredictionCostCrossColor(const int accumulated[256],
- const int counts[256]) {
- // Favor low entropy, locally and globally.
- // Favor small absolute values for PredictionCostSpatial
- static const double kExpValue = 2.4;
- return VP8LCombinedShannonEntropy(counts, accumulated) +
- PredictionCostSpatial(counts, 3, kExpValue);
-}
-
void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride,
int tile_width, int tile_height,
int green_to_red, int histo[]) {
@@ -1014,59 +562,6 @@ void VP8LCollectColorRedTransforms_C(const uint32_t* argb, int stride,
}
}
-static float GetPredictionCostCrossColorRed(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int green_to_red,
- const int accumulated_red_histo[256]) {
- int histo[256] = { 0 };
- float cur_diff;
-
- VP8LCollectColorRedTransforms(argb, stride, tile_width, tile_height,
- green_to_red, histo);
-
- cur_diff = PredictionCostCrossColor(accumulated_red_histo, histo);
- if ((uint8_t)green_to_red == prev_x.green_to_red_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)green_to_red == prev_y.green_to_red_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if (green_to_red == 0) {
- cur_diff -= 3;
- }
- return cur_diff;
-}
-
-static void GetBestGreenToRed(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
- const int accumulated_red_histo[256], VP8LMultipliers* const best_tx) {
- const int kMaxIters = 4 + ((7 * quality) >> 8); // in range [4..6]
- int green_to_red_best = 0;
- int iter, offset;
- float best_diff = GetPredictionCostCrossColorRed(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_red_best, accumulated_red_histo);
- for (iter = 0; iter < kMaxIters; ++iter) {
- // ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to
- // one in color computation. Having initial delta here as 1 is sufficient
- // to explore the range of (-2, 2).
- const int delta = 32 >> iter;
- // Try a negative and a positive delta from the best known value.
- for (offset = -delta; offset <= delta; offset += 2 * delta) {
- const int green_to_red_cur = offset + green_to_red_best;
- const float cur_diff = GetPredictionCostCrossColorRed(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_red_cur, accumulated_red_histo);
- if (cur_diff < best_diff) {
- best_diff = cur_diff;
- green_to_red_best = green_to_red_cur;
- }
- }
- }
- best_tx->green_to_red_ = green_to_red_best;
-}
-
void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
int tile_width, int tile_height,
int green_to_blue, int red_to_blue,
@@ -1080,187 +575,6 @@ void VP8LCollectColorBlueTransforms_C(const uint32_t* argb, int stride,
}
}
-static float GetPredictionCostCrossColorBlue(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y,
- int green_to_blue, int red_to_blue, const int accumulated_blue_histo[256]) {
- int histo[256] = { 0 };
- float cur_diff;
-
- VP8LCollectColorBlueTransforms(argb, stride, tile_width, tile_height,
- green_to_blue, red_to_blue, histo);
-
- cur_diff = PredictionCostCrossColor(accumulated_blue_histo, histo);
- if ((uint8_t)green_to_blue == prev_x.green_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)green_to_blue == prev_y.green_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)red_to_blue == prev_x.red_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if ((uint8_t)red_to_blue == prev_y.red_to_blue_) {
- cur_diff -= 3; // favor keeping the areas locally similar
- }
- if (green_to_blue == 0) {
- cur_diff -= 3;
- }
- if (red_to_blue == 0) {
- cur_diff -= 3;
- }
- return cur_diff;
-}
-
-#define kGreenRedToBlueNumAxis 8
-#define kGreenRedToBlueMaxIters 7
-static void GetBestGreenRedToBlue(
- const uint32_t* argb, int stride, int tile_width, int tile_height,
- VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
- const int accumulated_blue_histo[256],
- VP8LMultipliers* const best_tx) {
- const int8_t offset[kGreenRedToBlueNumAxis][2] =
- {{0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
- const int8_t delta_lut[kGreenRedToBlueMaxIters] = { 16, 16, 8, 4, 2, 2, 2 };
- const int iters =
- (quality < 25) ? 1 : (quality > 50) ? kGreenRedToBlueMaxIters : 4;
- int green_to_blue_best = 0;
- int red_to_blue_best = 0;
- int iter;
- // Initial value at origin:
- float best_diff = GetPredictionCostCrossColorBlue(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_blue_best, red_to_blue_best, accumulated_blue_histo);
- for (iter = 0; iter < iters; ++iter) {
- const int delta = delta_lut[iter];
- int axis;
- for (axis = 0; axis < kGreenRedToBlueNumAxis; ++axis) {
- const int green_to_blue_cur =
- offset[axis][0] * delta + green_to_blue_best;
- const int red_to_blue_cur = offset[axis][1] * delta + red_to_blue_best;
- const float cur_diff = GetPredictionCostCrossColorBlue(
- argb, stride, tile_width, tile_height, prev_x, prev_y,
- green_to_blue_cur, red_to_blue_cur, accumulated_blue_histo);
- if (cur_diff < best_diff) {
- best_diff = cur_diff;
- green_to_blue_best = green_to_blue_cur;
- red_to_blue_best = red_to_blue_cur;
- }
- if (quality < 25 && iter == 4) {
- // Only axis aligned diffs for lower quality.
- break; // next iter.
- }
- }
- if (delta == 2 && green_to_blue_best == 0 && red_to_blue_best == 0) {
- // Further iterations would not help.
- break; // out of iter-loop.
- }
- }
- best_tx->green_to_blue_ = green_to_blue_best;
- best_tx->red_to_blue_ = red_to_blue_best;
-}
-#undef kGreenRedToBlueMaxIters
-#undef kGreenRedToBlueNumAxis
-
-static VP8LMultipliers GetBestColorTransformForTile(
- int tile_x, int tile_y, int bits,
- VP8LMultipliers prev_x,
- VP8LMultipliers prev_y,
- int quality, int xsize, int ysize,
- const int accumulated_red_histo[256],
- const int accumulated_blue_histo[256],
- const uint32_t* const argb) {
- const int max_tile_size = 1 << bits;
- const int tile_y_offset = tile_y * max_tile_size;
- const int tile_x_offset = tile_x * max_tile_size;
- const int all_x_max = GetMin(tile_x_offset + max_tile_size, xsize);
- const int all_y_max = GetMin(tile_y_offset + max_tile_size, ysize);
- const int tile_width = all_x_max - tile_x_offset;
- const int tile_height = all_y_max - tile_y_offset;
- const uint32_t* const tile_argb = argb + tile_y_offset * xsize
- + tile_x_offset;
- VP8LMultipliers best_tx;
- MultipliersClear(&best_tx);
-
- GetBestGreenToRed(tile_argb, xsize, tile_width, tile_height,
- prev_x, prev_y, quality, accumulated_red_histo, &best_tx);
- GetBestGreenRedToBlue(tile_argb, xsize, tile_width, tile_height,
- prev_x, prev_y, quality, accumulated_blue_histo,
- &best_tx);
- return best_tx;
-}
-
-static void CopyTileWithColorTransform(int xsize, int ysize,
- int tile_x, int tile_y,
- int max_tile_size,
- VP8LMultipliers color_transform,
- uint32_t* argb) {
- const int xscan = GetMin(max_tile_size, xsize - tile_x);
- int yscan = GetMin(max_tile_size, ysize - tile_y);
- argb += tile_y * xsize + tile_x;
- while (yscan-- > 0) {
- VP8LTransformColor(&color_transform, argb, xscan);
- argb += xsize;
- }
-}
-
-void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
- uint32_t* const argb, uint32_t* image) {
- const int max_tile_size = 1 << bits;
- const int tile_xsize = VP8LSubSampleSize(width, bits);
- const int tile_ysize = VP8LSubSampleSize(height, bits);
- int accumulated_red_histo[256] = { 0 };
- int accumulated_blue_histo[256] = { 0 };
- int tile_x, tile_y;
- VP8LMultipliers prev_x, prev_y;
- MultipliersClear(&prev_y);
- MultipliersClear(&prev_x);
- for (tile_y = 0; tile_y < tile_ysize; ++tile_y) {
- for (tile_x = 0; tile_x < tile_xsize; ++tile_x) {
- int y;
- const int tile_x_offset = tile_x * max_tile_size;
- const int tile_y_offset = tile_y * max_tile_size;
- const int all_x_max = GetMin(tile_x_offset + max_tile_size, width);
- const int all_y_max = GetMin(tile_y_offset + max_tile_size, height);
- const int offset = tile_y * tile_xsize + tile_x;
- if (tile_y != 0) {
- ColorCodeToMultipliers(image[offset - tile_xsize], &prev_y);
- }
- prev_x = GetBestColorTransformForTile(tile_x, tile_y, bits,
- prev_x, prev_y,
- quality, width, height,
- accumulated_red_histo,
- accumulated_blue_histo,
- argb);
- image[offset] = MultipliersToColorCode(&prev_x);
- CopyTileWithColorTransform(width, height, tile_x_offset, tile_y_offset,
- max_tile_size, prev_x, argb);
-
- // Gather accumulated histogram data.
- for (y = tile_y_offset; y < all_y_max; ++y) {
- int ix = y * width + tile_x_offset;
- const int ix_end = ix + all_x_max - tile_x_offset;
- for (; ix < ix_end; ++ix) {
- const uint32_t pix = argb[ix];
- if (ix >= 2 &&
- pix == argb[ix - 2] &&
- pix == argb[ix - 1]) {
- continue; // repeated pixels are handled by backward references
- }
- if (ix >= width + 2 &&
- argb[ix - 2] == argb[ix - width - 2] &&
- argb[ix - 1] == argb[ix - width - 1] &&
- pix == argb[ix - width]) {
- continue; // repeated pixels are handled by backward references
- }
- ++accumulated_red_histo[(pix >> 16) & 0xff];
- ++accumulated_blue_histo[(pix >> 0) & 0xff];
- }
- }
- }
- }
-}
-
//------------------------------------------------------------------------------
static int VectorMismatch(const uint32_t* const array1,
@@ -1274,8 +588,8 @@ static int VectorMismatch(const uint32_t* const array1,
}
// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
-void VP8LBundleColorMap(const uint8_t* const row, int width,
- int xbits, uint32_t* const dst) {
+void VP8LBundleColorMap_C(const uint8_t* const row, int width, int xbits,
+ uint32_t* dst) {
int x;
if (xbits > 0) {
const int bit_depth = 1 << (3 - xbits);
@@ -1350,8 +664,172 @@ static void HistogramAdd(const VP8LHistogram* const a,
}
//------------------------------------------------------------------------------
+// Image transforms.
-VP8LProcessBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
+static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
+ return (((a0 ^ a1) & 0xfefefefeu) >> 1) + (a0 & a1);
+}
+
+static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
+ return Average2(Average2(a0, a2), a1);
+}
+
+static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
+ uint32_t a2, uint32_t a3) {
+ return Average2(Average2(a0, a1), Average2(a2, a3));
+}
+
+static WEBP_INLINE uint32_t Clip255(uint32_t a) {
+ if (a < 256) {
+ return a;
+ }
+ // return 0, when a is a negative integer.
+ // return 255, when a is positive.
+ return ~a >> 24;
+}
+
+static WEBP_INLINE int AddSubtractComponentFull(int a, int b, int c) {
+ return Clip255(a + b - c);
+}
+
+static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,
+ uint32_t c2) {
+ const int a = AddSubtractComponentFull(c0 >> 24, c1 >> 24, c2 >> 24);
+ const int r = AddSubtractComponentFull((c0 >> 16) & 0xff,
+ (c1 >> 16) & 0xff,
+ (c2 >> 16) & 0xff);
+ const int g = AddSubtractComponentFull((c0 >> 8) & 0xff,
+ (c1 >> 8) & 0xff,
+ (c2 >> 8) & 0xff);
+ const int b = AddSubtractComponentFull(c0 & 0xff, c1 & 0xff, c2 & 0xff);
+ return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
+}
+
+static WEBP_INLINE int AddSubtractComponentHalf(int a, int b) {
+ return Clip255(a + (a - b) / 2);
+}
+
+static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,
+ uint32_t c2) {
+ const uint32_t ave = Average2(c0, c1);
+ const int a = AddSubtractComponentHalf(ave >> 24, c2 >> 24);
+ const int r = AddSubtractComponentHalf((ave >> 16) & 0xff, (c2 >> 16) & 0xff);
+ const int g = AddSubtractComponentHalf((ave >> 8) & 0xff, (c2 >> 8) & 0xff);
+ const int b = AddSubtractComponentHalf((ave >> 0) & 0xff, (c2 >> 0) & 0xff);
+ return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
+}
+
+// gcc-4.9 on ARM generates incorrect code in Select() when Sub3() is inlined.
+#if defined(__arm__) && \
+ (LOCAL_GCC_VERSION == 0x409 || LOCAL_GCC_VERSION == 0x408)
+# define LOCAL_INLINE __attribute__ ((noinline))
+#else
+# define LOCAL_INLINE WEBP_INLINE
+#endif
+
+static LOCAL_INLINE int Sub3(int a, int b, int c) {
+ const int pb = b - c;
+ const int pa = a - c;
+ return abs(pb) - abs(pa);
+}
+
+#undef LOCAL_INLINE
+
+static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
+ const int pa_minus_pb =
+ Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +
+ Sub3((a >> 16) & 0xff, (b >> 16) & 0xff, (c >> 16) & 0xff) +
+ Sub3((a >> 8) & 0xff, (b >> 8) & 0xff, (c >> 8) & 0xff) +
+ Sub3((a ) & 0xff, (b ) & 0xff, (c ) & 0xff);
+ return (pa_minus_pb <= 0) ? a : b;
+}
+
+//------------------------------------------------------------------------------
+// Predictors
+
+static uint32_t Predictor2(uint32_t left, const uint32_t* const top) {
+ (void)left;
+ return top[0];
+}
+static uint32_t Predictor3(uint32_t left, const uint32_t* const top) {
+ (void)left;
+ return top[1];
+}
+static uint32_t Predictor4(uint32_t left, const uint32_t* const top) {
+ (void)left;
+ return top[-1];
+}
+static uint32_t Predictor5(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average3(left, top[0], top[1]);
+ return pred;
+}
+static uint32_t Predictor6(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average2(left, top[-1]);
+ return pred;
+}
+static uint32_t Predictor7(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average2(left, top[0]);
+ return pred;
+}
+static uint32_t Predictor8(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average2(top[-1], top[0]);
+ (void)left;
+ return pred;
+}
+static uint32_t Predictor9(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average2(top[0], top[1]);
+ (void)left;
+ return pred;
+}
+static uint32_t Predictor10(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Average4(left, top[-1], top[0], top[1]);
+ return pred;
+}
+static uint32_t Predictor11(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = Select(top[0], left, top[-1]);
+ return pred;
+}
+static uint32_t Predictor12(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = ClampedAddSubtractFull(left, top[0], top[-1]);
+ return pred;
+}
+static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
+ const uint32_t pred = ClampedAddSubtractHalf(left, top[0], top[-1]);
+ return pred;
+}
+
+//------------------------------------------------------------------------------
+
+static void PredictorSub0_C(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], ARGB_BLACK);
+ (void)upper;
+}
+
+static void PredictorSub1_C(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ for (i = 0; i < num_pixels; ++i) out[i] = VP8LSubPixels(in[i], in[i - 1]);
+ (void)upper;
+}
+
+GENERATE_PREDICTOR_SUB(Predictor2, PredictorSub2_C)
+GENERATE_PREDICTOR_SUB(Predictor3, PredictorSub3_C)
+GENERATE_PREDICTOR_SUB(Predictor4, PredictorSub4_C)
+GENERATE_PREDICTOR_SUB(Predictor5, PredictorSub5_C)
+GENERATE_PREDICTOR_SUB(Predictor6, PredictorSub6_C)
+GENERATE_PREDICTOR_SUB(Predictor7, PredictorSub7_C)
+GENERATE_PREDICTOR_SUB(Predictor8, PredictorSub8_C)
+GENERATE_PREDICTOR_SUB(Predictor9, PredictorSub9_C)
+GENERATE_PREDICTOR_SUB(Predictor10, PredictorSub10_C)
+GENERATE_PREDICTOR_SUB(Predictor11, PredictorSub11_C)
+GENERATE_PREDICTOR_SUB(Predictor12, PredictorSub12_C)
+GENERATE_PREDICTOR_SUB(Predictor13, PredictorSub13_C)
+
+//------------------------------------------------------------------------------
+
+VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
VP8LTransformColorFunc VP8LTransformColor;
@@ -1365,17 +843,23 @@ VP8LCostFunc VP8LExtraCost;
VP8LCostCombinedFunc VP8LExtraCostCombined;
VP8LCombinedShannonEntropyFunc VP8LCombinedShannonEntropy;
-GetEntropyUnrefinedHelperFunc VP8LGetEntropyUnrefinedHelper;
+VP8LGetEntropyUnrefinedFunc VP8LGetEntropyUnrefined;
+VP8LGetCombinedEntropyUnrefinedFunc VP8LGetCombinedEntropyUnrefined;
VP8LHistogramAddFunc VP8LHistogramAdd;
VP8LVectorMismatchFunc VP8LVectorMismatch;
+VP8LBundleColorMapFunc VP8LBundleColorMap;
+
+VP8LPredictorAddSubFunc VP8LPredictorsSub[16];
+VP8LPredictorAddSubFunc VP8LPredictorsSub_C[16];
extern void VP8LEncDspInitSSE2(void);
extern void VP8LEncDspInitSSE41(void);
extern void VP8LEncDspInitNEON(void);
extern void VP8LEncDspInitMIPS32(void);
extern void VP8LEncDspInitMIPSdspR2(void);
+extern void VP8LEncDspInitMSA(void);
static volatile VP8CPUInfo lossless_enc_last_cpuinfo_used =
(VP8CPUInfo)&lossless_enc_last_cpuinfo_used;
@@ -1399,11 +883,47 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) {
VP8LExtraCostCombined = ExtraCostCombined;
VP8LCombinedShannonEntropy = CombinedShannonEntropy;
- VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper;
+ VP8LGetEntropyUnrefined = GetEntropyUnrefined;
+ VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
VP8LHistogramAdd = HistogramAdd;
VP8LVectorMismatch = VectorMismatch;
+ VP8LBundleColorMap = VP8LBundleColorMap_C;
+
+ VP8LPredictorsSub[0] = PredictorSub0_C;
+ VP8LPredictorsSub[1] = PredictorSub1_C;
+ VP8LPredictorsSub[2] = PredictorSub2_C;
+ VP8LPredictorsSub[3] = PredictorSub3_C;
+ VP8LPredictorsSub[4] = PredictorSub4_C;
+ VP8LPredictorsSub[5] = PredictorSub5_C;
+ VP8LPredictorsSub[6] = PredictorSub6_C;
+ VP8LPredictorsSub[7] = PredictorSub7_C;
+ VP8LPredictorsSub[8] = PredictorSub8_C;
+ VP8LPredictorsSub[9] = PredictorSub9_C;
+ VP8LPredictorsSub[10] = PredictorSub10_C;
+ VP8LPredictorsSub[11] = PredictorSub11_C;
+ VP8LPredictorsSub[12] = PredictorSub12_C;
+ VP8LPredictorsSub[13] = PredictorSub13_C;
+ VP8LPredictorsSub[14] = PredictorSub0_C; // <- padding security sentinels
+ VP8LPredictorsSub[15] = PredictorSub0_C;
+
+ VP8LPredictorsSub_C[0] = PredictorSub0_C;
+ VP8LPredictorsSub_C[1] = PredictorSub1_C;
+ VP8LPredictorsSub_C[2] = PredictorSub2_C;
+ VP8LPredictorsSub_C[3] = PredictorSub3_C;
+ VP8LPredictorsSub_C[4] = PredictorSub4_C;
+ VP8LPredictorsSub_C[5] = PredictorSub5_C;
+ VP8LPredictorsSub_C[6] = PredictorSub6_C;
+ VP8LPredictorsSub_C[7] = PredictorSub7_C;
+ VP8LPredictorsSub_C[8] = PredictorSub8_C;
+ VP8LPredictorsSub_C[9] = PredictorSub9_C;
+ VP8LPredictorsSub_C[10] = PredictorSub10_C;
+ VP8LPredictorsSub_C[11] = PredictorSub11_C;
+ VP8LPredictorsSub_C[12] = PredictorSub12_C;
+ VP8LPredictorsSub_C[13] = PredictorSub13_C;
+ VP8LPredictorsSub_C[14] = PredictorSub0_C; // <- padding security sentinels
+ VP8LPredictorsSub_C[15] = PredictorSub0_C;
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo != NULL) {
@@ -1432,6 +952,11 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInit(void) {
VP8LEncDspInitMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ VP8LEncDspInitMSA();
+ }
+#endif
}
lossless_enc_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/thirdparty/libwebp/dsp/lossless_enc_mips32.c b/thirdparty/libwebp/dsp/lossless_enc_mips32.c
index 49c666d4fd..4186b9f50d 100644
--- a/thirdparty/libwebp/dsp/lossless_enc_mips32.c
+++ b/thirdparty/libwebp/dsp/lossless_enc_mips32.c
@@ -14,6 +14,7 @@
#include "./dsp.h"
#include "./lossless.h"
+#include "./lossless_common.h"
#if defined(WEBP_USE_MIPS32)
@@ -240,6 +241,49 @@ static WEBP_INLINE void GetEntropyUnrefinedHelper(
*i_prev = i;
}
+static void GetEntropyUnrefined(const uint32_t X[], int length,
+ VP8LBitEntropy* const bit_entropy,
+ VP8LStreaks* const stats) {
+ int i;
+ int i_prev = 0;
+ uint32_t x_prev = X[0];
+
+ memset(stats, 0, sizeof(*stats));
+ VP8LBitEntropyInit(bit_entropy);
+
+ for (i = 1; i < length; ++i) {
+ const uint32_t x = X[i];
+ if (x != x_prev) {
+ GetEntropyUnrefinedHelper(x, i, &x_prev, &i_prev, bit_entropy, stats);
+ }
+ }
+ GetEntropyUnrefinedHelper(0, i, &x_prev, &i_prev, bit_entropy, stats);
+
+ bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
+}
+
+static void GetCombinedEntropyUnrefined(const uint32_t X[], const uint32_t Y[],
+ int length,
+ VP8LBitEntropy* const bit_entropy,
+ VP8LStreaks* const stats) {
+ int i = 1;
+ int i_prev = 0;
+ uint32_t xy_prev = X[0] + Y[0];
+
+ memset(stats, 0, sizeof(*stats));
+ VP8LBitEntropyInit(bit_entropy);
+
+ for (i = 1; i < length; ++i) {
+ const uint32_t xy = X[i] + Y[i];
+ if (xy != xy_prev) {
+ GetEntropyUnrefinedHelper(xy, i, &xy_prev, &i_prev, bit_entropy, stats);
+ }
+ }
+ GetEntropyUnrefinedHelper(0, i, &xy_prev, &i_prev, bit_entropy, stats);
+
+ bit_entropy->entropy += VP8LFastSLog2(bit_entropy->sum);
+}
+
#define ASM_START \
__asm__ volatile( \
".set push \n\t" \
@@ -375,7 +419,8 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMIPS32(void) {
VP8LFastLog2Slow = FastLog2Slow;
VP8LExtraCost = ExtraCost;
VP8LExtraCostCombined = ExtraCostCombined;
- VP8LGetEntropyUnrefinedHelper = GetEntropyUnrefinedHelper;
+ VP8LGetEntropyUnrefined = GetEntropyUnrefined;
+ VP8LGetCombinedEntropyUnrefined = GetCombinedEntropyUnrefined;
VP8LHistogramAdd = HistogramAdd;
}
diff --git a/thirdparty/libwebp/dsp/lossless_enc_msa.c b/thirdparty/libwebp/dsp/lossless_enc_msa.c
new file mode 100644
index 0000000000..2f69ba3bca
--- /dev/null
+++ b/thirdparty/libwebp/dsp/lossless_enc_msa.c
@@ -0,0 +1,147 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA variant of Image transform methods for lossless encoder.
+//
+// Authors: Prashant Patil (Prashant.Patil@imgtec.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include "./lossless.h"
+#include "./msa_macro.h"
+
+#define TRANSFORM_COLOR_8(src0, src1, dst0, dst1, c0, c1, mask0, mask1) do { \
+ v8i16 g0, g1, t0, t1, t2, t3; \
+ v4i32 t4, t5; \
+ VSHF_B2_SH(src0, src0, src1, src1, mask0, mask0, g0, g1); \
+ DOTP_SB2_SH(g0, g1, c0, c0, t0, t1); \
+ SRAI_H2_SH(t0, t1, 5); \
+ t0 = __msa_subv_h((v8i16)src0, t0); \
+ t1 = __msa_subv_h((v8i16)src1, t1); \
+ t4 = __msa_srli_w((v4i32)src0, 16); \
+ t5 = __msa_srli_w((v4i32)src1, 16); \
+ DOTP_SB2_SH(t4, t5, c1, c1, t2, t3); \
+ SRAI_H2_SH(t2, t3, 5); \
+ SUB2(t0, t2, t1, t3, t0, t1); \
+ VSHF_B2_UB(src0, t0, src1, t1, mask1, mask1, dst0, dst1); \
+} while (0)
+
+#define TRANSFORM_COLOR_4(src, dst, c0, c1, mask0, mask1) do { \
+ const v16i8 g0 = VSHF_SB(src, src, mask0); \
+ v8i16 t0 = __msa_dotp_s_h(c0, g0); \
+ v8i16 t1; \
+ v4i32 t2; \
+ t0 = SRAI_H(t0, 5); \
+ t0 = __msa_subv_h((v8i16)src, t0); \
+ t2 = __msa_srli_w((v4i32)src, 16); \
+ t1 = __msa_dotp_s_h(c1, (v16i8)t2); \
+ t1 = SRAI_H(t1, 5); \
+ t0 = t0 - t1; \
+ dst = VSHF_UB(src, t0, mask1); \
+} while (0)
+
+static void TransformColor(const VP8LMultipliers* const m, uint32_t* data,
+ int num_pixels) {
+ v16u8 src0, dst0;
+ const v16i8 g2br = (v16i8)__msa_fill_w(m->green_to_blue_ |
+ (m->green_to_red_ << 16));
+ const v16i8 r2b = (v16i8)__msa_fill_w(m->red_to_blue_);
+ const v16u8 mask0 = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
+ 13, 255, 13, 255 };
+ const v16u8 mask1 = { 16, 1, 18, 3, 20, 5, 22, 7, 24, 9, 26, 11,
+ 28, 13, 30, 15 };
+
+ while (num_pixels >= 8) {
+ v16u8 src1, dst1;
+ LD_UB2(data, 4, src0, src1);
+ TRANSFORM_COLOR_8(src0, src1, dst0, dst1, g2br, r2b, mask0, mask1);
+ ST_UB2(dst0, dst1, data, 4);
+ data += 8;
+ num_pixels -= 8;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 4) {
+ src0 = LD_UB(data);
+ TRANSFORM_COLOR_4(src0, dst0, g2br, r2b, mask0, mask1);
+ ST_UB(dst0, data);
+ data += 4;
+ num_pixels -= 4;
+ }
+ if (num_pixels > 0) {
+ src0 = LD_UB(data);
+ TRANSFORM_COLOR_4(src0, dst0, g2br, r2b, mask0, mask1);
+ if (num_pixels == 3) {
+ const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
+ const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2);
+ SD(pix_d, data + 0);
+ SW(pix_w, data + 2);
+ } else if (num_pixels == 2) {
+ const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
+ SD(pix_d, data);
+ } else {
+ const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 0);
+ SW(pix_w, data);
+ }
+ }
+ }
+}
+
+static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
+ int i;
+ uint8_t* ptemp_data = (uint8_t*)argb_data;
+ v16u8 src0, dst0, tmp0;
+ const v16u8 mask = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
+ 13, 255, 13, 255 };
+
+ while (num_pixels >= 8) {
+ v16u8 src1, dst1, tmp1;
+ LD_UB2(ptemp_data, 16, src0, src1);
+ VSHF_B2_UB(src0, src1, src1, src0, mask, mask, tmp0, tmp1);
+ SUB2(src0, tmp0, src1, tmp1, dst0, dst1);
+ ST_UB2(dst0, dst1, ptemp_data, 16);
+ ptemp_data += 8 * 4;
+ num_pixels -= 8;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 4) {
+ src0 = LD_UB(ptemp_data);
+ tmp0 = VSHF_UB(src0, src0, mask);
+ dst0 = src0 - tmp0;
+ ST_UB(dst0, ptemp_data);
+ ptemp_data += 4 * 4;
+ num_pixels -= 4;
+ }
+ for (i = 0; i < num_pixels; i++) {
+ const uint8_t b = ptemp_data[0];
+ const uint8_t g = ptemp_data[1];
+ const uint8_t r = ptemp_data[2];
+ ptemp_data[0] = (b - g) & 0xff;
+ ptemp_data[2] = (r - g) & 0xff;
+ ptemp_data += 4;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void VP8LEncDspInitMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitMSA(void) {
+ VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed;
+ VP8LTransformColor = TransformColor;
+}
+
+#else // !WEBP_USE_MSA
+
+WEBP_DSP_INIT_STUB(VP8LEncDspInitMSA)
+
+#endif // WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/lossless_enc_sse2.c b/thirdparty/libwebp/dsp/lossless_enc_sse2.c
index 7c894e7ca4..8ad85d94d7 100644
--- a/thirdparty/libwebp/dsp/lossless_enc_sse2.c
+++ b/thirdparty/libwebp/dsp/lossless_enc_sse2.c
@@ -17,6 +17,8 @@
#include <assert.h>
#include <emmintrin.h>
#include "./lossless.h"
+#include "./common_sse2.h"
+#include "./lossless_common.h"
// For sign-extended multiplying constants, pre-shifted by 5:
#define CST_5b(X) (((int16_t)((uint16_t)X << 8)) >> 5)
@@ -35,7 +37,9 @@ static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
_mm_storeu_si128((__m128i*)&argb_data[i], out);
}
// fallthrough and finish off with plain-C
- VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
+ if (i != num_pixels) {
+ VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
+ }
}
//------------------------------------------------------------------------------
@@ -69,7 +73,9 @@ static void TransformColor(const VP8LMultipliers* const m,
_mm_storeu_si128((__m128i*)&argb_data[i], out);
}
// fallthrough and finish off with plain-C
- VP8LTransformColor_C(m, argb_data + i, num_pixels - i);
+ if (i != num_pixels) {
+ VP8LTransformColor_C(m, argb_data + i, num_pixels - i);
+ }
}
//------------------------------------------------------------------------------
@@ -364,8 +370,9 @@ static int VectorMismatch(const uint32_t* const array1,
if (length >= 8 &&
_mm_movemask_epi8(_mm_cmpeq_epi32(
_mm_loadu_si128((const __m128i*)&array1[4]),
- _mm_loadu_si128((const __m128i*)&array2[4]))) == 0xffff)
+ _mm_loadu_si128((const __m128i*)&array2[4]))) == 0xffff) {
match_len = 8;
+ }
}
}
@@ -375,6 +382,295 @@ static int VectorMismatch(const uint32_t* const array1,
return match_len;
}
+// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
+static void BundleColorMap_SSE2(const uint8_t* const row, int width, int xbits,
+ uint32_t* dst) {
+ int x;
+ assert(xbits >= 0);
+ assert(xbits <= 3);
+ switch (xbits) {
+ case 0: {
+ const __m128i ff = _mm_set1_epi16(0xff00);
+ const __m128i zero = _mm_setzero_si128();
+ // Store 0xff000000 | (row[x] << 8).
+ for (x = 0; x + 16 <= width; x += 16, dst += 16) {
+ const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
+ const __m128i in_lo = _mm_unpacklo_epi8(zero, in);
+ const __m128i dst0 = _mm_unpacklo_epi16(in_lo, ff);
+ const __m128i dst1 = _mm_unpackhi_epi16(in_lo, ff);
+ const __m128i in_hi = _mm_unpackhi_epi8(zero, in);
+ const __m128i dst2 = _mm_unpacklo_epi16(in_hi, ff);
+ const __m128i dst3 = _mm_unpackhi_epi16(in_hi, ff);
+ _mm_storeu_si128((__m128i*)&dst[0], dst0);
+ _mm_storeu_si128((__m128i*)&dst[4], dst1);
+ _mm_storeu_si128((__m128i*)&dst[8], dst2);
+ _mm_storeu_si128((__m128i*)&dst[12], dst3);
+ }
+ break;
+ }
+ case 1: {
+ const __m128i ff = _mm_set1_epi16(0xff00);
+ const __m128i mul = _mm_set1_epi16(0x110);
+ for (x = 0; x + 16 <= width; x += 16, dst += 8) {
+ // 0a0b | (where a/b are 4 bits).
+ const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
+ const __m128i tmp = _mm_mullo_epi16(in, mul); // aba0
+ const __m128i pack = _mm_and_si128(tmp, ff); // ab00
+ const __m128i dst0 = _mm_unpacklo_epi16(pack, ff);
+ const __m128i dst1 = _mm_unpackhi_epi16(pack, ff);
+ _mm_storeu_si128((__m128i*)&dst[0], dst0);
+ _mm_storeu_si128((__m128i*)&dst[4], dst1);
+ }
+ break;
+ }
+ case 2: {
+ const __m128i mask_or = _mm_set1_epi32(0xff000000);
+ const __m128i mul_cst = _mm_set1_epi16(0x0104);
+ const __m128i mask_mul = _mm_set1_epi16(0x0f00);
+ for (x = 0; x + 16 <= width; x += 16, dst += 4) {
+ // 000a000b000c000d | (where a/b/c/d are 2 bits).
+ const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
+ const __m128i mul = _mm_mullo_epi16(in, mul_cst); // 00ab00b000cd00d0
+ const __m128i tmp = _mm_and_si128(mul, mask_mul); // 00ab000000cd0000
+ const __m128i shift = _mm_srli_epi32(tmp, 12); // 00000000ab000000
+ const __m128i pack = _mm_or_si128(shift, tmp); // 00000000abcd0000
+ // Convert to 0xff00**00.
+ const __m128i res = _mm_or_si128(pack, mask_or);
+ _mm_storeu_si128((__m128i*)dst, res);
+ }
+ break;
+ }
+ default: {
+ assert(xbits == 3);
+ for (x = 0; x + 16 <= width; x += 16, dst += 2) {
+ // 0000000a00000000b... | (where a/b are 1 bit).
+ const __m128i in = _mm_loadu_si128((const __m128i*)&row[x]);
+ const __m128i shift = _mm_slli_epi64(in, 7);
+ const uint32_t move = _mm_movemask_epi8(shift);
+ dst[0] = 0xff000000 | ((move & 0xff) << 8);
+ dst[1] = 0xff000000 | (move & 0xff00);
+ }
+ break;
+ }
+ }
+ if (x != width) {
+ VP8LBundleColorMap_C(row + x, width - x, xbits, dst);
+ }
+}
+
+//------------------------------------------------------------------------------
+// Batch version of Predictor Transform subtraction
+
+static WEBP_INLINE void Average2_m128i(const __m128i* const a0,
+ const __m128i* const a1,
+ __m128i* const avg) {
+ // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
+ const __m128i ones = _mm_set1_epi8(1);
+ const __m128i avg1 = _mm_avg_epu8(*a0, *a1);
+ const __m128i one = _mm_and_si128(_mm_xor_si128(*a0, *a1), ones);
+ *avg = _mm_sub_epi8(avg1, one);
+}
+
+// Predictor0: ARGB_BLACK.
+static void PredictorSub0_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const __m128i black = _mm_set1_epi32(ARGB_BLACK);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ const __m128i res = _mm_sub_epi8(src, black);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[0](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+#define GENERATE_PREDICTOR_1(X, IN) \
+static void PredictorSub##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
+ const __m128i pred = _mm_loadu_si128((const __m128i*)&(IN)); \
+ const __m128i res = _mm_sub_epi8(src, pred); \
+ _mm_storeu_si128((__m128i*)&out[i], res); \
+ } \
+ if (i != num_pixels) { \
+ VP8LPredictorsSub_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+ } \
+}
+
+GENERATE_PREDICTOR_1(1, in[i - 1]) // Predictor1: L
+GENERATE_PREDICTOR_1(2, upper[i]) // Predictor2: T
+GENERATE_PREDICTOR_1(3, upper[i + 1]) // Predictor3: TR
+GENERATE_PREDICTOR_1(4, upper[i - 1]) // Predictor4: TL
+#undef GENERATE_PREDICTOR_1
+
+// Predictor5: avg2(avg2(L, TR), T)
+static void PredictorSub5_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ __m128i avg, pred, res;
+ Average2_m128i(&L, &TR, &avg);
+ Average2_m128i(&avg, &T, &pred);
+ res = _mm_sub_epi8(src, pred);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[5](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+#define GENERATE_PREDICTOR_2(X, A, B) \
+static void PredictorSub##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const __m128i tA = _mm_loadu_si128((const __m128i*)&(A)); \
+ const __m128i tB = _mm_loadu_si128((const __m128i*)&(B)); \
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
+ __m128i pred, res; \
+ Average2_m128i(&tA, &tB, &pred); \
+ res = _mm_sub_epi8(src, pred); \
+ _mm_storeu_si128((__m128i*)&out[i], res); \
+ } \
+ if (i != num_pixels) { \
+ VP8LPredictorsSub_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+ } \
+}
+
+GENERATE_PREDICTOR_2(6, in[i - 1], upper[i - 1]) // Predictor6: avg(L, TL)
+GENERATE_PREDICTOR_2(7, in[i - 1], upper[i]) // Predictor7: avg(L, T)
+GENERATE_PREDICTOR_2(8, upper[i - 1], upper[i]) // Predictor8: avg(TL, T)
+GENERATE_PREDICTOR_2(9, upper[i], upper[i + 1]) // Predictor9: average(T, TR)
+#undef GENERATE_PREDICTOR_2
+
+// Predictor10: avg(avg(L,TL), avg(T, TR)).
+static void PredictorSub10_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
+ __m128i avgTTR, avgLTL, avg, res;
+ Average2_m128i(&T, &TR, &avgTTR);
+ Average2_m128i(&L, &TL, &avgLTL);
+ Average2_m128i(&avgTTR, &avgLTL, &avg);
+ res = _mm_sub_epi8(src, avg);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[10](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictor11: select.
+static void GetSumAbsDiff32(const __m128i* const A, const __m128i* const B,
+ __m128i* const out) {
+ // We can unpack with any value on the upper 32 bits, provided it's the same
+ // on both operands (to that their sum of abs diff is zero). Here we use *A.
+ const __m128i A_lo = _mm_unpacklo_epi32(*A, *A);
+ const __m128i B_lo = _mm_unpacklo_epi32(*B, *A);
+ const __m128i A_hi = _mm_unpackhi_epi32(*A, *A);
+ const __m128i B_hi = _mm_unpackhi_epi32(*B, *A);
+ const __m128i s_lo = _mm_sad_epu8(A_lo, B_lo);
+ const __m128i s_hi = _mm_sad_epu8(A_hi, B_hi);
+ *out = _mm_packs_epi32(s_lo, s_hi);
+}
+
+static void PredictorSub11_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ __m128i pa, pb;
+ GetSumAbsDiff32(&T, &TL, &pa); // pa = sum |T-TL|
+ GetSumAbsDiff32(&L, &TL, &pb); // pb = sum |L-TL|
+ {
+ const __m128i mask = _mm_cmpgt_epi32(pb, pa);
+ const __m128i A = _mm_and_si128(mask, L);
+ const __m128i B = _mm_andnot_si128(mask, T);
+ const __m128i pred = _mm_or_si128(A, B); // pred = (L > T)? L : T
+ const __m128i res = _mm_sub_epi8(src, pred);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[11](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictor12: ClampedSubSubtractFull.
+static void PredictorSub12_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const __m128i zero = _mm_setzero_si128();
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ const __m128i L = _mm_loadu_si128((const __m128i*)&in[i - 1]);
+ const __m128i L_lo = _mm_unpacklo_epi8(L, zero);
+ const __m128i L_hi = _mm_unpackhi_epi8(L, zero);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
+ const __m128i T_hi = _mm_unpackhi_epi8(T, zero);
+ const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
+ const __m128i TL_hi = _mm_unpackhi_epi8(TL, zero);
+ const __m128i diff_lo = _mm_sub_epi16(T_lo, TL_lo);
+ const __m128i diff_hi = _mm_sub_epi16(T_hi, TL_hi);
+ const __m128i pred_lo = _mm_add_epi16(L_lo, diff_lo);
+ const __m128i pred_hi = _mm_add_epi16(L_hi, diff_hi);
+ const __m128i pred = _mm_packus_epi16(pred_lo, pred_hi);
+ const __m128i res = _mm_sub_epi8(src, pred);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[12](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictors13: ClampedAddSubtractHalf
+static void PredictorSub13_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const __m128i zero = _mm_setzero_si128();
+ for (i = 0; i + 2 <= num_pixels; i += 2) {
+ // we can only process two pixels at a time
+ const __m128i L = _mm_loadl_epi64((const __m128i*)&in[i - 1]);
+ const __m128i src = _mm_loadl_epi64((const __m128i*)&in[i]);
+ const __m128i T = _mm_loadl_epi64((const __m128i*)&upper[i]);
+ const __m128i TL = _mm_loadl_epi64((const __m128i*)&upper[i - 1]);
+ const __m128i L_lo = _mm_unpacklo_epi8(L, zero);
+ const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
+ const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
+ const __m128i sum = _mm_add_epi16(T_lo, L_lo);
+ const __m128i avg = _mm_srli_epi16(sum, 1);
+ const __m128i A1 = _mm_sub_epi16(avg, TL_lo);
+ const __m128i bit_fix = _mm_cmpgt_epi16(TL_lo, avg);
+ const __m128i A2 = _mm_sub_epi16(A1, bit_fix);
+ const __m128i A3 = _mm_srai_epi16(A2, 1);
+ const __m128i A4 = _mm_add_epi16(avg, A3);
+ const __m128i pred = _mm_packus_epi16(A4, A4);
+ const __m128i res = _mm_sub_epi8(src, pred);
+ _mm_storel_epi64((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsSub_C[13](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
//------------------------------------------------------------------------------
// Entry point
@@ -388,6 +684,24 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LEncDspInitSSE2(void) {
VP8LHistogramAdd = HistogramAdd;
VP8LCombinedShannonEntropy = CombinedShannonEntropy;
VP8LVectorMismatch = VectorMismatch;
+ VP8LBundleColorMap = BundleColorMap_SSE2;
+
+ VP8LPredictorsSub[0] = PredictorSub0_SSE2;
+ VP8LPredictorsSub[1] = PredictorSub1_SSE2;
+ VP8LPredictorsSub[2] = PredictorSub2_SSE2;
+ VP8LPredictorsSub[3] = PredictorSub3_SSE2;
+ VP8LPredictorsSub[4] = PredictorSub4_SSE2;
+ VP8LPredictorsSub[5] = PredictorSub5_SSE2;
+ VP8LPredictorsSub[6] = PredictorSub6_SSE2;
+ VP8LPredictorsSub[7] = PredictorSub7_SSE2;
+ VP8LPredictorsSub[8] = PredictorSub8_SSE2;
+ VP8LPredictorsSub[9] = PredictorSub9_SSE2;
+ VP8LPredictorsSub[10] = PredictorSub10_SSE2;
+ VP8LPredictorsSub[11] = PredictorSub11_SSE2;
+ VP8LPredictorsSub[12] = PredictorSub12_SSE2;
+ VP8LPredictorsSub[13] = PredictorSub13_SSE2;
+ VP8LPredictorsSub[14] = PredictorSub0_SSE2; // <- padding security sentinels
+ VP8LPredictorsSub[15] = PredictorSub0_SSE2;
}
#else // !WEBP_USE_SSE2
diff --git a/thirdparty/libwebp/dsp/lossless_enc_sse41.c b/thirdparty/libwebp/dsp/lossless_enc_sse41.c
index 3e493198db..821057ccd4 100644
--- a/thirdparty/libwebp/dsp/lossless_enc_sse41.c
+++ b/thirdparty/libwebp/dsp/lossless_enc_sse41.c
@@ -32,7 +32,9 @@ static void SubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixels) {
_mm_storeu_si128((__m128i*)&argb_data[i], out);
}
// fallthrough and finish off with plain-C
- VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
+ if (i != num_pixels) {
+ VP8LSubtractGreenFromBlueAndRed_C(argb_data + i, num_pixels - i);
+ }
}
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dsp/lossless_mips_dsp_r2.c b/thirdparty/libwebp/dsp/lossless_mips_dsp_r2.c
index 90aed7f151..2984ce8df7 100644
--- a/thirdparty/libwebp/dsp/lossless_mips_dsp_r2.c
+++ b/thirdparty/libwebp/dsp/lossless_mips_dsp_r2.c
@@ -17,6 +17,7 @@
#if defined(WEBP_USE_MIPS_DSP_R2)
#include "./lossless.h"
+#include "./lossless_common.h"
#define MAP_COLOR_FUNCS(FUNC_NAME, TYPE, GET_INDEX, GET_VALUE) \
static void FUNC_NAME(const TYPE* src, \
@@ -227,25 +228,27 @@ static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
// Add green to blue and red channels (i.e. perform the inverse transform of
// 'subtract green').
-static void AddGreenToBlueAndRed(uint32_t* data, int num_pixels) {
+static void AddGreenToBlueAndRed(const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
- uint32_t* const p_loop1_end = data + (num_pixels & ~3);
- uint32_t* const p_loop2_end = data + num_pixels;
+ const uint32_t* const p_loop1_end = src + (num_pixels & ~3);
+ const uint32_t* const p_loop2_end = src + num_pixels;
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
- "beq %[data], %[p_loop1_end], 3f \n\t"
+ "beq %[src], %[p_loop1_end], 3f \n\t"
" nop \n\t"
"0: \n\t"
- "lw %[temp0], 0(%[data]) \n\t"
- "lw %[temp1], 4(%[data]) \n\t"
- "lw %[temp2], 8(%[data]) \n\t"
- "lw %[temp3], 12(%[data]) \n\t"
+ "lw %[temp0], 0(%[src]) \n\t"
+ "lw %[temp1], 4(%[src]) \n\t"
+ "lw %[temp2], 8(%[src]) \n\t"
+ "lw %[temp3], 12(%[src]) \n\t"
"ext %[temp4], %[temp0], 8, 8 \n\t"
"ext %[temp5], %[temp1], 8, 8 \n\t"
"ext %[temp6], %[temp2], 8, 8 \n\t"
"ext %[temp7], %[temp3], 8, 8 \n\t"
- "addiu %[data], %[data], 16 \n\t"
+ "addiu %[src], %[src], 16 \n\t"
+ "addiu %[dst], %[dst], 16 \n\t"
"replv.ph %[temp4], %[temp4] \n\t"
"replv.ph %[temp5], %[temp5] \n\t"
"replv.ph %[temp6], %[temp6] \n\t"
@@ -254,44 +257,47 @@ static void AddGreenToBlueAndRed(uint32_t* data, int num_pixels) {
"addu.qb %[temp1], %[temp1], %[temp5] \n\t"
"addu.qb %[temp2], %[temp2], %[temp6] \n\t"
"addu.qb %[temp3], %[temp3], %[temp7] \n\t"
- "sw %[temp0], -16(%[data]) \n\t"
- "sw %[temp1], -12(%[data]) \n\t"
- "sw %[temp2], -8(%[data]) \n\t"
- "bne %[data], %[p_loop1_end], 0b \n\t"
- " sw %[temp3], -4(%[data]) \n\t"
+ "sw %[temp0], -16(%[dst]) \n\t"
+ "sw %[temp1], -12(%[dst]) \n\t"
+ "sw %[temp2], -8(%[dst]) \n\t"
+ "bne %[src], %[p_loop1_end], 0b \n\t"
+ " sw %[temp3], -4(%[dst]) \n\t"
"3: \n\t"
- "beq %[data], %[p_loop2_end], 2f \n\t"
+ "beq %[src], %[p_loop2_end], 2f \n\t"
" nop \n\t"
"1: \n\t"
- "lw %[temp0], 0(%[data]) \n\t"
- "addiu %[data], %[data], 4 \n\t"
+ "lw %[temp0], 0(%[src]) \n\t"
+ "addiu %[src], %[src], 4 \n\t"
+ "addiu %[dst], %[dst], 4 \n\t"
"ext %[temp4], %[temp0], 8, 8 \n\t"
"replv.ph %[temp4], %[temp4] \n\t"
"addu.qb %[temp0], %[temp0], %[temp4] \n\t"
- "bne %[data], %[p_loop2_end], 1b \n\t"
- " sw %[temp0], -4(%[data]) \n\t"
+ "bne %[src], %[p_loop2_end], 1b \n\t"
+ " sw %[temp0], -4(%[dst]) \n\t"
"2: \n\t"
".set pop \n\t"
- : [data]"+&r"(data), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
- [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4),
- [temp5]"=&r"(temp5), [temp6]"=&r"(temp6), [temp7]"=&r"(temp7)
+ : [dst]"+&r"(dst), [src]"+&r"(src), [temp0]"=&r"(temp0),
+ [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3),
+ [temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6),
+ [temp7]"=&r"(temp7)
: [p_loop1_end]"r"(p_loop1_end), [p_loop2_end]"r"(p_loop2_end)
: "memory"
);
}
static void TransformColorInverse(const VP8LMultipliers* const m,
- uint32_t* data, int num_pixels) {
+ const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
int temp0, temp1, temp2, temp3, temp4, temp5;
uint32_t argb, argb1, new_red;
const uint32_t G_to_R = m->green_to_red_;
const uint32_t G_to_B = m->green_to_blue_;
const uint32_t R_to_B = m->red_to_blue_;
- uint32_t* const p_loop_end = data + (num_pixels & ~1);
+ const uint32_t* const p_loop_end = src + (num_pixels & ~1);
__asm__ volatile (
".set push \n\t"
".set noreorder \n\t"
- "beq %[data], %[p_loop_end], 1f \n\t"
+ "beq %[src], %[p_loop_end], 1f \n\t"
" nop \n\t"
"replv.ph %[temp0], %[G_to_R] \n\t"
"replv.ph %[temp1], %[G_to_B] \n\t"
@@ -303,9 +309,12 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
"shra.ph %[temp1], %[temp1], 8 \n\t"
"shra.ph %[temp2], %[temp2], 8 \n\t"
"0: \n\t"
- "lw %[argb], 0(%[data]) \n\t"
- "lw %[argb1], 4(%[data]) \n\t"
- "addiu %[data], %[data], 8 \n\t"
+ "lw %[argb], 0(%[src]) \n\t"
+ "lw %[argb1], 4(%[src]) \n\t"
+ "sw %[argb], 0(%[dst]) \n\t"
+ "sw %[argb1], 4(%[dst]) \n\t"
+ "addiu %[src], %[src], 8 \n\t"
+ "addiu %[dst], %[dst], 8 \n\t"
"precrq.qb.ph %[temp3], %[argb], %[argb1] \n\t"
"preceu.ph.qbra %[temp3], %[temp3] \n\t"
"shll.ph %[temp3], %[temp3], 8 \n\t"
@@ -322,29 +331,29 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
"shll.ph %[temp4], %[temp5], 8 \n\t"
"shra.ph %[temp4], %[temp4], 8 \n\t"
"mul.ph %[temp4], %[temp4], %[temp2] \n\t"
- "sb %[temp5], -2(%[data]) \n\t"
+ "sb %[temp5], -2(%[dst]) \n\t"
"sra %[temp5], %[temp5], 16 \n\t"
"shra.ph %[temp4], %[temp4], 5 \n\t"
"addu.ph %[argb1], %[argb1], %[temp4] \n\t"
"preceu.ph.qbra %[temp3], %[argb1] \n\t"
- "sb %[temp5], -6(%[data]) \n\t"
- "sb %[temp3], -4(%[data]) \n\t"
+ "sb %[temp5], -6(%[dst]) \n\t"
+ "sb %[temp3], -4(%[dst]) \n\t"
"sra %[temp3], %[temp3], 16 \n\t"
- "bne %[data], %[p_loop_end], 0b \n\t"
- " sb %[temp3], -8(%[data]) \n\t"
+ "bne %[src], %[p_loop_end], 0b \n\t"
+ " sb %[temp3], -8(%[dst]) \n\t"
"1: \n\t"
".set pop \n\t"
: [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [temp2]"=&r"(temp2),
[temp3]"=&r"(temp3), [temp4]"=&r"(temp4), [temp5]"=&r"(temp5),
[new_red]"=&r"(new_red), [argb]"=&r"(argb),
- [argb1]"=&r"(argb1), [data]"+&r"(data)
+ [argb1]"=&r"(argb1), [dst]"+&r"(dst), [src]"+&r"(src)
: [G_to_R]"r"(G_to_R), [R_to_B]"r"(R_to_B),
[G_to_B]"r"(G_to_B), [p_loop_end]"r"(p_loop_end)
: "memory", "hi", "lo"
);
// Fall-back to C-version for left-overs.
- if (num_pixels & 1) VP8LTransformColorInverse_C(m, data, 1);
+ if (num_pixels & 1) VP8LTransformColorInverse_C(m, src, 1, dst);
}
static void ConvertBGRAToRGB(const uint32_t* src,
diff --git a/thirdparty/libwebp/dsp/lossless_msa.c b/thirdparty/libwebp/dsp/lossless_msa.c
new file mode 100644
index 0000000000..f6dd5649ac
--- /dev/null
+++ b/thirdparty/libwebp/dsp/lossless_msa.c
@@ -0,0 +1,355 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA variant of methods for lossless decoder
+//
+// Author: Prashant Patil (prashant.patil@imgtec.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include "./lossless.h"
+#include "./msa_macro.h"
+
+//------------------------------------------------------------------------------
+// Colorspace conversion functions
+
+#define CONVERT16_BGRA_XXX(psrc, pdst, m0, m1, m2) do { \
+ v16u8 src0, src1, src2, src3, dst0, dst1, dst2; \
+ LD_UB4(psrc, 16, src0, src1, src2, src3); \
+ VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
+ dst2 = VSHF_UB(src2, src3, m2); \
+ ST_UB2(dst0, dst1, pdst, 16); \
+ ST_UB(dst2, pdst + 32); \
+} while (0)
+
+#define CONVERT12_BGRA_XXX(psrc, pdst, m0, m1, m2) do { \
+ uint32_t pix_w; \
+ v16u8 src0, src1, src2, dst0, dst1, dst2; \
+ LD_UB3(psrc, 16, src0, src1, src2); \
+ VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
+ dst2 = VSHF_UB(src2, src2, m2); \
+ ST_UB2(dst0, dst1, pdst, 16); \
+ pix_w = __msa_copy_s_w((v4i32)dst2, 0); \
+ SW(pix_w, pdst + 32); \
+} while (0)
+
+#define CONVERT8_BGRA_XXX(psrc, pdst, m0, m1) do { \
+ uint64_t pix_d; \
+ v16u8 src0, src1, src2, dst0, dst1; \
+ LD_UB2(psrc, 16, src0, src1); \
+ VSHF_B2_UB(src0, src1, src1, src2, m0, m1, dst0, dst1); \
+ ST_UB(dst0, pdst); \
+ pix_d = __msa_copy_s_d((v2i64)dst1, 0); \
+ SD(pix_d, pdst + 16); \
+} while (0)
+
+#define CONVERT4_BGRA_XXX(psrc, pdst, m) do { \
+ const v16u8 src0 = LD_UB(psrc); \
+ const v16u8 dst0 = VSHF_UB(src0, src0, m); \
+ uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0); \
+ uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2); \
+ SD(pix_d, pdst + 0); \
+ SW(pix_w, pdst + 8); \
+} while (0)
+
+#define CONVERT1_BGRA_BGR(psrc, pdst) do { \
+ const int32_t b = (psrc)[0]; \
+ const int32_t g = (psrc)[1]; \
+ const int32_t r = (psrc)[2]; \
+ (pdst)[0] = b; \
+ (pdst)[1] = g; \
+ (pdst)[2] = r; \
+} while (0)
+
+#define CONVERT1_BGRA_RGB(psrc, pdst) do { \
+ const int32_t b = (psrc)[0]; \
+ const int32_t g = (psrc)[1]; \
+ const int32_t r = (psrc)[2]; \
+ (pdst)[0] = r; \
+ (pdst)[1] = g; \
+ (pdst)[2] = b; \
+} while (0)
+
+#define TRANSFORM_COLOR_INVERSE_8(src0, src1, dst0, dst1, \
+ c0, c1, mask0, mask1) do { \
+ v8i16 g0, g1, t0, t1, t2, t3; \
+ v4i32 t4, t5; \
+ VSHF_B2_SH(src0, src0, src1, src1, mask0, mask0, g0, g1); \
+ DOTP_SB2_SH(g0, g1, c0, c0, t0, t1); \
+ SRAI_H2_SH(t0, t1, 5); \
+ t0 = __msa_addv_h(t0, (v8i16)src0); \
+ t1 = __msa_addv_h(t1, (v8i16)src1); \
+ t4 = __msa_srli_w((v4i32)t0, 16); \
+ t5 = __msa_srli_w((v4i32)t1, 16); \
+ DOTP_SB2_SH(t4, t5, c1, c1, t2, t3); \
+ SRAI_H2_SH(t2, t3, 5); \
+ ADD2(t0, t2, t1, t3, t0, t1); \
+ VSHF_B2_UB(src0, t0, src1, t1, mask1, mask1, dst0, dst1); \
+} while (0)
+
+#define TRANSFORM_COLOR_INVERSE_4(src, dst, c0, c1, mask0, mask1) do { \
+ const v16i8 g0 = VSHF_SB(src, src, mask0); \
+ v8i16 t0 = __msa_dotp_s_h(c0, g0); \
+ v8i16 t1; \
+ v4i32 t2; \
+ t0 = SRAI_H(t0, 5); \
+ t0 = __msa_addv_h(t0, (v8i16)src); \
+ t2 = __msa_srli_w((v4i32)t0, 16); \
+ t1 = __msa_dotp_s_h(c1, (v16i8)t2); \
+ t1 = SRAI_H(t1, 5); \
+ t0 = t0 + t1; \
+ dst = VSHF_UB(src, t0, mask1); \
+} while (0)
+
+static void ConvertBGRAToRGBA(const uint32_t* src,
+ int num_pixels, uint8_t* dst) {
+ int i;
+ const uint8_t* ptemp_src = (const uint8_t*)src;
+ uint8_t* ptemp_dst = (uint8_t*)dst;
+ v16u8 src0, dst0;
+ const v16u8 mask = { 2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15 };
+
+ while (num_pixels >= 8) {
+ v16u8 src1, dst1;
+ LD_UB2(ptemp_src, 16, src0, src1);
+ VSHF_B2_UB(src0, src0, src1, src1, mask, mask, dst0, dst1);
+ ST_UB2(dst0, dst1, ptemp_dst, 16);
+ ptemp_src += 32;
+ ptemp_dst += 32;
+ num_pixels -= 8;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 4) {
+ src0 = LD_UB(ptemp_src);
+ dst0 = VSHF_UB(src0, src0, mask);
+ ST_UB(dst0, ptemp_dst);
+ ptemp_src += 16;
+ ptemp_dst += 16;
+ num_pixels -= 4;
+ }
+ for (i = 0; i < num_pixels; i++) {
+ const uint8_t b = ptemp_src[2];
+ const uint8_t g = ptemp_src[1];
+ const uint8_t r = ptemp_src[0];
+ const uint8_t a = ptemp_src[3];
+ ptemp_dst[0] = b;
+ ptemp_dst[1] = g;
+ ptemp_dst[2] = r;
+ ptemp_dst[3] = a;
+ ptemp_src += 4;
+ ptemp_dst += 4;
+ }
+ }
+}
+
+static void ConvertBGRAToBGR(const uint32_t* src,
+ int num_pixels, uint8_t* dst) {
+ const uint8_t* ptemp_src = (const uint8_t*)src;
+ uint8_t* ptemp_dst = (uint8_t*)dst;
+ const v16u8 mask0 = { 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14,
+ 16, 17, 18, 20 };
+ const v16u8 mask1 = { 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20,
+ 21, 22, 24, 25 };
+ const v16u8 mask2 = { 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25,
+ 26, 28, 29, 30 };
+
+ while (num_pixels >= 16) {
+ CONVERT16_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
+ ptemp_src += 64;
+ ptemp_dst += 48;
+ num_pixels -= 16;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 12) {
+ CONVERT12_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
+ ptemp_src += 48;
+ ptemp_dst += 36;
+ num_pixels -= 12;
+ } else if (num_pixels >= 8) {
+ CONVERT8_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1);
+ ptemp_src += 32;
+ ptemp_dst += 24;
+ num_pixels -= 8;
+ } else if (num_pixels >= 4) {
+ CONVERT4_BGRA_XXX(ptemp_src, ptemp_dst, mask0);
+ ptemp_src += 16;
+ ptemp_dst += 12;
+ num_pixels -= 4;
+ }
+ if (num_pixels == 3) {
+ CONVERT1_BGRA_BGR(ptemp_src + 0, ptemp_dst + 0);
+ CONVERT1_BGRA_BGR(ptemp_src + 4, ptemp_dst + 3);
+ CONVERT1_BGRA_BGR(ptemp_src + 8, ptemp_dst + 6);
+ } else if (num_pixels == 2) {
+ CONVERT1_BGRA_BGR(ptemp_src + 0, ptemp_dst + 0);
+ CONVERT1_BGRA_BGR(ptemp_src + 4, ptemp_dst + 3);
+ } else if (num_pixels == 1) {
+ CONVERT1_BGRA_BGR(ptemp_src, ptemp_dst);
+ }
+ }
+}
+
+static void ConvertBGRAToRGB(const uint32_t* src,
+ int num_pixels, uint8_t* dst) {
+ const uint8_t* ptemp_src = (const uint8_t*)src;
+ uint8_t* ptemp_dst = (uint8_t*)dst;
+ const v16u8 mask0 = { 2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12,
+ 18, 17, 16, 22 };
+ const v16u8 mask1 = { 5, 4, 10, 9, 8, 14, 13, 12, 18, 17, 16, 22,
+ 21, 20, 26, 25 };
+ const v16u8 mask2 = { 8, 14, 13, 12, 18, 17, 16, 22, 21, 20, 26, 25,
+ 24, 30, 29, 28 };
+
+ while (num_pixels >= 16) {
+ CONVERT16_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
+ ptemp_src += 64;
+ ptemp_dst += 48;
+ num_pixels -= 16;
+ }
+ if (num_pixels) {
+ if (num_pixels >= 12) {
+ CONVERT12_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1, mask2);
+ ptemp_src += 48;
+ ptemp_dst += 36;
+ num_pixels -= 12;
+ } else if (num_pixels >= 8) {
+ CONVERT8_BGRA_XXX(ptemp_src, ptemp_dst, mask0, mask1);
+ ptemp_src += 32;
+ ptemp_dst += 24;
+ num_pixels -= 8;
+ } else if (num_pixels >= 4) {
+ CONVERT4_BGRA_XXX(ptemp_src, ptemp_dst, mask0);
+ ptemp_src += 16;
+ ptemp_dst += 12;
+ num_pixels -= 4;
+ }
+ if (num_pixels == 3) {
+ CONVERT1_BGRA_RGB(ptemp_src + 0, ptemp_dst + 0);
+ CONVERT1_BGRA_RGB(ptemp_src + 4, ptemp_dst + 3);
+ CONVERT1_BGRA_RGB(ptemp_src + 8, ptemp_dst + 6);
+ } else if (num_pixels == 2) {
+ CONVERT1_BGRA_RGB(ptemp_src + 0, ptemp_dst + 0);
+ CONVERT1_BGRA_RGB(ptemp_src + 4, ptemp_dst + 3);
+ } else if (num_pixels == 1) {
+ CONVERT1_BGRA_RGB(ptemp_src, ptemp_dst);
+ }
+ }
+}
+
+static void AddGreenToBlueAndRed(const uint32_t* const src, int num_pixels,
+ uint32_t* dst) {
+ int i;
+ const uint8_t* in = (const uint8_t*)src;
+ uint8_t* out = (uint8_t*)dst;
+ v16u8 src0, dst0, tmp0;
+ const v16u8 mask = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
+ 13, 255, 13, 255 };
+
+ while (num_pixels >= 8) {
+ v16u8 src1, dst1, tmp1;
+ LD_UB2(in, 16, src0, src1);
+ VSHF_B2_UB(src0, src1, src1, src0, mask, mask, tmp0, tmp1);
+ ADD2(src0, tmp0, src1, tmp1, dst0, dst1);
+ ST_UB2(dst0, dst1, out, 16);
+ in += 32;
+ out += 32;
+ num_pixels -= 8;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 4) {
+ src0 = LD_UB(in);
+ tmp0 = VSHF_UB(src0, src0, mask);
+ dst0 = src0 + tmp0;
+ ST_UB(dst0, out);
+ in += 16;
+ out += 16;
+ num_pixels -= 4;
+ }
+ for (i = 0; i < num_pixels; i++) {
+ const uint8_t b = in[0];
+ const uint8_t g = in[1];
+ const uint8_t r = in[2];
+ out[0] = (b + g) & 0xff;
+ out[1] = g;
+ out[2] = (r + g) & 0xff;
+ out[4] = in[4];
+ out += 4;
+ }
+ }
+}
+
+static void TransformColorInverse(const VP8LMultipliers* const m,
+ const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
+ v16u8 src0, dst0;
+ const v16i8 g2br = (v16i8)__msa_fill_w(m->green_to_blue_ |
+ (m->green_to_red_ << 16));
+ const v16i8 r2b = (v16i8)__msa_fill_w(m->red_to_blue_);
+ const v16u8 mask0 = { 1, 255, 1, 255, 5, 255, 5, 255, 9, 255, 9, 255,
+ 13, 255, 13, 255 };
+ const v16u8 mask1 = { 16, 1, 18, 3, 20, 5, 22, 7, 24, 9, 26, 11,
+ 28, 13, 30, 15 };
+
+ while (num_pixels >= 8) {
+ v16u8 src1, dst1;
+ LD_UB2(src, 4, src0, src1);
+ TRANSFORM_COLOR_INVERSE_8(src0, src1, dst0, dst1, g2br, r2b, mask0, mask1);
+ ST_UB2(dst0, dst1, dst, 4);
+ src += 8;
+ dst += 8;
+ num_pixels -= 8;
+ }
+ if (num_pixels > 0) {
+ if (num_pixels >= 4) {
+ src0 = LD_UB(src);
+ TRANSFORM_COLOR_INVERSE_4(src0, dst0, g2br, r2b, mask0, mask1);
+ ST_UB(dst0, dst);
+ src += 4;
+ dst += 4;
+ num_pixels -= 4;
+ }
+ if (num_pixels > 0) {
+ src0 = LD_UB(src);
+ TRANSFORM_COLOR_INVERSE_4(src0, dst0, g2br, r2b, mask0, mask1);
+ if (num_pixels == 3) {
+ const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
+ const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 2);
+ SD(pix_d, dst + 0);
+ SW(pix_w, dst + 2);
+ } else if (num_pixels == 2) {
+ const uint64_t pix_d = __msa_copy_s_d((v2i64)dst0, 0);
+ SD(pix_d, dst);
+ } else {
+ const uint32_t pix_w = __msa_copy_s_w((v4i32)dst0, 0);
+ SW(pix_w, dst);
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void VP8LDspInitMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitMSA(void) {
+ VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA;
+ VP8LConvertBGRAToBGR = ConvertBGRAToBGR;
+ VP8LConvertBGRAToRGB = ConvertBGRAToRGB;
+ VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed;
+ VP8LTransformColorInverse = TransformColorInverse;
+}
+
+#else // !WEBP_USE_MSA
+
+WEBP_DSP_INIT_STUB(VP8LDspInitMSA)
+
+#endif // WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/lossless_neon.c b/thirdparty/libwebp/dsp/lossless_neon.c
index 6faccb8f97..1145d5fad0 100644
--- a/thirdparty/libwebp/dsp/lossless_neon.c
+++ b/thirdparty/libwebp/dsp/lossless_neon.c
@@ -139,6 +139,357 @@ static void ConvertBGRAToRGB(const uint32_t* src,
#endif // !WORK_AROUND_GCC
+
+//------------------------------------------------------------------------------
+// Predictor Transform
+
+#define LOAD_U32_AS_U8(IN) vreinterpret_u8_u32(vdup_n_u32((IN)))
+#define LOAD_U32P_AS_U8(IN) vreinterpret_u8_u32(vld1_u32((IN)))
+#define LOADQ_U32_AS_U8(IN) vreinterpretq_u8_u32(vdupq_n_u32((IN)))
+#define LOADQ_U32P_AS_U8(IN) vreinterpretq_u8_u32(vld1q_u32((IN)))
+#define GET_U8_AS_U32(IN) vget_lane_u32(vreinterpret_u32_u8((IN)), 0);
+#define GETQ_U8_AS_U32(IN) vgetq_lane_u32(vreinterpretq_u32_u8((IN)), 0);
+#define STOREQ_U8_AS_U32P(OUT, IN) vst1q_u32((OUT), vreinterpretq_u32_u8((IN)));
+#define ROTATE32_LEFT(L) vextq_u8((L), (L), 12) // D|C|B|A -> C|B|A|D
+
+static WEBP_INLINE uint8x8_t Average2_u8_NEON(uint32_t a0, uint32_t a1) {
+ const uint8x8_t A0 = LOAD_U32_AS_U8(a0);
+ const uint8x8_t A1 = LOAD_U32_AS_U8(a1);
+ return vhadd_u8(A0, A1);
+}
+
+static WEBP_INLINE uint32_t ClampedAddSubtractHalf_NEON(uint32_t c0,
+ uint32_t c1,
+ uint32_t c2) {
+ const uint8x8_t avg = Average2_u8_NEON(c0, c1);
+ // Remove one to c2 when bigger than avg.
+ const uint8x8_t C2 = LOAD_U32_AS_U8(c2);
+ const uint8x8_t cmp = vcgt_u8(C2, avg);
+ const uint8x8_t C2_1 = vadd_u8(C2, cmp);
+ // Compute half of the difference between avg and c2.
+ const int8x8_t diff_avg = vreinterpret_s8_u8(vhsub_u8(avg, C2_1));
+ // Compute the sum with avg and saturate.
+ const int16x8_t avg_16 = vreinterpretq_s16_u16(vmovl_u8(avg));
+ const uint8x8_t res = vqmovun_s16(vaddw_s8(avg_16, diff_avg));
+ const uint32_t output = GET_U8_AS_U32(res);
+ return output;
+}
+
+static WEBP_INLINE uint32_t Average2_NEON(uint32_t a0, uint32_t a1) {
+ const uint8x8_t avg_u8x8 = Average2_u8_NEON(a0, a1);
+ const uint32_t avg = GET_U8_AS_U32(avg_u8x8);
+ return avg;
+}
+
+static WEBP_INLINE uint32_t Average3_NEON(uint32_t a0, uint32_t a1,
+ uint32_t a2) {
+ const uint8x8_t avg0 = Average2_u8_NEON(a0, a2);
+ const uint8x8_t A1 = LOAD_U32_AS_U8(a1);
+ const uint32_t avg = GET_U8_AS_U32(vhadd_u8(avg0, A1));
+ return avg;
+}
+
+static uint32_t Predictor5_NEON(uint32_t left, const uint32_t* const top) {
+ return Average3_NEON(left, top[0], top[1]);
+}
+static uint32_t Predictor6_NEON(uint32_t left, const uint32_t* const top) {
+ return Average2_NEON(left, top[-1]);
+}
+static uint32_t Predictor7_NEON(uint32_t left, const uint32_t* const top) {
+ return Average2_NEON(left, top[0]);
+}
+static uint32_t Predictor13_NEON(uint32_t left, const uint32_t* const top) {
+ return ClampedAddSubtractHalf_NEON(left, top[0], top[-1]);
+}
+
+// Batch versions of those functions.
+
+// Predictor0: ARGB_BLACK.
+static void PredictorAdd0_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const uint8x16_t black = vreinterpretq_u8_u32(vdupq_n_u32(ARGB_BLACK));
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t res = vaddq_u8(src, black);
+ STOREQ_U8_AS_U32P(&out[i], res);
+ }
+ VP8LPredictorsAdd_C[0](in + i, upper + i, num_pixels - i, out + i);
+}
+
+// Predictor1: left.
+static void PredictorAdd1_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const uint8x16_t zero = LOADQ_U32_AS_U8(0);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ // a | b | c | d
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ // 0 | a | b | c
+ const uint8x16_t shift0 = vextq_u8(zero, src, 12);
+ // a | a + b | b + c | c + d
+ const uint8x16_t sum0 = vaddq_u8(src, shift0);
+ // 0 | 0 | a | a + b
+ const uint8x16_t shift1 = vextq_u8(zero, sum0, 8);
+ // a | a + b | a + b + c | a + b + c + d
+ const uint8x16_t sum1 = vaddq_u8(sum0, shift1);
+ const uint8x16_t prev = LOADQ_U32_AS_U8(out[i - 1]);
+ const uint8x16_t res = vaddq_u8(sum1, prev);
+ STOREQ_U8_AS_U32P(&out[i], res);
+ }
+ VP8LPredictorsAdd_C[1](in + i, upper + i, num_pixels - i, out + i);
+}
+
+// Macro that adds 32-bit integers from IN using mod 256 arithmetic
+// per 8 bit channel.
+#define GENERATE_PREDICTOR_1(X, IN) \
+static void PredictorAdd##X##_NEON(const uint32_t* in, \
+ const uint32_t* upper, int num_pixels, \
+ uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]); \
+ const uint8x16_t other = LOADQ_U32P_AS_U8(&(IN)); \
+ const uint8x16_t res = vaddq_u8(src, other); \
+ STOREQ_U8_AS_U32P(&out[i], res); \
+ } \
+ VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+}
+// Predictor2: Top.
+GENERATE_PREDICTOR_1(2, upper[i])
+// Predictor3: Top-right.
+GENERATE_PREDICTOR_1(3, upper[i + 1])
+// Predictor4: Top-left.
+GENERATE_PREDICTOR_1(4, upper[i - 1])
+#undef GENERATE_PREDICTOR_1
+
+// Predictor5: average(average(left, TR), T)
+#define DO_PRED5(LANE) do { \
+ const uint8x16_t avgLTR = vhaddq_u8(L, TR); \
+ const uint8x16_t avg = vhaddq_u8(avgLTR, T); \
+ const uint8x16_t res = vaddq_u8(avg, src); \
+ vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
+ L = ROTATE32_LEFT(res); \
+} while (0)
+
+static void PredictorAdd5_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i + 0]);
+ const uint8x16_t TR = LOADQ_U32P_AS_U8(&upper[i + 1]);
+ DO_PRED5(0);
+ DO_PRED5(1);
+ DO_PRED5(2);
+ DO_PRED5(3);
+ }
+ VP8LPredictorsAdd_C[5](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED5
+
+#define DO_PRED67(LANE) do { \
+ const uint8x16_t avg = vhaddq_u8(L, top); \
+ const uint8x16_t res = vaddq_u8(avg, src); \
+ vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
+ L = ROTATE32_LEFT(res); \
+} while (0)
+
+// Predictor6: average(left, TL)
+static void PredictorAdd6_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t top = LOADQ_U32P_AS_U8(&upper[i - 1]);
+ DO_PRED67(0);
+ DO_PRED67(1);
+ DO_PRED67(2);
+ DO_PRED67(3);
+ }
+ VP8LPredictorsAdd_C[6](in + i, upper + i, num_pixels - i, out + i);
+}
+
+// Predictor7: average(left, T)
+static void PredictorAdd7_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t top = LOADQ_U32P_AS_U8(&upper[i]);
+ DO_PRED67(0);
+ DO_PRED67(1);
+ DO_PRED67(2);
+ DO_PRED67(3);
+ }
+ VP8LPredictorsAdd_C[7](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED67
+
+#define GENERATE_PREDICTOR_2(X, IN) \
+static void PredictorAdd##X##_NEON(const uint32_t* in, \
+ const uint32_t* upper, int num_pixels, \
+ uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]); \
+ const uint8x16_t Tother = LOADQ_U32P_AS_U8(&(IN)); \
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]); \
+ const uint8x16_t avg = vhaddq_u8(T, Tother); \
+ const uint8x16_t res = vaddq_u8(avg, src); \
+ STOREQ_U8_AS_U32P(&out[i], res); \
+ } \
+ VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+}
+// Predictor8: average TL T.
+GENERATE_PREDICTOR_2(8, upper[i - 1])
+// Predictor9: average T TR.
+GENERATE_PREDICTOR_2(9, upper[i + 1])
+#undef GENERATE_PREDICTOR_2
+
+// Predictor10: average of (average of (L,TL), average of (T, TR)).
+#define DO_PRED10(LANE) do { \
+ const uint8x16_t avgLTL = vhaddq_u8(L, TL); \
+ const uint8x16_t avg = vhaddq_u8(avgTTR, avgLTL); \
+ const uint8x16_t res = vaddq_u8(avg, src); \
+ vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
+ L = ROTATE32_LEFT(res); \
+} while (0)
+
+static void PredictorAdd10_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
+ const uint8x16_t TR = LOADQ_U32P_AS_U8(&upper[i + 1]);
+ const uint8x16_t avgTTR = vhaddq_u8(T, TR);
+ DO_PRED10(0);
+ DO_PRED10(1);
+ DO_PRED10(2);
+ DO_PRED10(3);
+ }
+ VP8LPredictorsAdd_C[10](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED10
+
+// Predictor11: select.
+#define DO_PRED11(LANE) do { \
+ const uint8x16_t sumLin = vaddq_u8(L, src); /* in + L */ \
+ const uint8x16_t pLTL = vabdq_u8(L, TL); /* |L - TL| */ \
+ const uint16x8_t sum_LTL = vpaddlq_u8(pLTL); \
+ const uint32x4_t pa = vpaddlq_u16(sum_LTL); \
+ const uint32x4_t mask = vcleq_u32(pa, pb); \
+ const uint8x16_t res = vbslq_u8(vreinterpretq_u8_u32(mask), sumTin, sumLin); \
+ vst1q_lane_u32(&out[i + (LANE)], vreinterpretq_u32_u8(res), (LANE)); \
+ L = ROTATE32_LEFT(res); \
+} while (0)
+
+static void PredictorAdd11_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
+ const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
+ const uint8x16_t pTTL = vabdq_u8(T, TL); // |T - TL|
+ const uint16x8_t sum_TTL = vpaddlq_u8(pTTL);
+ const uint32x4_t pb = vpaddlq_u16(sum_TTL);
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t sumTin = vaddq_u8(T, src); // in + T
+ DO_PRED11(0);
+ DO_PRED11(1);
+ DO_PRED11(2);
+ DO_PRED11(3);
+ }
+ VP8LPredictorsAdd_C[11](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED11
+
+// Predictor12: ClampedAddSubtractFull.
+#define DO_PRED12(DIFF, LANE) do { \
+ const uint8x8_t pred = \
+ vqmovun_s16(vaddq_s16(vreinterpretq_s16_u16(L), (DIFF))); \
+ const uint8x8_t res = \
+ vadd_u8(pred, (LANE <= 1) ? vget_low_u8(src) : vget_high_u8(src)); \
+ const uint16x8_t res16 = vmovl_u8(res); \
+ vst1_lane_u32(&out[i + (LANE)], vreinterpret_u32_u8(res), (LANE) & 1); \
+ /* rotate in the left predictor for next iteration */ \
+ L = vextq_u16(res16, res16, 4); \
+} while (0)
+
+static void PredictorAdd12_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint16x8_t L = vmovl_u8(LOAD_U32_AS_U8(out[-1]));
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ // load four pixels of source
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ // precompute the difference T - TL once for all, stored as s16
+ const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
+ const int16x8_t diff_lo =
+ vreinterpretq_s16_u16(vsubl_u8(vget_low_u8(T), vget_low_u8(TL)));
+ const int16x8_t diff_hi =
+ vreinterpretq_s16_u16(vsubl_u8(vget_high_u8(T), vget_high_u8(TL)));
+ // loop over the four reconstructed pixels
+ DO_PRED12(diff_lo, 0);
+ DO_PRED12(diff_lo, 1);
+ DO_PRED12(diff_hi, 2);
+ DO_PRED12(diff_hi, 3);
+ }
+ VP8LPredictorsAdd_C[12](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED12
+
+// Predictor13: ClampedAddSubtractHalf
+#define DO_PRED13(LANE, LOW_OR_HI) do { \
+ const uint8x16_t avg = vhaddq_u8(L, T); \
+ const uint8x16_t cmp = vcgtq_u8(TL, avg); \
+ const uint8x16_t TL_1 = vaddq_u8(TL, cmp); \
+ /* Compute half of the difference between avg and TL'. */ \
+ const int8x8_t diff_avg = \
+ vreinterpret_s8_u8(LOW_OR_HI(vhsubq_u8(avg, TL_1))); \
+ /* Compute the sum with avg and saturate. */ \
+ const int16x8_t avg_16 = vreinterpretq_s16_u16(vmovl_u8(LOW_OR_HI(avg))); \
+ const uint8x8_t delta = vqmovun_s16(vaddw_s8(avg_16, diff_avg)); \
+ const uint8x8_t res = vadd_u8(LOW_OR_HI(src), delta); \
+ const uint8x16_t res2 = vcombine_u8(res, res); \
+ vst1_lane_u32(&out[i + (LANE)], vreinterpret_u32_u8(res), (LANE) & 1); \
+ L = ROTATE32_LEFT(res2); \
+} while (0)
+
+static void PredictorAdd13_NEON(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ uint8x16_t L = LOADQ_U32_AS_U8(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const uint8x16_t src = LOADQ_U32P_AS_U8(&in[i]);
+ const uint8x16_t T = LOADQ_U32P_AS_U8(&upper[i]);
+ const uint8x16_t TL = LOADQ_U32P_AS_U8(&upper[i - 1]);
+ DO_PRED13(0, vget_low_u8);
+ DO_PRED13(1, vget_low_u8);
+ DO_PRED13(2, vget_high_u8);
+ DO_PRED13(3, vget_high_u8);
+ }
+ VP8LPredictorsAdd_C[13](in + i, upper + i, num_pixels - i, out + i);
+}
+#undef DO_PRED13
+
+#undef LOAD_U32_AS_U8
+#undef LOAD_U32P_AS_U8
+#undef LOADQ_U32_AS_U8
+#undef LOADQ_U32P_AS_U8
+#undef GET_U8_AS_U32
+#undef GETQ_U8_AS_U32
+#undef STOREQ_U8_AS_U32P
+#undef ROTATE32_LEFT
+
//------------------------------------------------------------------------------
// Subtract-Green Transform
@@ -171,28 +522,30 @@ static WEBP_INLINE uint8x16_t DoGreenShuffle(const uint8x16_t argb,
}
#endif // USE_VTBLQ
-static void AddGreenToBlueAndRed(uint32_t* argb_data, int num_pixels) {
- const uint32_t* const end = argb_data + (num_pixels & ~3);
+static void AddGreenToBlueAndRed(const uint32_t* src, int num_pixels,
+ uint32_t* dst) {
+ const uint32_t* const end = src + (num_pixels & ~3);
#ifdef USE_VTBLQ
const uint8x16_t shuffle = vld1q_u8(kGreenShuffle);
#else
const uint8x8_t shuffle = vld1_u8(kGreenShuffle);
#endif
- for (; argb_data < end; argb_data += 4) {
- const uint8x16_t argb = vld1q_u8((uint8_t*)argb_data);
+ for (; src < end; src += 4, dst += 4) {
+ const uint8x16_t argb = vld1q_u8((const uint8_t*)src);
const uint8x16_t greens = DoGreenShuffle(argb, shuffle);
- vst1q_u8((uint8_t*)argb_data, vaddq_u8(argb, greens));
+ vst1q_u8((uint8_t*)dst, vaddq_u8(argb, greens));
}
// fallthrough and finish off with plain-C
- VP8LAddGreenToBlueAndRed_C(argb_data, num_pixels & 3);
+ VP8LAddGreenToBlueAndRed_C(src, num_pixels & 3, dst);
}
//------------------------------------------------------------------------------
// Color Transform
static void TransformColorInverse(const VP8LMultipliers* const m,
- uint32_t* argb_data, int num_pixels) {
- // sign-extended multiplying constants, pre-shifted by 6.
+ const uint32_t* const src, int num_pixels,
+ uint32_t* dst) {
+// sign-extended multiplying constants, pre-shifted by 6.
#define CST(X) (((int16_t)(m->X << 8)) >> 6)
const int16_t rb[8] = {
CST(green_to_blue_), CST(green_to_red_),
@@ -219,7 +572,7 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
const uint32x4_t mask_ag = vdupq_n_u32(0xff00ff00u);
int i;
for (i = 0; i + 4 <= num_pixels; i += 4) {
- const uint8x16_t in = vld1q_u8((uint8_t*)(argb_data + i));
+ const uint8x16_t in = vld1q_u8((const uint8_t*)(src + i));
const uint32x4_t a0g0 = vandq_u32(vreinterpretq_u32_u8(in), mask_ag);
// 0 g 0 g
const uint8x16_t greens = DoGreenShuffle(in, shuffle);
@@ -240,10 +593,10 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
// 0 r' 0 b''
const uint16x8_t G = vshrq_n_u16(vreinterpretq_u16_s8(F), 8);
const uint32x4_t out = vorrq_u32(vreinterpretq_u32_u16(G), a0g0);
- vst1q_u32(argb_data + i, out);
+ vst1q_u32(dst + i, out);
}
// Fall-back to C-version for left-overs.
- VP8LTransformColorInverse_C(m, argb_data + i, num_pixels - i);
+ VP8LTransformColorInverse_C(m, src + i, num_pixels - i, dst + i);
}
#undef USE_VTBLQ
@@ -254,6 +607,26 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
extern void VP8LDspInitNEON(void);
WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitNEON(void) {
+ VP8LPredictors[5] = Predictor5_NEON;
+ VP8LPredictors[6] = Predictor6_NEON;
+ VP8LPredictors[7] = Predictor7_NEON;
+ VP8LPredictors[13] = Predictor13_NEON;
+
+ VP8LPredictorsAdd[0] = PredictorAdd0_NEON;
+ VP8LPredictorsAdd[1] = PredictorAdd1_NEON;
+ VP8LPredictorsAdd[2] = PredictorAdd2_NEON;
+ VP8LPredictorsAdd[3] = PredictorAdd3_NEON;
+ VP8LPredictorsAdd[4] = PredictorAdd4_NEON;
+ VP8LPredictorsAdd[5] = PredictorAdd5_NEON;
+ VP8LPredictorsAdd[6] = PredictorAdd6_NEON;
+ VP8LPredictorsAdd[7] = PredictorAdd7_NEON;
+ VP8LPredictorsAdd[8] = PredictorAdd8_NEON;
+ VP8LPredictorsAdd[9] = PredictorAdd9_NEON;
+ VP8LPredictorsAdd[10] = PredictorAdd10_NEON;
+ VP8LPredictorsAdd[11] = PredictorAdd11_NEON;
+ VP8LPredictorsAdd[12] = PredictorAdd12_NEON;
+ VP8LPredictorsAdd[13] = PredictorAdd13_NEON;
+
VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA;
VP8LConvertBGRAToBGR = ConvertBGRAToBGR;
VP8LConvertBGRAToRGB = ConvertBGRAToRGB;
diff --git a/thirdparty/libwebp/dsp/lossless_sse2.c b/thirdparty/libwebp/dsp/lossless_sse2.c
index 2d016c2911..15aae93869 100644
--- a/thirdparty/libwebp/dsp/lossless_sse2.c
+++ b/thirdparty/libwebp/dsp/lossless_sse2.c
@@ -14,9 +14,12 @@
#include "./dsp.h"
#if defined(WEBP_USE_SSE2)
+
+#include "./common_sse2.h"
+#include "./lossless.h"
+#include "./lossless_common.h"
#include <assert.h>
#include <emmintrin.h>
-#include "./lossless.h"
//------------------------------------------------------------------------------
// Predictor Transform
@@ -75,25 +78,44 @@ static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
return (pa_minus_pb <= 0) ? a : b;
}
-static WEBP_INLINE __m128i Average2_128i(uint32_t a0, uint32_t a1) {
+static WEBP_INLINE void Average2_m128i(const __m128i* const a0,
+ const __m128i* const a1,
+ __m128i* const avg) {
+ // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
+ const __m128i ones = _mm_set1_epi8(1);
+ const __m128i avg1 = _mm_avg_epu8(*a0, *a1);
+ const __m128i one = _mm_and_si128(_mm_xor_si128(*a0, *a1), ones);
+ *avg = _mm_sub_epi8(avg1, one);
+}
+
+static WEBP_INLINE void Average2_uint32(const uint32_t a0, const uint32_t a1,
+ __m128i* const avg) {
+ // (a + b) >> 1 = ((a + b + 1) >> 1) - ((a ^ b) & 1)
+ const __m128i ones = _mm_set1_epi8(1);
+ const __m128i A0 = _mm_cvtsi32_si128(a0);
+ const __m128i A1 = _mm_cvtsi32_si128(a1);
+ const __m128i avg1 = _mm_avg_epu8(A0, A1);
+ const __m128i one = _mm_and_si128(_mm_xor_si128(A0, A1), ones);
+ *avg = _mm_sub_epi8(avg1, one);
+}
+
+static WEBP_INLINE __m128i Average2_uint32_16(uint32_t a0, uint32_t a1) {
const __m128i zero = _mm_setzero_si128();
const __m128i A0 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a0), zero);
const __m128i A1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a1), zero);
const __m128i sum = _mm_add_epi16(A1, A0);
- const __m128i avg = _mm_srli_epi16(sum, 1);
- return avg;
+ return _mm_srli_epi16(sum, 1);
}
static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
- const __m128i avg = Average2_128i(a0, a1);
- const __m128i A2 = _mm_packus_epi16(avg, avg);
- const uint32_t output = _mm_cvtsi128_si32(A2);
- return output;
+ __m128i output;
+ Average2_uint32(a0, a1, &output);
+ return _mm_cvtsi128_si32(output);
}
static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
const __m128i zero = _mm_setzero_si128();
- const __m128i avg1 = Average2_128i(a0, a2);
+ const __m128i avg1 = Average2_uint32_16(a0, a2);
const __m128i A1 = _mm_unpacklo_epi8(_mm_cvtsi32_si128(a1), zero);
const __m128i sum = _mm_add_epi16(avg1, A1);
const __m128i avg2 = _mm_srli_epi16(sum, 1);
@@ -104,8 +126,8 @@ static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
uint32_t a2, uint32_t a3) {
- const __m128i avg1 = Average2_128i(a0, a1);
- const __m128i avg2 = Average2_128i(a2, a3);
+ const __m128i avg1 = Average2_uint32_16(a0, a1);
+ const __m128i avg2 = Average2_uint32_16(a2, a3);
const __m128i sum = _mm_add_epi16(avg2, avg1);
const __m128i avg3 = _mm_srli_epi16(sum, 1);
const __m128i A0 = _mm_packus_epi16(avg3, avg3);
@@ -113,68 +135,289 @@ static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
return output;
}
-static uint32_t Predictor5(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor5_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average3(left, top[0], top[1]);
return pred;
}
-static uint32_t Predictor6(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor6_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average2(left, top[-1]);
return pred;
}
-static uint32_t Predictor7(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor7_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average2(left, top[0]);
return pred;
}
-static uint32_t Predictor8(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor8_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average2(top[-1], top[0]);
(void)left;
return pred;
}
-static uint32_t Predictor9(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor9_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average2(top[0], top[1]);
(void)left;
return pred;
}
-static uint32_t Predictor10(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor10_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Average4(left, top[-1], top[0], top[1]);
return pred;
}
-static uint32_t Predictor11(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor11_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = Select(top[0], left, top[-1]);
return pred;
}
-static uint32_t Predictor12(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor12_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = ClampedAddSubtractFull(left, top[0], top[-1]);
return pred;
}
-static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
+static uint32_t Predictor13_SSE2(uint32_t left, const uint32_t* const top) {
const uint32_t pred = ClampedAddSubtractHalf(left, top[0], top[-1]);
return pred;
}
+// Batch versions of those functions.
+
+// Predictor0: ARGB_BLACK.
+static void PredictorAdd0_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const __m128i black = _mm_set1_epi32(ARGB_BLACK);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ const __m128i res = _mm_add_epi8(src, black);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsAdd_C[0](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictor1: left.
+static void PredictorAdd1_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ __m128i prev = _mm_set1_epi32(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ // a | b | c | d
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ // 0 | a | b | c
+ const __m128i shift0 = _mm_slli_si128(src, 4);
+ // a | a + b | b + c | c + d
+ const __m128i sum0 = _mm_add_epi8(src, shift0);
+ // 0 | 0 | a | a + b
+ const __m128i shift1 = _mm_slli_si128(sum0, 8);
+ // a | a + b | a + b + c | a + b + c + d
+ const __m128i sum1 = _mm_add_epi8(sum0, shift1);
+ const __m128i res = _mm_add_epi8(sum1, prev);
+ _mm_storeu_si128((__m128i*)&out[i], res);
+ // replicate prev output on the four lanes
+ prev = _mm_shuffle_epi32(res, (3 << 0) | (3 << 2) | (3 << 4) | (3 << 6));
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsAdd_C[1](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Macro that adds 32-bit integers from IN using mod 256 arithmetic
+// per 8 bit channel.
+#define GENERATE_PREDICTOR_1(X, IN) \
+static void PredictorAdd##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
+ const __m128i other = _mm_loadu_si128((const __m128i*)&(IN)); \
+ const __m128i res = _mm_add_epi8(src, other); \
+ _mm_storeu_si128((__m128i*)&out[i], res); \
+ } \
+ if (i != num_pixels) { \
+ VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+ } \
+}
+
+// Predictor2: Top.
+GENERATE_PREDICTOR_1(2, upper[i])
+// Predictor3: Top-right.
+GENERATE_PREDICTOR_1(3, upper[i + 1])
+// Predictor4: Top-left.
+GENERATE_PREDICTOR_1(4, upper[i - 1])
+#undef GENERATE_PREDICTOR_1
+
+// Due to averages with integers, values cannot be accumulated in parallel for
+// predictors 5 to 7.
+GENERATE_PREDICTOR_ADD(Predictor5_SSE2, PredictorAdd5_SSE2)
+GENERATE_PREDICTOR_ADD(Predictor6_SSE2, PredictorAdd6_SSE2)
+GENERATE_PREDICTOR_ADD(Predictor7_SSE2, PredictorAdd7_SSE2)
+
+#define GENERATE_PREDICTOR_2(X, IN) \
+static void PredictorAdd##X##_SSE2(const uint32_t* in, const uint32_t* upper, \
+ int num_pixels, uint32_t* out) { \
+ int i; \
+ for (i = 0; i + 4 <= num_pixels; i += 4) { \
+ const __m128i Tother = _mm_loadu_si128((const __m128i*)&(IN)); \
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]); \
+ const __m128i src = _mm_loadu_si128((const __m128i*)&in[i]); \
+ __m128i avg, res; \
+ Average2_m128i(&T, &Tother, &avg); \
+ res = _mm_add_epi8(avg, src); \
+ _mm_storeu_si128((__m128i*)&out[i], res); \
+ } \
+ if (i != num_pixels) { \
+ VP8LPredictorsAdd_C[(X)](in + i, upper + i, num_pixels - i, out + i); \
+ } \
+}
+// Predictor8: average TL T.
+GENERATE_PREDICTOR_2(8, upper[i - 1])
+// Predictor9: average T TR.
+GENERATE_PREDICTOR_2(9, upper[i + 1])
+#undef GENERATE_PREDICTOR_2
+
+// Predictor10: average of (average of (L,TL), average of (T, TR)).
+static void PredictorAdd10_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i, j;
+ __m128i L = _mm_cvtsi32_si128(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i TR = _mm_loadu_si128((const __m128i*)&upper[i + 1]);
+ __m128i avgTTR;
+ Average2_m128i(&T, &TR, &avgTTR);
+ for (j = 0; j < 4; ++j) {
+ __m128i avgLTL, avg;
+ Average2_m128i(&L, &TL, &avgLTL);
+ Average2_m128i(&avgTTR, &avgLTL, &avg);
+ L = _mm_add_epi8(avg, src);
+ out[i + j] = _mm_cvtsi128_si32(L);
+ // Rotate the pre-computed values for the next iteration.
+ avgTTR = _mm_srli_si128(avgTTR, 4);
+ TL = _mm_srli_si128(TL, 4);
+ src = _mm_srli_si128(src, 4);
+ }
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsAdd_C[10](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictor11: select.
+static void GetSumAbsDiff32(const __m128i* const A, const __m128i* const B,
+ __m128i* const out) {
+ // We can unpack with any value on the upper 32 bits, provided it's the same
+ // on both operands (to that their sum of abs diff is zero). Here we use *A.
+ const __m128i A_lo = _mm_unpacklo_epi32(*A, *A);
+ const __m128i B_lo = _mm_unpacklo_epi32(*B, *A);
+ const __m128i A_hi = _mm_unpackhi_epi32(*A, *A);
+ const __m128i B_hi = _mm_unpackhi_epi32(*B, *A);
+ const __m128i s_lo = _mm_sad_epu8(A_lo, B_lo);
+ const __m128i s_hi = _mm_sad_epu8(A_hi, B_hi);
+ *out = _mm_packs_epi32(s_lo, s_hi);
+}
+
+static void PredictorAdd11_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i, j;
+ __m128i L = _mm_cvtsi32_si128(out[-1]);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ __m128i pa;
+ GetSumAbsDiff32(&T, &TL, &pa); // pa = sum |T-TL|
+ for (j = 0; j < 4; ++j) {
+ const __m128i L_lo = _mm_unpacklo_epi32(L, L);
+ const __m128i TL_lo = _mm_unpacklo_epi32(TL, L);
+ const __m128i pb = _mm_sad_epu8(L_lo, TL_lo); // pb = sum |L-TL|
+ const __m128i mask = _mm_cmpgt_epi32(pb, pa);
+ const __m128i A = _mm_and_si128(mask, L);
+ const __m128i B = _mm_andnot_si128(mask, T);
+ const __m128i pred = _mm_or_si128(A, B); // pred = (L > T)? L : T
+ L = _mm_add_epi8(src, pred);
+ out[i + j] = _mm_cvtsi128_si32(L);
+ // Shift the pre-computed value for the next iteration.
+ T = _mm_srli_si128(T, 4);
+ TL = _mm_srli_si128(TL, 4);
+ src = _mm_srli_si128(src, 4);
+ pa = _mm_srli_si128(pa, 4);
+ }
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsAdd_C[11](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+
+// Predictor12: ClampedAddSubtractFull.
+#define DO_PRED12(DIFF, LANE, OUT) \
+do { \
+ const __m128i all = _mm_add_epi16(L, (DIFF)); \
+ const __m128i alls = _mm_packus_epi16(all, all); \
+ const __m128i res = _mm_add_epi8(src, alls); \
+ out[i + (OUT)] = _mm_cvtsi128_si32(res); \
+ L = _mm_unpacklo_epi8(res, zero); \
+ /* Shift the pre-computed value for the next iteration.*/ \
+ if (LANE == 0) (DIFF) = _mm_srli_si128((DIFF), 8); \
+ src = _mm_srli_si128(src, 4); \
+} while (0)
+
+static void PredictorAdd12_SSE2(const uint32_t* in, const uint32_t* upper,
+ int num_pixels, uint32_t* out) {
+ int i;
+ const __m128i zero = _mm_setzero_si128();
+ const __m128i L8 = _mm_cvtsi32_si128(out[-1]);
+ __m128i L = _mm_unpacklo_epi8(L8, zero);
+ for (i = 0; i + 4 <= num_pixels; i += 4) {
+ // Load 4 pixels at a time.
+ __m128i src = _mm_loadu_si128((const __m128i*)&in[i]);
+ const __m128i T = _mm_loadu_si128((const __m128i*)&upper[i]);
+ const __m128i T_lo = _mm_unpacklo_epi8(T, zero);
+ const __m128i T_hi = _mm_unpackhi_epi8(T, zero);
+ const __m128i TL = _mm_loadu_si128((const __m128i*)&upper[i - 1]);
+ const __m128i TL_lo = _mm_unpacklo_epi8(TL, zero);
+ const __m128i TL_hi = _mm_unpackhi_epi8(TL, zero);
+ __m128i diff_lo = _mm_sub_epi16(T_lo, TL_lo);
+ __m128i diff_hi = _mm_sub_epi16(T_hi, TL_hi);
+ DO_PRED12(diff_lo, 0, 0);
+ DO_PRED12(diff_lo, 1, 1);
+ DO_PRED12(diff_hi, 0, 2);
+ DO_PRED12(diff_hi, 1, 3);
+ }
+ if (i != num_pixels) {
+ VP8LPredictorsAdd_C[12](in + i, upper + i, num_pixels - i, out + i);
+ }
+}
+#undef DO_PRED12
+
+// Due to averages with integers, values cannot be accumulated in parallel for
+// predictors 13.
+GENERATE_PREDICTOR_ADD(Predictor13_SSE2, PredictorAdd13_SSE2)
+
//------------------------------------------------------------------------------
// Subtract-Green Transform
-static void AddGreenToBlueAndRed(uint32_t* argb_data, int num_pixels) {
+static void AddGreenToBlueAndRed(const uint32_t* const src, int num_pixels,
+ uint32_t* dst) {
int i;
for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]); // argb
+ const __m128i in = _mm_loadu_si128((const __m128i*)&src[i]); // argb
const __m128i A = _mm_srli_epi16(in, 8); // 0 a 0 g
const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // 0g0g
const __m128i out = _mm_add_epi8(in, C);
- _mm_storeu_si128((__m128i*)&argb_data[i], out);
+ _mm_storeu_si128((__m128i*)&dst[i], out);
}
// fallthrough and finish off with plain-C
- VP8LAddGreenToBlueAndRed_C(argb_data + i, num_pixels - i);
+ if (i != num_pixels) {
+ VP8LAddGreenToBlueAndRed_C(src + i, num_pixels - i, dst + i);
+ }
}
//------------------------------------------------------------------------------
// Color Transform
static void TransformColorInverse(const VP8LMultipliers* const m,
- uint32_t* argb_data, int num_pixels) {
- // sign-extended multiplying constants, pre-shifted by 5.
+ const uint32_t* const src, int num_pixels,
+ uint32_t* dst) {
+// sign-extended multiplying constants, pre-shifted by 5.
#define CST(X) (((int16_t)(m->X << 8)) >> 5) // sign-extend
const __m128i mults_rb = _mm_set_epi16(
CST(green_to_red_), CST(green_to_blue_),
@@ -188,7 +431,7 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
const __m128i mask_ag = _mm_set1_epi32(0xff00ff00); // alpha-green masks
int i;
for (i = 0; i + 4 <= num_pixels; i += 4) {
- const __m128i in = _mm_loadu_si128((__m128i*)&argb_data[i]); // argb
+ const __m128i in = _mm_loadu_si128((const __m128i*)&src[i]); // argb
const __m128i A = _mm_and_si128(in, mask_ag); // a 0 g 0
const __m128i B = _mm_shufflelo_epi16(A, _MM_SHUFFLE(2, 2, 0, 0));
const __m128i C = _mm_shufflehi_epi16(B, _MM_SHUFFLE(2, 2, 0, 0)); // g0g0
@@ -200,15 +443,53 @@ static void TransformColorInverse(const VP8LMultipliers* const m,
const __m128i I = _mm_add_epi8(H, F); // r' x b'' 0
const __m128i J = _mm_srli_epi16(I, 8); // 0 r' 0 b''
const __m128i out = _mm_or_si128(J, A);
- _mm_storeu_si128((__m128i*)&argb_data[i], out);
+ _mm_storeu_si128((__m128i*)&dst[i], out);
}
// Fall-back to C-version for left-overs.
- VP8LTransformColorInverse_C(m, argb_data + i, num_pixels - i);
+ if (i != num_pixels) {
+ VP8LTransformColorInverse_C(m, src + i, num_pixels - i, dst + i);
+ }
}
//------------------------------------------------------------------------------
// Color-space conversion functions
+static void ConvertBGRAToRGB(const uint32_t* src, int num_pixels,
+ uint8_t* dst) {
+ const __m128i* in = (const __m128i*)src;
+ __m128i* out = (__m128i*)dst;
+
+ while (num_pixels >= 32) {
+ // Load the BGRA buffers.
+ __m128i in0 = _mm_loadu_si128(in + 0);
+ __m128i in1 = _mm_loadu_si128(in + 1);
+ __m128i in2 = _mm_loadu_si128(in + 2);
+ __m128i in3 = _mm_loadu_si128(in + 3);
+ __m128i in4 = _mm_loadu_si128(in + 4);
+ __m128i in5 = _mm_loadu_si128(in + 5);
+ __m128i in6 = _mm_loadu_si128(in + 6);
+ __m128i in7 = _mm_loadu_si128(in + 7);
+ VP8L32bToPlanar(&in0, &in1, &in2, &in3);
+ VP8L32bToPlanar(&in4, &in5, &in6, &in7);
+ // At this points, in1/in5 contains red only, in2/in6 green only ...
+ // Pack the colors in 24b RGB.
+ VP8PlanarTo24b(&in1, &in5, &in2, &in6, &in3, &in7);
+ _mm_storeu_si128(out + 0, in1);
+ _mm_storeu_si128(out + 1, in5);
+ _mm_storeu_si128(out + 2, in2);
+ _mm_storeu_si128(out + 3, in6);
+ _mm_storeu_si128(out + 4, in3);
+ _mm_storeu_si128(out + 5, in7);
+ in += 8;
+ out += 6;
+ num_pixels -= 32;
+ }
+ // left-overs
+ if (num_pixels > 0) {
+ VP8LConvertBGRAToRGB_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ }
+}
+
static void ConvertBGRAToRGBA(const uint32_t* src,
int num_pixels, uint8_t* dst) {
const __m128i* in = (const __m128i*)src;
@@ -233,7 +514,9 @@ static void ConvertBGRAToRGBA(const uint32_t* src,
num_pixels -= 8;
}
// left-overs
- VP8LConvertBGRAToRGBA_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ if (num_pixels > 0) {
+ VP8LConvertBGRAToRGBA_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ }
}
static void ConvertBGRAToRGBA4444(const uint32_t* src,
@@ -267,7 +550,9 @@ static void ConvertBGRAToRGBA4444(const uint32_t* src,
num_pixels -= 8;
}
// left-overs
- VP8LConvertBGRAToRGBA4444_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ if (num_pixels > 0) {
+ VP8LConvertBGRAToRGBA4444_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ }
}
static void ConvertBGRAToRGB565(const uint32_t* src,
@@ -306,7 +591,9 @@ static void ConvertBGRAToRGB565(const uint32_t* src,
num_pixels -= 8;
}
// left-overs
- VP8LConvertBGRAToRGB565_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ if (num_pixels > 0) {
+ VP8LConvertBGRAToRGB565_C((const uint32_t*)in, num_pixels, (uint8_t*)out);
+ }
}
static void ConvertBGRAToBGR(const uint32_t* src,
@@ -337,7 +624,9 @@ static void ConvertBGRAToBGR(const uint32_t* src,
num_pixels -= 8;
}
// left-overs
- VP8LConvertBGRAToBGR_C((const uint32_t*)in, num_pixels, dst);
+ if (num_pixels > 0) {
+ VP8LConvertBGRAToBGR_C((const uint32_t*)in, num_pixels, dst);
+ }
}
//------------------------------------------------------------------------------
@@ -346,19 +635,35 @@ static void ConvertBGRAToBGR(const uint32_t* src,
extern void VP8LDspInitSSE2(void);
WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitSSE2(void) {
- VP8LPredictors[5] = Predictor5;
- VP8LPredictors[6] = Predictor6;
- VP8LPredictors[7] = Predictor7;
- VP8LPredictors[8] = Predictor8;
- VP8LPredictors[9] = Predictor9;
- VP8LPredictors[10] = Predictor10;
- VP8LPredictors[11] = Predictor11;
- VP8LPredictors[12] = Predictor12;
- VP8LPredictors[13] = Predictor13;
+ VP8LPredictors[5] = Predictor5_SSE2;
+ VP8LPredictors[6] = Predictor6_SSE2;
+ VP8LPredictors[7] = Predictor7_SSE2;
+ VP8LPredictors[8] = Predictor8_SSE2;
+ VP8LPredictors[9] = Predictor9_SSE2;
+ VP8LPredictors[10] = Predictor10_SSE2;
+ VP8LPredictors[11] = Predictor11_SSE2;
+ VP8LPredictors[12] = Predictor12_SSE2;
+ VP8LPredictors[13] = Predictor13_SSE2;
+
+ VP8LPredictorsAdd[0] = PredictorAdd0_SSE2;
+ VP8LPredictorsAdd[1] = PredictorAdd1_SSE2;
+ VP8LPredictorsAdd[2] = PredictorAdd2_SSE2;
+ VP8LPredictorsAdd[3] = PredictorAdd3_SSE2;
+ VP8LPredictorsAdd[4] = PredictorAdd4_SSE2;
+ VP8LPredictorsAdd[5] = PredictorAdd5_SSE2;
+ VP8LPredictorsAdd[6] = PredictorAdd6_SSE2;
+ VP8LPredictorsAdd[7] = PredictorAdd7_SSE2;
+ VP8LPredictorsAdd[8] = PredictorAdd8_SSE2;
+ VP8LPredictorsAdd[9] = PredictorAdd9_SSE2;
+ VP8LPredictorsAdd[10] = PredictorAdd10_SSE2;
+ VP8LPredictorsAdd[11] = PredictorAdd11_SSE2;
+ VP8LPredictorsAdd[12] = PredictorAdd12_SSE2;
+ VP8LPredictorsAdd[13] = PredictorAdd13_SSE2;
VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed;
VP8LTransformColorInverse = TransformColorInverse;
+ VP8LConvertBGRAToRGB = ConvertBGRAToRGB;
VP8LConvertBGRAToRGBA = ConvertBGRAToRGBA;
VP8LConvertBGRAToRGBA4444 = ConvertBGRAToRGBA4444;
VP8LConvertBGRAToRGB565 = ConvertBGRAToRGB565;
diff --git a/thirdparty/libwebp/dsp/msa_macro.h b/thirdparty/libwebp/dsp/msa_macro.h
index 5c707f476a..d0e5f45e01 100644
--- a/thirdparty/libwebp/dsp/msa_macro.h
+++ b/thirdparty/libwebp/dsp/msa_macro.h
@@ -23,12 +23,24 @@
#ifdef CLANG_BUILD
#define ADDVI_H(a, b) __msa_addvi_h((v8i16)a, b)
+ #define ADDVI_W(a, b) __msa_addvi_w((v4i32)a, b)
+ #define SRAI_B(a, b) __msa_srai_b((v16i8)a, b)
#define SRAI_H(a, b) __msa_srai_h((v8i16)a, b)
#define SRAI_W(a, b) __msa_srai_w((v4i32)a, b)
+ #define SRLI_H(a, b) __msa_srli_h((v8i16)a, b)
+ #define SLLI_B(a, b) __msa_slli_b((v4i32)a, b)
+ #define ANDI_B(a, b) __msa_andi_b((v16u8)a, b)
+ #define ORI_B(a, b) __msa_ori_b((v16u8)a, b)
#else
#define ADDVI_H(a, b) (a + b)
+ #define ADDVI_W(a, b) (a + b)
+ #define SRAI_B(a, b) (a >> b)
#define SRAI_H(a, b) (a >> b)
#define SRAI_W(a, b) (a >> b)
+ #define SRLI_H(a, b) (a << b)
+ #define SLLI_B(a, b) (a << b)
+ #define ANDI_B(a, b) (a & b)
+ #define ORI_B(a, b) (a | b)
#endif
#define LD_B(RTYPE, psrc) *((RTYPE*)(psrc))
@@ -116,13 +128,13 @@
#define SH(val, pdst) MSA_STORE(val, pdst, msa_ush)
MSA_STORE_FUNC(uint32_t, usw, msa_usw);
#define SW(val, pdst) MSA_STORE(val, pdst, msa_usw)
- #define SD(val, pdst) { \
+ #define SD(val, pdst) do { \
uint8_t* const pdst_sd_m = (uint8_t*)(pdst); \
const uint32_t val0_m = (uint32_t)(val & 0x00000000FFFFFFFF); \
const uint32_t val1_m = (uint32_t)((val >> 32) & 0x00000000FFFFFFFF); \
SW(val0_m, pdst_sd_m); \
SW(val1_m, pdst_sd_m + 4); \
- }
+ } while (0)
#endif // (__mips_isa_rev >= 6)
/* Description : Load 4 words with stride
@@ -133,34 +145,68 @@
* Load word in 'out2' from (psrc + 2 * stride)
* Load word in 'out3' from (psrc + 3 * stride)
*/
-#define LW4(psrc, stride, out0, out1, out2, out3) { \
- const uint8_t* ptmp = (const uint8_t*)psrc; \
- out0 = LW(ptmp); \
- ptmp += stride; \
- out1 = LW(ptmp); \
- ptmp += stride; \
- out2 = LW(ptmp); \
- ptmp += stride; \
- out3 = LW(ptmp); \
-}
+#define LW4(psrc, stride, out0, out1, out2, out3) do { \
+ const uint8_t* ptmp = (const uint8_t*)psrc; \
+ out0 = LW(ptmp); \
+ ptmp += stride; \
+ out1 = LW(ptmp); \
+ ptmp += stride; \
+ out2 = LW(ptmp); \
+ ptmp += stride; \
+ out3 = LW(ptmp); \
+} while (0)
-/* Description : Store 4 words with stride
+/* Description : Store words with stride
* Arguments : Inputs - in0, in1, in2, in3, pdst, stride
* Details : Store word from 'in0' to (pdst)
* Store word from 'in1' to (pdst + stride)
* Store word from 'in2' to (pdst + 2 * stride)
* Store word from 'in3' to (pdst + 3 * stride)
*/
-#define SW4(in0, in1, in2, in3, pdst, stride) { \
- uint8_t* ptmp = (uint8_t*)pdst; \
- SW(in0, ptmp); \
- ptmp += stride; \
- SW(in1, ptmp); \
- ptmp += stride; \
- SW(in2, ptmp); \
- ptmp += stride; \
- SW(in3, ptmp); \
-}
+#define SW4(in0, in1, in2, in3, pdst, stride) do { \
+ uint8_t* ptmp = (uint8_t*)pdst; \
+ SW(in0, ptmp); \
+ ptmp += stride; \
+ SW(in1, ptmp); \
+ ptmp += stride; \
+ SW(in2, ptmp); \
+ ptmp += stride; \
+ SW(in3, ptmp); \
+} while (0)
+
+#define SW3(in0, in1, in2, pdst, stride) do { \
+ uint8_t* ptmp = (uint8_t*)pdst; \
+ SW(in0, ptmp); \
+ ptmp += stride; \
+ SW(in1, ptmp); \
+ ptmp += stride; \
+ SW(in2, ptmp); \
+} while (0)
+
+#define SW2(in0, in1, pdst, stride) do { \
+ uint8_t* ptmp = (uint8_t*)pdst; \
+ SW(in0, ptmp); \
+ ptmp += stride; \
+ SW(in1, ptmp); \
+} while (0)
+
+/* Description : Store 4 double words with stride
+ * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
+ * Details : Store double word from 'in0' to (pdst)
+ * Store double word from 'in1' to (pdst + stride)
+ * Store double word from 'in2' to (pdst + 2 * stride)
+ * Store double word from 'in3' to (pdst + 3 * stride)
+ */
+#define SD4(in0, in1, in2, in3, pdst, stride) do { \
+ uint8_t* ptmp = (uint8_t*)pdst; \
+ SD(in0, ptmp); \
+ ptmp += stride; \
+ SD(in1, ptmp); \
+ ptmp += stride; \
+ SD(in2, ptmp); \
+ ptmp += stride; \
+ SD(in3, ptmp); \
+} while (0)
/* Description : Load vectors with 16 byte elements with stride
* Arguments : Inputs - psrc, stride
@@ -169,33 +215,169 @@
* Details : Load 16 byte elements in 'out0' from (psrc)
* Load 16 byte elements in 'out1' from (psrc + stride)
*/
-#define LD_B2(RTYPE, psrc, stride, out0, out1) { \
- out0 = LD_B(RTYPE, psrc); \
- out1 = LD_B(RTYPE, psrc + stride); \
-}
+#define LD_B2(RTYPE, psrc, stride, out0, out1) do { \
+ out0 = LD_B(RTYPE, psrc); \
+ out1 = LD_B(RTYPE, psrc + stride); \
+} while (0)
#define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__)
#define LD_SB2(...) LD_B2(v16i8, __VA_ARGS__)
-#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) { \
- LD_B2(RTYPE, psrc, stride, out0, out1); \
- LD_B2(RTYPE, psrc + 2 * stride , stride, out2, out3); \
-}
+#define LD_B3(RTYPE, psrc, stride, out0, out1, out2) do { \
+ LD_B2(RTYPE, psrc, stride, out0, out1); \
+ out2 = LD_B(RTYPE, psrc + 2 * stride); \
+} while (0)
+#define LD_UB3(...) LD_B3(v16u8, __VA_ARGS__)
+#define LD_SB3(...) LD_B3(v16i8, __VA_ARGS__)
+
+#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) do { \
+ LD_B2(RTYPE, psrc, stride, out0, out1); \
+ LD_B2(RTYPE, psrc + 2 * stride , stride, out2, out3); \
+} while (0)
#define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__)
#define LD_SB4(...) LD_B4(v16i8, __VA_ARGS__)
+#define LD_B8(RTYPE, psrc, stride, \
+ out0, out1, out2, out3, out4, out5, out6, out7) do { \
+ LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3); \
+ LD_B4(RTYPE, psrc + 4 * stride, stride, out4, out5, out6, out7); \
+} while (0)
+#define LD_UB8(...) LD_B8(v16u8, __VA_ARGS__)
+#define LD_SB8(...) LD_B8(v16i8, __VA_ARGS__)
+
/* Description : Load vectors with 8 halfword elements with stride
* Arguments : Inputs - psrc, stride
* Outputs - out0, out1
* Details : Load 8 halfword elements in 'out0' from (psrc)
* Load 8 halfword elements in 'out1' from (psrc + stride)
*/
-#define LD_H2(RTYPE, psrc, stride, out0, out1) { \
- out0 = LD_H(RTYPE, psrc); \
- out1 = LD_H(RTYPE, psrc + stride); \
-}
+#define LD_H2(RTYPE, psrc, stride, out0, out1) do { \
+ out0 = LD_H(RTYPE, psrc); \
+ out1 = LD_H(RTYPE, psrc + stride); \
+} while (0)
#define LD_UH2(...) LD_H2(v8u16, __VA_ARGS__)
#define LD_SH2(...) LD_H2(v8i16, __VA_ARGS__)
+/* Description : Load vectors with 4 word elements with stride
+ * Arguments : Inputs - psrc, stride
+ * Outputs - out0, out1, out2, out3
+ * Details : Load 4 word elements in 'out0' from (psrc + 0 * stride)
+ * Load 4 word elements in 'out1' from (psrc + 1 * stride)
+ * Load 4 word elements in 'out2' from (psrc + 2 * stride)
+ * Load 4 word elements in 'out3' from (psrc + 3 * stride)
+ */
+#define LD_W2(RTYPE, psrc, stride, out0, out1) do { \
+ out0 = LD_W(RTYPE, psrc); \
+ out1 = LD_W(RTYPE, psrc + stride); \
+} while (0)
+#define LD_UW2(...) LD_W2(v4u32, __VA_ARGS__)
+#define LD_SW2(...) LD_W2(v4i32, __VA_ARGS__)
+
+#define LD_W3(RTYPE, psrc, stride, out0, out1, out2) do { \
+ LD_W2(RTYPE, psrc, stride, out0, out1); \
+ out2 = LD_W(RTYPE, psrc + 2 * stride); \
+} while (0)
+#define LD_UW3(...) LD_W3(v4u32, __VA_ARGS__)
+#define LD_SW3(...) LD_W3(v4i32, __VA_ARGS__)
+
+#define LD_W4(RTYPE, psrc, stride, out0, out1, out2, out3) do { \
+ LD_W2(RTYPE, psrc, stride, out0, out1); \
+ LD_W2(RTYPE, psrc + 2 * stride, stride, out2, out3); \
+} while (0)
+#define LD_UW4(...) LD_W4(v4u32, __VA_ARGS__)
+#define LD_SW4(...) LD_W4(v4i32, __VA_ARGS__)
+
+/* Description : Store vectors of 16 byte elements with stride
+ * Arguments : Inputs - in0, in1, pdst, stride
+ * Details : Store 16 byte elements from 'in0' to (pdst)
+ * Store 16 byte elements from 'in1' to (pdst + stride)
+ */
+#define ST_B2(RTYPE, in0, in1, pdst, stride) do { \
+ ST_B(RTYPE, in0, pdst); \
+ ST_B(RTYPE, in1, pdst + stride); \
+} while (0)
+#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
+#define ST_SB2(...) ST_B2(v16i8, __VA_ARGS__)
+
+#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) do { \
+ ST_B2(RTYPE, in0, in1, pdst, stride); \
+ ST_B2(RTYPE, in2, in3, pdst + 2 * stride, stride); \
+} while (0)
+#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
+#define ST_SB4(...) ST_B4(v16i8, __VA_ARGS__)
+
+#define ST_B8(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
+ pdst, stride) do { \
+ ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride); \
+ ST_B4(RTYPE, in4, in5, in6, in7, pdst + 4 * stride, stride); \
+} while (0)
+#define ST_UB8(...) ST_B8(v16u8, __VA_ARGS__)
+
+/* Description : Store vectors of 4 word elements with stride
+ * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
+ * Details : Store 4 word elements from 'in0' to (pdst + 0 * stride)
+ * Store 4 word elements from 'in1' to (pdst + 1 * stride)
+ * Store 4 word elements from 'in2' to (pdst + 2 * stride)
+ * Store 4 word elements from 'in3' to (pdst + 3 * stride)
+ */
+#define ST_W2(RTYPE, in0, in1, pdst, stride) do { \
+ ST_W(RTYPE, in0, pdst); \
+ ST_W(RTYPE, in1, pdst + stride); \
+} while (0)
+#define ST_UW2(...) ST_W2(v4u32, __VA_ARGS__)
+#define ST_SW2(...) ST_W2(v4i32, __VA_ARGS__)
+
+#define ST_W3(RTYPE, in0, in1, in2, pdst, stride) do { \
+ ST_W2(RTYPE, in0, in1, pdst, stride); \
+ ST_W(RTYPE, in2, pdst + 2 * stride); \
+} while (0)
+#define ST_UW3(...) ST_W3(v4u32, __VA_ARGS__)
+#define ST_SW3(...) ST_W3(v4i32, __VA_ARGS__)
+
+#define ST_W4(RTYPE, in0, in1, in2, in3, pdst, stride) do { \
+ ST_W2(RTYPE, in0, in1, pdst, stride); \
+ ST_W2(RTYPE, in2, in3, pdst + 2 * stride, stride); \
+} while (0)
+#define ST_UW4(...) ST_W4(v4u32, __VA_ARGS__)
+#define ST_SW4(...) ST_W4(v4i32, __VA_ARGS__)
+
+/* Description : Store vectors of 8 halfword elements with stride
+ * Arguments : Inputs - in0, in1, pdst, stride
+ * Details : Store 8 halfword elements from 'in0' to (pdst)
+ * Store 8 halfword elements from 'in1' to (pdst + stride)
+ */
+#define ST_H2(RTYPE, in0, in1, pdst, stride) do { \
+ ST_H(RTYPE, in0, pdst); \
+ ST_H(RTYPE, in1, pdst + stride); \
+} while (0)
+#define ST_UH2(...) ST_H2(v8u16, __VA_ARGS__)
+#define ST_SH2(...) ST_H2(v8i16, __VA_ARGS__)
+
+/* Description : Store 2x4 byte block to destination memory from input vector
+ * Arguments : Inputs - in, stidx, pdst, stride
+ * Details : Index 'stidx' halfword element from 'in' vector is copied to
+ * the GP register and stored to (pdst)
+ * Index 'stidx+1' halfword element from 'in' vector is copied to
+ * the GP register and stored to (pdst + stride)
+ * Index 'stidx+2' halfword element from 'in' vector is copied to
+ * the GP register and stored to (pdst + 2 * stride)
+ * Index 'stidx+3' halfword element from 'in' vector is copied to
+ * the GP register and stored to (pdst + 3 * stride)
+ */
+#define ST2x4_UB(in, stidx, pdst, stride) do { \
+ uint8_t* pblk_2x4_m = (uint8_t*)pdst; \
+ const uint16_t out0_m = __msa_copy_s_h((v8i16)in, stidx); \
+ const uint16_t out1_m = __msa_copy_s_h((v8i16)in, stidx + 1); \
+ const uint16_t out2_m = __msa_copy_s_h((v8i16)in, stidx + 2); \
+ const uint16_t out3_m = __msa_copy_s_h((v8i16)in, stidx + 3); \
+ SH(out0_m, pblk_2x4_m); \
+ pblk_2x4_m += stride; \
+ SH(out1_m, pblk_2x4_m); \
+ pblk_2x4_m += stride; \
+ SH(out2_m, pblk_2x4_m); \
+ pblk_2x4_m += stride; \
+ SH(out3_m, pblk_2x4_m); \
+} while (0)
+
/* Description : Store 4x4 byte block to destination memory from input vector
* Arguments : Inputs - in0, in1, pdst, stride
* Details : 'Idx0' word element from input vector 'in0' is copied to the
@@ -207,14 +389,20 @@
* 'Idx3' word element from input vector 'in0' is copied to the
* GP register and stored to (pdst + 3 * stride)
*/
-#define ST4x4_UB(in0, in1, idx0, idx1, idx2, idx3, pdst, stride) { \
- uint8_t* const pblk_4x4_m = (uint8_t*)pdst; \
- const uint32_t out0_m = __msa_copy_s_w((v4i32)in0, idx0); \
- const uint32_t out1_m = __msa_copy_s_w((v4i32)in0, idx1); \
- const uint32_t out2_m = __msa_copy_s_w((v4i32)in1, idx2); \
- const uint32_t out3_m = __msa_copy_s_w((v4i32)in1, idx3); \
- SW4(out0_m, out1_m, out2_m, out3_m, pblk_4x4_m, stride); \
-}
+#define ST4x4_UB(in0, in1, idx0, idx1, idx2, idx3, pdst, stride) do { \
+ uint8_t* const pblk_4x4_m = (uint8_t*)pdst; \
+ const uint32_t out0_m = __msa_copy_s_w((v4i32)in0, idx0); \
+ const uint32_t out1_m = __msa_copy_s_w((v4i32)in0, idx1); \
+ const uint32_t out2_m = __msa_copy_s_w((v4i32)in1, idx2); \
+ const uint32_t out3_m = __msa_copy_s_w((v4i32)in1, idx3); \
+ SW4(out0_m, out1_m, out2_m, out3_m, pblk_4x4_m, stride); \
+} while (0)
+
+#define ST4x8_UB(in0, in1, pdst, stride) do { \
+ uint8_t* const pblk_4x8 = (uint8_t*)pdst; \
+ ST4x4_UB(in0, in0, 0, 1, 2, 3, pblk_4x8, stride); \
+ ST4x4_UB(in1, in1, 0, 1, 2, 3, pblk_4x8 + 4 * stride, stride); \
+} while (0)
/* Description : Immediate number of elements to slide
* Arguments : Inputs - in0, in1, slide_val
@@ -230,6 +418,30 @@
#define SLDI_SB(...) SLDI_B(v16i8, __VA_ARGS__)
#define SLDI_SH(...) SLDI_B(v8i16, __VA_ARGS__)
+/* Description : Shuffle byte vector elements as per mask vector
+ * Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Byte elements from 'in0' & 'in1' are copied selectively to
+ * 'out0' as per control vector 'mask0'
+ */
+#define VSHF_B(RTYPE, in0, in1, mask) \
+ (RTYPE)__msa_vshf_b((v16i8)mask, (v16i8)in1, (v16i8)in0)
+
+#define VSHF_UB(...) VSHF_B(v16u8, __VA_ARGS__)
+#define VSHF_SB(...) VSHF_B(v16i8, __VA_ARGS__)
+#define VSHF_UH(...) VSHF_B(v8u16, __VA_ARGS__)
+#define VSHF_SH(...) VSHF_B(v8i16, __VA_ARGS__)
+
+#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) do { \
+ out0 = VSHF_B(RTYPE, in0, in1, mask0); \
+ out1 = VSHF_B(RTYPE, in2, in3, mask1); \
+} while (0)
+#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
+#define VSHF_B2_SB(...) VSHF_B2(v16i8, __VA_ARGS__)
+#define VSHF_B2_UH(...) VSHF_B2(v8u16, __VA_ARGS__)
+#define VSHF_B2_SH(...) VSHF_B2(v8i16, __VA_ARGS__)
+
/* Description : Shuffle halfword vector elements as per mask vector
* Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
* Outputs - out0, out1
@@ -237,44 +449,219 @@
* Details : halfword elements from 'in0' & 'in1' are copied selectively to
* 'out0' as per control vector 'mask0'
*/
-#define VSHF_H2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) { \
- out0 = (RTYPE)__msa_vshf_h((v8i16)mask0, (v8i16)in1, (v8i16)in0); \
- out1 = (RTYPE)__msa_vshf_h((v8i16)mask1, (v8i16)in3, (v8i16)in2); \
-}
+#define VSHF_H2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) do { \
+ out0 = (RTYPE)__msa_vshf_h((v8i16)mask0, (v8i16)in1, (v8i16)in0); \
+ out1 = (RTYPE)__msa_vshf_h((v8i16)mask1, (v8i16)in3, (v8i16)in2); \
+} while (0)
#define VSHF_H2_UH(...) VSHF_H2(v8u16, __VA_ARGS__)
#define VSHF_H2_SH(...) VSHF_H2(v8i16, __VA_ARGS__)
+/* Description : Dot product of byte vector elements
+ * Arguments : Inputs - mult0, mult1, cnst0, cnst1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Signed byte elements from 'mult0' are multiplied with
+ * signed byte elements from 'cnst0' producing a result
+ * twice the size of input i.e. signed halfword.
+ * The multiplication result of adjacent odd-even elements
+ * are added together and written to the 'out0' vector
+*/
+#define DOTP_SB2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
+ out0 = (RTYPE)__msa_dotp_s_h((v16i8)mult0, (v16i8)cnst0); \
+ out1 = (RTYPE)__msa_dotp_s_h((v16i8)mult1, (v16i8)cnst1); \
+} while (0)
+#define DOTP_SB2_SH(...) DOTP_SB2(v8i16, __VA_ARGS__)
+
+/* Description : Dot product of halfword vector elements
+ * Arguments : Inputs - mult0, mult1, cnst0, cnst1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Signed halfword elements from 'mult0' are multiplied with
+ * signed halfword elements from 'cnst0' producing a result
+ * twice the size of input i.e. signed word.
+ * The multiplication result of adjacent odd-even elements
+ * are added together and written to the 'out0' vector
+ */
+#define DOTP_SH2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
+ out0 = (RTYPE)__msa_dotp_s_w((v8i16)mult0, (v8i16)cnst0); \
+ out1 = (RTYPE)__msa_dotp_s_w((v8i16)mult1, (v8i16)cnst1); \
+} while (0)
+#define DOTP_SH2_SW(...) DOTP_SH2(v4i32, __VA_ARGS__)
+
+/* Description : Dot product of unsigned word vector elements
+ * Arguments : Inputs - mult0, mult1, cnst0, cnst1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Unsigned word elements from 'mult0' are multiplied with
+ * unsigned word elements from 'cnst0' producing a result
+ * twice the size of input i.e. unsigned double word.
+ * The multiplication result of adjacent odd-even elements
+ * are added together and written to the 'out0' vector
+ */
+#define DOTP_UW2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
+ out0 = (RTYPE)__msa_dotp_u_d((v4u32)mult0, (v4u32)cnst0); \
+ out1 = (RTYPE)__msa_dotp_u_d((v4u32)mult1, (v4u32)cnst1); \
+} while (0)
+#define DOTP_UW2_UD(...) DOTP_UW2(v2u64, __VA_ARGS__)
+
+/* Description : Dot product & addition of halfword vector elements
+ * Arguments : Inputs - mult0, mult1, cnst0, cnst1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Signed halfword elements from 'mult0' are multiplied with
+ * signed halfword elements from 'cnst0' producing a result
+ * twice the size of input i.e. signed word.
+ * The multiplication result of adjacent odd-even elements
+ * are added to the 'out0' vector
+ */
+#define DPADD_SH2(RTYPE, mult0, mult1, cnst0, cnst1, out0, out1) do { \
+ out0 = (RTYPE)__msa_dpadd_s_w((v4i32)out0, (v8i16)mult0, (v8i16)cnst0); \
+ out1 = (RTYPE)__msa_dpadd_s_w((v4i32)out1, (v8i16)mult1, (v8i16)cnst1); \
+} while (0)
+#define DPADD_SH2_SW(...) DPADD_SH2(v4i32, __VA_ARGS__)
+
/* Description : Clips all signed halfword elements of input vector
* between 0 & 255
* Arguments : Input/output - val
* Return Type - signed halfword
*/
-#define CLIP_SH_0_255(val) { \
+#define CLIP_SH_0_255(val) do { \
const v8i16 max_m = __msa_ldi_h(255); \
val = __msa_maxi_s_h((v8i16)val, 0); \
val = __msa_min_s_h(max_m, (v8i16)val); \
-}
-#define CLIP_SH2_0_255(in0, in1) { \
- CLIP_SH_0_255(in0); \
- CLIP_SH_0_255(in1); \
-}
+} while (0)
+
+#define CLIP_SH2_0_255(in0, in1) do { \
+ CLIP_SH_0_255(in0); \
+ CLIP_SH_0_255(in1); \
+} while (0)
+
+#define CLIP_SH4_0_255(in0, in1, in2, in3) do { \
+ CLIP_SH2_0_255(in0, in1); \
+ CLIP_SH2_0_255(in2, in3); \
+} while (0)
+
+/* Description : Clips all unsigned halfword elements of input vector
+ * between 0 & 255
+ * Arguments : Input - in
+ * Output - out_m
+ * Return Type - unsigned halfword
+ */
+#define CLIP_UH_0_255(in) do { \
+ const v8u16 max_m = (v8u16)__msa_ldi_h(255); \
+ in = __msa_maxi_u_h((v8u16) in, 0); \
+ in = __msa_min_u_h((v8u16) max_m, (v8u16) in); \
+} while (0)
+
+#define CLIP_UH2_0_255(in0, in1) do { \
+ CLIP_UH_0_255(in0); \
+ CLIP_UH_0_255(in1); \
+} while (0)
/* Description : Clips all signed word elements of input vector
* between 0 & 255
* Arguments : Input/output - val
* Return Type - signed word
*/
-#define CLIP_SW_0_255(val) { \
+#define CLIP_SW_0_255(val) do { \
const v4i32 max_m = __msa_ldi_w(255); \
val = __msa_maxi_s_w((v4i32)val, 0); \
val = __msa_min_s_w(max_m, (v4i32)val); \
+} while (0)
+
+#define CLIP_SW4_0_255(in0, in1, in2, in3) do { \
+ CLIP_SW_0_255(in0); \
+ CLIP_SW_0_255(in1); \
+ CLIP_SW_0_255(in2); \
+ CLIP_SW_0_255(in3); \
+} while (0)
+
+/* Description : Horizontal addition of 4 signed word elements of input vector
+ * Arguments : Input - in (signed word vector)
+ * Output - sum_m (i32 sum)
+ * Return Type - signed word (GP)
+ * Details : 4 signed word elements of 'in' vector are added together and
+ * the resulting integer sum is returned
+ */
+static WEBP_INLINE int32_t func_hadd_sw_s32(v4i32 in) {
+ const v2i64 res0_m = __msa_hadd_s_d((v4i32)in, (v4i32)in);
+ const v2i64 res1_m = __msa_splati_d(res0_m, 1);
+ const v2i64 out = res0_m + res1_m;
+ int32_t sum_m = __msa_copy_s_w((v4i32)out, 0);
+ return sum_m;
}
-#define CLIP_SW4_0_255(in0, in1, in2, in3) { \
- CLIP_SW_0_255(in0); \
- CLIP_SW_0_255(in1); \
- CLIP_SW_0_255(in2); \
- CLIP_SW_0_255(in3); \
+#define HADD_SW_S32(in) func_hadd_sw_s32(in)
+
+/* Description : Horizontal addition of 8 signed halfword elements
+ * Arguments : Input - in (signed halfword vector)
+ * Output - sum_m (s32 sum)
+ * Return Type - signed word
+ * Details : 8 signed halfword elements of input vector are added
+ * together and the resulting integer sum is returned
+ */
+static WEBP_INLINE int32_t func_hadd_sh_s32(v8i16 in) {
+ const v4i32 res = __msa_hadd_s_w(in, in);
+ const v2i64 res0 = __msa_hadd_s_d(res, res);
+ const v2i64 res1 = __msa_splati_d(res0, 1);
+ const v2i64 res2 = res0 + res1;
+ const int32_t sum_m = __msa_copy_s_w((v4i32)res2, 0);
+ return sum_m;
+}
+#define HADD_SH_S32(in) func_hadd_sh_s32(in)
+
+/* Description : Horizontal addition of 8 unsigned halfword elements
+ * Arguments : Input - in (unsigned halfword vector)
+ * Output - sum_m (u32 sum)
+ * Return Type - unsigned word
+ * Details : 8 unsigned halfword elements of input vector are added
+ * together and the resulting integer sum is returned
+ */
+static WEBP_INLINE uint32_t func_hadd_uh_u32(v8u16 in) {
+ uint32_t sum_m;
+ const v4u32 res_m = __msa_hadd_u_w(in, in);
+ v2u64 res0_m = __msa_hadd_u_d(res_m, res_m);
+ v2u64 res1_m = (v2u64)__msa_splati_d((v2i64)res0_m, 1);
+ res0_m = res0_m + res1_m;
+ sum_m = __msa_copy_s_w((v4i32)res0_m, 0);
+ return sum_m;
}
+#define HADD_UH_U32(in) func_hadd_uh_u32(in)
+
+/* Description : Horizontal addition of signed half word vector elements
+ Arguments : Inputs - in0, in1
+ Outputs - out0, out1
+ Return Type - as per RTYPE
+ Details : Each signed odd half word element from 'in0' is added to
+ even signed half word element from 'in0' (pairwise) and the
+ halfword result is written in 'out0'
+*/
+#define HADD_SH2(RTYPE, in0, in1, out0, out1) do { \
+ out0 = (RTYPE)__msa_hadd_s_w((v8i16)in0, (v8i16)in0); \
+ out1 = (RTYPE)__msa_hadd_s_w((v8i16)in1, (v8i16)in1); \
+} while (0)
+#define HADD_SH2_SW(...) HADD_SH2(v4i32, __VA_ARGS__)
+
+#define HADD_SH4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) do { \
+ HADD_SH2(RTYPE, in0, in1, out0, out1); \
+ HADD_SH2(RTYPE, in2, in3, out2, out3); \
+} while (0)
+#define HADD_SH4_SW(...) HADD_SH4(v4i32, __VA_ARGS__)
+
+/* Description : Horizontal subtraction of unsigned byte vector elements
+ * Arguments : Inputs - in0, in1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Each unsigned odd byte element from 'in0' is subtracted from
+ * even unsigned byte element from 'in0' (pairwise) and the
+ * halfword result is written to 'out0'
+ */
+#define HSUB_UB2(RTYPE, in0, in1, out0, out1) do { \
+ out0 = (RTYPE)__msa_hsub_u_h((v16u8)in0, (v16u8)in0); \
+ out1 = (RTYPE)__msa_hsub_u_h((v16u8)in1, (v16u8)in1); \
+} while (0)
+#define HSUB_UB2_UH(...) HSUB_UB2(v8u16, __VA_ARGS__)
+#define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__)
+#define HSUB_UB2_SW(...) HSUB_UB2(v4i32, __VA_ARGS__)
/* Description : Set element n input vector to GPR value
* Arguments : Inputs - in0, in1, in2, in3
@@ -282,23 +669,188 @@
* Return Type - as per RTYPE
* Details : Set element 0 in vector 'out' to value specified in 'in0'
*/
-#define INSERT_W2(RTYPE, in0, in1, out) { \
+#define INSERT_W2(RTYPE, in0, in1, out) do { \
out = (RTYPE)__msa_insert_w((v4i32)out, 0, in0); \
out = (RTYPE)__msa_insert_w((v4i32)out, 1, in1); \
-}
+} while (0)
#define INSERT_W2_UB(...) INSERT_W2(v16u8, __VA_ARGS__)
#define INSERT_W2_SB(...) INSERT_W2(v16i8, __VA_ARGS__)
-#define INSERT_W4(RTYPE, in0, in1, in2, in3, out) { \
- out = (RTYPE)__msa_insert_w((v4i32)out, 0, in0); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 1, in1); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 2, in2); \
- out = (RTYPE)__msa_insert_w((v4i32)out, 3, in3); \
-}
+#define INSERT_W4(RTYPE, in0, in1, in2, in3, out) do { \
+ out = (RTYPE)__msa_insert_w((v4i32)out, 0, in0); \
+ out = (RTYPE)__msa_insert_w((v4i32)out, 1, in1); \
+ out = (RTYPE)__msa_insert_w((v4i32)out, 2, in2); \
+ out = (RTYPE)__msa_insert_w((v4i32)out, 3, in3); \
+} while (0)
#define INSERT_W4_UB(...) INSERT_W4(v16u8, __VA_ARGS__)
#define INSERT_W4_SB(...) INSERT_W4(v16i8, __VA_ARGS__)
#define INSERT_W4_SW(...) INSERT_W4(v4i32, __VA_ARGS__)
+/* Description : Set element n of double word input vector to GPR value
+ * Arguments : Inputs - in0, in1
+ * Output - out
+ * Return Type - as per RTYPE
+ * Details : Set element 0 in vector 'out' to GPR value specified in 'in0'
+ * Set element 1 in vector 'out' to GPR value specified in 'in1'
+ */
+#define INSERT_D2(RTYPE, in0, in1, out) do { \
+ out = (RTYPE)__msa_insert_d((v2i64)out, 0, in0); \
+ out = (RTYPE)__msa_insert_d((v2i64)out, 1, in1); \
+} while (0)
+#define INSERT_D2_UB(...) INSERT_D2(v16u8, __VA_ARGS__)
+#define INSERT_D2_SB(...) INSERT_D2(v16i8, __VA_ARGS__)
+
+/* Description : Interleave even byte elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even byte elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_b((v16i8)in1, (v16i8)in0); \
+ out1 = (RTYPE)__msa_ilvev_b((v16i8)in3, (v16i8)in2); \
+} while (0)
+#define ILVEV_B2_UB(...) ILVEV_B2(v16u8, __VA_ARGS__)
+#define ILVEV_B2_SB(...) ILVEV_B2(v16i8, __VA_ARGS__)
+#define ILVEV_B2_UH(...) ILVEV_B2(v8u16, __VA_ARGS__)
+#define ILVEV_B2_SH(...) ILVEV_B2(v8i16, __VA_ARGS__)
+#define ILVEV_B2_SD(...) ILVEV_B2(v2i64, __VA_ARGS__)
+
+/* Description : Interleave odd byte elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Odd byte elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVOD_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvod_b((v16i8)in1, (v16i8)in0); \
+ out1 = (RTYPE)__msa_ilvod_b((v16i8)in3, (v16i8)in2); \
+} while (0)
+#define ILVOD_B2_UB(...) ILVOD_B2(v16u8, __VA_ARGS__)
+#define ILVOD_B2_SB(...) ILVOD_B2(v16i8, __VA_ARGS__)
+#define ILVOD_B2_UH(...) ILVOD_B2(v8u16, __VA_ARGS__)
+#define ILVOD_B2_SH(...) ILVOD_B2(v8i16, __VA_ARGS__)
+#define ILVOD_B2_SD(...) ILVOD_B2(v2i64, __VA_ARGS__)
+
+/* Description : Interleave even halfword elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even halfword elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_h((v8i16)in1, (v8i16)in0); \
+ out1 = (RTYPE)__msa_ilvev_h((v8i16)in3, (v8i16)in2); \
+} while (0)
+#define ILVEV_H2_UB(...) ILVEV_H2(v16u8, __VA_ARGS__)
+#define ILVEV_H2_UH(...) ILVEV_H2(v8u16, __VA_ARGS__)
+#define ILVEV_H2_SH(...) ILVEV_H2(v8i16, __VA_ARGS__)
+#define ILVEV_H2_SW(...) ILVEV_H2(v4i32, __VA_ARGS__)
+
+/* Description : Interleave odd halfword elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Odd halfword elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvod_h((v8i16)in1, (v8i16)in0); \
+ out1 = (RTYPE)__msa_ilvod_h((v8i16)in3, (v8i16)in2); \
+} while (0)
+#define ILVOD_H2_UB(...) ILVOD_H2(v16u8, __VA_ARGS__)
+#define ILVOD_H2_UH(...) ILVOD_H2(v8u16, __VA_ARGS__)
+#define ILVOD_H2_SH(...) ILVOD_H2(v8i16, __VA_ARGS__)
+#define ILVOD_H2_SW(...) ILVOD_H2(v4i32, __VA_ARGS__)
+
+/* Description : Interleave even word elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even word elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_w((v4i32)in1, (v4i32)in0); \
+ out1 = (RTYPE)__msa_ilvev_w((v4i32)in3, (v4i32)in2); \
+} while (0)
+#define ILVEV_W2_UB(...) ILVEV_W2(v16u8, __VA_ARGS__)
+#define ILVEV_W2_SB(...) ILVEV_W2(v16i8, __VA_ARGS__)
+#define ILVEV_W2_UH(...) ILVEV_W2(v8u16, __VA_ARGS__)
+#define ILVEV_W2_SD(...) ILVEV_W2(v2i64, __VA_ARGS__)
+
+/* Description : Interleave even-odd word elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even word elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ * Odd word elements of 'in2' and 'in3' are interleaved
+ * and written to 'out1'
+ */
+#define ILVEVOD_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_w((v4i32)in1, (v4i32)in0); \
+ out1 = (RTYPE)__msa_ilvod_w((v4i32)in3, (v4i32)in2); \
+} while (0)
+#define ILVEVOD_W2_UB(...) ILVEVOD_W2(v16u8, __VA_ARGS__)
+#define ILVEVOD_W2_UH(...) ILVEVOD_W2(v8u16, __VA_ARGS__)
+#define ILVEVOD_W2_SH(...) ILVEVOD_W2(v8i16, __VA_ARGS__)
+#define ILVEVOD_W2_SW(...) ILVEVOD_W2(v4i32, __VA_ARGS__)
+
+/* Description : Interleave even-odd half-word elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even half-word elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ * Odd half-word elements of 'in2' and 'in3' are interleaved
+ * and written to 'out1'
+ */
+#define ILVEVOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_h((v8i16)in1, (v8i16)in0); \
+ out1 = (RTYPE)__msa_ilvod_h((v8i16)in3, (v8i16)in2); \
+} while (0)
+#define ILVEVOD_H2_UB(...) ILVEVOD_H2(v16u8, __VA_ARGS__)
+#define ILVEVOD_H2_UH(...) ILVEVOD_H2(v8u16, __VA_ARGS__)
+#define ILVEVOD_H2_SH(...) ILVEVOD_H2(v8i16, __VA_ARGS__)
+#define ILVEVOD_H2_SW(...) ILVEVOD_H2(v4i32, __VA_ARGS__)
+
+/* Description : Interleave even double word elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even double word elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'
+ */
+#define ILVEV_D2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvev_d((v2i64)in1, (v2i64)in0); \
+ out1 = (RTYPE)__msa_ilvev_d((v2i64)in3, (v2i64)in2); \
+} while (0)
+#define ILVEV_D2_UB(...) ILVEV_D2(v16u8, __VA_ARGS__)
+#define ILVEV_D2_SB(...) ILVEV_D2(v16i8, __VA_ARGS__)
+#define ILVEV_D2_SW(...) ILVEV_D2(v4i32, __VA_ARGS__)
+#define ILVEV_D2_SD(...) ILVEV_D2(v2i64, __VA_ARGS__)
+
+/* Description : Interleave left half of byte elements from vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Left half of byte elements of 'in0' and 'in1' are interleaved
+ * and written to 'out0'.
+ */
+#define ILVL_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
+ out1 = (RTYPE)__msa_ilvl_b((v16i8)in2, (v16i8)in3); \
+} while (0)
+#define ILVL_B2_UB(...) ILVL_B2(v16u8, __VA_ARGS__)
+#define ILVL_B2_SB(...) ILVL_B2(v16i8, __VA_ARGS__)
+#define ILVL_B2_UH(...) ILVL_B2(v8u16, __VA_ARGS__)
+#define ILVL_B2_SH(...) ILVL_B2(v8i16, __VA_ARGS__)
+#define ILVL_B2_SW(...) ILVL_B2(v4i32, __VA_ARGS__)
+
/* Description : Interleave right half of byte elements from vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1
@@ -306,10 +858,10 @@
* Details : Right half of byte elements of 'in0' and 'in1' are interleaved
* and written to out0.
*/
-#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) { \
- out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_ilvr_b((v16i8)in2, (v16i8)in3); \
-}
+#define ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
+ out1 = (RTYPE)__msa_ilvr_b((v16i8)in2, (v16i8)in3); \
+} while (0)
#define ILVR_B2_UB(...) ILVR_B2(v16u8, __VA_ARGS__)
#define ILVR_B2_SB(...) ILVR_B2(v16i8, __VA_ARGS__)
#define ILVR_B2_UH(...) ILVR_B2(v8u16, __VA_ARGS__)
@@ -317,10 +869,10 @@
#define ILVR_B2_SW(...) ILVR_B2(v4i32, __VA_ARGS__)
#define ILVR_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) { \
+ out0, out1, out2, out3) do { \
ILVR_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
ILVR_B2(RTYPE, in4, in5, in6, in7, out2, out3); \
-}
+} while (0)
#define ILVR_B4_UB(...) ILVR_B4(v16u8, __VA_ARGS__)
#define ILVR_B4_SB(...) ILVR_B4(v16i8, __VA_ARGS__)
#define ILVR_B4_UH(...) ILVR_B4(v8u16, __VA_ARGS__)
@@ -334,19 +886,19 @@
* Details : Right half of halfword elements of 'in0' and 'in1' are
* interleaved and written to 'out0'.
*/
-#define ILVR_H2(RTYPE, in0, in1, in2, in3, out0, out1) { \
- out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
- out1 = (RTYPE)__msa_ilvr_h((v8i16)in2, (v8i16)in3); \
-}
+#define ILVR_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
+ out1 = (RTYPE)__msa_ilvr_h((v8i16)in2, (v8i16)in3); \
+} while (0)
#define ILVR_H2_UB(...) ILVR_H2(v16u8, __VA_ARGS__)
#define ILVR_H2_SH(...) ILVR_H2(v8i16, __VA_ARGS__)
#define ILVR_H2_SW(...) ILVR_H2(v4i32, __VA_ARGS__)
#define ILVR_H4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) { \
+ out0, out1, out2, out3) do { \
ILVR_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
ILVR_H2(RTYPE, in4, in5, in6, in7, out2, out3); \
-}
+} while (0)
#define ILVR_H4_UB(...) ILVR_H4(v16u8, __VA_ARGS__)
#define ILVR_H4_SH(...) ILVR_H4(v8i16, __VA_ARGS__)
#define ILVR_H4_SW(...) ILVR_H4(v4i32, __VA_ARGS__)
@@ -358,31 +910,57 @@
* Details : Right half of double word elements of 'in0' and 'in1' are
* interleaved and written to 'out0'.
*/
-#define ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1) { \
- out0 = (RTYPE)__msa_ilvr_d((v2i64)in0, (v2i64)in1); \
- out1 = (RTYPE)__msa_ilvr_d((v2i64)in2, (v2i64)in3); \
-}
+#define ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvr_d((v2i64)in0, (v2i64)in1); \
+ out1 = (RTYPE)__msa_ilvr_d((v2i64)in2, (v2i64)in3); \
+} while (0)
#define ILVR_D2_UB(...) ILVR_D2(v16u8, __VA_ARGS__)
#define ILVR_D2_SB(...) ILVR_D2(v16i8, __VA_ARGS__)
#define ILVR_D2_SH(...) ILVR_D2(v8i16, __VA_ARGS__)
-#define ILVRL_H2(RTYPE, in0, in1, out0, out1) { \
+#define ILVR_D4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
+ out0, out1, out2, out3) do { \
+ ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1); \
+ ILVR_D2(RTYPE, in4, in5, in6, in7, out2, out3); \
+} while (0)
+#define ILVR_D4_SB(...) ILVR_D4(v16i8, __VA_ARGS__)
+#define ILVR_D4_UB(...) ILVR_D4(v16u8, __VA_ARGS__)
+
+/* Description : Interleave both left and right half of input vectors
+ * Arguments : Inputs - in0, in1
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Right half of byte elements from 'in0' and 'in1' are
+ * interleaved and written to 'out0'
+ */
+#define ILVRL_B2(RTYPE, in0, in1, out0, out1) do { \
+ out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
+ out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
+} while (0)
+#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
+#define ILVRL_B2_SB(...) ILVRL_B2(v16i8, __VA_ARGS__)
+#define ILVRL_B2_UH(...) ILVRL_B2(v8u16, __VA_ARGS__)
+#define ILVRL_B2_SH(...) ILVRL_B2(v8i16, __VA_ARGS__)
+#define ILVRL_B2_SW(...) ILVRL_B2(v4i32, __VA_ARGS__)
+
+#define ILVRL_H2(RTYPE, in0, in1, out0, out1) do { \
out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
out1 = (RTYPE)__msa_ilvl_h((v8i16)in0, (v8i16)in1); \
-}
+} while (0)
#define ILVRL_H2_UB(...) ILVRL_H2(v16u8, __VA_ARGS__)
#define ILVRL_H2_SB(...) ILVRL_H2(v16i8, __VA_ARGS__)
#define ILVRL_H2_SH(...) ILVRL_H2(v8i16, __VA_ARGS__)
#define ILVRL_H2_SW(...) ILVRL_H2(v4i32, __VA_ARGS__)
#define ILVRL_H2_UW(...) ILVRL_H2(v4u32, __VA_ARGS__)
-#define ILVRL_W2(RTYPE, in0, in1, out0, out1) { \
+#define ILVRL_W2(RTYPE, in0, in1, out0, out1) do { \
out0 = (RTYPE)__msa_ilvr_w((v4i32)in0, (v4i32)in1); \
out1 = (RTYPE)__msa_ilvl_w((v4i32)in0, (v4i32)in1); \
-}
+} while (0)
#define ILVRL_W2_UB(...) ILVRL_W2(v16u8, __VA_ARGS__)
#define ILVRL_W2_SH(...) ILVRL_W2(v8i16, __VA_ARGS__)
#define ILVRL_W2_SW(...) ILVRL_W2(v4i32, __VA_ARGS__)
+#define ILVRL_W2_UW(...) ILVRL_W2(v4u32, __VA_ARGS__)
/* Description : Pack even byte elements of vector pairs
* Arguments : Inputs - in0, in1, in2, in3
@@ -392,15 +970,76 @@
* 'out0' & even byte elements of 'in1' are copied to the right
* half of 'out0'.
*/
-#define PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) { \
- out0 = (RTYPE)__msa_pckev_b((v16i8)in0, (v16i8)in1); \
- out1 = (RTYPE)__msa_pckev_b((v16i8)in2, (v16i8)in3); \
-}
+#define PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_pckev_b((v16i8)in0, (v16i8)in1); \
+ out1 = (RTYPE)__msa_pckev_b((v16i8)in2, (v16i8)in3); \
+} while (0)
#define PCKEV_B2_SB(...) PCKEV_B2(v16i8, __VA_ARGS__)
#define PCKEV_B2_UB(...) PCKEV_B2(v16u8, __VA_ARGS__)
#define PCKEV_B2_SH(...) PCKEV_B2(v8i16, __VA_ARGS__)
#define PCKEV_B2_SW(...) PCKEV_B2(v4i32, __VA_ARGS__)
+#define PCKEV_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, \
+ out0, out1, out2, out3) do { \
+ PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
+ PCKEV_B2(RTYPE, in4, in5, in6, in7, out2, out3); \
+} while (0)
+#define PCKEV_B4_SB(...) PCKEV_B4(v16i8, __VA_ARGS__)
+#define PCKEV_B4_UB(...) PCKEV_B4(v16u8, __VA_ARGS__)
+#define PCKEV_B4_SH(...) PCKEV_B4(v8i16, __VA_ARGS__)
+#define PCKEV_B4_SW(...) PCKEV_B4(v4i32, __VA_ARGS__)
+
+/* Description : Pack even halfword elements of vector pairs
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even halfword elements of 'in0' are copied to the left half of
+ * 'out0' & even halfword elements of 'in1' are copied to the
+ * right half of 'out0'.
+ */
+#define PCKEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_pckev_h((v8i16)in0, (v8i16)in1); \
+ out1 = (RTYPE)__msa_pckev_h((v8i16)in2, (v8i16)in3); \
+} while (0)
+#define PCKEV_H2_UH(...) PCKEV_H2(v8u16, __VA_ARGS__)
+#define PCKEV_H2_SH(...) PCKEV_H2(v8i16, __VA_ARGS__)
+#define PCKEV_H2_SW(...) PCKEV_H2(v4i32, __VA_ARGS__)
+#define PCKEV_H2_UW(...) PCKEV_H2(v4u32, __VA_ARGS__)
+
+/* Description : Pack even word elements of vector pairs
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Even word elements of 'in0' are copied to the left half of
+ * 'out0' & even word elements of 'in1' are copied to the
+ * right half of 'out0'.
+ */
+#define PCKEV_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_pckev_w((v4i32)in0, (v4i32)in1); \
+ out1 = (RTYPE)__msa_pckev_w((v4i32)in2, (v4i32)in3); \
+} while (0)
+#define PCKEV_W2_UH(...) PCKEV_W2(v8u16, __VA_ARGS__)
+#define PCKEV_W2_SH(...) PCKEV_W2(v8i16, __VA_ARGS__)
+#define PCKEV_W2_SW(...) PCKEV_W2(v4i32, __VA_ARGS__)
+#define PCKEV_W2_UW(...) PCKEV_W2(v4u32, __VA_ARGS__)
+
+/* Description : Pack odd halfword elements of vector pairs
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Odd halfword elements of 'in0' are copied to the left half of
+ * 'out0' & odd halfword elements of 'in1' are copied to the
+ * right half of 'out0'.
+ */
+#define PCKOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_pckod_h((v8i16)in0, (v8i16)in1); \
+ out1 = (RTYPE)__msa_pckod_h((v8i16)in2, (v8i16)in3); \
+} while (0)
+#define PCKOD_H2_UH(...) PCKOD_H2(v8u16, __VA_ARGS__)
+#define PCKOD_H2_SH(...) PCKOD_H2(v8i16, __VA_ARGS__)
+#define PCKOD_H2_SW(...) PCKOD_H2(v4i32, __VA_ARGS__)
+#define PCKOD_H2_UW(...) PCKOD_H2(v4u32, __VA_ARGS__)
+
/* Description : Arithmetic immediate shift right all elements of word vector
* Arguments : Inputs - in0, in1, shift
* Outputs - in place operation
@@ -408,17 +1047,17 @@
* Details : Each element of vector 'in0' is right shifted by 'shift' and
* the result is written in-place. 'shift' is a GP variable.
*/
-#define SRAI_W2(RTYPE, in0, in1, shift_val) { \
- in0 = (RTYPE)SRAI_W(in0, shift_val); \
- in1 = (RTYPE)SRAI_W(in1, shift_val); \
-}
+#define SRAI_W2(RTYPE, in0, in1, shift_val) do { \
+ in0 = (RTYPE)SRAI_W(in0, shift_val); \
+ in1 = (RTYPE)SRAI_W(in1, shift_val); \
+} while (0)
#define SRAI_W2_SW(...) SRAI_W2(v4i32, __VA_ARGS__)
#define SRAI_W2_UW(...) SRAI_W2(v4u32, __VA_ARGS__)
-#define SRAI_W4(RTYPE, in0, in1, in2, in3, shift_val) { \
- SRAI_W2(RTYPE, in0, in1, shift_val); \
- SRAI_W2(RTYPE, in2, in3, shift_val); \
-}
+#define SRAI_W4(RTYPE, in0, in1, in2, in3, shift_val) do { \
+ SRAI_W2(RTYPE, in0, in1, shift_val); \
+ SRAI_W2(RTYPE, in2, in3, shift_val); \
+} while (0)
#define SRAI_W4_SW(...) SRAI_W4(v4i32, __VA_ARGS__)
#define SRAI_W4_UW(...) SRAI_W4(v4u32, __VA_ARGS__)
@@ -429,10 +1068,10 @@
* Details : Each element of vector 'in0' is right shifted by 'shift' and
* the result is written in-place. 'shift' is a GP variable.
*/
-#define SRAI_H2(RTYPE, in0, in1, shift_val) { \
- in0 = (RTYPE)SRAI_H(in0, shift_val); \
- in1 = (RTYPE)SRAI_H(in1, shift_val); \
-}
+#define SRAI_H2(RTYPE, in0, in1, shift_val) do { \
+ in0 = (RTYPE)SRAI_H(in0, shift_val); \
+ in1 = (RTYPE)SRAI_H(in1, shift_val); \
+} while (0)
#define SRAI_H2_SH(...) SRAI_H2(v8i16, __VA_ARGS__)
#define SRAI_H2_UH(...) SRAI_H2(v8u16, __VA_ARGS__)
@@ -443,48 +1082,166 @@
* Details : Each element of vector 'in0' is right shifted by 'shift' and
* the result is written in-place. 'shift' is a GP variable.
*/
-#define SRARI_W2(RTYPE, in0, in1, shift) { \
+#define SRARI_W2(RTYPE, in0, in1, shift) do { \
in0 = (RTYPE)__msa_srari_w((v4i32)in0, shift); \
in1 = (RTYPE)__msa_srari_w((v4i32)in1, shift); \
-}
+} while (0)
#define SRARI_W2_SW(...) SRARI_W2(v4i32, __VA_ARGS__)
-#define SRARI_W4(RTYPE, in0, in1, in2, in3, shift) { \
- SRARI_W2(RTYPE, in0, in1, shift); \
- SRARI_W2(RTYPE, in2, in3, shift); \
-}
+#define SRARI_W4(RTYPE, in0, in1, in2, in3, shift) do { \
+ SRARI_W2(RTYPE, in0, in1, shift); \
+ SRARI_W2(RTYPE, in2, in3, shift); \
+} while (0)
#define SRARI_W4_SH(...) SRARI_W4(v8i16, __VA_ARGS__)
#define SRARI_W4_UW(...) SRARI_W4(v4u32, __VA_ARGS__)
#define SRARI_W4_SW(...) SRARI_W4(v4i32, __VA_ARGS__)
+/* Description : Shift right arithmetic rounded double words
+ * Arguments : Inputs - in0, in1, shift
+ * Outputs - in place operation
+ * Return Type - as per RTYPE
+ * Details : Each element of vector 'in0' is shifted right arithmetically by
+ * the number of bits in the corresponding element in the vector
+ * 'shift'. The last discarded bit is added to shifted value for
+ * rounding and the result is written in-place.
+ * 'shift' is a vector.
+ */
+#define SRAR_D2(RTYPE, in0, in1, shift) do { \
+ in0 = (RTYPE)__msa_srar_d((v2i64)in0, (v2i64)shift); \
+ in1 = (RTYPE)__msa_srar_d((v2i64)in1, (v2i64)shift); \
+} while (0)
+#define SRAR_D2_SW(...) SRAR_D2(v4i32, __VA_ARGS__)
+#define SRAR_D2_SD(...) SRAR_D2(v2i64, __VA_ARGS__)
+#define SRAR_D2_UD(...) SRAR_D2(v2u64, __VA_ARGS__)
+
+#define SRAR_D4(RTYPE, in0, in1, in2, in3, shift) do { \
+ SRAR_D2(RTYPE, in0, in1, shift); \
+ SRAR_D2(RTYPE, in2, in3, shift); \
+} while (0)
+#define SRAR_D4_SD(...) SRAR_D4(v2i64, __VA_ARGS__)
+#define SRAR_D4_UD(...) SRAR_D4(v2u64, __VA_ARGS__)
+
/* Description : Addition of 2 pairs of half-word vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1
* Details : Each element in 'in0' is added to 'in1' and result is written
* to 'out0'.
*/
-#define ADDVI_H2(RTYPE, in0, in1, in2, in3, out0, out1) { \
- out0 = (RTYPE)ADDVI_H(in0, in1); \
- out1 = (RTYPE)ADDVI_H(in2, in3); \
-}
+#define ADDVI_H2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)ADDVI_H(in0, in1); \
+ out1 = (RTYPE)ADDVI_H(in2, in3); \
+} while (0)
#define ADDVI_H2_SH(...) ADDVI_H2(v8i16, __VA_ARGS__)
#define ADDVI_H2_UH(...) ADDVI_H2(v8u16, __VA_ARGS__)
+/* Description : Addition of 2 pairs of word vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Details : Each element in 'in0' is added to 'in1' and result is written
+ * to 'out0'.
+ */
+#define ADDVI_W2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)ADDVI_W(in0, in1); \
+ out1 = (RTYPE)ADDVI_W(in2, in3); \
+} while (0)
+#define ADDVI_W2_SW(...) ADDVI_W2(v4i32, __VA_ARGS__)
+
+/* Description : Fill 2 pairs of word vectors with GP registers
+ * Arguments : Inputs - in0, in1
+ * Outputs - out0, out1
+ * Details : GP register in0 is replicated in each word element of out0
+ * GP register in1 is replicated in each word element of out1
+ */
+#define FILL_W2(RTYPE, in0, in1, out0, out1) do { \
+ out0 = (RTYPE)__msa_fill_w(in0); \
+ out1 = (RTYPE)__msa_fill_w(in1); \
+} while (0)
+#define FILL_W2_SW(...) FILL_W2(v4i32, __VA_ARGS__)
+
/* Description : Addition of 2 pairs of vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1
* Details : Each element in 'in0' is added to 'in1' and result is written
* to 'out0'.
*/
-#define ADD2(in0, in1, in2, in3, out0, out1) { \
- out0 = in0 + in1; \
- out1 = in2 + in3; \
-}
+#define ADD2(in0, in1, in2, in3, out0, out1) do { \
+ out0 = in0 + in1; \
+ out1 = in2 + in3; \
+} while (0)
+
#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, \
- out0, out1, out2, out3) { \
+ out0, out1, out2, out3) do { \
ADD2(in0, in1, in2, in3, out0, out1); \
ADD2(in4, in5, in6, in7, out2, out3); \
-}
+} while (0)
+
+/* Description : Subtraction of 2 pairs of vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Details : Each element in 'in1' is subtracted from 'in0' and result is
+ * written to 'out0'.
+ */
+#define SUB2(in0, in1, in2, in3, out0, out1) do { \
+ out0 = in0 - in1; \
+ out1 = in2 - in3; \
+} while (0)
+
+#define SUB3(in0, in1, in2, in3, in4, in5, out0, out1, out2) do { \
+ out0 = in0 - in1; \
+ out1 = in2 - in3; \
+ out2 = in4 - in5; \
+} while (0)
+
+#define SUB4(in0, in1, in2, in3, in4, in5, in6, in7, \
+ out0, out1, out2, out3) do { \
+ out0 = in0 - in1; \
+ out1 = in2 - in3; \
+ out2 = in4 - in5; \
+ out3 = in6 - in7; \
+} while (0)
+
+/* Description : Addition - Subtraction of input vectors
+ * Arguments : Inputs - in0, in1
+ * Outputs - out0, out1
+ * Details : Each element in 'in1' is added to 'in0' and result is
+ * written to 'out0'.
+ * Each element in 'in1' is subtracted from 'in0' and result is
+ * written to 'out1'.
+ */
+#define ADDSUB2(in0, in1, out0, out1) do { \
+ out0 = in0 + in1; \
+ out1 = in0 - in1; \
+} while (0)
+
+/* Description : Multiplication of pairs of vectors
+ * Arguments : Inputs - in0, in1, in2, in3
+ * Outputs - out0, out1
+ * Details : Each element from 'in0' is multiplied with elements from 'in1'
+ * and the result is written to 'out0'
+ */
+#define MUL2(in0, in1, in2, in3, out0, out1) do { \
+ out0 = in0 * in1; \
+ out1 = in2 * in3; \
+} while (0)
+
+#define MUL4(in0, in1, in2, in3, in4, in5, in6, in7, \
+ out0, out1, out2, out3) do { \
+ MUL2(in0, in1, in2, in3, out0, out1); \
+ MUL2(in4, in5, in6, in7, out2, out3); \
+} while (0)
+
+/* Description : Sign extend halfword elements from right half of the vector
+ * Arguments : Input - in (halfword vector)
+ * Output - out (sign extended word vector)
+ * Return Type - signed word
+ * Details : Sign bit of halfword elements from input vector 'in' is
+ * extracted and interleaved with same vector 'in0' to generate
+ * 4 word elements keeping sign intact
+ */
+#define UNPCK_R_SH_SW(in, out) do { \
+ const v8i16 sign_m = __msa_clti_s_h((v8i16)in, 0); \
+ out = (v4i32)__msa_ilvr_h(sign_m, (v8i16)in); \
+} while (0)
/* Description : Sign extend halfword elements from input vector and return
* the result in pair of vectors
@@ -497,29 +1254,82 @@
* Then interleaved left with same vector 'in0' to
* generate 4 signed word elements in 'out1'
*/
-#define UNPCK_SH_SW(in, out0, out1) { \
+#define UNPCK_SH_SW(in, out0, out1) do { \
const v8i16 tmp_m = __msa_clti_s_h((v8i16)in, 0); \
ILVRL_H2_SW(tmp_m, in, out0, out1); \
-}
+} while (0)
/* Description : Butterfly of 4 input vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1, out2, out3
* Details : Butterfly operation
*/
-#define BUTTERFLY_4(in0, in1, in2, in3, out0, out1, out2, out3) { \
- out0 = in0 + in3; \
- out1 = in1 + in2; \
- out2 = in1 - in2; \
- out3 = in0 - in3; \
-}
+#define BUTTERFLY_4(in0, in1, in2, in3, out0, out1, out2, out3) do { \
+ out0 = in0 + in3; \
+ out1 = in1 + in2; \
+ out2 = in1 - in2; \
+ out3 = in0 - in3; \
+} while (0)
+
+/* Description : Transpose 16x4 block into 4x16 with byte elements in vectors
+ * Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7,
+ * in8, in9, in10, in11, in12, in13, in14, in15
+ * Outputs - out0, out1, out2, out3
+ * Return Type - unsigned byte
+ */
+#define TRANSPOSE16x4_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, \
+ in8, in9, in10, in11, in12, in13, in14, in15, \
+ out0, out1, out2, out3) do { \
+ v2i64 tmp0_m, tmp1_m, tmp2_m, tmp3_m, tmp4_m, tmp5_m; \
+ ILVEV_W2_SD(in0, in4, in8, in12, tmp2_m, tmp3_m); \
+ ILVEV_W2_SD(in1, in5, in9, in13, tmp0_m, tmp1_m); \
+ ILVEV_D2_UB(tmp2_m, tmp3_m, tmp0_m, tmp1_m, out1, out3); \
+ ILVEV_W2_SD(in2, in6, in10, in14, tmp4_m, tmp5_m); \
+ ILVEV_W2_SD(in3, in7, in11, in15, tmp0_m, tmp1_m); \
+ ILVEV_D2_SD(tmp4_m, tmp5_m, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \
+ ILVEV_B2_SD(out1, out3, tmp2_m, tmp3_m, tmp0_m, tmp1_m); \
+ ILVEVOD_H2_UB(tmp0_m, tmp1_m, tmp0_m, tmp1_m, out0, out2); \
+ ILVOD_B2_SD(out1, out3, tmp2_m, tmp3_m, tmp0_m, tmp1_m); \
+ ILVEVOD_H2_UB(tmp0_m, tmp1_m, tmp0_m, tmp1_m, out1, out3); \
+} while (0)
+
+/* Description : Transpose 16x8 block into 8x16 with byte elements in vectors
+ * Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7,
+ * in8, in9, in10, in11, in12, in13, in14, in15
+ * Outputs - out0, out1, out2, out3, out4, out5, out6, out7
+ * Return Type - unsigned byte
+ */
+#define TRANSPOSE16x8_UB_UB(in0, in1, in2, in3, in4, in5, in6, in7, \
+ in8, in9, in10, in11, in12, in13, in14, in15, \
+ out0, out1, out2, out3, out4, out5, \
+ out6, out7) do { \
+ v8i16 tmp0_m, tmp1_m, tmp4_m, tmp5_m, tmp6_m, tmp7_m; \
+ v4i32 tmp2_m, tmp3_m; \
+ ILVEV_D2_UB(in0, in8, in1, in9, out7, out6); \
+ ILVEV_D2_UB(in2, in10, in3, in11, out5, out4); \
+ ILVEV_D2_UB(in4, in12, in5, in13, out3, out2); \
+ ILVEV_D2_UB(in6, in14, in7, in15, out1, out0); \
+ ILVEV_B2_SH(out7, out6, out5, out4, tmp0_m, tmp1_m); \
+ ILVOD_B2_SH(out7, out6, out5, out4, tmp4_m, tmp5_m); \
+ ILVEV_B2_UB(out3, out2, out1, out0, out5, out7); \
+ ILVOD_B2_SH(out3, out2, out1, out0, tmp6_m, tmp7_m); \
+ ILVEV_H2_SW(tmp0_m, tmp1_m, out5, out7, tmp2_m, tmp3_m); \
+ ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out0, out4); \
+ ILVOD_H2_SW(tmp0_m, tmp1_m, out5, out7, tmp2_m, tmp3_m); \
+ ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out2, out6); \
+ ILVEV_H2_SW(tmp4_m, tmp5_m, tmp6_m, tmp7_m, tmp2_m, tmp3_m); \
+ ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out1, out5); \
+ ILVOD_H2_SW(tmp4_m, tmp5_m, tmp6_m, tmp7_m, tmp2_m, tmp3_m); \
+ ILVEVOD_W2_UB(tmp2_m, tmp3_m, tmp2_m, tmp3_m, out3, out7); \
+} while (0)
/* Description : Transpose 4x4 block with word elements in vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1, out2, out3
* Return Type - as per RTYPE
*/
-#define TRANSPOSE4x4_W(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) { \
+#define TRANSPOSE4x4_W(RTYPE, in0, in1, in2, in3, \
+ out0, out1, out2, out3) do { \
v4i32 s0_m, s1_m, s2_m, s3_m; \
ILVRL_W2_SW(in1, in0, s0_m, s1_m); \
ILVRL_W2_SW(in3, in2, s2_m, s3_m); \
@@ -527,7 +1337,7 @@
out1 = (RTYPE)__msa_ilvl_d((v2i64)s2_m, (v2i64)s0_m); \
out2 = (RTYPE)__msa_ilvr_d((v2i64)s3_m, (v2i64)s1_m); \
out3 = (RTYPE)__msa_ilvl_d((v2i64)s3_m, (v2i64)s1_m); \
-}
+} while (0)
#define TRANSPOSE4x4_SW_SW(...) TRANSPOSE4x4_W(v4i32, __VA_ARGS__)
/* Description : Add block 4x4
@@ -535,7 +1345,7 @@
* Details : Least significant 4 bytes from each input vector are added to
* the destination bytes, clipped between 0-255 and stored.
*/
-#define ADDBLK_ST4x4_UB(in0, in1, in2, in3, pdst, stride) { \
+#define ADDBLK_ST4x4_UB(in0, in1, in2, in3, pdst, stride) do { \
uint32_t src0_m, src1_m, src2_m, src3_m; \
v8i16 inp0_m, inp1_m, res0_m, res1_m; \
v16i8 dst0_m = { 0 }; \
@@ -550,6 +1360,31 @@
CLIP_SH2_0_255(res0_m, res1_m); \
PCKEV_B2_SB(res0_m, res0_m, res1_m, res1_m, dst0_m, dst1_m); \
ST4x4_UB(dst0_m, dst1_m, 0, 1, 0, 1, pdst, stride); \
-}
+} while (0)
+
+/* Description : Pack even byte elements, extract 0 & 2 index words from pair
+ * of results and store 4 words in destination memory as per
+ * stride
+ * Arguments : Inputs - in0, in1, in2, in3, pdst, stride
+ */
+#define PCKEV_ST4x4_UB(in0, in1, in2, in3, pdst, stride) do { \
+ v16i8 tmp0_m, tmp1_m; \
+ PCKEV_B2_SB(in1, in0, in3, in2, tmp0_m, tmp1_m); \
+ ST4x4_UB(tmp0_m, tmp1_m, 0, 2, 0, 2, pdst, stride); \
+} while (0)
+
+/* Description : average with rounding (in0 + in1 + 1) / 2.
+ * Arguments : Inputs - in0, in1, in2, in3,
+ * Outputs - out0, out1
+ * Return Type - as per RTYPE
+ * Details : Each unsigned byte element from 'in0' vector is added with
+ * each unsigned byte element from 'in1' vector. Then the average
+ * with rounding is calculated and written to 'out0'
+ */
+#define AVER_UB2(RTYPE, in0, in1, in2, in3, out0, out1) do { \
+ out0 = (RTYPE)__msa_aver_u_b((v16u8)in0, (v16u8)in1); \
+ out1 = (RTYPE)__msa_aver_u_b((v16u8)in2, (v16u8)in3); \
+} while (0)
+#define AVER_UB2_UB(...) AVER_UB2(v16u8, __VA_ARGS__)
#endif /* WEBP_DSP_MSA_MACRO_H_ */
diff --git a/thirdparty/libwebp/dsp/neon.h b/thirdparty/libwebp/dsp/neon.h
index 0a06266848..3b548a6855 100644
--- a/thirdparty/libwebp/dsp/neon.h
+++ b/thirdparty/libwebp/dsp/neon.h
@@ -79,4 +79,22 @@ static WEBP_INLINE int32x4x4_t Transpose4x4(const int32x4x4_t rows) {
}
}
+#if 0 // Useful debug macro.
+#include <stdio.h>
+#define PRINT_REG(REG, SIZE) do { \
+ int i; \
+ printf("%s \t[%d]: 0x", #REG, SIZE); \
+ if (SIZE == 8) { \
+ uint8_t _tmp[8]; \
+ vst1_u8(_tmp, (REG)); \
+ for (i = 0; i < 8; ++i) printf("%.2x ", _tmp[i]); \
+ } else if (SIZE == 16) { \
+ uint16_t _tmp[4]; \
+ vst1_u16(_tmp, (REG)); \
+ for (i = 0; i < 4; ++i) printf("%.4x ", _tmp[i]); \
+ } \
+ printf("\n"); \
+} while (0)
+#endif
+
#endif // WEBP_DSP_NEON_H_
diff --git a/thirdparty/libwebp/dsp/rescaler.c b/thirdparty/libwebp/dsp/rescaler.c
index f5b07756cf..0f54502352 100644
--- a/thirdparty/libwebp/dsp/rescaler.c
+++ b/thirdparty/libwebp/dsp/rescaler.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include "./dsp.h"
-#include "../utils/rescaler.h"
+#include "../utils/rescaler_utils.h"
//------------------------------------------------------------------------------
// Implementations of critical functions ImportRow / ExportRow
@@ -199,6 +199,7 @@ WebPRescalerExportRowFunc WebPRescalerExportRowShrink;
extern void WebPRescalerDspInitSSE2(void);
extern void WebPRescalerDspInitMIPS32(void);
extern void WebPRescalerDspInitMIPSdspR2(void);
+extern void WebPRescalerDspInitMSA(void);
extern void WebPRescalerDspInitNEON(void);
static volatile VP8CPUInfo rescaler_last_cpuinfo_used =
@@ -233,6 +234,11 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInit(void) {
WebPRescalerDspInitMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ WebPRescalerDspInitMSA();
+ }
+#endif
}
rescaler_last_cpuinfo_used = VP8GetCPUInfo;
}
diff --git a/thirdparty/libwebp/dsp/rescaler_mips32.c b/thirdparty/libwebp/dsp/rescaler_mips32.c
index ddaa391336..e09ad5d19f 100644
--- a/thirdparty/libwebp/dsp/rescaler_mips32.c
+++ b/thirdparty/libwebp/dsp/rescaler_mips32.c
@@ -16,7 +16,7 @@
#if defined(WEBP_USE_MIPS32)
#include <assert.h>
-#include "../utils/rescaler.h"
+#include "../utils/rescaler_utils.h"
//------------------------------------------------------------------------------
// Row import
diff --git a/thirdparty/libwebp/dsp/rescaler_mips_dsp_r2.c b/thirdparty/libwebp/dsp/rescaler_mips_dsp_r2.c
index b457d0a30a..2308d64544 100644
--- a/thirdparty/libwebp/dsp/rescaler_mips_dsp_r2.c
+++ b/thirdparty/libwebp/dsp/rescaler_mips_dsp_r2.c
@@ -16,7 +16,7 @@
#if defined(WEBP_USE_MIPS_DSP_R2)
#include <assert.h>
-#include "../utils/rescaler.h"
+#include "../utils/rescaler_utils.h"
#define ROUNDER (WEBP_RESCALER_ONE >> 1)
#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
diff --git a/thirdparty/libwebp/dsp/rescaler_msa.c b/thirdparty/libwebp/dsp/rescaler_msa.c
new file mode 100644
index 0000000000..2c10e55d8c
--- /dev/null
+++ b/thirdparty/libwebp/dsp/rescaler_msa.c
@@ -0,0 +1,444 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA version of rescaling functions
+//
+// Author: Prashant Patil (prashant.patil@imgtec.com)
+
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include <assert.h>
+
+#include "../utils/rescaler_utils.h"
+#include "./msa_macro.h"
+
+#define ROUNDER (WEBP_RESCALER_ONE >> 1)
+#define MULT_FIX(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
+
+#define CALC_MULT_FIX_16(in0, in1, in2, in3, scale, shift, dst) do { \
+ v4u32 tmp0, tmp1, tmp2, tmp3; \
+ v16u8 t0, t1, t2, t3, t4, t5; \
+ v2u64 out0, out1, out2, out3; \
+ ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
+ ILVRL_W2_UW(zero, in1, tmp2, tmp3); \
+ DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
+ DOTP_UW2_UD(tmp2, tmp3, scale, scale, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ PCKEV_B2_UB(out1, out0, out3, out2, t0, t1); \
+ ILVRL_W2_UW(zero, in2, tmp0, tmp1); \
+ ILVRL_W2_UW(zero, in3, tmp2, tmp3); \
+ DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
+ DOTP_UW2_UD(tmp2, tmp3, scale, scale, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ PCKEV_B2_UB(out1, out0, out3, out2, t2, t3); \
+ PCKEV_B2_UB(t1, t0, t3, t2, t4, t5); \
+ dst = (v16u8)__msa_pckev_b((v16i8)t5, (v16i8)t4); \
+} while (0)
+
+#define CALC_MULT_FIX_4(in0, scale, shift, dst) do { \
+ v4u32 tmp0, tmp1; \
+ v16i8 t0, t1; \
+ v2u64 out0, out1; \
+ ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
+ DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
+ SRAR_D2_UD(out0, out1, shift); \
+ t0 = __msa_pckev_b((v16i8)out1, (v16i8)out0); \
+ t1 = __msa_pckev_b(t0, t0); \
+ t0 = __msa_pckev_b(t1, t1); \
+ dst = __msa_copy_s_w((v4i32)t0, 0); \
+} while (0)
+
+#define CALC_MULT_FIX1_16(in0, in1, in2, in3, fyscale, shift, \
+ dst0, dst1, dst2, dst3) do { \
+ v4u32 tmp0, tmp1, tmp2, tmp3; \
+ v2u64 out0, out1, out2, out3; \
+ ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
+ ILVRL_W2_UW(zero, in1, tmp2, tmp3); \
+ DOTP_UW2_UD(tmp0, tmp1, fyscale, fyscale, out0, out1); \
+ DOTP_UW2_UD(tmp2, tmp3, fyscale, fyscale, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ PCKEV_W2_UW(out1, out0, out3, out2, dst0, dst1); \
+ ILVRL_W2_UW(zero, in2, tmp0, tmp1); \
+ ILVRL_W2_UW(zero, in3, tmp2, tmp3); \
+ DOTP_UW2_UD(tmp0, tmp1, fyscale, fyscale, out0, out1); \
+ DOTP_UW2_UD(tmp2, tmp3, fyscale, fyscale, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ PCKEV_W2_UW(out1, out0, out3, out2, dst2, dst3); \
+} while (0)
+
+#define CALC_MULT_FIX1_4(in0, scale, shift, dst) do { \
+ v4u32 tmp0, tmp1; \
+ v2u64 out0, out1; \
+ ILVRL_W2_UW(zero, in0, tmp0, tmp1); \
+ DOTP_UW2_UD(tmp0, tmp1, scale, scale, out0, out1); \
+ SRAR_D2_UD(out0, out1, shift); \
+ dst = (v4u32)__msa_pckev_w((v4i32)out1, (v4i32)out0); \
+} while (0)
+
+#define CALC_MULT_FIX2_16(in0, in1, in2, in3, mult, scale, shift, \
+ dst0, dst1) do { \
+ v4u32 tmp0, tmp1, tmp2, tmp3; \
+ v2u64 out0, out1, out2, out3; \
+ ILVRL_W2_UW(in0, in2, tmp0, tmp1); \
+ ILVRL_W2_UW(in1, in3, tmp2, tmp3); \
+ DOTP_UW2_UD(tmp0, tmp1, mult, mult, out0, out1); \
+ DOTP_UW2_UD(tmp2, tmp3, mult, mult, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ DOTP_UW2_UD(out0, out1, scale, scale, out0, out1); \
+ DOTP_UW2_UD(out2, out3, scale, scale, out2, out3); \
+ SRAR_D4_UD(out0, out1, out2, out3, shift); \
+ PCKEV_B2_UB(out1, out0, out3, out2, dst0, dst1); \
+} while (0)
+
+#define CALC_MULT_FIX2_4(in0, in1, mult, scale, shift, dst) do { \
+ v4u32 tmp0, tmp1; \
+ v2u64 out0, out1; \
+ v16i8 t0, t1; \
+ ILVRL_W2_UW(in0, in1, tmp0, tmp1); \
+ DOTP_UW2_UD(tmp0, tmp1, mult, mult, out0, out1); \
+ SRAR_D2_UD(out0, out1, shift); \
+ DOTP_UW2_UD(out0, out1, scale, scale, out0, out1); \
+ SRAR_D2_UD(out0, out1, shift); \
+ t0 = __msa_pckev_b((v16i8)out1, (v16i8)out0); \
+ t1 = __msa_pckev_b(t0, t0); \
+ t0 = __msa_pckev_b(t1, t1); \
+ dst = __msa_copy_s_w((v4i32)t0, 0); \
+} while (0)
+
+static WEBP_INLINE void ExportRowExpand_0(const uint32_t* frow, uint8_t* dst,
+ int length,
+ WebPRescaler* const wrk) {
+ const v4u32 scale = (v4u32)__msa_fill_w(wrk->fy_scale);
+ const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
+ const v4i32 zero = { 0 };
+
+ while (length >= 16) {
+ v4u32 src0, src1, src2, src3;
+ v16u8 out;
+ LD_UW4(frow, 4, src0, src1, src2, src3);
+ CALC_MULT_FIX_16(src0, src1, src2, src3, scale, shift, out);
+ ST_UB(out, dst);
+ length -= 16;
+ frow += 16;
+ dst += 16;
+ }
+ if (length > 0) {
+ int x_out;
+ if (length >= 12) {
+ uint32_t val0_m, val1_m, val2_m;
+ v4u32 src0, src1, src2;
+ LD_UW3(frow, 4, src0, src1, src2);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ CALC_MULT_FIX_4(src1, scale, shift, val1_m);
+ CALC_MULT_FIX_4(src2, scale, shift, val2_m);
+ SW3(val0_m, val1_m, val2_m, dst, 4);
+ length -= 12;
+ frow += 12;
+ dst += 12;
+ } else if (length >= 8) {
+ uint32_t val0_m, val1_m;
+ v4u32 src0, src1;
+ LD_UW2(frow, 4, src0, src1);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ CALC_MULT_FIX_4(src1, scale, shift, val1_m);
+ SW2(val0_m, val1_m, dst, 4);
+ length -= 8;
+ frow += 8;
+ dst += 8;
+ } else if (length >= 4) {
+ uint32_t val0_m;
+ const v4u32 src0 = LD_UW(frow);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ SW(val0_m, dst);
+ length -= 4;
+ frow += 4;
+ dst += 4;
+ }
+ for (x_out = 0; x_out < length; ++x_out) {
+ const uint32_t J = frow[x_out];
+ const int v = (int)MULT_FIX(J, wrk->fy_scale);
+ assert(v >= 0 && v <= 255);
+ dst[x_out] = v;
+ }
+ }
+}
+
+static WEBP_INLINE void ExportRowExpand_1(const uint32_t* frow, uint32_t* irow,
+ uint8_t* dst, int length,
+ WebPRescaler* const wrk) {
+ const uint32_t B = WEBP_RESCALER_FRAC(-wrk->y_accum, wrk->y_sub);
+ const uint32_t A = (uint32_t)(WEBP_RESCALER_ONE - B);
+ const v4i32 B1 = __msa_fill_w(B);
+ const v4i32 A1 = __msa_fill_w(A);
+ const v4i32 AB = __msa_ilvr_w(A1, B1);
+ const v4u32 scale = (v4u32)__msa_fill_w(wrk->fy_scale);
+ const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
+
+ while (length >= 16) {
+ v4u32 frow0, frow1, frow2, frow3, irow0, irow1, irow2, irow3;
+ v16u8 t0, t1, t2, t3, t4, t5;
+ LD_UW4(frow, 4, frow0, frow1, frow2, frow3);
+ LD_UW4(irow, 4, irow0, irow1, irow2, irow3);
+ CALC_MULT_FIX2_16(frow0, frow1, irow0, irow1, AB, scale, shift, t0, t1);
+ CALC_MULT_FIX2_16(frow2, frow3, irow2, irow3, AB, scale, shift, t2, t3);
+ PCKEV_B2_UB(t1, t0, t3, t2, t4, t5);
+ t0 = (v16u8)__msa_pckev_b((v16i8)t5, (v16i8)t4);
+ ST_UB(t0, dst);
+ frow += 16;
+ irow += 16;
+ dst += 16;
+ length -= 16;
+ }
+ if (length > 0) {
+ int x_out;
+ if (length >= 12) {
+ uint32_t val0_m, val1_m, val2_m;
+ v4u32 frow0, frow1, frow2, irow0, irow1, irow2;
+ LD_UW3(frow, 4, frow0, frow1, frow2);
+ LD_UW3(irow, 4, irow0, irow1, irow2);
+ CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
+ CALC_MULT_FIX2_4(frow1, irow1, AB, scale, shift, val1_m);
+ CALC_MULT_FIX2_4(frow2, irow2, AB, scale, shift, val2_m);
+ SW3(val0_m, val1_m, val2_m, dst, 4);
+ frow += 12;
+ irow += 12;
+ dst += 12;
+ length -= 12;
+ } else if (length >= 8) {
+ uint32_t val0_m, val1_m;
+ v4u32 frow0, frow1, irow0, irow1;
+ LD_UW2(frow, 4, frow0, frow1);
+ LD_UW2(irow, 4, irow0, irow1);
+ CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
+ CALC_MULT_FIX2_4(frow1, irow1, AB, scale, shift, val1_m);
+ SW2(val0_m, val1_m, dst, 4);
+ frow += 4;
+ irow += 4;
+ dst += 4;
+ length -= 4;
+ } else if (length >= 4) {
+ uint32_t val0_m;
+ const v4u32 frow0 = LD_UW(frow + 0);
+ const v4u32 irow0 = LD_UW(irow + 0);
+ CALC_MULT_FIX2_4(frow0, irow0, AB, scale, shift, val0_m);
+ SW(val0_m, dst);
+ frow += 4;
+ irow += 4;
+ dst += 4;
+ length -= 4;
+ }
+ for (x_out = 0; x_out < length; ++x_out) {
+ const uint64_t I = (uint64_t)A * frow[x_out]
+ + (uint64_t)B * irow[x_out];
+ const uint32_t J = (uint32_t)((I + ROUNDER) >> WEBP_RESCALER_RFIX);
+ const int v = (int)MULT_FIX(J, wrk->fy_scale);
+ assert(v >= 0 && v <= 255);
+ dst[x_out] = v;
+ }
+ }
+}
+
+static void RescalerExportRowExpand(WebPRescaler* const wrk) {
+ uint8_t* dst = wrk->dst;
+ rescaler_t* irow = wrk->irow;
+ const int x_out_max = wrk->dst_width * wrk->num_channels;
+ const rescaler_t* frow = wrk->frow;
+ assert(!WebPRescalerOutputDone(wrk));
+ assert(wrk->y_accum <= 0);
+ assert(wrk->y_expand);
+ assert(wrk->y_sub != 0);
+ if (wrk->y_accum == 0) {
+ ExportRowExpand_0(frow, dst, x_out_max, wrk);
+ } else {
+ ExportRowExpand_1(frow, irow, dst, x_out_max, wrk);
+ }
+}
+
+static WEBP_INLINE void ExportRowShrink_0(const uint32_t* frow, uint32_t* irow,
+ uint8_t* dst, int length,
+ const uint32_t yscale,
+ WebPRescaler* const wrk) {
+ const v4u32 y_scale = (v4u32)__msa_fill_w(yscale);
+ const v4u32 fxyscale = (v4u32)__msa_fill_w(wrk->fxy_scale);
+ const v4u32 shiftval = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
+ const v4i32 zero = { 0 };
+
+ while (length >= 16) {
+ v4u32 src0, src1, src2, src3, frac0, frac1, frac2, frac3;
+ v16u8 out;
+ LD_UW4(frow, 4, src0, src1, src2, src3);
+ CALC_MULT_FIX1_16(src0, src1, src2, src3, y_scale, shiftval,
+ frac0, frac1, frac2, frac3);
+ LD_UW4(irow, 4, src0, src1, src2, src3);
+ SUB4(src0, frac0, src1, frac1, src2, frac2, src3, frac3,
+ src0, src1, src2, src3);
+ CALC_MULT_FIX_16(src0, src1, src2, src3, fxyscale, shiftval, out);
+ ST_UB(out, dst);
+ ST_UW4(frac0, frac1, frac2, frac3, irow, 4);
+ frow += 16;
+ irow += 16;
+ dst += 16;
+ length -= 16;
+ }
+ if (length > 0) {
+ int x_out;
+ if (length >= 12) {
+ uint32_t val0_m, val1_m, val2_m;
+ v4u32 src0, src1, src2, frac0, frac1, frac2;
+ LD_UW3(frow, 4, src0, src1, src2);
+ CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
+ CALC_MULT_FIX1_4(src1, y_scale, shiftval, frac1);
+ CALC_MULT_FIX1_4(src2, y_scale, shiftval, frac2);
+ LD_UW3(irow, 4, src0, src1, src2);
+ SUB3(src0, frac0, src1, frac1, src2, frac2, src0, src1, src2);
+ CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
+ CALC_MULT_FIX_4(src1, fxyscale, shiftval, val1_m);
+ CALC_MULT_FIX_4(src2, fxyscale, shiftval, val2_m);
+ SW3(val0_m, val1_m, val2_m, dst, 4);
+ ST_UW3(frac0, frac1, frac2, irow, 4);
+ frow += 12;
+ irow += 12;
+ dst += 12;
+ length -= 12;
+ } else if (length >= 8) {
+ uint32_t val0_m, val1_m;
+ v4u32 src0, src1, frac0, frac1;
+ LD_UW2(frow, 4, src0, src1);
+ CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
+ CALC_MULT_FIX1_4(src1, y_scale, shiftval, frac1);
+ LD_UW2(irow, 4, src0, src1);
+ SUB2(src0, frac0, src1, frac1, src0, src1);
+ CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
+ CALC_MULT_FIX_4(src1, fxyscale, shiftval, val1_m);
+ SW2(val0_m, val1_m, dst, 4);
+ ST_UW2(frac0, frac1, irow, 4);
+ frow += 8;
+ irow += 8;
+ dst += 8;
+ length -= 8;
+ } else if (length >= 4) {
+ uint32_t val0_m;
+ v4u32 frac0;
+ v4u32 src0 = LD_UW(frow);
+ CALC_MULT_FIX1_4(src0, y_scale, shiftval, frac0);
+ src0 = LD_UW(irow);
+ src0 = src0 - frac0;
+ CALC_MULT_FIX_4(src0, fxyscale, shiftval, val0_m);
+ SW(val0_m, dst);
+ ST_UW(frac0, irow);
+ frow += 4;
+ irow += 4;
+ dst += 4;
+ length -= 4;
+ }
+ for (x_out = 0; x_out < length; ++x_out) {
+ const uint32_t frac = (uint32_t)MULT_FIX(frow[x_out], yscale);
+ const int v = (int)MULT_FIX(irow[x_out] - frac, wrk->fxy_scale);
+ assert(v >= 0 && v <= 255);
+ dst[x_out] = v;
+ irow[x_out] = frac;
+ }
+ }
+}
+
+static WEBP_INLINE void ExportRowShrink_1(uint32_t* irow, uint8_t* dst,
+ int length,
+ WebPRescaler* const wrk) {
+ const v4u32 scale = (v4u32)__msa_fill_w(wrk->fxy_scale);
+ const v4u32 shift = (v4u32)__msa_fill_w(WEBP_RESCALER_RFIX);
+ const v4i32 zero = { 0 };
+
+ while (length >= 16) {
+ v4u32 src0, src1, src2, src3;
+ v16u8 dst0;
+ LD_UW4(irow, 4, src0, src1, src2, src3);
+ CALC_MULT_FIX_16(src0, src1, src2, src3, scale, shift, dst0);
+ ST_UB(dst0, dst);
+ ST_SW4(zero, zero, zero, zero, irow, 4);
+ length -= 16;
+ irow += 16;
+ dst += 16;
+ }
+ if (length > 0) {
+ int x_out;
+ if (length >= 12) {
+ uint32_t val0_m, val1_m, val2_m;
+ v4u32 src0, src1, src2;
+ LD_UW3(irow, 4, src0, src1, src2);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ CALC_MULT_FIX_4(src1, scale, shift, val1_m);
+ CALC_MULT_FIX_4(src2, scale, shift, val2_m);
+ SW3(val0_m, val1_m, val2_m, dst, 4);
+ ST_SW3(zero, zero, zero, irow, 4);
+ length -= 12;
+ irow += 12;
+ dst += 12;
+ } else if (length >= 8) {
+ uint32_t val0_m, val1_m;
+ v4u32 src0, src1;
+ LD_UW2(irow, 4, src0, src1);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ CALC_MULT_FIX_4(src1, scale, shift, val1_m);
+ SW2(val0_m, val1_m, dst, 4);
+ ST_SW2(zero, zero, irow, 4);
+ length -= 8;
+ irow += 8;
+ dst += 8;
+ } else if (length >= 4) {
+ uint32_t val0_m;
+ const v4u32 src0 = LD_UW(irow + 0);
+ CALC_MULT_FIX_4(src0, scale, shift, val0_m);
+ SW(val0_m, dst);
+ ST_SW(zero, irow);
+ length -= 4;
+ irow += 4;
+ dst += 4;
+ }
+ for (x_out = 0; x_out < length; ++x_out) {
+ const int v = (int)MULT_FIX(irow[x_out], wrk->fxy_scale);
+ assert(v >= 0 && v <= 255);
+ dst[x_out] = v;
+ irow[x_out] = 0;
+ }
+ }
+}
+
+static void RescalerExportRowShrink(WebPRescaler* const wrk) {
+ uint8_t* dst = wrk->dst;
+ rescaler_t* irow = wrk->irow;
+ const int x_out_max = wrk->dst_width * wrk->num_channels;
+ const rescaler_t* frow = wrk->frow;
+ const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
+ assert(!WebPRescalerOutputDone(wrk));
+ assert(wrk->y_accum <= 0);
+ assert(!wrk->y_expand);
+ if (yscale) {
+ ExportRowShrink_0(frow, irow, dst, x_out_max, yscale, wrk);
+ } else {
+ ExportRowShrink_1(irow, dst, x_out_max, wrk);
+ }
+}
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern void WebPRescalerDspInitMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void WebPRescalerDspInitMSA(void) {
+ WebPRescalerExportRowExpand = RescalerExportRowExpand;
+ WebPRescalerExportRowShrink = RescalerExportRowShrink;
+}
+
+#else // !WEBP_USE_MSA
+
+WEBP_DSP_INIT_STUB(WebPRescalerDspInitMSA)
+
+#endif // WEBP_USE_MSA
diff --git a/thirdparty/libwebp/dsp/rescaler_neon.c b/thirdparty/libwebp/dsp/rescaler_neon.c
index 16fd450ea3..b2dd8f30cc 100644
--- a/thirdparty/libwebp/dsp/rescaler_neon.c
+++ b/thirdparty/libwebp/dsp/rescaler_neon.c
@@ -18,7 +18,7 @@
#include <arm_neon.h>
#include <assert.h>
#include "./neon.h"
-#include "../utils/rescaler.h"
+#include "../utils/rescaler_utils.h"
#define ROUNDER (WEBP_RESCALER_ONE >> 1)
#define MULT_FIX_C(x, y) (((uint64_t)(x) * (y) + ROUNDER) >> WEBP_RESCALER_RFIX)
diff --git a/thirdparty/libwebp/dsp/rescaler_sse2.c b/thirdparty/libwebp/dsp/rescaler_sse2.c
index 5b9702817c..8271c22e05 100644
--- a/thirdparty/libwebp/dsp/rescaler_sse2.c
+++ b/thirdparty/libwebp/dsp/rescaler_sse2.c
@@ -17,7 +17,7 @@
#include <emmintrin.h>
#include <assert.h>
-#include "../utils/rescaler.h"
+#include "../utils/rescaler_utils.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/dsp/upsampling.c b/thirdparty/libwebp/dsp/upsampling.c
index 651274fcee..265e722c10 100644
--- a/thirdparty/libwebp/dsp/upsampling.c
+++ b/thirdparty/libwebp/dsp/upsampling.c
@@ -215,6 +215,7 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitYUV444Converters(void) {
extern void WebPInitUpsamplersSSE2(void);
extern void WebPInitUpsamplersNEON(void);
extern void WebPInitUpsamplersMIPSdspR2(void);
+extern void WebPInitUpsamplersMSA(void);
static volatile VP8CPUInfo upsampling_last_cpuinfo_used2 =
(VP8CPUInfo)&upsampling_last_cpuinfo_used2;
@@ -252,6 +253,11 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplers(void) {
WebPInitUpsamplersMIPSdspR2();
}
#endif
+#if defined(WEBP_USE_MSA)
+ if (VP8GetCPUInfo(kMSA)) {
+ WebPInitUpsamplersMSA();
+ }
+#endif
}
#endif // FANCY_UPSAMPLING
upsampling_last_cpuinfo_used2 = VP8GetCPUInfo;
diff --git a/thirdparty/libwebp/dsp/upsampling_msa.c b/thirdparty/libwebp/dsp/upsampling_msa.c
new file mode 100644
index 0000000000..f24926fa94
--- /dev/null
+++ b/thirdparty/libwebp/dsp/upsampling_msa.c
@@ -0,0 +1,678 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// MSA version of YUV to RGB upsampling functions.
+//
+// Author: Prashant Patil (prashant.patil@imgtec.com)
+
+#include <string.h>
+#include "./dsp.h"
+
+#if defined(WEBP_USE_MSA)
+
+#include "./msa_macro.h"
+#include "./yuv.h"
+
+#ifdef FANCY_UPSAMPLING
+
+#define ILVR_UW2(in, out0, out1) do { \
+ const v8i16 t0 = (v8i16)__msa_ilvr_b((v16i8)zero, (v16i8)in); \
+ out0 = (v4u32)__msa_ilvr_h((v8i16)zero, t0); \
+ out1 = (v4u32)__msa_ilvl_h((v8i16)zero, t0); \
+} while (0)
+
+#define ILVRL_UW4(in, out0, out1, out2, out3) do { \
+ v16u8 t0, t1; \
+ ILVRL_B2_UB(zero, in, t0, t1); \
+ ILVRL_H2_UW(zero, t0, out0, out1); \
+ ILVRL_H2_UW(zero, t1, out2, out3); \
+} while (0)
+
+#define MULTHI_16(in0, in1, in2, in3, cnst, out0, out1) do { \
+ const v4i32 const0 = (v4i32)__msa_fill_w(cnst * 256); \
+ v4u32 temp0, temp1, temp2, temp3; \
+ MUL4(in0, const0, in1, const0, in2, const0, in3, const0, \
+ temp0, temp1, temp2, temp3); \
+ PCKOD_H2_UH(temp1, temp0, temp3, temp2, out0, out1); \
+} while (0)
+
+#define MULTHI_8(in0, in1, cnst, out0) do { \
+ const v4i32 const0 = (v4i32)__msa_fill_w(cnst * 256); \
+ v4u32 temp0, temp1; \
+ MUL2(in0, const0, in1, const0, temp0, temp1); \
+ out0 = (v8u16)__msa_pckod_h((v8i16)temp1, (v8i16)temp0); \
+} while (0)
+
+#define CALC_R16(y0, y1, v0, v1, dst) do { \
+ const v8i16 const_a = (v8i16)__msa_fill_h(14234); \
+ const v8i16 a0 = __msa_adds_s_h((v8i16)y0, (v8i16)v0); \
+ const v8i16 a1 = __msa_adds_s_h((v8i16)y1, (v8i16)v1); \
+ v8i16 b0 = __msa_subs_s_h(a0, const_a); \
+ v8i16 b1 = __msa_subs_s_h(a1, const_a); \
+ SRAI_H2_SH(b0, b1, 6); \
+ CLIP_SH2_0_255(b0, b1); \
+ dst = (v16u8)__msa_pckev_b((v16i8)b1, (v16i8)b0); \
+} while (0)
+
+#define CALC_R8(y0, v0, dst) do { \
+ const v8i16 const_a = (v8i16)__msa_fill_h(14234); \
+ const v8i16 a0 = __msa_adds_s_h((v8i16)y0, (v8i16)v0); \
+ v8i16 b0 = __msa_subs_s_h(a0, const_a); \
+ b0 = SRAI_H(b0, 6); \
+ CLIP_SH_0_255(b0); \
+ dst = (v16u8)__msa_pckev_b((v16i8)b0, (v16i8)b0); \
+} while (0)
+
+#define CALC_G16(y0, y1, u0, u1, v0, v1, dst) do { \
+ const v8i16 const_a = (v8i16)__msa_fill_h(8708); \
+ v8i16 a0 = __msa_subs_s_h((v8i16)y0, (v8i16)u0); \
+ v8i16 a1 = __msa_subs_s_h((v8i16)y1, (v8i16)u1); \
+ const v8i16 b0 = __msa_subs_s_h(a0, (v8i16)v0); \
+ const v8i16 b1 = __msa_subs_s_h(a1, (v8i16)v1); \
+ a0 = __msa_adds_s_h(b0, const_a); \
+ a1 = __msa_adds_s_h(b1, const_a); \
+ SRAI_H2_SH(a0, a1, 6); \
+ CLIP_SH2_0_255(a0, a1); \
+ dst = (v16u8)__msa_pckev_b((v16i8)a1, (v16i8)a0); \
+} while (0)
+
+#define CALC_G8(y0, u0, v0, dst) do { \
+ const v8i16 const_a = (v8i16)__msa_fill_h(8708); \
+ v8i16 a0 = __msa_subs_s_h((v8i16)y0, (v8i16)u0); \
+ const v8i16 b0 = __msa_subs_s_h(a0, (v8i16)v0); \
+ a0 = __msa_adds_s_h(b0, const_a); \
+ a0 = SRAI_H(a0, 6); \
+ CLIP_SH_0_255(a0); \
+ dst = (v16u8)__msa_pckev_b((v16i8)a0, (v16i8)a0); \
+} while (0)
+
+#define CALC_B16(y0, y1, u0, u1, dst) do { \
+ const v8u16 const_a = (v8u16)__msa_fill_h(17685); \
+ const v8u16 a0 = __msa_adds_u_h((v8u16)y0, u0); \
+ const v8u16 a1 = __msa_adds_u_h((v8u16)y1, u1); \
+ v8u16 b0 = __msa_subs_u_h(a0, const_a); \
+ v8u16 b1 = __msa_subs_u_h(a1, const_a); \
+ SRAI_H2_UH(b0, b1, 6); \
+ CLIP_UH2_0_255(b0, b1); \
+ dst = (v16u8)__msa_pckev_b((v16i8)b1, (v16i8)b0); \
+} while (0)
+
+#define CALC_B8(y0, u0, dst) do { \
+ const v8u16 const_a = (v8u16)__msa_fill_h(17685); \
+ const v8u16 a0 = __msa_adds_u_h((v8u16)y0, u0); \
+ v8u16 b0 = __msa_subs_u_h(a0, const_a); \
+ b0 = SRAI_H(b0, 6); \
+ CLIP_UH_0_255(b0); \
+ dst = (v16u8)__msa_pckev_b((v16i8)b0, (v16i8)b0); \
+} while (0)
+
+#define CALC_RGB16(y, u, v, R, G, B) do { \
+ const v16u8 zero = { 0 }; \
+ v8u16 y0, y1, u0, u1, v0, v1; \
+ v4u32 p0, p1, p2, p3; \
+ const v16u8 in_y = LD_UB(y); \
+ const v16u8 in_u = LD_UB(u); \
+ const v16u8 in_v = LD_UB(v); \
+ ILVRL_UW4(in_y, p0, p1, p2, p3); \
+ MULTHI_16(p0, p1, p2, p3, 19077, y0, y1); \
+ ILVRL_UW4(in_v, p0, p1, p2, p3); \
+ MULTHI_16(p0, p1, p2, p3, 26149, v0, v1); \
+ CALC_R16(y0, y1, v0, v1, R); \
+ MULTHI_16(p0, p1, p2, p3, 13320, v0, v1); \
+ ILVRL_UW4(in_u, p0, p1, p2, p3); \
+ MULTHI_16(p0, p1, p2, p3, 6419, u0, u1); \
+ CALC_G16(y0, y1, u0, u1, v0, v1, G); \
+ MULTHI_16(p0, p1, p2, p3, 33050, u0, u1); \
+ CALC_B16(y0, y1, u0, u1, B); \
+} while (0)
+
+#define CALC_RGB8(y, u, v, R, G, B) do { \
+ const v16u8 zero = { 0 }; \
+ v8u16 y0, u0, v0; \
+ v4u32 p0, p1; \
+ const v16u8 in_y = LD_UB(y); \
+ const v16u8 in_u = LD_UB(u); \
+ const v16u8 in_v = LD_UB(v); \
+ ILVR_UW2(in_y, p0, p1); \
+ MULTHI_8(p0, p1, 19077, y0); \
+ ILVR_UW2(in_v, p0, p1); \
+ MULTHI_8(p0, p1, 26149, v0); \
+ CALC_R8(y0, v0, R); \
+ MULTHI_8(p0, p1, 13320, v0); \
+ ILVR_UW2(in_u, p0, p1); \
+ MULTHI_8(p0, p1, 6419, u0); \
+ CALC_G8(y0, u0, v0, G); \
+ MULTHI_8(p0, p1, 33050, u0); \
+ CALC_B8(y0, u0, B); \
+} while (0)
+
+#define STORE16_3(a0, a1, a2, dst) do { \
+ const v16u8 mask0 = { 0, 1, 16, 2, 3, 17, 4, 5, 18, 6, 7, 19, \
+ 8, 9, 20, 10 }; \
+ const v16u8 mask1 = { 0, 21, 1, 2, 22, 3, 4, 23, 5, 6, 24, 7, \
+ 8, 25, 9, 10 }; \
+ const v16u8 mask2 = { 26, 0, 1, 27, 2, 3, 28, 4, 5, 29, 6, 7, \
+ 30, 8, 9, 31 }; \
+ v16u8 out0, out1, out2, tmp0, tmp1, tmp2; \
+ ILVRL_B2_UB(a1, a0, tmp0, tmp1); \
+ out0 = VSHF_UB(tmp0, a2, mask0); \
+ tmp2 = SLDI_UB(tmp1, tmp0, 11); \
+ out1 = VSHF_UB(tmp2, a2, mask1); \
+ tmp2 = SLDI_UB(tmp1, tmp1, 6); \
+ out2 = VSHF_UB(tmp2, a2, mask2); \
+ ST_UB(out0, dst + 0); \
+ ST_UB(out1, dst + 16); \
+ ST_UB(out2, dst + 32); \
+} while (0)
+
+#define STORE8_3(a0, a1, a2, dst) do { \
+ int64_t out_m; \
+ const v16u8 mask0 = { 0, 1, 16, 2, 3, 17, 4, 5, 18, 6, 7, 19, \
+ 8, 9, 20, 10 }; \
+ const v16u8 mask1 = { 11, 21, 12, 13, 22, 14, 15, 23, \
+ 255, 255, 255, 255, 255, 255, 255, 255 }; \
+ const v16u8 tmp0 = (v16u8)__msa_ilvr_b((v16i8)a1, (v16i8)a0); \
+ v16u8 out0, out1; \
+ VSHF_B2_UB(tmp0, a2, tmp0, a2, mask0, mask1, out0, out1); \
+ ST_UB(out0, dst); \
+ out_m = __msa_copy_s_d((v2i64)out1, 0); \
+ SD(out_m, dst + 16); \
+} while (0)
+
+#define STORE16_4(a0, a1, a2, a3, dst) do { \
+ v16u8 tmp0, tmp1, tmp2, tmp3; \
+ v16u8 out0, out1, out2, out3; \
+ ILVRL_B2_UB(a1, a0, tmp0, tmp1); \
+ ILVRL_B2_UB(a3, a2, tmp2, tmp3); \
+ ILVRL_H2_UB(tmp2, tmp0, out0, out1); \
+ ILVRL_H2_UB(tmp3, tmp1, out2, out3); \
+ ST_UB(out0, dst + 0); \
+ ST_UB(out1, dst + 16); \
+ ST_UB(out2, dst + 32); \
+ ST_UB(out3, dst + 48); \
+} while (0)
+
+#define STORE8_4(a0, a1, a2, a3, dst) do { \
+ v16u8 tmp0, tmp1, tmp2, tmp3; \
+ ILVR_B2_UB(a1, a0, a3, a2, tmp0, tmp1); \
+ ILVRL_H2_UB(tmp1, tmp0, tmp2, tmp3); \
+ ST_UB(tmp2, dst + 0); \
+ ST_UB(tmp3, dst + 16); \
+} while (0)
+
+#define STORE2_16(a0, a1, dst) do { \
+ v16u8 out0, out1; \
+ ILVRL_B2_UB(a1, a0, out0, out1); \
+ ST_UB(out0, dst + 0); \
+ ST_UB(out1, dst + 16); \
+} while (0)
+
+#define STORE2_8(a0, a1, dst) do { \
+ const v16u8 out0 = (v16u8)__msa_ilvr_b((v16i8)a1, (v16i8)a0); \
+ ST_UB(out0, dst); \
+} while (0)
+
+#define CALC_RGBA4444(y, u, v, out0, out1, N, dst) do { \
+ CALC_RGB##N(y, u, v, R, G, B); \
+ tmp0 = ANDI_B(R, 0xf0); \
+ tmp1 = SRAI_B(G, 4); \
+ RG = tmp0 | tmp1; \
+ tmp0 = ANDI_B(B, 0xf0); \
+ BA = ORI_B(tmp0, 0x0f); \
+ STORE2_##N(out0, out1, dst); \
+} while (0)
+
+#define CALC_RGB565(y, u, v, out0, out1, N, dst) do { \
+ CALC_RGB##N(y, u, v, R, G, B); \
+ tmp0 = ANDI_B(R, 0xf8); \
+ tmp1 = SRAI_B(G, 5); \
+ RG = tmp0 | tmp1; \
+ tmp0 = SLLI_B(G, 3); \
+ tmp1 = ANDI_B(tmp0, 0xe0); \
+ tmp0 = SRAI_B(B, 3); \
+ GB = tmp0 | tmp1; \
+ STORE2_##N(out0, out1, dst); \
+} while (0)
+
+static WEBP_INLINE int Clip8(int v) {
+ return v < 0 ? 0 : v > 255 ? 255 : v;
+}
+
+static void YuvToRgb(int y, int u, int v, uint8_t* const rgb) {
+ const int y1 = MultHi(y, 19077);
+ const int r1 = y1 + MultHi(v, 26149) - 14234;
+ const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
+ const int b1 = y1 + MultHi(u, 33050) - 17685;
+ rgb[0] = Clip8(r1 >> 6);
+ rgb[1] = Clip8(g1 >> 6);
+ rgb[2] = Clip8(b1 >> 6);
+}
+
+static void YuvToBgr(int y, int u, int v, uint8_t* const bgr) {
+ const int y1 = MultHi(y, 19077);
+ const int r1 = y1 + MultHi(v, 26149) - 14234;
+ const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
+ const int b1 = y1 + MultHi(u, 33050) - 17685;
+ bgr[0] = Clip8(b1 >> 6);
+ bgr[1] = Clip8(g1 >> 6);
+ bgr[2] = Clip8(r1 >> 6);
+}
+
+static void YuvToRgb565(int y, int u, int v, uint8_t* const rgb) {
+ const int y1 = MultHi(y, 19077);
+ const int r1 = y1 + MultHi(v, 26149) - 14234;
+ const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
+ const int b1 = y1 + MultHi(u, 33050) - 17685;
+ const int r = Clip8(r1 >> 6);
+ const int g = Clip8(g1 >> 6);
+ const int b = Clip8(b1 >> 6);
+ const int rg = (r & 0xf8) | (g >> 5);
+ const int gb = ((g << 3) & 0xe0) | (b >> 3);
+#ifdef WEBP_SWAP_16BIT_CSP
+ rgb[0] = gb;
+ rgb[1] = rg;
+#else
+ rgb[0] = rg;
+ rgb[1] = gb;
+#endif
+}
+
+static void YuvToRgba4444(int y, int u, int v, uint8_t* const argb) {
+ const int y1 = MultHi(y, 19077);
+ const int r1 = y1 + MultHi(v, 26149) - 14234;
+ const int g1 = y1 - MultHi(u, 6419) - MultHi(v, 13320) + 8708;
+ const int b1 = y1 + MultHi(u, 33050) - 17685;
+ const int r = Clip8(r1 >> 6);
+ const int g = Clip8(g1 >> 6);
+ const int b = Clip8(b1 >> 6);
+ const int rg = (r & 0xf0) | (g >> 4);
+ const int ba = (b & 0xf0) | 0x0f; // overwrite the lower 4 bits
+#ifdef WEBP_SWAP_16BIT_CSP
+ argb[0] = ba;
+ argb[1] = rg;
+#else
+ argb[0] = rg;
+ argb[1] = ba;
+#endif
+}
+
+static void YuvToArgb(uint8_t y, uint8_t u, uint8_t v, uint8_t* const argb) {
+ argb[0] = 0xff;
+ YuvToRgb(y, u, v, argb + 1);
+}
+
+static void YuvToBgra(uint8_t y, uint8_t u, uint8_t v, uint8_t* const bgra) {
+ YuvToBgr(y, u, v, bgra);
+ bgra[3] = 0xff;
+}
+
+static void YuvToRgba(uint8_t y, uint8_t u, uint8_t v, uint8_t* const rgba) {
+ YuvToRgb(y, u, v, rgba);
+ rgba[3] = 0xff;
+}
+
+static void YuvToRgbLine(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B;
+ while (length >= 16) {
+ CALC_RGB16(y, u, v, R, G, B);
+ STORE16_3(R, G, B, dst);
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 3;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[3 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB16(temp, u, v, R, G, B);
+ STORE16_3(R, G, B, temp);
+ memcpy(dst, temp, length * 3 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[3 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB8(temp, u, v, R, G, B);
+ STORE8_3(R, G, B, temp);
+ memcpy(dst, temp, length * 3 * sizeof(*dst));
+ }
+}
+
+static void YuvToBgrLine(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B;
+ while (length >= 16) {
+ CALC_RGB16(y, u, v, R, G, B);
+ STORE16_3(B, G, R, dst);
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 3;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[3 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB16(temp, u, v, R, G, B);
+ STORE16_3(B, G, R, temp);
+ memcpy(dst, temp, length * 3 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[3 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB8(temp, u, v, R, G, B);
+ STORE8_3(B, G, R, temp);
+ memcpy(dst, temp, length * 3 * sizeof(*dst));
+ }
+}
+
+static void YuvToRgbaLine(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B;
+ const v16u8 A = (v16u8)__msa_ldi_b(0xff);
+ while (length >= 16) {
+ CALC_RGB16(y, u, v, R, G, B);
+ STORE16_4(R, G, B, A, dst);
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 4;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[4 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB16(&temp[0], u, v, R, G, B);
+ STORE16_4(R, G, B, A, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[4 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB8(temp, u, v, R, G, B);
+ STORE8_4(R, G, B, A, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ }
+}
+
+static void YuvToBgraLine(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B;
+ const v16u8 A = (v16u8)__msa_ldi_b(0xff);
+ while (length >= 16) {
+ CALC_RGB16(y, u, v, R, G, B);
+ STORE16_4(B, G, R, A, dst);
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 4;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[4 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB16(temp, u, v, R, G, B);
+ STORE16_4(B, G, R, A, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[4 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB8(temp, u, v, R, G, B);
+ STORE8_4(B, G, R, A, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ }
+}
+
+static void YuvToArgbLine(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B;
+ const v16u8 A = (v16u8)__msa_ldi_b(0xff);
+ while (length >= 16) {
+ CALC_RGB16(y, u, v, R, G, B);
+ STORE16_4(A, R, G, B, dst);
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 4;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[4 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB16(temp, u, v, R, G, B);
+ STORE16_4(A, R, G, B, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[4 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+ CALC_RGB8(temp, u, v, R, G, B);
+ STORE8_4(A, R, G, B, temp);
+ memcpy(dst, temp, length * 4 * sizeof(*dst));
+ }
+}
+
+static void YuvToRgba4444Line(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B, RG, BA, tmp0, tmp1;
+ while (length >= 16) {
+ #ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGBA4444(y, u, v, BA, RG, 16, dst);
+ #else
+ CALC_RGBA4444(y, u, v, RG, BA, 16, dst);
+ #endif
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 2;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[2 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+#ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGBA4444(temp, u, v, BA, RG, 16, temp);
+#else
+ CALC_RGBA4444(temp, u, v, RG, BA, 16, temp);
+#endif
+ memcpy(dst, temp, length * 2 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[2 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+#ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGBA4444(temp, u, v, BA, RG, 8, temp);
+#else
+ CALC_RGBA4444(temp, u, v, RG, BA, 8, temp);
+#endif
+ memcpy(dst, temp, length * 2 * sizeof(*dst));
+ }
+}
+
+static void YuvToRgb565Line(const uint8_t* y, const uint8_t* u,
+ const uint8_t* v, uint8_t* dst, int length) {
+ v16u8 R, G, B, RG, GB, tmp0, tmp1;
+ while (length >= 16) {
+ #ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGB565(y, u, v, GB, RG, 16, dst);
+ #else
+ CALC_RGB565(y, u, v, RG, GB, 16, dst);
+ #endif
+ y += 16;
+ u += 16;
+ v += 16;
+ dst += 16 * 2;
+ length -= 16;
+ }
+ if (length > 8) {
+ uint8_t temp[2 * 16] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+#ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGB565(temp, u, v, GB, RG, 16, temp);
+#else
+ CALC_RGB565(temp, u, v, RG, GB, 16, temp);
+#endif
+ memcpy(dst, temp, length * 2 * sizeof(*dst));
+ } else if (length > 0) {
+ uint8_t temp[2 * 8] = { 0 };
+ memcpy(temp, y, length * sizeof(*temp));
+#ifdef WEBP_SWAP_16BIT_CSP
+ CALC_RGB565(temp, u, v, GB, RG, 8, temp);
+#else
+ CALC_RGB565(temp, u, v, RG, GB, 8, temp);
+#endif
+ memcpy(dst, temp, length * 2 * sizeof(*dst));
+ }
+}
+
+#define UPSAMPLE_32PIXELS(a, b, c, d) do { \
+ v16u8 s = __msa_aver_u_b(a, d); \
+ v16u8 t = __msa_aver_u_b(b, c); \
+ const v16u8 st = s ^ t; \
+ v16u8 ad = a ^ d; \
+ v16u8 bc = b ^ c; \
+ v16u8 t0 = ad | bc; \
+ v16u8 t1 = t0 | st; \
+ v16u8 t2 = ANDI_B(t1, 1); \
+ v16u8 t3 = __msa_aver_u_b(s, t); \
+ const v16u8 k = t3 - t2; \
+ v16u8 diag1, diag2; \
+ AVER_UB2_UB(t, k, s, k, t0, t1); \
+ bc = bc & st; \
+ ad = ad & st; \
+ t = t ^ k; \
+ s = s ^ k; \
+ t2 = bc | t; \
+ t3 = ad | s; \
+ t2 = ANDI_B(t2, 1); \
+ t3 = ANDI_B(t3, 1); \
+ SUB2(t0, t2, t1, t3, diag1, diag2); \
+ AVER_UB2_UB(a, diag1, b, diag2, t0, t1); \
+ ILVRL_B2_UB(t1, t0, a, b); \
+ if (pbot_y != NULL) { \
+ AVER_UB2_UB(c, diag2, d, diag1, t0, t1); \
+ ILVRL_B2_UB(t1, t0, c, d); \
+ } \
+} while (0)
+
+#define UPSAMPLE_FUNC(FUNC_NAME, FUNC, XSTEP) \
+static void FUNC_NAME(const uint8_t* top_y, const uint8_t* bot_y, \
+ const uint8_t* top_u, const uint8_t* top_v, \
+ const uint8_t* cur_u, const uint8_t* cur_v, \
+ uint8_t* top_dst, uint8_t* bot_dst, int len) \
+{ \
+ int size = (len - 1) >> 1; \
+ uint8_t temp_u[64]; \
+ uint8_t temp_v[64]; \
+ const uint32_t tl_uv = ((top_u[0]) | ((top_v[0]) << 16)); \
+ const uint32_t l_uv = ((cur_u[0]) | ((cur_v[0]) << 16)); \
+ const uint32_t uv0 = (3 * tl_uv + l_uv + 0x00020002u) >> 2; \
+ const uint8_t* ptop_y = &top_y[1]; \
+ uint8_t *ptop_dst = top_dst + XSTEP; \
+ const uint8_t* pbot_y = &bot_y[1]; \
+ uint8_t *pbot_dst = bot_dst + XSTEP; \
+ \
+ FUNC(top_y[0], uv0 & 0xff, (uv0 >> 16), top_dst); \
+ if (bot_y != NULL) { \
+ const uint32_t uv1 = (3 * l_uv + tl_uv + 0x00020002u) >> 2; \
+ FUNC(bot_y[0], uv1 & 0xff, (uv1 >> 16), bot_dst); \
+ } \
+ while (size >= 16) { \
+ v16u8 tu0, tu1, tv0, tv1, cu0, cu1, cv0, cv1; \
+ LD_UB2(top_u, 1, tu0, tu1); \
+ LD_UB2(cur_u, 1, cu0, cu1); \
+ LD_UB2(top_v, 1, tv0, tv1); \
+ LD_UB2(cur_v, 1, cv0, cv1); \
+ UPSAMPLE_32PIXELS(tu0, tu1, cu0, cu1); \
+ UPSAMPLE_32PIXELS(tv0, tv1, cv0, cv1); \
+ ST_UB4(tu0, tu1, cu0, cu1, &temp_u[0], 16); \
+ ST_UB4(tv0, tv1, cv0, cv1, &temp_v[0], 16); \
+ FUNC##Line(ptop_y, &temp_u[ 0], &temp_v[0], ptop_dst, 32); \
+ if (bot_y != NULL) { \
+ FUNC##Line(pbot_y, &temp_u[32], &temp_v[32], pbot_dst, 32); \
+ } \
+ ptop_y += 32; \
+ pbot_y += 32; \
+ ptop_dst += XSTEP * 32; \
+ pbot_dst += XSTEP * 32; \
+ top_u += 16; \
+ top_v += 16; \
+ cur_u += 16; \
+ cur_v += 16; \
+ size -= 16; \
+ } \
+ if (size > 0) { \
+ v16u8 tu0, tu1, tv0, tv1, cu0, cu1, cv0, cv1; \
+ memcpy(&temp_u[ 0], top_u, 17 * sizeof(uint8_t)); \
+ memcpy(&temp_u[32], cur_u, 17 * sizeof(uint8_t)); \
+ memcpy(&temp_v[ 0], top_v, 17 * sizeof(uint8_t)); \
+ memcpy(&temp_v[32], cur_v, 17 * sizeof(uint8_t)); \
+ LD_UB2(&temp_u[ 0], 1, tu0, tu1); \
+ LD_UB2(&temp_u[32], 1, cu0, cu1); \
+ LD_UB2(&temp_v[ 0], 1, tv0, tv1); \
+ LD_UB2(&temp_v[32], 1, cv0, cv1); \
+ UPSAMPLE_32PIXELS(tu0, tu1, cu0, cu1); \
+ UPSAMPLE_32PIXELS(tv0, tv1, cv0, cv1); \
+ ST_UB4(tu0, tu1, cu0, cu1, &temp_u[0], 16); \
+ ST_UB4(tv0, tv1, cv0, cv1, &temp_v[0], 16); \
+ FUNC##Line(ptop_y, &temp_u[ 0], &temp_v[0], ptop_dst, size * 2); \
+ if (bot_y != NULL) { \
+ FUNC##Line(pbot_y, &temp_u[32], &temp_v[32], pbot_dst, size * 2); \
+ } \
+ top_u += size; \
+ top_v += size; \
+ cur_u += size; \
+ cur_v += size; \
+ } \
+ if (!(len & 1)) { \
+ const uint32_t t0 = ((top_u[0]) | ((top_v[0]) << 16)); \
+ const uint32_t c0 = ((cur_u[0]) | ((cur_v[0]) << 16)); \
+ const uint32_t tmp0 = (3 * t0 + c0 + 0x00020002u) >> 2; \
+ FUNC(top_y[len - 1], tmp0 & 0xff, (tmp0 >> 16), \
+ top_dst + (len - 1) * XSTEP); \
+ if (bot_y != NULL) { \
+ const uint32_t tmp1 = (3 * c0 + t0 + 0x00020002u) >> 2; \
+ FUNC(bot_y[len - 1], tmp1 & 0xff, (tmp1 >> 16), \
+ bot_dst + (len - 1) * XSTEP); \
+ } \
+ } \
+}
+
+UPSAMPLE_FUNC(UpsampleRgbLinePair, YuvToRgb, 3)
+UPSAMPLE_FUNC(UpsampleBgrLinePair, YuvToBgr, 3)
+UPSAMPLE_FUNC(UpsampleRgbaLinePair, YuvToRgba, 4)
+UPSAMPLE_FUNC(UpsampleBgraLinePair, YuvToBgra, 4)
+UPSAMPLE_FUNC(UpsampleArgbLinePair, YuvToArgb, 4)
+UPSAMPLE_FUNC(UpsampleRgba4444LinePair, YuvToRgba4444, 2)
+UPSAMPLE_FUNC(UpsampleRgb565LinePair, YuvToRgb565, 2)
+
+//------------------------------------------------------------------------------
+// Entry point
+
+extern WebPUpsampleLinePairFunc WebPUpsamplers[/* MODE_LAST */];
+
+extern void WebPInitUpsamplersMSA(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void WebPInitUpsamplersMSA(void) {
+ WebPUpsamplers[MODE_RGB] = UpsampleRgbLinePair;
+ WebPUpsamplers[MODE_RGBA] = UpsampleRgbaLinePair;
+ WebPUpsamplers[MODE_BGR] = UpsampleBgrLinePair;
+ WebPUpsamplers[MODE_BGRA] = UpsampleBgraLinePair;
+ WebPUpsamplers[MODE_ARGB] = UpsampleArgbLinePair;
+ WebPUpsamplers[MODE_rgbA] = UpsampleRgbaLinePair;
+ WebPUpsamplers[MODE_bgrA] = UpsampleBgraLinePair;
+ WebPUpsamplers[MODE_Argb] = UpsampleArgbLinePair;
+ WebPUpsamplers[MODE_RGB_565] = UpsampleRgb565LinePair;
+ WebPUpsamplers[MODE_RGBA_4444] = UpsampleRgba4444LinePair;
+ WebPUpsamplers[MODE_rgbA_4444] = UpsampleRgba4444LinePair;
+}
+
+#endif // FANCY_UPSAMPLING
+
+#endif // WEBP_USE_MSA
+
+#if !(defined(FANCY_UPSAMPLING) && defined(WEBP_USE_MSA))
+WEBP_DSP_INIT_STUB(WebPInitUpsamplersMSA)
+#endif
diff --git a/thirdparty/libwebp/dsp/upsampling_neon.c b/thirdparty/libwebp/dsp/upsampling_neon.c
index 2b0c99bddb..d371a834ff 100644
--- a/thirdparty/libwebp/dsp/upsampling_neon.c
+++ b/thirdparty/libwebp/dsp/upsampling_neon.c
@@ -28,47 +28,34 @@
// U/V upsampling
// Loads 9 pixels each from rows r1 and r2 and generates 16 pixels.
-#define UPSAMPLE_16PIXELS(r1, r2, out) { \
- uint8x8_t a = vld1_u8(r1); \
- uint8x8_t b = vld1_u8(r1 + 1); \
- uint8x8_t c = vld1_u8(r2); \
- uint8x8_t d = vld1_u8(r2 + 1); \
- \
- uint16x8_t al = vshll_n_u8(a, 1); \
- uint16x8_t bl = vshll_n_u8(b, 1); \
- uint16x8_t cl = vshll_n_u8(c, 1); \
- uint16x8_t dl = vshll_n_u8(d, 1); \
- \
- uint8x8_t diag1, diag2; \
- uint16x8_t sl; \
- \
+#define UPSAMPLE_16PIXELS(r1, r2, out) do { \
+ const uint8x8_t a = vld1_u8(r1 + 0); \
+ const uint8x8_t b = vld1_u8(r1 + 1); \
+ const uint8x8_t c = vld1_u8(r2 + 0); \
+ const uint8x8_t d = vld1_u8(r2 + 1); \
/* a + b + c + d */ \
- sl = vaddl_u8(a, b); \
- sl = vaddw_u8(sl, c); \
- sl = vaddw_u8(sl, d); \
- \
- al = vaddq_u16(sl, al); /* 3a + b + c + d */ \
- bl = vaddq_u16(sl, bl); /* a + 3b + c + d */ \
- \
- al = vaddq_u16(al, dl); /* 3a + b + c + 3d */ \
- bl = vaddq_u16(bl, cl); /* a + 3b + 3c + d */ \
+ const uint16x8_t ad = vaddl_u8(a, d); \
+ const uint16x8_t bc = vaddl_u8(b, c); \
+ const uint16x8_t abcd = vaddq_u16(ad, bc); \
+ /* 3a + b + c + 3d */ \
+ const uint16x8_t al = vaddq_u16(abcd, vshlq_n_u16(ad, 1)); \
+ /* a + 3b + 3c + d */ \
+ const uint16x8_t bl = vaddq_u16(abcd, vshlq_n_u16(bc, 1)); \
\
- diag2 = vshrn_n_u16(al, 3); \
- diag1 = vshrn_n_u16(bl, 3); \
+ const uint8x8_t diag2 = vshrn_n_u16(al, 3); \
+ const uint8x8_t diag1 = vshrn_n_u16(bl, 3); \
\
- a = vrhadd_u8(a, diag1); \
- b = vrhadd_u8(b, diag2); \
- c = vrhadd_u8(c, diag2); \
- d = vrhadd_u8(d, diag1); \
+ const uint8x8_t A = vrhadd_u8(a, diag1); \
+ const uint8x8_t B = vrhadd_u8(b, diag2); \
+ const uint8x8_t C = vrhadd_u8(c, diag2); \
+ const uint8x8_t D = vrhadd_u8(d, diag1); \
\
- { \
- uint8x8x2_t a_b, c_d; \
- INIT_VECTOR2(a_b, a, b); \
- INIT_VECTOR2(c_d, c, d); \
- vst2_u8(out, a_b); \
- vst2_u8(out + 32, c_d); \
- } \
-}
+ uint8x8x2_t A_B, C_D; \
+ INIT_VECTOR2(A_B, A, B); \
+ INIT_VECTOR2(C_D, C, D); \
+ vst2_u8(out + 0, A_B); \
+ vst2_u8(out + 32, C_D); \
+} while (0)
// Turn the macro into a function for reducing code-size when non-critical
static void Upsample16Pixels(const uint8_t *r1, const uint8_t *r2,
@@ -93,7 +80,6 @@ static void Upsample16Pixels(const uint8_t *r1, const uint8_t *r2,
static const int16_t kCoeffs1[4] = { 19077, 26149, 6419, 13320 };
#define v255 vdup_n_u8(255)
-#define v_0x0f vdup_n_u8(15)
#define STORE_Rgb(out, r, g, b) do { \
uint8x8x3_t r_g_b; \
@@ -132,21 +118,16 @@ static const int16_t kCoeffs1[4] = { 19077, 26149, 6419, 13320 };
#endif
#define STORE_Rgba4444(out, r, g, b) do { \
- const uint8x8_t r1 = vshl_n_u8(vshr_n_u8(r, 4), 4); /* 4bits */ \
- const uint8x8_t g1 = vshr_n_u8(g, 4); \
- const uint8x8_t ba = vorr_u8(b, v_0x0f); \
- const uint8x8_t rg = vorr_u8(r1, g1); \
+ const uint8x8_t rg = vsri_n_u8(r, g, 4); /* shift g, insert r */ \
+ const uint8x8_t ba = vsri_n_u8(b, v255, 4); /* shift a, insert b */ \
const uint8x8x2_t rgba4444 = ZIP_U8(rg, ba); \
vst1q_u8(out, vcombine_u8(rgba4444.val[0], rgba4444.val[1])); \
} while (0)
#define STORE_Rgb565(out, r, g, b) do { \
- const uint8x8_t r1 = vshl_n_u8(vshr_n_u8(r, 3), 3); /* 5bits */ \
- const uint8x8_t g1 = vshr_n_u8(g, 5); /* upper 3bits */\
- const uint8x8_t g2 = vshl_n_u8(vshr_n_u8(g, 2), 5); /* lower 3bits */\
- const uint8x8_t b1 = vshr_n_u8(b, 3); /* 5bits */ \
- const uint8x8_t rg = vorr_u8(r1, g1); \
- const uint8x8_t gb = vorr_u8(g2, b1); \
+ const uint8x8_t rg = vsri_n_u8(r, g, 5); /* shift g and insert r */ \
+ const uint8x8_t g1 = vshl_n_u8(g, 3); /* pre-shift g: 3bits */ \
+ const uint8x8_t gb = vsri_n_u8(g1, b, 3); /* shift b and insert g */ \
const uint8x8x2_t rgb565 = ZIP_U8(rg, gb); \
vst1q_u8(out, vcombine_u8(rgb565.val[0], rgb565.val[1])); \
} while (0)
diff --git a/thirdparty/libwebp/dsp/yuv.c b/thirdparty/libwebp/dsp/yuv.c
index f50a253168..dd7d9dedfa 100644
--- a/thirdparty/libwebp/dsp/yuv.c
+++ b/thirdparty/libwebp/dsp/yuv.c
@@ -13,6 +13,8 @@
#include "./yuv.h"
+#include <stdlib.h>
+
#if defined(WEBP_YUV_USE_TABLE)
static int done = 0;
@@ -244,6 +246,48 @@ void WebPConvertRGBA32ToUV_C(const uint16_t* rgb,
//-----------------------------------------------------------------------------
+#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic
+static uint16_t clip_y(int v) {
+ return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v;
+}
+
+static uint64_t SharpYUVUpdateY_C(const uint16_t* ref, const uint16_t* src,
+ uint16_t* dst, int len) {
+ uint64_t diff = 0;
+ int i;
+ for (i = 0; i < len; ++i) {
+ const int diff_y = ref[i] - src[i];
+ const int new_y = (int)dst[i] + diff_y;
+ dst[i] = clip_y(new_y);
+ diff += (uint64_t)abs(diff_y);
+ }
+ return diff;
+}
+
+static void SharpYUVUpdateRGB_C(const int16_t* ref, const int16_t* src,
+ int16_t* dst, int len) {
+ int i;
+ for (i = 0; i < len; ++i) {
+ const int diff_uv = ref[i] - src[i];
+ dst[i] += diff_uv;
+ }
+}
+
+static void SharpYUVFilterRow_C(const int16_t* A, const int16_t* B, int len,
+ const uint16_t* best_y, uint16_t* out) {
+ int i;
+ for (i = 0; i < len; ++i, ++A, ++B) {
+ const int v0 = (A[0] * 9 + A[1] * 3 + B[0] * 3 + B[1] + 8) >> 4;
+ const int v1 = (A[1] * 9 + A[0] * 3 + B[1] * 3 + B[0] + 8) >> 4;
+ out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0);
+ out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1);
+ }
+}
+
+#undef MAX_Y
+
+//-----------------------------------------------------------------------------
+
void (*WebPConvertRGB24ToY)(const uint8_t* rgb, uint8_t* y, int width);
void (*WebPConvertBGR24ToY)(const uint8_t* bgr, uint8_t* y, int width);
void (*WebPConvertRGBA32ToUV)(const uint16_t* rgb,
@@ -253,10 +297,18 @@ void (*WebPConvertARGBToY)(const uint32_t* argb, uint8_t* y, int width);
void (*WebPConvertARGBToUV)(const uint32_t* argb, uint8_t* u, uint8_t* v,
int src_width, int do_store);
+uint64_t (*WebPSharpYUVUpdateY)(const uint16_t* ref, const uint16_t* src,
+ uint16_t* dst, int len);
+void (*WebPSharpYUVUpdateRGB)(const int16_t* ref, const int16_t* src,
+ int16_t* dst, int len);
+void (*WebPSharpYUVFilterRow)(const int16_t* A, const int16_t* B, int len,
+ const uint16_t* best_y, uint16_t* out);
+
static volatile VP8CPUInfo rgba_to_yuv_last_cpuinfo_used =
(VP8CPUInfo)&rgba_to_yuv_last_cpuinfo_used;
extern void WebPInitConvertARGBToYUVSSE2(void);
+extern void WebPInitSharpYUVSSE2(void);
WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUV(void) {
if (rgba_to_yuv_last_cpuinfo_used == VP8GetCPUInfo) return;
@@ -269,10 +321,15 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUV(void) {
WebPConvertRGBA32ToUV = WebPConvertRGBA32ToUV_C;
+ WebPSharpYUVUpdateY = SharpYUVUpdateY_C;
+ WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_C;
+ WebPSharpYUVFilterRow = SharpYUVFilterRow_C;
+
if (VP8GetCPUInfo != NULL) {
#if defined(WEBP_USE_SSE2)
if (VP8GetCPUInfo(kSSE2)) {
WebPInitConvertARGBToYUVSSE2();
+ WebPInitSharpYUVSSE2();
}
#endif // WEBP_USE_SSE2
}
diff --git a/thirdparty/libwebp/dsp/yuv.h b/thirdparty/libwebp/dsp/yuv.h
index 01c40fcb84..1d33b5863b 100644
--- a/thirdparty/libwebp/dsp/yuv.h
+++ b/thirdparty/libwebp/dsp/yuv.h
@@ -36,7 +36,7 @@
#define WEBP_DSP_YUV_H_
#include "./dsp.h"
-#include "../dec/decode_vp8.h"
+#include "../dec/vp8_dec.h"
#if defined(WEBP_EXPERIMENTAL_FEATURES)
// Do NOT activate this feature for real compression. This is only experimental!
diff --git a/thirdparty/libwebp/dsp/yuv_sse2.c b/thirdparty/libwebp/dsp/yuv_sse2.c
index e19bddff6c..e33c2bbafd 100644
--- a/thirdparty/libwebp/dsp/yuv_sse2.c
+++ b/thirdparty/libwebp/dsp/yuv_sse2.c
@@ -15,6 +15,8 @@
#if defined(WEBP_USE_SSE2)
+#include "./common_sse2.h"
+#include <stdlib.h>
#include <emmintrin.h>
//-----------------------------------------------------------------------------
@@ -155,30 +157,13 @@ static WEBP_INLINE void PackAndStore565(const __m128i* const R,
_mm_storeu_si128((__m128i*)dst, rgb565);
}
-// Function used several times in PlanarTo24b.
-// It samples the in buffer as follows: one every two unsigned char is stored
-// at the beginning of the buffer, while the other half is stored at the end.
-static WEBP_INLINE void PlanarTo24bHelper(const __m128i* const in /*in[6]*/,
- __m128i* const out /*out[6]*/) {
- const __m128i v_mask = _mm_set1_epi16(0x00ff);
-
- // Take one every two upper 8b values.
- out[0] = _mm_packus_epi16(_mm_and_si128(in[0], v_mask),
- _mm_and_si128(in[1], v_mask));
- out[1] = _mm_packus_epi16(_mm_and_si128(in[2], v_mask),
- _mm_and_si128(in[3], v_mask));
- out[2] = _mm_packus_epi16(_mm_and_si128(in[4], v_mask),
- _mm_and_si128(in[5], v_mask));
- // Take one every two lower 8b values.
- out[3] = _mm_packus_epi16(_mm_srli_epi16(in[0], 8), _mm_srli_epi16(in[1], 8));
- out[4] = _mm_packus_epi16(_mm_srli_epi16(in[2], 8), _mm_srli_epi16(in[3], 8));
- out[5] = _mm_packus_epi16(_mm_srli_epi16(in[4], 8), _mm_srli_epi16(in[5], 8));
-}
-
// Pack the planar buffers
// rrrr... rrrr... gggg... gggg... bbbb... bbbb....
// triplet by triplet in the output buffer rgb as rgbrgbrgbrgb ...
-static WEBP_INLINE void PlanarTo24b(__m128i* const in /*in[6]*/, uint8_t* rgb) {
+static WEBP_INLINE void PlanarTo24b(__m128i* const in0, __m128i* const in1,
+ __m128i* const in2, __m128i* const in3,
+ __m128i* const in4, __m128i* const in5,
+ uint8_t* const rgb) {
// The input is 6 registers of sixteen 8b but for the sake of explanation,
// let's take 6 registers of four 8b values.
// To pack, we will keep taking one every two 8b integer and move it
@@ -191,22 +176,15 @@ static WEBP_INLINE void PlanarTo24b(__m128i* const in /*in[6]*/, uint8_t* rgb) {
// Repeat the same permutations twice more:
// r0r4g0g4 | b0b4r1r5 | g1g5b1b5 | r2r6g2g6 | b2b6r3r7 | g3g7b3b7
// r0g0b0r1 | g1b1r2g2 | b2r3g3b3 | r4g4b4r5 | g5b5r6g6 | b6r7g7b7
- __m128i tmp[6];
- PlanarTo24bHelper(in, tmp);
- PlanarTo24bHelper(tmp, in);
- PlanarTo24bHelper(in, tmp);
- // We need to do it two more times than the example as we have sixteen bytes.
- PlanarTo24bHelper(tmp, in);
- PlanarTo24bHelper(in, tmp);
-
- _mm_storeu_si128((__m128i*)(rgb + 0), tmp[0]);
- _mm_storeu_si128((__m128i*)(rgb + 16), tmp[1]);
- _mm_storeu_si128((__m128i*)(rgb + 32), tmp[2]);
- _mm_storeu_si128((__m128i*)(rgb + 48), tmp[3]);
- _mm_storeu_si128((__m128i*)(rgb + 64), tmp[4]);
- _mm_storeu_si128((__m128i*)(rgb + 80), tmp[5]);
-}
-#undef MK_UINT32
+ VP8PlanarTo24b(in0, in1, in2, in3, in4, in5);
+
+ _mm_storeu_si128((__m128i*)(rgb + 0), *in0);
+ _mm_storeu_si128((__m128i*)(rgb + 16), *in1);
+ _mm_storeu_si128((__m128i*)(rgb + 32), *in2);
+ _mm_storeu_si128((__m128i*)(rgb + 48), *in3);
+ _mm_storeu_si128((__m128i*)(rgb + 64), *in4);
+ _mm_storeu_si128((__m128i*)(rgb + 80), *in5);
+}
void VP8YuvToRgba32(const uint8_t* y, const uint8_t* u, const uint8_t* v,
uint8_t* dst) {
@@ -265,29 +243,29 @@ void VP8YuvToRgb56532(const uint8_t* y, const uint8_t* u, const uint8_t* v,
void VP8YuvToRgb32(const uint8_t* y, const uint8_t* u, const uint8_t* v,
uint8_t* dst) {
__m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb[6];
+ __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
- YUV444ToRGB(y + 0, u + 0, v + 0, &R0, &G0, &B0);
- YUV444ToRGB(y + 8, u + 8, v + 8, &R1, &G1, &B1);
+ YUV444ToRGB(y + 0, u + 0, v + 0, &R0, &G0, &B0);
+ YUV444ToRGB(y + 8, u + 8, v + 8, &R1, &G1, &B1);
YUV444ToRGB(y + 16, u + 16, v + 16, &R2, &G2, &B2);
YUV444ToRGB(y + 24, u + 24, v + 24, &R3, &G3, &B3);
// Cast to 8b and store as RRRRGGGGBBBB.
- rgb[0] = _mm_packus_epi16(R0, R1);
- rgb[1] = _mm_packus_epi16(R2, R3);
- rgb[2] = _mm_packus_epi16(G0, G1);
- rgb[3] = _mm_packus_epi16(G2, G3);
- rgb[4] = _mm_packus_epi16(B0, B1);
- rgb[5] = _mm_packus_epi16(B2, B3);
+ rgb0 = _mm_packus_epi16(R0, R1);
+ rgb1 = _mm_packus_epi16(R2, R3);
+ rgb2 = _mm_packus_epi16(G0, G1);
+ rgb3 = _mm_packus_epi16(G2, G3);
+ rgb4 = _mm_packus_epi16(B0, B1);
+ rgb5 = _mm_packus_epi16(B2, B3);
// Pack as RGBRGBRGBRGB.
- PlanarTo24b(rgb, dst);
+ PlanarTo24b(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
}
void VP8YuvToBgr32(const uint8_t* y, const uint8_t* u, const uint8_t* v,
uint8_t* dst) {
__m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr[6];
+ __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
YUV444ToRGB(y + 0, u + 0, v + 0, &R0, &G0, &B0);
YUV444ToRGB(y + 8, u + 8, v + 8, &R1, &G1, &B1);
@@ -295,15 +273,15 @@ void VP8YuvToBgr32(const uint8_t* y, const uint8_t* u, const uint8_t* v,
YUV444ToRGB(y + 24, u + 24, v + 24, &R3, &G3, &B3);
// Cast to 8b and store as BBBBGGGGRRRR.
- bgr[0] = _mm_packus_epi16(B0, B1);
- bgr[1] = _mm_packus_epi16(B2, B3);
- bgr[2] = _mm_packus_epi16(G0, G1);
- bgr[3] = _mm_packus_epi16(G2, G3);
- bgr[4] = _mm_packus_epi16(R0, R1);
- bgr[5] = _mm_packus_epi16(R2, R3);
+ bgr0 = _mm_packus_epi16(B0, B1);
+ bgr1 = _mm_packus_epi16(B2, B3);
+ bgr2 = _mm_packus_epi16(G0, G1);
+ bgr3 = _mm_packus_epi16(G2, G3);
+ bgr4 = _mm_packus_epi16(R0, R1);
+ bgr5= _mm_packus_epi16(R2, R3);
// Pack as BGRBGRBGRBGR.
- PlanarTo24b(bgr, dst);
+ PlanarTo24b(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
}
//-----------------------------------------------------------------------------
@@ -377,7 +355,7 @@ static void YuvToRgbRow(const uint8_t* y, const uint8_t* u, const uint8_t* v,
int n;
for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
__m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i rgb[6];
+ __m128i rgb0, rgb1, rgb2, rgb3, rgb4, rgb5;
YUV420ToRGB(y + 0, u + 0, v + 0, &R0, &G0, &B0);
YUV420ToRGB(y + 8, u + 4, v + 4, &R1, &G1, &B1);
@@ -385,15 +363,15 @@ static void YuvToRgbRow(const uint8_t* y, const uint8_t* u, const uint8_t* v,
YUV420ToRGB(y + 24, u + 12, v + 12, &R3, &G3, &B3);
// Cast to 8b and store as RRRRGGGGBBBB.
- rgb[0] = _mm_packus_epi16(R0, R1);
- rgb[1] = _mm_packus_epi16(R2, R3);
- rgb[2] = _mm_packus_epi16(G0, G1);
- rgb[3] = _mm_packus_epi16(G2, G3);
- rgb[4] = _mm_packus_epi16(B0, B1);
- rgb[5] = _mm_packus_epi16(B2, B3);
+ rgb0 = _mm_packus_epi16(R0, R1);
+ rgb1 = _mm_packus_epi16(R2, R3);
+ rgb2 = _mm_packus_epi16(G0, G1);
+ rgb3 = _mm_packus_epi16(G2, G3);
+ rgb4 = _mm_packus_epi16(B0, B1);
+ rgb5 = _mm_packus_epi16(B2, B3);
// Pack as RGBRGBRGBRGB.
- PlanarTo24b(rgb, dst);
+ PlanarTo24b(&rgb0, &rgb1, &rgb2, &rgb3, &rgb4, &rgb5, dst);
y += 32;
u += 16;
@@ -413,7 +391,7 @@ static void YuvToBgrRow(const uint8_t* y, const uint8_t* u, const uint8_t* v,
int n;
for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
__m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
- __m128i bgr[6];
+ __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;
YUV420ToRGB(y + 0, u + 0, v + 0, &R0, &G0, &B0);
YUV420ToRGB(y + 8, u + 4, v + 4, &R1, &G1, &B1);
@@ -421,15 +399,15 @@ static void YuvToBgrRow(const uint8_t* y, const uint8_t* u, const uint8_t* v,
YUV420ToRGB(y + 24, u + 12, v + 12, &R3, &G3, &B3);
// Cast to 8b and store as BBBBGGGGRRRR.
- bgr[0] = _mm_packus_epi16(B0, B1);
- bgr[1] = _mm_packus_epi16(B2, B3);
- bgr[2] = _mm_packus_epi16(G0, G1);
- bgr[3] = _mm_packus_epi16(G2, G3);
- bgr[4] = _mm_packus_epi16(R0, R1);
- bgr[5] = _mm_packus_epi16(R2, R3);
+ bgr0 = _mm_packus_epi16(B0, B1);
+ bgr1 = _mm_packus_epi16(B2, B3);
+ bgr2 = _mm_packus_epi16(G0, G1);
+ bgr3 = _mm_packus_epi16(G2, G3);
+ bgr4 = _mm_packus_epi16(R0, R1);
+ bgr5 = _mm_packus_epi16(R2, R3);
// Pack as BGRBGRBGRBGR.
- PlanarTo24b(bgr, dst);
+ PlanarTo24b(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);
y += 32;
u += 16;
@@ -499,25 +477,19 @@ static WEBP_INLINE void RGB24PackedToPlanar(const uint8_t* const rgb,
// Convert 8 packed ARGB to r[], g[], b[]
static WEBP_INLINE void RGB32PackedToPlanar(const uint32_t* const argb,
- __m128i* const r,
- __m128i* const g,
- __m128i* const b) {
+ __m128i* const rgb /*in[6]*/) {
const __m128i zero = _mm_setzero_si128();
- const __m128i in0 = LOAD_16(argb + 0); // argb3 | argb2 | argb1 | argb0
- const __m128i in1 = LOAD_16(argb + 4); // argb7 | argb6 | argb5 | argb4
- // column-wise transpose
- const __m128i A0 = _mm_unpacklo_epi8(in0, in1);
- const __m128i A1 = _mm_unpackhi_epi8(in0, in1);
- const __m128i B0 = _mm_unpacklo_epi8(A0, A1);
- const __m128i B1 = _mm_unpackhi_epi8(A0, A1);
- // C0 = g7 g6 ... g1 g0 | b7 b6 ... b1 b0
- // C1 = a7 a6 ... a1 a0 | r7 r6 ... r1 r0
- const __m128i C0 = _mm_unpacklo_epi8(B0, B1);
- const __m128i C1 = _mm_unpackhi_epi8(B0, B1);
- // store 16b
- *r = _mm_unpacklo_epi8(C1, zero);
- *g = _mm_unpackhi_epi8(C0, zero);
- *b = _mm_unpacklo_epi8(C0, zero);
+ __m128i a0 = LOAD_16(argb + 0);
+ __m128i a1 = LOAD_16(argb + 4);
+ __m128i a2 = LOAD_16(argb + 8);
+ __m128i a3 = LOAD_16(argb + 12);
+ VP8L32bToPlanar(&a0, &a1, &a2, &a3);
+ rgb[0] = _mm_unpacklo_epi8(a1, zero);
+ rgb[1] = _mm_unpackhi_epi8(a1, zero);
+ rgb[2] = _mm_unpacklo_epi8(a2, zero);
+ rgb[3] = _mm_unpackhi_epi8(a2, zero);
+ rgb[4] = _mm_unpacklo_epi8(a3, zero);
+ rgb[5] = _mm_unpackhi_epi8(a3, zero);
}
// This macro computes (RG * MULT_RG + GB * MULT_GB + ROUNDER) >> DESCALE_FIX
@@ -649,11 +621,10 @@ static void ConvertARGBToY(const uint32_t* argb, uint8_t* y, int width) {
const int max_width = width & ~15;
int i;
for (i = 0; i < max_width; i += 16) {
- __m128i r, g, b, Y0, Y1;
- RGB32PackedToPlanar(&argb[i + 0], &r, &g, &b);
- ConvertRGBToY(&r, &g, &b, &Y0);
- RGB32PackedToPlanar(&argb[i + 8], &r, &g, &b);
- ConvertRGBToY(&r, &g, &b, &Y1);
+ __m128i Y0, Y1, rgb[6];
+ RGB32PackedToPlanar(&argb[i], rgb);
+ ConvertRGBToY(&rgb[0], &rgb[2], &rgb[4], &Y0);
+ ConvertRGBToY(&rgb[1], &rgb[3], &rgb[5], &Y1);
STORE_16(_mm_packus_epi16(Y0, Y1), y + i);
}
for (; i < width; ++i) { // left-over
@@ -678,20 +649,18 @@ static void ConvertARGBToUV(const uint32_t* argb, uint8_t* u, uint8_t* v,
const int max_width = src_width & ~31;
int i;
for (i = 0; i < max_width; i += 32, u += 16, v += 16) {
- __m128i r0, g0, b0, r1, g1, b1, U0, V0, U1, V1;
- RGB32PackedToPlanar(&argb[i + 0], &r0, &g0, &b0);
- RGB32PackedToPlanar(&argb[i + 8], &r1, &g1, &b1);
- HorizontalAddPack(&r0, &r1, &r0);
- HorizontalAddPack(&g0, &g1, &g0);
- HorizontalAddPack(&b0, &b1, &b0);
- ConvertRGBToUV(&r0, &g0, &b0, &U0, &V0);
-
- RGB32PackedToPlanar(&argb[i + 16], &r0, &g0, &b0);
- RGB32PackedToPlanar(&argb[i + 24], &r1, &g1, &b1);
- HorizontalAddPack(&r0, &r1, &r0);
- HorizontalAddPack(&g0, &g1, &g0);
- HorizontalAddPack(&b0, &b1, &b0);
- ConvertRGBToUV(&r0, &g0, &b0, &U1, &V1);
+ __m128i rgb[6], U0, V0, U1, V1;
+ RGB32PackedToPlanar(&argb[i], rgb);
+ HorizontalAddPack(&rgb[0], &rgb[1], &rgb[0]);
+ HorizontalAddPack(&rgb[2], &rgb[3], &rgb[2]);
+ HorizontalAddPack(&rgb[4], &rgb[5], &rgb[4]);
+ ConvertRGBToUV(&rgb[0], &rgb[2], &rgb[4], &U0, &V0);
+
+ RGB32PackedToPlanar(&argb[i + 16], rgb);
+ HorizontalAddPack(&rgb[0], &rgb[1], &rgb[0]);
+ HorizontalAddPack(&rgb[2], &rgb[3], &rgb[2]);
+ HorizontalAddPack(&rgb[4], &rgb[5], &rgb[4]);
+ ConvertRGBToUV(&rgb[0], &rgb[2], &rgb[4], &U1, &V1);
U0 = _mm_packus_epi16(U0, U1);
V0 = _mm_packus_epi16(V0, V1);
@@ -767,9 +736,128 @@ WEBP_TSAN_IGNORE_FUNCTION void WebPInitConvertARGBToYUVSSE2(void) {
WebPConvertRGBA32ToUV = ConvertRGBA32ToUV;
}
+//------------------------------------------------------------------------------
+
+#define MAX_Y ((1 << 10) - 1) // 10b precision over 16b-arithmetic
+static uint16_t clip_y(int v) {
+ return (v < 0) ? 0 : (v > MAX_Y) ? MAX_Y : (uint16_t)v;
+}
+
+static uint64_t SharpYUVUpdateY_SSE2(const uint16_t* ref, const uint16_t* src,
+ uint16_t* dst, int len) {
+ uint64_t diff = 0;
+ uint32_t tmp[4];
+ int i;
+ const __m128i zero = _mm_setzero_si128();
+ const __m128i max = _mm_set1_epi16(MAX_Y);
+ const __m128i one = _mm_set1_epi16(1);
+ __m128i sum = zero;
+
+ for (i = 0; i + 8 <= len; i += 8) {
+ const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i));
+ const __m128i B = _mm_loadu_si128((const __m128i*)(src + i));
+ const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i));
+ const __m128i D = _mm_sub_epi16(A, B); // diff_y
+ const __m128i E = _mm_cmpgt_epi16(zero, D); // sign (-1 or 0)
+ const __m128i F = _mm_add_epi16(C, D); // new_y
+ const __m128i G = _mm_or_si128(E, one); // -1 or 1
+ const __m128i H = _mm_max_epi16(_mm_min_epi16(F, max), zero);
+ const __m128i I = _mm_madd_epi16(D, G); // sum(abs(...))
+ _mm_storeu_si128((__m128i*)(dst + i), H);
+ sum = _mm_add_epi32(sum, I);
+ }
+ _mm_storeu_si128((__m128i*)tmp, sum);
+ diff = tmp[3] + tmp[2] + tmp[1] + tmp[0];
+ for (; i < len; ++i) {
+ const int diff_y = ref[i] - src[i];
+ const int new_y = (int)dst[i] + diff_y;
+ dst[i] = clip_y(new_y);
+ diff += (uint64_t)abs(diff_y);
+ }
+ return diff;
+}
+
+static void SharpYUVUpdateRGB_SSE2(const int16_t* ref, const int16_t* src,
+ int16_t* dst, int len) {
+ int i = 0;
+ for (i = 0; i + 8 <= len; i += 8) {
+ const __m128i A = _mm_loadu_si128((const __m128i*)(ref + i));
+ const __m128i B = _mm_loadu_si128((const __m128i*)(src + i));
+ const __m128i C = _mm_loadu_si128((const __m128i*)(dst + i));
+ const __m128i D = _mm_sub_epi16(A, B); // diff_uv
+ const __m128i E = _mm_add_epi16(C, D); // new_uv
+ _mm_storeu_si128((__m128i*)(dst + i), E);
+ }
+ for (; i < len; ++i) {
+ const int diff_uv = ref[i] - src[i];
+ dst[i] += diff_uv;
+ }
+}
+
+static void SharpYUVFilterRow_SSE2(const int16_t* A, const int16_t* B, int len,
+ const uint16_t* best_y, uint16_t* out) {
+ int i;
+ const __m128i kCst8 = _mm_set1_epi16(8);
+ const __m128i max = _mm_set1_epi16(MAX_Y);
+ const __m128i zero = _mm_setzero_si128();
+ for (i = 0; i + 8 <= len; i += 8) {
+ const __m128i a0 = _mm_loadu_si128((const __m128i*)(A + i + 0));
+ const __m128i a1 = _mm_loadu_si128((const __m128i*)(A + i + 1));
+ const __m128i b0 = _mm_loadu_si128((const __m128i*)(B + i + 0));
+ const __m128i b1 = _mm_loadu_si128((const __m128i*)(B + i + 1));
+ const __m128i a0b1 = _mm_add_epi16(a0, b1);
+ const __m128i a1b0 = _mm_add_epi16(a1, b0);
+ const __m128i a0a1b0b1 = _mm_add_epi16(a0b1, a1b0); // A0+A1+B0+B1
+ const __m128i a0a1b0b1_8 = _mm_add_epi16(a0a1b0b1, kCst8);
+ const __m128i a0b1_2 = _mm_add_epi16(a0b1, a0b1); // 2*(A0+B1)
+ const __m128i a1b0_2 = _mm_add_epi16(a1b0, a1b0); // 2*(A1+B0)
+ const __m128i c0 = _mm_srai_epi16(_mm_add_epi16(a0b1_2, a0a1b0b1_8), 3);
+ const __m128i c1 = _mm_srai_epi16(_mm_add_epi16(a1b0_2, a0a1b0b1_8), 3);
+ const __m128i d0 = _mm_add_epi16(c1, a0);
+ const __m128i d1 = _mm_add_epi16(c0, a1);
+ const __m128i e0 = _mm_srai_epi16(d0, 1);
+ const __m128i e1 = _mm_srai_epi16(d1, 1);
+ const __m128i f0 = _mm_unpacklo_epi16(e0, e1);
+ const __m128i f1 = _mm_unpackhi_epi16(e0, e1);
+ const __m128i g0 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 0));
+ const __m128i g1 = _mm_loadu_si128((const __m128i*)(best_y + 2 * i + 8));
+ const __m128i h0 = _mm_add_epi16(g0, f0);
+ const __m128i h1 = _mm_add_epi16(g1, f1);
+ const __m128i i0 = _mm_max_epi16(_mm_min_epi16(h0, max), zero);
+ const __m128i i1 = _mm_max_epi16(_mm_min_epi16(h1, max), zero);
+ _mm_storeu_si128((__m128i*)(out + 2 * i + 0), i0);
+ _mm_storeu_si128((__m128i*)(out + 2 * i + 8), i1);
+ }
+ for (; i < len; ++i) {
+ // (9 * A0 + 3 * A1 + 3 * B0 + B1 + 8) >> 4 =
+ // = (8 * A0 + 2 * (A1 + B0) + (A0 + A1 + B0 + B1 + 8)) >> 4
+ // We reuse the common sub-expressions.
+ const int a0b1 = A[i + 0] + B[i + 1];
+ const int a1b0 = A[i + 1] + B[i + 0];
+ const int a0a1b0b1 = a0b1 + a1b0 + 8;
+ const int v0 = (8 * A[i + 0] + 2 * a1b0 + a0a1b0b1) >> 4;
+ const int v1 = (8 * A[i + 1] + 2 * a0b1 + a0a1b0b1) >> 4;
+ out[2 * i + 0] = clip_y(best_y[2 * i + 0] + v0);
+ out[2 * i + 1] = clip_y(best_y[2 * i + 1] + v1);
+ }
+}
+
+#undef MAX_Y
+
+//------------------------------------------------------------------------------
+
+extern void WebPInitSharpYUVSSE2(void);
+
+WEBP_TSAN_IGNORE_FUNCTION void WebPInitSharpYUVSSE2(void) {
+ WebPSharpYUVUpdateY = SharpYUVUpdateY_SSE2;
+ WebPSharpYUVUpdateRGB = SharpYUVUpdateRGB_SSE2;
+ WebPSharpYUVFilterRow = SharpYUVFilterRow_SSE2;
+}
+
#else // !WEBP_USE_SSE2
WEBP_DSP_INIT_STUB(WebPInitSamplersSSE2)
WEBP_DSP_INIT_STUB(WebPInitConvertARGBToYUVSSE2)
+WEBP_DSP_INIT_STUB(WebPInitSharpYUVSSE2)
#endif // WEBP_USE_SSE2
diff --git a/thirdparty/libwebp/dsp/yuv_tables_sse2.h b/thirdparty/libwebp/dsp/yuv_tables_sse2.h
deleted file mode 100644
index 2b0f057518..0000000000
--- a/thirdparty/libwebp/dsp/yuv_tables_sse2.h
+++ /dev/null
@@ -1,536 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// SSE2 tables for YUV->RGB conversion (12kB overall)
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-// This file is not compiled, but #include'd directly from yuv.c
-// Only used if WEBP_YUV_USE_SSE2_TABLES is defined.
-
-static const VP8kCstSSE2 VP8kYtoRGBA[256] = {
- {{0xfffb77b0, 0xfffb77b0, 0xfffb77b0, 0x003fc000}},
- {{0xfffbc235, 0xfffbc235, 0xfffbc235, 0x003fc000}},
- {{0xfffc0cba, 0xfffc0cba, 0xfffc0cba, 0x003fc000}},
- {{0xfffc573f, 0xfffc573f, 0xfffc573f, 0x003fc000}},
- {{0xfffca1c4, 0xfffca1c4, 0xfffca1c4, 0x003fc000}},
- {{0xfffcec49, 0xfffcec49, 0xfffcec49, 0x003fc000}},
- {{0xfffd36ce, 0xfffd36ce, 0xfffd36ce, 0x003fc000}},
- {{0xfffd8153, 0xfffd8153, 0xfffd8153, 0x003fc000}},
- {{0xfffdcbd8, 0xfffdcbd8, 0xfffdcbd8, 0x003fc000}},
- {{0xfffe165d, 0xfffe165d, 0xfffe165d, 0x003fc000}},
- {{0xfffe60e2, 0xfffe60e2, 0xfffe60e2, 0x003fc000}},
- {{0xfffeab67, 0xfffeab67, 0xfffeab67, 0x003fc000}},
- {{0xfffef5ec, 0xfffef5ec, 0xfffef5ec, 0x003fc000}},
- {{0xffff4071, 0xffff4071, 0xffff4071, 0x003fc000}},
- {{0xffff8af6, 0xffff8af6, 0xffff8af6, 0x003fc000}},
- {{0xffffd57b, 0xffffd57b, 0xffffd57b, 0x003fc000}},
- {{0x00002000, 0x00002000, 0x00002000, 0x003fc000}},
- {{0x00006a85, 0x00006a85, 0x00006a85, 0x003fc000}},
- {{0x0000b50a, 0x0000b50a, 0x0000b50a, 0x003fc000}},
- {{0x0000ff8f, 0x0000ff8f, 0x0000ff8f, 0x003fc000}},
- {{0x00014a14, 0x00014a14, 0x00014a14, 0x003fc000}},
- {{0x00019499, 0x00019499, 0x00019499, 0x003fc000}},
- {{0x0001df1e, 0x0001df1e, 0x0001df1e, 0x003fc000}},
- {{0x000229a3, 0x000229a3, 0x000229a3, 0x003fc000}},
- {{0x00027428, 0x00027428, 0x00027428, 0x003fc000}},
- {{0x0002bead, 0x0002bead, 0x0002bead, 0x003fc000}},
- {{0x00030932, 0x00030932, 0x00030932, 0x003fc000}},
- {{0x000353b7, 0x000353b7, 0x000353b7, 0x003fc000}},
- {{0x00039e3c, 0x00039e3c, 0x00039e3c, 0x003fc000}},
- {{0x0003e8c1, 0x0003e8c1, 0x0003e8c1, 0x003fc000}},
- {{0x00043346, 0x00043346, 0x00043346, 0x003fc000}},
- {{0x00047dcb, 0x00047dcb, 0x00047dcb, 0x003fc000}},
- {{0x0004c850, 0x0004c850, 0x0004c850, 0x003fc000}},
- {{0x000512d5, 0x000512d5, 0x000512d5, 0x003fc000}},
- {{0x00055d5a, 0x00055d5a, 0x00055d5a, 0x003fc000}},
- {{0x0005a7df, 0x0005a7df, 0x0005a7df, 0x003fc000}},
- {{0x0005f264, 0x0005f264, 0x0005f264, 0x003fc000}},
- {{0x00063ce9, 0x00063ce9, 0x00063ce9, 0x003fc000}},
- {{0x0006876e, 0x0006876e, 0x0006876e, 0x003fc000}},
- {{0x0006d1f3, 0x0006d1f3, 0x0006d1f3, 0x003fc000}},
- {{0x00071c78, 0x00071c78, 0x00071c78, 0x003fc000}},
- {{0x000766fd, 0x000766fd, 0x000766fd, 0x003fc000}},
- {{0x0007b182, 0x0007b182, 0x0007b182, 0x003fc000}},
- {{0x0007fc07, 0x0007fc07, 0x0007fc07, 0x003fc000}},
- {{0x0008468c, 0x0008468c, 0x0008468c, 0x003fc000}},
- {{0x00089111, 0x00089111, 0x00089111, 0x003fc000}},
- {{0x0008db96, 0x0008db96, 0x0008db96, 0x003fc000}},
- {{0x0009261b, 0x0009261b, 0x0009261b, 0x003fc000}},
- {{0x000970a0, 0x000970a0, 0x000970a0, 0x003fc000}},
- {{0x0009bb25, 0x0009bb25, 0x0009bb25, 0x003fc000}},
- {{0x000a05aa, 0x000a05aa, 0x000a05aa, 0x003fc000}},
- {{0x000a502f, 0x000a502f, 0x000a502f, 0x003fc000}},
- {{0x000a9ab4, 0x000a9ab4, 0x000a9ab4, 0x003fc000}},
- {{0x000ae539, 0x000ae539, 0x000ae539, 0x003fc000}},
- {{0x000b2fbe, 0x000b2fbe, 0x000b2fbe, 0x003fc000}},
- {{0x000b7a43, 0x000b7a43, 0x000b7a43, 0x003fc000}},
- {{0x000bc4c8, 0x000bc4c8, 0x000bc4c8, 0x003fc000}},
- {{0x000c0f4d, 0x000c0f4d, 0x000c0f4d, 0x003fc000}},
- {{0x000c59d2, 0x000c59d2, 0x000c59d2, 0x003fc000}},
- {{0x000ca457, 0x000ca457, 0x000ca457, 0x003fc000}},
- {{0x000ceedc, 0x000ceedc, 0x000ceedc, 0x003fc000}},
- {{0x000d3961, 0x000d3961, 0x000d3961, 0x003fc000}},
- {{0x000d83e6, 0x000d83e6, 0x000d83e6, 0x003fc000}},
- {{0x000dce6b, 0x000dce6b, 0x000dce6b, 0x003fc000}},
- {{0x000e18f0, 0x000e18f0, 0x000e18f0, 0x003fc000}},
- {{0x000e6375, 0x000e6375, 0x000e6375, 0x003fc000}},
- {{0x000eadfa, 0x000eadfa, 0x000eadfa, 0x003fc000}},
- {{0x000ef87f, 0x000ef87f, 0x000ef87f, 0x003fc000}},
- {{0x000f4304, 0x000f4304, 0x000f4304, 0x003fc000}},
- {{0x000f8d89, 0x000f8d89, 0x000f8d89, 0x003fc000}},
- {{0x000fd80e, 0x000fd80e, 0x000fd80e, 0x003fc000}},
- {{0x00102293, 0x00102293, 0x00102293, 0x003fc000}},
- {{0x00106d18, 0x00106d18, 0x00106d18, 0x003fc000}},
- {{0x0010b79d, 0x0010b79d, 0x0010b79d, 0x003fc000}},
- {{0x00110222, 0x00110222, 0x00110222, 0x003fc000}},
- {{0x00114ca7, 0x00114ca7, 0x00114ca7, 0x003fc000}},
- {{0x0011972c, 0x0011972c, 0x0011972c, 0x003fc000}},
- {{0x0011e1b1, 0x0011e1b1, 0x0011e1b1, 0x003fc000}},
- {{0x00122c36, 0x00122c36, 0x00122c36, 0x003fc000}},
- {{0x001276bb, 0x001276bb, 0x001276bb, 0x003fc000}},
- {{0x0012c140, 0x0012c140, 0x0012c140, 0x003fc000}},
- {{0x00130bc5, 0x00130bc5, 0x00130bc5, 0x003fc000}},
- {{0x0013564a, 0x0013564a, 0x0013564a, 0x003fc000}},
- {{0x0013a0cf, 0x0013a0cf, 0x0013a0cf, 0x003fc000}},
- {{0x0013eb54, 0x0013eb54, 0x0013eb54, 0x003fc000}},
- {{0x001435d9, 0x001435d9, 0x001435d9, 0x003fc000}},
- {{0x0014805e, 0x0014805e, 0x0014805e, 0x003fc000}},
- {{0x0014cae3, 0x0014cae3, 0x0014cae3, 0x003fc000}},
- {{0x00151568, 0x00151568, 0x00151568, 0x003fc000}},
- {{0x00155fed, 0x00155fed, 0x00155fed, 0x003fc000}},
- {{0x0015aa72, 0x0015aa72, 0x0015aa72, 0x003fc000}},
- {{0x0015f4f7, 0x0015f4f7, 0x0015f4f7, 0x003fc000}},
- {{0x00163f7c, 0x00163f7c, 0x00163f7c, 0x003fc000}},
- {{0x00168a01, 0x00168a01, 0x00168a01, 0x003fc000}},
- {{0x0016d486, 0x0016d486, 0x0016d486, 0x003fc000}},
- {{0x00171f0b, 0x00171f0b, 0x00171f0b, 0x003fc000}},
- {{0x00176990, 0x00176990, 0x00176990, 0x003fc000}},
- {{0x0017b415, 0x0017b415, 0x0017b415, 0x003fc000}},
- {{0x0017fe9a, 0x0017fe9a, 0x0017fe9a, 0x003fc000}},
- {{0x0018491f, 0x0018491f, 0x0018491f, 0x003fc000}},
- {{0x001893a4, 0x001893a4, 0x001893a4, 0x003fc000}},
- {{0x0018de29, 0x0018de29, 0x0018de29, 0x003fc000}},
- {{0x001928ae, 0x001928ae, 0x001928ae, 0x003fc000}},
- {{0x00197333, 0x00197333, 0x00197333, 0x003fc000}},
- {{0x0019bdb8, 0x0019bdb8, 0x0019bdb8, 0x003fc000}},
- {{0x001a083d, 0x001a083d, 0x001a083d, 0x003fc000}},
- {{0x001a52c2, 0x001a52c2, 0x001a52c2, 0x003fc000}},
- {{0x001a9d47, 0x001a9d47, 0x001a9d47, 0x003fc000}},
- {{0x001ae7cc, 0x001ae7cc, 0x001ae7cc, 0x003fc000}},
- {{0x001b3251, 0x001b3251, 0x001b3251, 0x003fc000}},
- {{0x001b7cd6, 0x001b7cd6, 0x001b7cd6, 0x003fc000}},
- {{0x001bc75b, 0x001bc75b, 0x001bc75b, 0x003fc000}},
- {{0x001c11e0, 0x001c11e0, 0x001c11e0, 0x003fc000}},
- {{0x001c5c65, 0x001c5c65, 0x001c5c65, 0x003fc000}},
- {{0x001ca6ea, 0x001ca6ea, 0x001ca6ea, 0x003fc000}},
- {{0x001cf16f, 0x001cf16f, 0x001cf16f, 0x003fc000}},
- {{0x001d3bf4, 0x001d3bf4, 0x001d3bf4, 0x003fc000}},
- {{0x001d8679, 0x001d8679, 0x001d8679, 0x003fc000}},
- {{0x001dd0fe, 0x001dd0fe, 0x001dd0fe, 0x003fc000}},
- {{0x001e1b83, 0x001e1b83, 0x001e1b83, 0x003fc000}},
- {{0x001e6608, 0x001e6608, 0x001e6608, 0x003fc000}},
- {{0x001eb08d, 0x001eb08d, 0x001eb08d, 0x003fc000}},
- {{0x001efb12, 0x001efb12, 0x001efb12, 0x003fc000}},
- {{0x001f4597, 0x001f4597, 0x001f4597, 0x003fc000}},
- {{0x001f901c, 0x001f901c, 0x001f901c, 0x003fc000}},
- {{0x001fdaa1, 0x001fdaa1, 0x001fdaa1, 0x003fc000}},
- {{0x00202526, 0x00202526, 0x00202526, 0x003fc000}},
- {{0x00206fab, 0x00206fab, 0x00206fab, 0x003fc000}},
- {{0x0020ba30, 0x0020ba30, 0x0020ba30, 0x003fc000}},
- {{0x002104b5, 0x002104b5, 0x002104b5, 0x003fc000}},
- {{0x00214f3a, 0x00214f3a, 0x00214f3a, 0x003fc000}},
- {{0x002199bf, 0x002199bf, 0x002199bf, 0x003fc000}},
- {{0x0021e444, 0x0021e444, 0x0021e444, 0x003fc000}},
- {{0x00222ec9, 0x00222ec9, 0x00222ec9, 0x003fc000}},
- {{0x0022794e, 0x0022794e, 0x0022794e, 0x003fc000}},
- {{0x0022c3d3, 0x0022c3d3, 0x0022c3d3, 0x003fc000}},
- {{0x00230e58, 0x00230e58, 0x00230e58, 0x003fc000}},
- {{0x002358dd, 0x002358dd, 0x002358dd, 0x003fc000}},
- {{0x0023a362, 0x0023a362, 0x0023a362, 0x003fc000}},
- {{0x0023ede7, 0x0023ede7, 0x0023ede7, 0x003fc000}},
- {{0x0024386c, 0x0024386c, 0x0024386c, 0x003fc000}},
- {{0x002482f1, 0x002482f1, 0x002482f1, 0x003fc000}},
- {{0x0024cd76, 0x0024cd76, 0x0024cd76, 0x003fc000}},
- {{0x002517fb, 0x002517fb, 0x002517fb, 0x003fc000}},
- {{0x00256280, 0x00256280, 0x00256280, 0x003fc000}},
- {{0x0025ad05, 0x0025ad05, 0x0025ad05, 0x003fc000}},
- {{0x0025f78a, 0x0025f78a, 0x0025f78a, 0x003fc000}},
- {{0x0026420f, 0x0026420f, 0x0026420f, 0x003fc000}},
- {{0x00268c94, 0x00268c94, 0x00268c94, 0x003fc000}},
- {{0x0026d719, 0x0026d719, 0x0026d719, 0x003fc000}},
- {{0x0027219e, 0x0027219e, 0x0027219e, 0x003fc000}},
- {{0x00276c23, 0x00276c23, 0x00276c23, 0x003fc000}},
- {{0x0027b6a8, 0x0027b6a8, 0x0027b6a8, 0x003fc000}},
- {{0x0028012d, 0x0028012d, 0x0028012d, 0x003fc000}},
- {{0x00284bb2, 0x00284bb2, 0x00284bb2, 0x003fc000}},
- {{0x00289637, 0x00289637, 0x00289637, 0x003fc000}},
- {{0x0028e0bc, 0x0028e0bc, 0x0028e0bc, 0x003fc000}},
- {{0x00292b41, 0x00292b41, 0x00292b41, 0x003fc000}},
- {{0x002975c6, 0x002975c6, 0x002975c6, 0x003fc000}},
- {{0x0029c04b, 0x0029c04b, 0x0029c04b, 0x003fc000}},
- {{0x002a0ad0, 0x002a0ad0, 0x002a0ad0, 0x003fc000}},
- {{0x002a5555, 0x002a5555, 0x002a5555, 0x003fc000}},
- {{0x002a9fda, 0x002a9fda, 0x002a9fda, 0x003fc000}},
- {{0x002aea5f, 0x002aea5f, 0x002aea5f, 0x003fc000}},
- {{0x002b34e4, 0x002b34e4, 0x002b34e4, 0x003fc000}},
- {{0x002b7f69, 0x002b7f69, 0x002b7f69, 0x003fc000}},
- {{0x002bc9ee, 0x002bc9ee, 0x002bc9ee, 0x003fc000}},
- {{0x002c1473, 0x002c1473, 0x002c1473, 0x003fc000}},
- {{0x002c5ef8, 0x002c5ef8, 0x002c5ef8, 0x003fc000}},
- {{0x002ca97d, 0x002ca97d, 0x002ca97d, 0x003fc000}},
- {{0x002cf402, 0x002cf402, 0x002cf402, 0x003fc000}},
- {{0x002d3e87, 0x002d3e87, 0x002d3e87, 0x003fc000}},
- {{0x002d890c, 0x002d890c, 0x002d890c, 0x003fc000}},
- {{0x002dd391, 0x002dd391, 0x002dd391, 0x003fc000}},
- {{0x002e1e16, 0x002e1e16, 0x002e1e16, 0x003fc000}},
- {{0x002e689b, 0x002e689b, 0x002e689b, 0x003fc000}},
- {{0x002eb320, 0x002eb320, 0x002eb320, 0x003fc000}},
- {{0x002efda5, 0x002efda5, 0x002efda5, 0x003fc000}},
- {{0x002f482a, 0x002f482a, 0x002f482a, 0x003fc000}},
- {{0x002f92af, 0x002f92af, 0x002f92af, 0x003fc000}},
- {{0x002fdd34, 0x002fdd34, 0x002fdd34, 0x003fc000}},
- {{0x003027b9, 0x003027b9, 0x003027b9, 0x003fc000}},
- {{0x0030723e, 0x0030723e, 0x0030723e, 0x003fc000}},
- {{0x0030bcc3, 0x0030bcc3, 0x0030bcc3, 0x003fc000}},
- {{0x00310748, 0x00310748, 0x00310748, 0x003fc000}},
- {{0x003151cd, 0x003151cd, 0x003151cd, 0x003fc000}},
- {{0x00319c52, 0x00319c52, 0x00319c52, 0x003fc000}},
- {{0x0031e6d7, 0x0031e6d7, 0x0031e6d7, 0x003fc000}},
- {{0x0032315c, 0x0032315c, 0x0032315c, 0x003fc000}},
- {{0x00327be1, 0x00327be1, 0x00327be1, 0x003fc000}},
- {{0x0032c666, 0x0032c666, 0x0032c666, 0x003fc000}},
- {{0x003310eb, 0x003310eb, 0x003310eb, 0x003fc000}},
- {{0x00335b70, 0x00335b70, 0x00335b70, 0x003fc000}},
- {{0x0033a5f5, 0x0033a5f5, 0x0033a5f5, 0x003fc000}},
- {{0x0033f07a, 0x0033f07a, 0x0033f07a, 0x003fc000}},
- {{0x00343aff, 0x00343aff, 0x00343aff, 0x003fc000}},
- {{0x00348584, 0x00348584, 0x00348584, 0x003fc000}},
- {{0x0034d009, 0x0034d009, 0x0034d009, 0x003fc000}},
- {{0x00351a8e, 0x00351a8e, 0x00351a8e, 0x003fc000}},
- {{0x00356513, 0x00356513, 0x00356513, 0x003fc000}},
- {{0x0035af98, 0x0035af98, 0x0035af98, 0x003fc000}},
- {{0x0035fa1d, 0x0035fa1d, 0x0035fa1d, 0x003fc000}},
- {{0x003644a2, 0x003644a2, 0x003644a2, 0x003fc000}},
- {{0x00368f27, 0x00368f27, 0x00368f27, 0x003fc000}},
- {{0x0036d9ac, 0x0036d9ac, 0x0036d9ac, 0x003fc000}},
- {{0x00372431, 0x00372431, 0x00372431, 0x003fc000}},
- {{0x00376eb6, 0x00376eb6, 0x00376eb6, 0x003fc000}},
- {{0x0037b93b, 0x0037b93b, 0x0037b93b, 0x003fc000}},
- {{0x003803c0, 0x003803c0, 0x003803c0, 0x003fc000}},
- {{0x00384e45, 0x00384e45, 0x00384e45, 0x003fc000}},
- {{0x003898ca, 0x003898ca, 0x003898ca, 0x003fc000}},
- {{0x0038e34f, 0x0038e34f, 0x0038e34f, 0x003fc000}},
- {{0x00392dd4, 0x00392dd4, 0x00392dd4, 0x003fc000}},
- {{0x00397859, 0x00397859, 0x00397859, 0x003fc000}},
- {{0x0039c2de, 0x0039c2de, 0x0039c2de, 0x003fc000}},
- {{0x003a0d63, 0x003a0d63, 0x003a0d63, 0x003fc000}},
- {{0x003a57e8, 0x003a57e8, 0x003a57e8, 0x003fc000}},
- {{0x003aa26d, 0x003aa26d, 0x003aa26d, 0x003fc000}},
- {{0x003aecf2, 0x003aecf2, 0x003aecf2, 0x003fc000}},
- {{0x003b3777, 0x003b3777, 0x003b3777, 0x003fc000}},
- {{0x003b81fc, 0x003b81fc, 0x003b81fc, 0x003fc000}},
- {{0x003bcc81, 0x003bcc81, 0x003bcc81, 0x003fc000}},
- {{0x003c1706, 0x003c1706, 0x003c1706, 0x003fc000}},
- {{0x003c618b, 0x003c618b, 0x003c618b, 0x003fc000}},
- {{0x003cac10, 0x003cac10, 0x003cac10, 0x003fc000}},
- {{0x003cf695, 0x003cf695, 0x003cf695, 0x003fc000}},
- {{0x003d411a, 0x003d411a, 0x003d411a, 0x003fc000}},
- {{0x003d8b9f, 0x003d8b9f, 0x003d8b9f, 0x003fc000}},
- {{0x003dd624, 0x003dd624, 0x003dd624, 0x003fc000}},
- {{0x003e20a9, 0x003e20a9, 0x003e20a9, 0x003fc000}},
- {{0x003e6b2e, 0x003e6b2e, 0x003e6b2e, 0x003fc000}},
- {{0x003eb5b3, 0x003eb5b3, 0x003eb5b3, 0x003fc000}},
- {{0x003f0038, 0x003f0038, 0x003f0038, 0x003fc000}},
- {{0x003f4abd, 0x003f4abd, 0x003f4abd, 0x003fc000}},
- {{0x003f9542, 0x003f9542, 0x003f9542, 0x003fc000}},
- {{0x003fdfc7, 0x003fdfc7, 0x003fdfc7, 0x003fc000}},
- {{0x00402a4c, 0x00402a4c, 0x00402a4c, 0x003fc000}},
- {{0x004074d1, 0x004074d1, 0x004074d1, 0x003fc000}},
- {{0x0040bf56, 0x0040bf56, 0x0040bf56, 0x003fc000}},
- {{0x004109db, 0x004109db, 0x004109db, 0x003fc000}},
- {{0x00415460, 0x00415460, 0x00415460, 0x003fc000}},
- {{0x00419ee5, 0x00419ee5, 0x00419ee5, 0x003fc000}},
- {{0x0041e96a, 0x0041e96a, 0x0041e96a, 0x003fc000}},
- {{0x004233ef, 0x004233ef, 0x004233ef, 0x003fc000}},
- {{0x00427e74, 0x00427e74, 0x00427e74, 0x003fc000}},
- {{0x0042c8f9, 0x0042c8f9, 0x0042c8f9, 0x003fc000}},
- {{0x0043137e, 0x0043137e, 0x0043137e, 0x003fc000}},
- {{0x00435e03, 0x00435e03, 0x00435e03, 0x003fc000}},
- {{0x0043a888, 0x0043a888, 0x0043a888, 0x003fc000}},
- {{0x0043f30d, 0x0043f30d, 0x0043f30d, 0x003fc000}},
- {{0x00443d92, 0x00443d92, 0x00443d92, 0x003fc000}},
- {{0x00448817, 0x00448817, 0x00448817, 0x003fc000}},
- {{0x0044d29c, 0x0044d29c, 0x0044d29c, 0x003fc000}},
- {{0x00451d21, 0x00451d21, 0x00451d21, 0x003fc000}},
- {{0x004567a6, 0x004567a6, 0x004567a6, 0x003fc000}},
- {{0x0045b22b, 0x0045b22b, 0x0045b22b, 0x003fc000}}
-};
-
-static const VP8kCstSSE2 VP8kUtoRGBA[256] = {
- {{0, 0x000c8980, 0xffbf7300, 0}}, {{0, 0x000c706d, 0xffbff41a, 0}},
- {{0, 0x000c575a, 0xffc07534, 0}}, {{0, 0x000c3e47, 0xffc0f64e, 0}},
- {{0, 0x000c2534, 0xffc17768, 0}}, {{0, 0x000c0c21, 0xffc1f882, 0}},
- {{0, 0x000bf30e, 0xffc2799c, 0}}, {{0, 0x000bd9fb, 0xffc2fab6, 0}},
- {{0, 0x000bc0e8, 0xffc37bd0, 0}}, {{0, 0x000ba7d5, 0xffc3fcea, 0}},
- {{0, 0x000b8ec2, 0xffc47e04, 0}}, {{0, 0x000b75af, 0xffc4ff1e, 0}},
- {{0, 0x000b5c9c, 0xffc58038, 0}}, {{0, 0x000b4389, 0xffc60152, 0}},
- {{0, 0x000b2a76, 0xffc6826c, 0}}, {{0, 0x000b1163, 0xffc70386, 0}},
- {{0, 0x000af850, 0xffc784a0, 0}}, {{0, 0x000adf3d, 0xffc805ba, 0}},
- {{0, 0x000ac62a, 0xffc886d4, 0}}, {{0, 0x000aad17, 0xffc907ee, 0}},
- {{0, 0x000a9404, 0xffc98908, 0}}, {{0, 0x000a7af1, 0xffca0a22, 0}},
- {{0, 0x000a61de, 0xffca8b3c, 0}}, {{0, 0x000a48cb, 0xffcb0c56, 0}},
- {{0, 0x000a2fb8, 0xffcb8d70, 0}}, {{0, 0x000a16a5, 0xffcc0e8a, 0}},
- {{0, 0x0009fd92, 0xffcc8fa4, 0}}, {{0, 0x0009e47f, 0xffcd10be, 0}},
- {{0, 0x0009cb6c, 0xffcd91d8, 0}}, {{0, 0x0009b259, 0xffce12f2, 0}},
- {{0, 0x00099946, 0xffce940c, 0}}, {{0, 0x00098033, 0xffcf1526, 0}},
- {{0, 0x00096720, 0xffcf9640, 0}}, {{0, 0x00094e0d, 0xffd0175a, 0}},
- {{0, 0x000934fa, 0xffd09874, 0}}, {{0, 0x00091be7, 0xffd1198e, 0}},
- {{0, 0x000902d4, 0xffd19aa8, 0}}, {{0, 0x0008e9c1, 0xffd21bc2, 0}},
- {{0, 0x0008d0ae, 0xffd29cdc, 0}}, {{0, 0x0008b79b, 0xffd31df6, 0}},
- {{0, 0x00089e88, 0xffd39f10, 0}}, {{0, 0x00088575, 0xffd4202a, 0}},
- {{0, 0x00086c62, 0xffd4a144, 0}}, {{0, 0x0008534f, 0xffd5225e, 0}},
- {{0, 0x00083a3c, 0xffd5a378, 0}}, {{0, 0x00082129, 0xffd62492, 0}},
- {{0, 0x00080816, 0xffd6a5ac, 0}}, {{0, 0x0007ef03, 0xffd726c6, 0}},
- {{0, 0x0007d5f0, 0xffd7a7e0, 0}}, {{0, 0x0007bcdd, 0xffd828fa, 0}},
- {{0, 0x0007a3ca, 0xffd8aa14, 0}}, {{0, 0x00078ab7, 0xffd92b2e, 0}},
- {{0, 0x000771a4, 0xffd9ac48, 0}}, {{0, 0x00075891, 0xffda2d62, 0}},
- {{0, 0x00073f7e, 0xffdaae7c, 0}}, {{0, 0x0007266b, 0xffdb2f96, 0}},
- {{0, 0x00070d58, 0xffdbb0b0, 0}}, {{0, 0x0006f445, 0xffdc31ca, 0}},
- {{0, 0x0006db32, 0xffdcb2e4, 0}}, {{0, 0x0006c21f, 0xffdd33fe, 0}},
- {{0, 0x0006a90c, 0xffddb518, 0}}, {{0, 0x00068ff9, 0xffde3632, 0}},
- {{0, 0x000676e6, 0xffdeb74c, 0}}, {{0, 0x00065dd3, 0xffdf3866, 0}},
- {{0, 0x000644c0, 0xffdfb980, 0}}, {{0, 0x00062bad, 0xffe03a9a, 0}},
- {{0, 0x0006129a, 0xffe0bbb4, 0}}, {{0, 0x0005f987, 0xffe13cce, 0}},
- {{0, 0x0005e074, 0xffe1bde8, 0}}, {{0, 0x0005c761, 0xffe23f02, 0}},
- {{0, 0x0005ae4e, 0xffe2c01c, 0}}, {{0, 0x0005953b, 0xffe34136, 0}},
- {{0, 0x00057c28, 0xffe3c250, 0}}, {{0, 0x00056315, 0xffe4436a, 0}},
- {{0, 0x00054a02, 0xffe4c484, 0}}, {{0, 0x000530ef, 0xffe5459e, 0}},
- {{0, 0x000517dc, 0xffe5c6b8, 0}}, {{0, 0x0004fec9, 0xffe647d2, 0}},
- {{0, 0x0004e5b6, 0xffe6c8ec, 0}}, {{0, 0x0004cca3, 0xffe74a06, 0}},
- {{0, 0x0004b390, 0xffe7cb20, 0}}, {{0, 0x00049a7d, 0xffe84c3a, 0}},
- {{0, 0x0004816a, 0xffe8cd54, 0}}, {{0, 0x00046857, 0xffe94e6e, 0}},
- {{0, 0x00044f44, 0xffe9cf88, 0}}, {{0, 0x00043631, 0xffea50a2, 0}},
- {{0, 0x00041d1e, 0xffead1bc, 0}}, {{0, 0x0004040b, 0xffeb52d6, 0}},
- {{0, 0x0003eaf8, 0xffebd3f0, 0}}, {{0, 0x0003d1e5, 0xffec550a, 0}},
- {{0, 0x0003b8d2, 0xffecd624, 0}}, {{0, 0x00039fbf, 0xffed573e, 0}},
- {{0, 0x000386ac, 0xffedd858, 0}}, {{0, 0x00036d99, 0xffee5972, 0}},
- {{0, 0x00035486, 0xffeeda8c, 0}}, {{0, 0x00033b73, 0xffef5ba6, 0}},
- {{0, 0x00032260, 0xffefdcc0, 0}}, {{0, 0x0003094d, 0xfff05dda, 0}},
- {{0, 0x0002f03a, 0xfff0def4, 0}}, {{0, 0x0002d727, 0xfff1600e, 0}},
- {{0, 0x0002be14, 0xfff1e128, 0}}, {{0, 0x0002a501, 0xfff26242, 0}},
- {{0, 0x00028bee, 0xfff2e35c, 0}}, {{0, 0x000272db, 0xfff36476, 0}},
- {{0, 0x000259c8, 0xfff3e590, 0}}, {{0, 0x000240b5, 0xfff466aa, 0}},
- {{0, 0x000227a2, 0xfff4e7c4, 0}}, {{0, 0x00020e8f, 0xfff568de, 0}},
- {{0, 0x0001f57c, 0xfff5e9f8, 0}}, {{0, 0x0001dc69, 0xfff66b12, 0}},
- {{0, 0x0001c356, 0xfff6ec2c, 0}}, {{0, 0x0001aa43, 0xfff76d46, 0}},
- {{0, 0x00019130, 0xfff7ee60, 0}}, {{0, 0x0001781d, 0xfff86f7a, 0}},
- {{0, 0x00015f0a, 0xfff8f094, 0}}, {{0, 0x000145f7, 0xfff971ae, 0}},
- {{0, 0x00012ce4, 0xfff9f2c8, 0}}, {{0, 0x000113d1, 0xfffa73e2, 0}},
- {{0, 0x0000fabe, 0xfffaf4fc, 0}}, {{0, 0x0000e1ab, 0xfffb7616, 0}},
- {{0, 0x0000c898, 0xfffbf730, 0}}, {{0, 0x0000af85, 0xfffc784a, 0}},
- {{0, 0x00009672, 0xfffcf964, 0}}, {{0, 0x00007d5f, 0xfffd7a7e, 0}},
- {{0, 0x0000644c, 0xfffdfb98, 0}}, {{0, 0x00004b39, 0xfffe7cb2, 0}},
- {{0, 0x00003226, 0xfffefdcc, 0}}, {{0, 0x00001913, 0xffff7ee6, 0}},
- {{0, 0x00000000, 0x00000000, 0}}, {{0, 0xffffe6ed, 0x0000811a, 0}},
- {{0, 0xffffcdda, 0x00010234, 0}}, {{0, 0xffffb4c7, 0x0001834e, 0}},
- {{0, 0xffff9bb4, 0x00020468, 0}}, {{0, 0xffff82a1, 0x00028582, 0}},
- {{0, 0xffff698e, 0x0003069c, 0}}, {{0, 0xffff507b, 0x000387b6, 0}},
- {{0, 0xffff3768, 0x000408d0, 0}}, {{0, 0xffff1e55, 0x000489ea, 0}},
- {{0, 0xffff0542, 0x00050b04, 0}}, {{0, 0xfffeec2f, 0x00058c1e, 0}},
- {{0, 0xfffed31c, 0x00060d38, 0}}, {{0, 0xfffeba09, 0x00068e52, 0}},
- {{0, 0xfffea0f6, 0x00070f6c, 0}}, {{0, 0xfffe87e3, 0x00079086, 0}},
- {{0, 0xfffe6ed0, 0x000811a0, 0}}, {{0, 0xfffe55bd, 0x000892ba, 0}},
- {{0, 0xfffe3caa, 0x000913d4, 0}}, {{0, 0xfffe2397, 0x000994ee, 0}},
- {{0, 0xfffe0a84, 0x000a1608, 0}}, {{0, 0xfffdf171, 0x000a9722, 0}},
- {{0, 0xfffdd85e, 0x000b183c, 0}}, {{0, 0xfffdbf4b, 0x000b9956, 0}},
- {{0, 0xfffda638, 0x000c1a70, 0}}, {{0, 0xfffd8d25, 0x000c9b8a, 0}},
- {{0, 0xfffd7412, 0x000d1ca4, 0}}, {{0, 0xfffd5aff, 0x000d9dbe, 0}},
- {{0, 0xfffd41ec, 0x000e1ed8, 0}}, {{0, 0xfffd28d9, 0x000e9ff2, 0}},
- {{0, 0xfffd0fc6, 0x000f210c, 0}}, {{0, 0xfffcf6b3, 0x000fa226, 0}},
- {{0, 0xfffcdda0, 0x00102340, 0}}, {{0, 0xfffcc48d, 0x0010a45a, 0}},
- {{0, 0xfffcab7a, 0x00112574, 0}}, {{0, 0xfffc9267, 0x0011a68e, 0}},
- {{0, 0xfffc7954, 0x001227a8, 0}}, {{0, 0xfffc6041, 0x0012a8c2, 0}},
- {{0, 0xfffc472e, 0x001329dc, 0}}, {{0, 0xfffc2e1b, 0x0013aaf6, 0}},
- {{0, 0xfffc1508, 0x00142c10, 0}}, {{0, 0xfffbfbf5, 0x0014ad2a, 0}},
- {{0, 0xfffbe2e2, 0x00152e44, 0}}, {{0, 0xfffbc9cf, 0x0015af5e, 0}},
- {{0, 0xfffbb0bc, 0x00163078, 0}}, {{0, 0xfffb97a9, 0x0016b192, 0}},
- {{0, 0xfffb7e96, 0x001732ac, 0}}, {{0, 0xfffb6583, 0x0017b3c6, 0}},
- {{0, 0xfffb4c70, 0x001834e0, 0}}, {{0, 0xfffb335d, 0x0018b5fa, 0}},
- {{0, 0xfffb1a4a, 0x00193714, 0}}, {{0, 0xfffb0137, 0x0019b82e, 0}},
- {{0, 0xfffae824, 0x001a3948, 0}}, {{0, 0xfffacf11, 0x001aba62, 0}},
- {{0, 0xfffab5fe, 0x001b3b7c, 0}}, {{0, 0xfffa9ceb, 0x001bbc96, 0}},
- {{0, 0xfffa83d8, 0x001c3db0, 0}}, {{0, 0xfffa6ac5, 0x001cbeca, 0}},
- {{0, 0xfffa51b2, 0x001d3fe4, 0}}, {{0, 0xfffa389f, 0x001dc0fe, 0}},
- {{0, 0xfffa1f8c, 0x001e4218, 0}}, {{0, 0xfffa0679, 0x001ec332, 0}},
- {{0, 0xfff9ed66, 0x001f444c, 0}}, {{0, 0xfff9d453, 0x001fc566, 0}},
- {{0, 0xfff9bb40, 0x00204680, 0}}, {{0, 0xfff9a22d, 0x0020c79a, 0}},
- {{0, 0xfff9891a, 0x002148b4, 0}}, {{0, 0xfff97007, 0x0021c9ce, 0}},
- {{0, 0xfff956f4, 0x00224ae8, 0}}, {{0, 0xfff93de1, 0x0022cc02, 0}},
- {{0, 0xfff924ce, 0x00234d1c, 0}}, {{0, 0xfff90bbb, 0x0023ce36, 0}},
- {{0, 0xfff8f2a8, 0x00244f50, 0}}, {{0, 0xfff8d995, 0x0024d06a, 0}},
- {{0, 0xfff8c082, 0x00255184, 0}}, {{0, 0xfff8a76f, 0x0025d29e, 0}},
- {{0, 0xfff88e5c, 0x002653b8, 0}}, {{0, 0xfff87549, 0x0026d4d2, 0}},
- {{0, 0xfff85c36, 0x002755ec, 0}}, {{0, 0xfff84323, 0x0027d706, 0}},
- {{0, 0xfff82a10, 0x00285820, 0}}, {{0, 0xfff810fd, 0x0028d93a, 0}},
- {{0, 0xfff7f7ea, 0x00295a54, 0}}, {{0, 0xfff7ded7, 0x0029db6e, 0}},
- {{0, 0xfff7c5c4, 0x002a5c88, 0}}, {{0, 0xfff7acb1, 0x002adda2, 0}},
- {{0, 0xfff7939e, 0x002b5ebc, 0}}, {{0, 0xfff77a8b, 0x002bdfd6, 0}},
- {{0, 0xfff76178, 0x002c60f0, 0}}, {{0, 0xfff74865, 0x002ce20a, 0}},
- {{0, 0xfff72f52, 0x002d6324, 0}}, {{0, 0xfff7163f, 0x002de43e, 0}},
- {{0, 0xfff6fd2c, 0x002e6558, 0}}, {{0, 0xfff6e419, 0x002ee672, 0}},
- {{0, 0xfff6cb06, 0x002f678c, 0}}, {{0, 0xfff6b1f3, 0x002fe8a6, 0}},
- {{0, 0xfff698e0, 0x003069c0, 0}}, {{0, 0xfff67fcd, 0x0030eada, 0}},
- {{0, 0xfff666ba, 0x00316bf4, 0}}, {{0, 0xfff64da7, 0x0031ed0e, 0}},
- {{0, 0xfff63494, 0x00326e28, 0}}, {{0, 0xfff61b81, 0x0032ef42, 0}},
- {{0, 0xfff6026e, 0x0033705c, 0}}, {{0, 0xfff5e95b, 0x0033f176, 0}},
- {{0, 0xfff5d048, 0x00347290, 0}}, {{0, 0xfff5b735, 0x0034f3aa, 0}},
- {{0, 0xfff59e22, 0x003574c4, 0}}, {{0, 0xfff5850f, 0x0035f5de, 0}},
- {{0, 0xfff56bfc, 0x003676f8, 0}}, {{0, 0xfff552e9, 0x0036f812, 0}},
- {{0, 0xfff539d6, 0x0037792c, 0}}, {{0, 0xfff520c3, 0x0037fa46, 0}},
- {{0, 0xfff507b0, 0x00387b60, 0}}, {{0, 0xfff4ee9d, 0x0038fc7a, 0}},
- {{0, 0xfff4d58a, 0x00397d94, 0}}, {{0, 0xfff4bc77, 0x0039feae, 0}},
- {{0, 0xfff4a364, 0x003a7fc8, 0}}, {{0, 0xfff48a51, 0x003b00e2, 0}},
- {{0, 0xfff4713e, 0x003b81fc, 0}}, {{0, 0xfff4582b, 0x003c0316, 0}},
- {{0, 0xfff43f18, 0x003c8430, 0}}, {{0, 0xfff42605, 0x003d054a, 0}},
- {{0, 0xfff40cf2, 0x003d8664, 0}}, {{0, 0xfff3f3df, 0x003e077e, 0}},
- {{0, 0xfff3dacc, 0x003e8898, 0}}, {{0, 0xfff3c1b9, 0x003f09b2, 0}},
- {{0, 0xfff3a8a6, 0x003f8acc, 0}}, {{0, 0xfff38f93, 0x00400be6, 0}}
-};
-
-static VP8kCstSSE2 VP8kVtoRGBA[256] = {
- {{0xffcced80, 0x001a0400, 0, 0}}, {{0xffcd53a5, 0x0019cff8, 0, 0}},
- {{0xffcdb9ca, 0x00199bf0, 0, 0}}, {{0xffce1fef, 0x001967e8, 0, 0}},
- {{0xffce8614, 0x001933e0, 0, 0}}, {{0xffceec39, 0x0018ffd8, 0, 0}},
- {{0xffcf525e, 0x0018cbd0, 0, 0}}, {{0xffcfb883, 0x001897c8, 0, 0}},
- {{0xffd01ea8, 0x001863c0, 0, 0}}, {{0xffd084cd, 0x00182fb8, 0, 0}},
- {{0xffd0eaf2, 0x0017fbb0, 0, 0}}, {{0xffd15117, 0x0017c7a8, 0, 0}},
- {{0xffd1b73c, 0x001793a0, 0, 0}}, {{0xffd21d61, 0x00175f98, 0, 0}},
- {{0xffd28386, 0x00172b90, 0, 0}}, {{0xffd2e9ab, 0x0016f788, 0, 0}},
- {{0xffd34fd0, 0x0016c380, 0, 0}}, {{0xffd3b5f5, 0x00168f78, 0, 0}},
- {{0xffd41c1a, 0x00165b70, 0, 0}}, {{0xffd4823f, 0x00162768, 0, 0}},
- {{0xffd4e864, 0x0015f360, 0, 0}}, {{0xffd54e89, 0x0015bf58, 0, 0}},
- {{0xffd5b4ae, 0x00158b50, 0, 0}}, {{0xffd61ad3, 0x00155748, 0, 0}},
- {{0xffd680f8, 0x00152340, 0, 0}}, {{0xffd6e71d, 0x0014ef38, 0, 0}},
- {{0xffd74d42, 0x0014bb30, 0, 0}}, {{0xffd7b367, 0x00148728, 0, 0}},
- {{0xffd8198c, 0x00145320, 0, 0}}, {{0xffd87fb1, 0x00141f18, 0, 0}},
- {{0xffd8e5d6, 0x0013eb10, 0, 0}}, {{0xffd94bfb, 0x0013b708, 0, 0}},
- {{0xffd9b220, 0x00138300, 0, 0}}, {{0xffda1845, 0x00134ef8, 0, 0}},
- {{0xffda7e6a, 0x00131af0, 0, 0}}, {{0xffdae48f, 0x0012e6e8, 0, 0}},
- {{0xffdb4ab4, 0x0012b2e0, 0, 0}}, {{0xffdbb0d9, 0x00127ed8, 0, 0}},
- {{0xffdc16fe, 0x00124ad0, 0, 0}}, {{0xffdc7d23, 0x001216c8, 0, 0}},
- {{0xffdce348, 0x0011e2c0, 0, 0}}, {{0xffdd496d, 0x0011aeb8, 0, 0}},
- {{0xffddaf92, 0x00117ab0, 0, 0}}, {{0xffde15b7, 0x001146a8, 0, 0}},
- {{0xffde7bdc, 0x001112a0, 0, 0}}, {{0xffdee201, 0x0010de98, 0, 0}},
- {{0xffdf4826, 0x0010aa90, 0, 0}}, {{0xffdfae4b, 0x00107688, 0, 0}},
- {{0xffe01470, 0x00104280, 0, 0}}, {{0xffe07a95, 0x00100e78, 0, 0}},
- {{0xffe0e0ba, 0x000fda70, 0, 0}}, {{0xffe146df, 0x000fa668, 0, 0}},
- {{0xffe1ad04, 0x000f7260, 0, 0}}, {{0xffe21329, 0x000f3e58, 0, 0}},
- {{0xffe2794e, 0x000f0a50, 0, 0}}, {{0xffe2df73, 0x000ed648, 0, 0}},
- {{0xffe34598, 0x000ea240, 0, 0}}, {{0xffe3abbd, 0x000e6e38, 0, 0}},
- {{0xffe411e2, 0x000e3a30, 0, 0}}, {{0xffe47807, 0x000e0628, 0, 0}},
- {{0xffe4de2c, 0x000dd220, 0, 0}}, {{0xffe54451, 0x000d9e18, 0, 0}},
- {{0xffe5aa76, 0x000d6a10, 0, 0}}, {{0xffe6109b, 0x000d3608, 0, 0}},
- {{0xffe676c0, 0x000d0200, 0, 0}}, {{0xffe6dce5, 0x000ccdf8, 0, 0}},
- {{0xffe7430a, 0x000c99f0, 0, 0}}, {{0xffe7a92f, 0x000c65e8, 0, 0}},
- {{0xffe80f54, 0x000c31e0, 0, 0}}, {{0xffe87579, 0x000bfdd8, 0, 0}},
- {{0xffe8db9e, 0x000bc9d0, 0, 0}}, {{0xffe941c3, 0x000b95c8, 0, 0}},
- {{0xffe9a7e8, 0x000b61c0, 0, 0}}, {{0xffea0e0d, 0x000b2db8, 0, 0}},
- {{0xffea7432, 0x000af9b0, 0, 0}}, {{0xffeada57, 0x000ac5a8, 0, 0}},
- {{0xffeb407c, 0x000a91a0, 0, 0}}, {{0xffeba6a1, 0x000a5d98, 0, 0}},
- {{0xffec0cc6, 0x000a2990, 0, 0}}, {{0xffec72eb, 0x0009f588, 0, 0}},
- {{0xffecd910, 0x0009c180, 0, 0}}, {{0xffed3f35, 0x00098d78, 0, 0}},
- {{0xffeda55a, 0x00095970, 0, 0}}, {{0xffee0b7f, 0x00092568, 0, 0}},
- {{0xffee71a4, 0x0008f160, 0, 0}}, {{0xffeed7c9, 0x0008bd58, 0, 0}},
- {{0xffef3dee, 0x00088950, 0, 0}}, {{0xffefa413, 0x00085548, 0, 0}},
- {{0xfff00a38, 0x00082140, 0, 0}}, {{0xfff0705d, 0x0007ed38, 0, 0}},
- {{0xfff0d682, 0x0007b930, 0, 0}}, {{0xfff13ca7, 0x00078528, 0, 0}},
- {{0xfff1a2cc, 0x00075120, 0, 0}}, {{0xfff208f1, 0x00071d18, 0, 0}},
- {{0xfff26f16, 0x0006e910, 0, 0}}, {{0xfff2d53b, 0x0006b508, 0, 0}},
- {{0xfff33b60, 0x00068100, 0, 0}}, {{0xfff3a185, 0x00064cf8, 0, 0}},
- {{0xfff407aa, 0x000618f0, 0, 0}}, {{0xfff46dcf, 0x0005e4e8, 0, 0}},
- {{0xfff4d3f4, 0x0005b0e0, 0, 0}}, {{0xfff53a19, 0x00057cd8, 0, 0}},
- {{0xfff5a03e, 0x000548d0, 0, 0}}, {{0xfff60663, 0x000514c8, 0, 0}},
- {{0xfff66c88, 0x0004e0c0, 0, 0}}, {{0xfff6d2ad, 0x0004acb8, 0, 0}},
- {{0xfff738d2, 0x000478b0, 0, 0}}, {{0xfff79ef7, 0x000444a8, 0, 0}},
- {{0xfff8051c, 0x000410a0, 0, 0}}, {{0xfff86b41, 0x0003dc98, 0, 0}},
- {{0xfff8d166, 0x0003a890, 0, 0}}, {{0xfff9378b, 0x00037488, 0, 0}},
- {{0xfff99db0, 0x00034080, 0, 0}}, {{0xfffa03d5, 0x00030c78, 0, 0}},
- {{0xfffa69fa, 0x0002d870, 0, 0}}, {{0xfffad01f, 0x0002a468, 0, 0}},
- {{0xfffb3644, 0x00027060, 0, 0}}, {{0xfffb9c69, 0x00023c58, 0, 0}},
- {{0xfffc028e, 0x00020850, 0, 0}}, {{0xfffc68b3, 0x0001d448, 0, 0}},
- {{0xfffcced8, 0x0001a040, 0, 0}}, {{0xfffd34fd, 0x00016c38, 0, 0}},
- {{0xfffd9b22, 0x00013830, 0, 0}}, {{0xfffe0147, 0x00010428, 0, 0}},
- {{0xfffe676c, 0x0000d020, 0, 0}}, {{0xfffecd91, 0x00009c18, 0, 0}},
- {{0xffff33b6, 0x00006810, 0, 0}}, {{0xffff99db, 0x00003408, 0, 0}},
- {{0x00000000, 0x00000000, 0, 0}}, {{0x00006625, 0xffffcbf8, 0, 0}},
- {{0x0000cc4a, 0xffff97f0, 0, 0}}, {{0x0001326f, 0xffff63e8, 0, 0}},
- {{0x00019894, 0xffff2fe0, 0, 0}}, {{0x0001feb9, 0xfffefbd8, 0, 0}},
- {{0x000264de, 0xfffec7d0, 0, 0}}, {{0x0002cb03, 0xfffe93c8, 0, 0}},
- {{0x00033128, 0xfffe5fc0, 0, 0}}, {{0x0003974d, 0xfffe2bb8, 0, 0}},
- {{0x0003fd72, 0xfffdf7b0, 0, 0}}, {{0x00046397, 0xfffdc3a8, 0, 0}},
- {{0x0004c9bc, 0xfffd8fa0, 0, 0}}, {{0x00052fe1, 0xfffd5b98, 0, 0}},
- {{0x00059606, 0xfffd2790, 0, 0}}, {{0x0005fc2b, 0xfffcf388, 0, 0}},
- {{0x00066250, 0xfffcbf80, 0, 0}}, {{0x0006c875, 0xfffc8b78, 0, 0}},
- {{0x00072e9a, 0xfffc5770, 0, 0}}, {{0x000794bf, 0xfffc2368, 0, 0}},
- {{0x0007fae4, 0xfffbef60, 0, 0}}, {{0x00086109, 0xfffbbb58, 0, 0}},
- {{0x0008c72e, 0xfffb8750, 0, 0}}, {{0x00092d53, 0xfffb5348, 0, 0}},
- {{0x00099378, 0xfffb1f40, 0, 0}}, {{0x0009f99d, 0xfffaeb38, 0, 0}},
- {{0x000a5fc2, 0xfffab730, 0, 0}}, {{0x000ac5e7, 0xfffa8328, 0, 0}},
- {{0x000b2c0c, 0xfffa4f20, 0, 0}}, {{0x000b9231, 0xfffa1b18, 0, 0}},
- {{0x000bf856, 0xfff9e710, 0, 0}}, {{0x000c5e7b, 0xfff9b308, 0, 0}},
- {{0x000cc4a0, 0xfff97f00, 0, 0}}, {{0x000d2ac5, 0xfff94af8, 0, 0}},
- {{0x000d90ea, 0xfff916f0, 0, 0}}, {{0x000df70f, 0xfff8e2e8, 0, 0}},
- {{0x000e5d34, 0xfff8aee0, 0, 0}}, {{0x000ec359, 0xfff87ad8, 0, 0}},
- {{0x000f297e, 0xfff846d0, 0, 0}}, {{0x000f8fa3, 0xfff812c8, 0, 0}},
- {{0x000ff5c8, 0xfff7dec0, 0, 0}}, {{0x00105bed, 0xfff7aab8, 0, 0}},
- {{0x0010c212, 0xfff776b0, 0, 0}}, {{0x00112837, 0xfff742a8, 0, 0}},
- {{0x00118e5c, 0xfff70ea0, 0, 0}}, {{0x0011f481, 0xfff6da98, 0, 0}},
- {{0x00125aa6, 0xfff6a690, 0, 0}}, {{0x0012c0cb, 0xfff67288, 0, 0}},
- {{0x001326f0, 0xfff63e80, 0, 0}}, {{0x00138d15, 0xfff60a78, 0, 0}},
- {{0x0013f33a, 0xfff5d670, 0, 0}}, {{0x0014595f, 0xfff5a268, 0, 0}},
- {{0x0014bf84, 0xfff56e60, 0, 0}}, {{0x001525a9, 0xfff53a58, 0, 0}},
- {{0x00158bce, 0xfff50650, 0, 0}}, {{0x0015f1f3, 0xfff4d248, 0, 0}},
- {{0x00165818, 0xfff49e40, 0, 0}}, {{0x0016be3d, 0xfff46a38, 0, 0}},
- {{0x00172462, 0xfff43630, 0, 0}}, {{0x00178a87, 0xfff40228, 0, 0}},
- {{0x0017f0ac, 0xfff3ce20, 0, 0}}, {{0x001856d1, 0xfff39a18, 0, 0}},
- {{0x0018bcf6, 0xfff36610, 0, 0}}, {{0x0019231b, 0xfff33208, 0, 0}},
- {{0x00198940, 0xfff2fe00, 0, 0}}, {{0x0019ef65, 0xfff2c9f8, 0, 0}},
- {{0x001a558a, 0xfff295f0, 0, 0}}, {{0x001abbaf, 0xfff261e8, 0, 0}},
- {{0x001b21d4, 0xfff22de0, 0, 0}}, {{0x001b87f9, 0xfff1f9d8, 0, 0}},
- {{0x001bee1e, 0xfff1c5d0, 0, 0}}, {{0x001c5443, 0xfff191c8, 0, 0}},
- {{0x001cba68, 0xfff15dc0, 0, 0}}, {{0x001d208d, 0xfff129b8, 0, 0}},
- {{0x001d86b2, 0xfff0f5b0, 0, 0}}, {{0x001decd7, 0xfff0c1a8, 0, 0}},
- {{0x001e52fc, 0xfff08da0, 0, 0}}, {{0x001eb921, 0xfff05998, 0, 0}},
- {{0x001f1f46, 0xfff02590, 0, 0}}, {{0x001f856b, 0xffeff188, 0, 0}},
- {{0x001feb90, 0xffefbd80, 0, 0}}, {{0x002051b5, 0xffef8978, 0, 0}},
- {{0x0020b7da, 0xffef5570, 0, 0}}, {{0x00211dff, 0xffef2168, 0, 0}},
- {{0x00218424, 0xffeeed60, 0, 0}}, {{0x0021ea49, 0xffeeb958, 0, 0}},
- {{0x0022506e, 0xffee8550, 0, 0}}, {{0x0022b693, 0xffee5148, 0, 0}},
- {{0x00231cb8, 0xffee1d40, 0, 0}}, {{0x002382dd, 0xffede938, 0, 0}},
- {{0x0023e902, 0xffedb530, 0, 0}}, {{0x00244f27, 0xffed8128, 0, 0}},
- {{0x0024b54c, 0xffed4d20, 0, 0}}, {{0x00251b71, 0xffed1918, 0, 0}},
- {{0x00258196, 0xffece510, 0, 0}}, {{0x0025e7bb, 0xffecb108, 0, 0}},
- {{0x00264de0, 0xffec7d00, 0, 0}}, {{0x0026b405, 0xffec48f8, 0, 0}},
- {{0x00271a2a, 0xffec14f0, 0, 0}}, {{0x0027804f, 0xffebe0e8, 0, 0}},
- {{0x0027e674, 0xffebace0, 0, 0}}, {{0x00284c99, 0xffeb78d8, 0, 0}},
- {{0x0028b2be, 0xffeb44d0, 0, 0}}, {{0x002918e3, 0xffeb10c8, 0, 0}},
- {{0x00297f08, 0xffeadcc0, 0, 0}}, {{0x0029e52d, 0xffeaa8b8, 0, 0}},
- {{0x002a4b52, 0xffea74b0, 0, 0}}, {{0x002ab177, 0xffea40a8, 0, 0}},
- {{0x002b179c, 0xffea0ca0, 0, 0}}, {{0x002b7dc1, 0xffe9d898, 0, 0}},
- {{0x002be3e6, 0xffe9a490, 0, 0}}, {{0x002c4a0b, 0xffe97088, 0, 0}},
- {{0x002cb030, 0xffe93c80, 0, 0}}, {{0x002d1655, 0xffe90878, 0, 0}},
- {{0x002d7c7a, 0xffe8d470, 0, 0}}, {{0x002de29f, 0xffe8a068, 0, 0}},
- {{0x002e48c4, 0xffe86c60, 0, 0}}, {{0x002eaee9, 0xffe83858, 0, 0}},
- {{0x002f150e, 0xffe80450, 0, 0}}, {{0x002f7b33, 0xffe7d048, 0, 0}},
- {{0x002fe158, 0xffe79c40, 0, 0}}, {{0x0030477d, 0xffe76838, 0, 0}},
- {{0x0030ada2, 0xffe73430, 0, 0}}, {{0x003113c7, 0xffe70028, 0, 0}},
- {{0x003179ec, 0xffe6cc20, 0, 0}}, {{0x0031e011, 0xffe69818, 0, 0}},
- {{0x00324636, 0xffe66410, 0, 0}}, {{0x0032ac5b, 0xffe63008, 0, 0}}
-};
diff --git a/thirdparty/libwebp/enc/alpha.c b/thirdparty/libwebp/enc/alpha_enc.c
index 03e3ad07f5..5a2c931f92 100644
--- a/thirdparty/libwebp/enc/alpha.c
+++ b/thirdparty/libwebp/enc/alpha_enc.c
@@ -14,10 +14,10 @@
#include <assert.h>
#include <stdlib.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#include "../dsp/dsp.h"
-#include "../utils/filters.h"
-#include "../utils/quant_levels.h"
+#include "../utils/filters_utils.h"
+#include "../utils/quant_levels_utils.h"
#include "../utils/utils.h"
#include "../webp/format_constants.h"
@@ -44,7 +44,7 @@
// invalid quality or method, or
// memory allocation for the compressed data fails.
-#include "../enc/vp8li.h"
+#include "../enc/vp8li_enc.h"
static int EncodeLossless(const uint8_t* const data, int width, int height,
int effort_level, // in [0..6] range
diff --git a/thirdparty/libwebp/enc/analysis.c b/thirdparty/libwebp/enc/analysis_enc.c
index 136c331289..dce159b316 100644
--- a/thirdparty/libwebp/enc/analysis.c
+++ b/thirdparty/libwebp/enc/analysis_enc.c
@@ -15,8 +15,8 @@
#include <string.h>
#include <assert.h>
-#include "./vp8enci.h"
-#include "./cost.h"
+#include "./vp8i_enc.h"
+#include "./cost_enc.h"
#include "../utils/utils.h"
#define MAX_ITERS_K_MEANS 6
@@ -262,6 +262,29 @@ static int MBAnalyzeBestIntra16Mode(VP8EncIterator* const it) {
return best_alpha;
}
+static int FastMBAnalyze(VP8EncIterator* const it) {
+ // Empirical cut-off value, should be around 16 (~=block size). We use the
+ // [8-17] range and favor intra4 at high quality, intra16 for low quality.
+ const int q = (int)it->enc_->config_->quality;
+ const uint32_t kThreshold = 8 + (17 - 8) * q / 100;
+ int k;
+ uint32_t dc[16], m, m2;
+ for (k = 0; k < 16; k += 4) {
+ VP8Mean16x4(it->yuv_in_ + Y_OFF_ENC + k * BPS, &dc[k]);
+ }
+ for (m = 0, m2 = 0, k = 0; k < 16; ++k) {
+ m += dc[k];
+ m2 += dc[k] * dc[k];
+ }
+ if (kThreshold * m2 < m * m) {
+ VP8SetIntra16Mode(it, 0); // DC16
+ } else {
+ const uint8_t modes[16] = { 0 }; // DC4
+ VP8SetIntra4Mode(it, modes);
+ }
+ return 0;
+}
+
static int MBAnalyzeBestIntra4Mode(VP8EncIterator* const it,
int best_alpha) {
uint8_t modes[16];
@@ -344,13 +367,17 @@ static void MBAnalyze(VP8EncIterator* const it,
VP8SetSkip(it, 0); // not skipped
VP8SetSegment(it, 0); // default segment, spec-wise.
- best_alpha = MBAnalyzeBestIntra16Mode(it);
- if (enc->method_ >= 5) {
- // We go and make a fast decision for intra4/intra16.
- // It's usually not a good and definitive pick, but helps seeding the stats
- // about level bit-cost.
- // TODO(skal): improve criterion.
- best_alpha = MBAnalyzeBestIntra4Mode(it, best_alpha);
+ if (enc->method_ <= 1) {
+ best_alpha = FastMBAnalyze(it);
+ } else {
+ best_alpha = MBAnalyzeBestIntra16Mode(it);
+ if (enc->method_ >= 5) {
+ // We go and make a fast decision for intra4/intra16.
+ // It's usually not a good and definitive pick, but helps seeding the
+ // stats about level bit-cost.
+ // TODO(skal): improve criterion.
+ best_alpha = MBAnalyzeBestIntra4Mode(it, best_alpha);
+ }
}
best_uv_alpha = MBAnalyzeBestUVMode(it);
@@ -453,7 +480,7 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
const int do_segments =
enc->config_->emulate_jpeg_size || // We need the complexity evaluation.
(enc->segment_hdr_.num_segments_ > 1) ||
- (enc->method_ == 0); // for method 0, we need preds_[] to be filled.
+ (enc->method_ <= 1); // for method 0 - 1, we need preds_[] to be filled.
if (do_segments) {
const int last_row = enc->mb_h_;
// We give a little more than a half work to the main thread.
diff --git a/thirdparty/libwebp/enc/backward_references.c b/thirdparty/libwebp/enc/backward_references_enc.c
index 136a24a8c3..7c0559ff1e 100644
--- a/thirdparty/libwebp/enc/backward_references.c
+++ b/thirdparty/libwebp/enc/backward_references_enc.c
@@ -13,11 +13,12 @@
#include <assert.h>
#include <math.h>
-#include "./backward_references.h"
-#include "./histogram.h"
+#include "./backward_references_enc.h"
+#include "./histogram_enc.h"
#include "../dsp/lossless.h"
+#include "../dsp/lossless_common.h"
#include "../dsp/dsp.h"
-#include "../utils/color_cache.h"
+#include "../utils/color_cache_utils.h"
#include "../utils/utils.h"
#define VALUES_IN_BYTE 256
@@ -30,8 +31,9 @@
#define WINDOW_SIZE_BITS 20
#define WINDOW_SIZE ((1 << WINDOW_SIZE_BITS) - 120)
-// Bounds for the match length.
-#define MIN_LENGTH 2
+// Minimum number of pixels for which it is cheaper to encode a
+// distance + length instead of each pixel as a literal.
+#define MIN_LENGTH 4
// If you change this, you need MAX_LENGTH_BITS + WINDOW_SIZE_BITS <= 32 as it
// is used in VP8LHashChain.
#define MAX_LENGTH_BITS 12
@@ -211,13 +213,13 @@ void VP8LHashChainClear(VP8LHashChain* const p) {
// -----------------------------------------------------------------------------
-#define HASH_MULTIPLIER_HI (0xc6a4a793U)
-#define HASH_MULTIPLIER_LO (0x5bd1e996U)
+#define HASH_MULTIPLIER_HI (0xc6a4a793ULL)
+#define HASH_MULTIPLIER_LO (0x5bd1e996ULL)
static WEBP_INLINE uint32_t GetPixPairHash64(const uint32_t* const argb) {
uint32_t key;
- key = argb[1] * HASH_MULTIPLIER_HI;
- key += argb[0] * HASH_MULTIPLIER_LO;
+ key = (argb[1] * HASH_MULTIPLIER_HI) & 0xffffffffu;
+ key += (argb[0] * HASH_MULTIPLIER_LO) & 0xffffffffu;
key = key >> (32 - HASH_BITS);
return key;
}
@@ -242,19 +244,26 @@ static WEBP_INLINE int MaxFindCopyLength(int len) {
}
int VP8LHashChainFill(VP8LHashChain* const p, int quality,
- const uint32_t* const argb, int xsize, int ysize) {
+ const uint32_t* const argb, int xsize, int ysize,
+ int low_effort) {
const int size = xsize * ysize;
const int iter_max = GetMaxItersForQuality(quality);
- const int iter_min = iter_max - quality / 10;
const uint32_t window_size = GetWindowSizeForHashChain(quality, xsize);
int pos;
+ int argb_comp;
uint32_t base_position;
int32_t* hash_to_first_index;
// Temporarily use the p->offset_length_ as a hash chain.
int32_t* chain = (int32_t*)p->offset_length_;
+ assert(size > 0);
assert(p->size_ != 0);
assert(p->offset_length_ != NULL);
+ if (size <= 2) {
+ p->offset_length_[0] = p->offset_length_[size - 1] = 0;
+ return 1;
+ }
+
hash_to_first_index =
(int32_t*)WebPSafeMalloc(HASH_SIZE, sizeof(*hash_to_first_index));
if (hash_to_first_index == NULL) return 0;
@@ -262,48 +271,111 @@ int VP8LHashChainFill(VP8LHashChain* const p, int quality,
// Set the int32_t array to -1.
memset(hash_to_first_index, 0xff, HASH_SIZE * sizeof(*hash_to_first_index));
// Fill the chain linking pixels with the same hash.
- for (pos = 0; pos < size - 1; ++pos) {
- const uint32_t hash_code = GetPixPairHash64(argb + pos);
- chain[pos] = hash_to_first_index[hash_code];
- hash_to_first_index[hash_code] = pos;
+ argb_comp = (argb[0] == argb[1]);
+ for (pos = 0; pos < size - 2;) {
+ uint32_t hash_code;
+ const int argb_comp_next = (argb[pos + 1] == argb[pos + 2]);
+ if (argb_comp && argb_comp_next) {
+ // Consecutive pixels with the same color will share the same hash.
+ // We therefore use a different hash: the color and its repetition
+ // length.
+ uint32_t tmp[2];
+ uint32_t len = 1;
+ tmp[0] = argb[pos];
+ // Figure out how far the pixels are the same.
+ // The last pixel has a different 64 bit hash, as its next pixel does
+ // not have the same color, so we just need to get to the last pixel equal
+ // to its follower.
+ while (pos + (int)len + 2 < size && argb[pos + len + 2] == argb[pos]) {
+ ++len;
+ }
+ if (len > MAX_LENGTH) {
+ // Skip the pixels that match for distance=1 and length>MAX_LENGTH
+ // because they are linked to their predecessor and we automatically
+ // check that in the main for loop below. Skipping means setting no
+ // predecessor in the chain, hence -1.
+ memset(chain + pos, 0xff, (len - MAX_LENGTH) * sizeof(*chain));
+ pos += len - MAX_LENGTH;
+ len = MAX_LENGTH;
+ }
+ // Process the rest of the hash chain.
+ while (len) {
+ tmp[1] = len--;
+ hash_code = GetPixPairHash64(tmp);
+ chain[pos] = hash_to_first_index[hash_code];
+ hash_to_first_index[hash_code] = pos++;
+ }
+ argb_comp = 0;
+ } else {
+ // Just move one pixel forward.
+ hash_code = GetPixPairHash64(argb + pos);
+ chain[pos] = hash_to_first_index[hash_code];
+ hash_to_first_index[hash_code] = pos++;
+ argb_comp = argb_comp_next;
+ }
}
+ // Process the penultimate pixel.
+ chain[pos] = hash_to_first_index[GetPixPairHash64(argb + pos)];
+
WebPSafeFree(hash_to_first_index);
// Find the best match interval at each pixel, defined by an offset to the
// pixel and a length. The right-most pixel cannot match anything to the right
// (hence a best length of 0) and the left-most pixel nothing to the left
// (hence an offset of 0).
+ assert(size > 2);
p->offset_length_[0] = p->offset_length_[size - 1] = 0;
- for (base_position = size - 2 < 0 ? 0 : size - 2; base_position > 0;) {
+ for (base_position = size - 2; base_position > 0;) {
const int max_len = MaxFindCopyLength(size - 1 - base_position);
const uint32_t* const argb_start = argb + base_position;
int iter = iter_max;
int best_length = 0;
uint32_t best_distance = 0;
+ uint32_t best_argb;
const int min_pos =
(base_position > window_size) ? base_position - window_size : 0;
const int length_max = (max_len < 256) ? max_len : 256;
uint32_t max_base_position;
- for (pos = chain[base_position]; pos >= min_pos; pos = chain[pos]) {
+ pos = chain[base_position];
+ if (!low_effort) {
int curr_length;
- if (--iter < 0) {
- break;
+ // Heuristic: use the comparison with the above line as an initialization.
+ if (base_position >= (uint32_t)xsize) {
+ curr_length = FindMatchLength(argb_start - xsize, argb_start,
+ best_length, max_len);
+ if (curr_length > best_length) {
+ best_length = curr_length;
+ best_distance = xsize;
+ }
+ --iter;
+ }
+ // Heuristic: compare to the previous pixel.
+ curr_length =
+ FindMatchLength(argb_start - 1, argb_start, best_length, max_len);
+ if (curr_length > best_length) {
+ best_length = curr_length;
+ best_distance = 1;
}
+ --iter;
+ // Skip the for loop if we already have the maximum.
+ if (best_length == MAX_LENGTH) pos = min_pos - 1;
+ }
+ best_argb = argb_start[best_length];
+
+ for (; pos >= min_pos && --iter; pos = chain[pos]) {
+ int curr_length;
assert(base_position > (uint32_t)pos);
- curr_length =
- FindMatchLength(argb + pos, argb_start, best_length, max_len);
+ if (argb[pos + best_length] != best_argb) continue;
+
+ curr_length = VP8LVectorMismatch(argb + pos, argb_start, max_len);
if (best_length < curr_length) {
best_length = curr_length;
best_distance = base_position - pos;
- // Stop if we have reached the maximum length. Otherwise, make sure
- // we have executed a minimum number of iterations depending on the
- // quality.
- if ((best_length == MAX_LENGTH) ||
- (curr_length >= length_max && iter < iter_min)) {
- break;
- }
+ best_argb = argb_start[best_length];
+ // Stop if we have reached a good enough length.
+ if (best_length >= length_max) break;
}
}
// We have the best match but in case the two intervals continue matching
@@ -392,17 +464,16 @@ static int BackwardReferencesRle(int xsize, int ysize,
i = 1;
while (i < pix_count) {
const int max_len = MaxFindCopyLength(pix_count - i);
- const int kMinLength = 4;
const int rle_len = FindMatchLength(argb + i, argb + i - 1, 0, max_len);
const int prev_row_len = (i < xsize) ? 0 :
FindMatchLength(argb + i, argb + i - xsize, 0, max_len);
- if (rle_len >= prev_row_len && rle_len >= kMinLength) {
+ if (rle_len >= prev_row_len && rle_len >= MIN_LENGTH) {
BackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(1, rle_len));
// We don't need to update the color cache here since it is always the
// same pixel being copied, and that does not change the color cache
// state.
i += rle_len;
- } else if (prev_row_len >= kMinLength) {
+ } else if (prev_row_len >= MIN_LENGTH) {
BackwardRefsCursorAdd(refs, PixOrCopyCreateCopy(xsize, prev_row_len));
if (use_color_cache) {
for (k = 0; k < prev_row_len; ++k) {
@@ -442,7 +513,7 @@ static int BackwardReferencesLz77(int xsize, int ysize,
int len = 0;
int j;
HashChainFindCopy(hash_chain, i, &offset, &len);
- if (len > MIN_LENGTH + 1) {
+ if (len >= MIN_LENGTH) {
const int len_ini = len;
int max_reach = 0;
assert(i + len < pix_count);
@@ -457,7 +528,7 @@ static int BackwardReferencesLz77(int xsize, int ysize,
for (j = i_last_check + 1; j <= i + len_ini; ++j) {
const int len_j = HashChainFindLength(hash_chain, j);
const int reach =
- j + (len_j > MIN_LENGTH + 1 ? len_j : 1); // 1 for single literal.
+ j + (len_j >= MIN_LENGTH ? len_j : 1); // 1 for single literal.
if (reach > max_reach) {
len = j - i;
max_reach = reach;
@@ -581,9 +652,10 @@ static void AddSingleLiteralWithCostModel(const uint32_t* const argb,
uint16_t* const dist_array) {
double cost_val = prev_cost;
const uint32_t color = argb[0];
- if (use_color_cache && VP8LColorCacheContains(hashers, color)) {
+ const int ix = use_color_cache ? VP8LColorCacheContains(hashers, color) : -1;
+ if (ix >= 0) {
+ // use_color_cache is true and hashers contains color
const double mul0 = 0.68;
- const int ix = VP8LColorCacheGetIndex(hashers, color);
cost_val += GetCacheCost(cost_model, ix) * mul0;
} else {
const double mul1 = 0.82;
@@ -1215,7 +1287,8 @@ static int BackwardReferencesHashChainDistanceOnly(
int offset = 0, len = 0;
double prev_cost = cost_manager->costs_[i - 1];
HashChainFindCopy(hash_chain, i, &offset, &len);
- if (len >= MIN_LENGTH) {
+ if (len >= 2) {
+ // If we are dealing with a non-literal.
const int code = DistanceToPlaneCode(xsize, offset);
const double offset_cost = GetDistanceCost(cost_model, code);
const int first_i = i;
@@ -1304,20 +1377,17 @@ static int BackwardReferencesHashChainDistanceOnly(
}
goto next_symbol;
}
- if (len > MIN_LENGTH) {
- int code_min_length;
- double cost_total;
- offset = HashChainFindOffset(hash_chain, i);
- code_min_length = DistanceToPlaneCode(xsize, offset);
- cost_total = prev_cost +
- GetDistanceCost(cost_model, code_min_length) +
- GetLengthCost(cost_model, 1);
+ if (len > 2) {
+ // Also try the smallest interval possible (size 2).
+ double cost_total =
+ prev_cost + offset_cost + GetLengthCost(cost_model, 1);
if (cost_manager->costs_[i + 1] > cost_total) {
cost_manager->costs_[i + 1] = (float)cost_total;
dist_array[i + 1] = 2;
}
}
- } else { // len < MIN_LENGTH
+ } else {
+ // The pixel is added as a single literal so just update the costs.
UpdateCostPerIndex(cost_manager, i + 1);
}
@@ -1393,9 +1463,11 @@ static int BackwardReferencesHashChainFollowChosenPath(
i += len;
} else {
PixOrCopy v;
- if (use_color_cache && VP8LColorCacheContains(&hashers, argb[i])) {
+ const int idx =
+ use_color_cache ? VP8LColorCacheContains(&hashers, argb[i]) : -1;
+ if (idx >= 0) {
+ // use_color_cache is true and hashers contains argb[i]
// push pixel as a color cache index
- const int idx = VP8LColorCacheGetIndex(&hashers, argb[i]);
v = PixOrCopyCreateCacheIdx(idx);
} else {
if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]);
@@ -1454,63 +1526,89 @@ static void BackwardReferences2DLocality(int xsize,
}
}
-// Returns entropy for the given cache bits.
-static double ComputeCacheEntropy(const uint32_t* argb,
- const VP8LBackwardRefs* const refs,
- int cache_bits) {
- const int use_color_cache = (cache_bits > 0);
- int cc_init = 0;
- double entropy = MAX_ENTROPY;
- const double kSmallPenaltyForLargeCache = 4.0;
- VP8LColorCache hashers;
+// Computes the entropies for a color cache size (in bits) between 0 (unused)
+// and cache_bits_max (inclusive).
+// Returns 1 on success, 0 in case of allocation error.
+static int ComputeCacheEntropies(const uint32_t* argb,
+ const VP8LBackwardRefs* const refs,
+ int cache_bits_max, double entropies[]) {
+ int cc_init[MAX_COLOR_CACHE_BITS + 1] = { 0 };
+ VP8LColorCache hashers[MAX_COLOR_CACHE_BITS + 1];
VP8LRefsCursor c = VP8LRefsCursorInit(refs);
- VP8LHistogram* histo = VP8LAllocateHistogram(cache_bits);
- if (histo == NULL) goto Error;
+ VP8LHistogram* histos[MAX_COLOR_CACHE_BITS + 1] = { NULL };
+ int ok = 0;
+ int i;
- if (use_color_cache) {
- cc_init = VP8LColorCacheInit(&hashers, cache_bits);
- if (!cc_init) goto Error;
+ for (i = 0; i <= cache_bits_max; ++i) {
+ histos[i] = VP8LAllocateHistogram(i);
+ if (histos[i] == NULL) goto Error;
+ if (i == 0) continue;
+ cc_init[i] = VP8LColorCacheInit(&hashers[i], i);
+ if (!cc_init[i]) goto Error;
}
- if (!use_color_cache) {
- while (VP8LRefsCursorOk(&c)) {
- VP8LHistogramAddSinglePixOrCopy(histo, c.cur_pos);
- VP8LRefsCursorNext(&c);
- }
- } else {
+
+ assert(cache_bits_max >= 0);
+ // Do not use the color cache for cache_bits=0.
+ while (VP8LRefsCursorOk(&c)) {
+ VP8LHistogramAddSinglePixOrCopy(histos[0], c.cur_pos);
+ VP8LRefsCursorNext(&c);
+ }
+ if (cache_bits_max > 0) {
+ c = VP8LRefsCursorInit(refs);
while (VP8LRefsCursorOk(&c)) {
const PixOrCopy* const v = c.cur_pos;
if (PixOrCopyIsLiteral(v)) {
const uint32_t pix = *argb++;
- const uint32_t key = VP8LColorCacheGetIndex(&hashers, pix);
- if (VP8LColorCacheLookup(&hashers, key) == pix) {
- ++histo->literal_[NUM_LITERAL_CODES + NUM_LENGTH_CODES + key];
- } else {
- VP8LColorCacheSet(&hashers, key, pix);
- ++histo->blue_[pix & 0xff];
- ++histo->literal_[(pix >> 8) & 0xff];
- ++histo->red_[(pix >> 16) & 0xff];
- ++histo->alpha_[pix >> 24];
+ // The keys of the caches can be derived from the longest one.
+ int key = HashPix(pix, 32 - cache_bits_max);
+ for (i = cache_bits_max; i >= 1; --i, key >>= 1) {
+ if (VP8LColorCacheLookup(&hashers[i], key) == pix) {
+ ++histos[i]->literal_[NUM_LITERAL_CODES + NUM_LENGTH_CODES + key];
+ } else {
+ VP8LColorCacheSet(&hashers[i], key, pix);
+ ++histos[i]->blue_[pix & 0xff];
+ ++histos[i]->literal_[(pix >> 8) & 0xff];
+ ++histos[i]->red_[(pix >> 16) & 0xff];
+ ++histos[i]->alpha_[pix >> 24];
+ }
}
} else {
+ // Update the histograms for distance/length.
int len = PixOrCopyLength(v);
- int code, extra_bits;
- VP8LPrefixEncodeBits(len, &code, &extra_bits);
- ++histo->literal_[NUM_LITERAL_CODES + code];
- VP8LPrefixEncodeBits(PixOrCopyDistance(v), &code, &extra_bits);
- ++histo->distance_[code];
+ int code_dist, code_len, extra_bits;
+ uint32_t argb_prev = *argb ^ 0xffffffffu;
+ VP8LPrefixEncodeBits(len, &code_len, &extra_bits);
+ VP8LPrefixEncodeBits(PixOrCopyDistance(v), &code_dist, &extra_bits);
+ for (i = 1; i <= cache_bits_max; ++i) {
+ ++histos[i]->literal_[NUM_LITERAL_CODES + code_len];
+ ++histos[i]->distance_[code_dist];
+ }
+ // Update the colors caches.
do {
- VP8LColorCacheInsert(&hashers, *argb++);
- } while(--len != 0);
+ if (*argb != argb_prev) {
+ // Efficiency: insert only if the color changes.
+ int key = HashPix(*argb, 32 - cache_bits_max);
+ for (i = cache_bits_max; i >= 1; --i, key >>= 1) {
+ hashers[i].colors_[key] = *argb;
+ }
+ argb_prev = *argb;
+ }
+ argb++;
+ } while (--len != 0);
}
VP8LRefsCursorNext(&c);
}
}
- entropy = VP8LHistogramEstimateBits(histo) +
- kSmallPenaltyForLargeCache * cache_bits;
- Error:
- if (cc_init) VP8LColorCacheClear(&hashers);
- VP8LFreeHistogram(histo);
- return entropy;
+ for (i = 0; i <= cache_bits_max; ++i) {
+ entropies[i] = VP8LHistogramEstimateBits(histos[i]);
+ }
+ ok = 1;
+Error:
+ for (i = 0; i <= cache_bits_max; ++i) {
+ if (cc_init[i]) VP8LColorCacheClear(&hashers[i]);
+ VP8LFreeHistogram(histos[i]);
+ }
+ return ok;
}
// Evaluate optimal cache bits for the local color cache.
@@ -1524,13 +1622,10 @@ static int CalculateBestCacheSize(const uint32_t* const argb,
VP8LBackwardRefs* const refs,
int* const lz77_computed,
int* const best_cache_bits) {
- int eval_low = 1;
- int eval_high = 1;
- double entropy_low = MAX_ENTROPY;
- double entropy_high = MAX_ENTROPY;
- const double cost_mul = 5e-4;
- int cache_bits_low = 0;
+ int i;
int cache_bits_high = (quality <= 25) ? 0 : *best_cache_bits;
+ double entropy_min = MAX_ENTROPY;
+ double entropies[MAX_COLOR_CACHE_BITS + 1];
assert(cache_bits_high <= MAX_COLOR_CACHE_BITS);
@@ -1540,34 +1635,23 @@ static int CalculateBestCacheSize(const uint32_t* const argb,
// Local color cache is disabled.
return 1;
}
- if (!BackwardReferencesLz77(xsize, ysize, argb, cache_bits_low, hash_chain,
- refs)) {
+ // Compute LZ77 with no cache (0 bits), as the ideal LZ77 with a color cache
+ // is not that different in practice.
+ if (!BackwardReferencesLz77(xsize, ysize, argb, 0, hash_chain, refs)) {
return 0;
}
- // Do a binary search to find the optimal entropy for cache_bits.
- while (eval_low || eval_high) {
- if (eval_low) {
- entropy_low = ComputeCacheEntropy(argb, refs, cache_bits_low);
- entropy_low += entropy_low * cache_bits_low * cost_mul;
- eval_low = 0;
- }
- if (eval_high) {
- entropy_high = ComputeCacheEntropy(argb, refs, cache_bits_high);
- entropy_high += entropy_high * cache_bits_high * cost_mul;
- eval_high = 0;
- }
- if (entropy_high < entropy_low) {
- const int prev_cache_bits_low = cache_bits_low;
- *best_cache_bits = cache_bits_high;
- cache_bits_low = (cache_bits_low + cache_bits_high) / 2;
- if (cache_bits_low != prev_cache_bits_low) eval_low = 1;
- } else {
- *best_cache_bits = cache_bits_low;
- cache_bits_high = (cache_bits_low + cache_bits_high) / 2;
- if (cache_bits_high != cache_bits_low) eval_high = 1;
+ // Find the cache_bits giving the lowest entropy. The search is done in a
+ // brute-force way as the function (entropy w.r.t cache_bits) can be
+ // anything in practice.
+ if (!ComputeCacheEntropies(argb, refs, cache_bits_high, entropies)) {
+ return 0;
+ }
+ for (i = 0; i <= cache_bits_high; ++i) {
+ if (i == 0 || entropies[i] < entropy_min) {
+ entropy_min = entropies[i];
+ *best_cache_bits = i;
}
}
- *lz77_computed = 1;
return 1;
}
@@ -1584,8 +1668,9 @@ static int BackwardRefsWithLocalCache(const uint32_t* const argb,
PixOrCopy* const v = c.cur_pos;
if (PixOrCopyIsLiteral(v)) {
const uint32_t argb_literal = v->argb_or_distance;
- if (VP8LColorCacheContains(&hashers, argb_literal)) {
- const int ix = VP8LColorCacheGetIndex(&hashers, argb_literal);
+ const int ix = VP8LColorCacheContains(&hashers, argb_literal);
+ if (ix >= 0) {
+ // hashers contains argb_literal
*v = PixOrCopyCreateCacheIdx(ix);
} else {
VP8LColorCacheInsert(&hashers, argb_literal);
diff --git a/thirdparty/libwebp/enc/backward_references.h b/thirdparty/libwebp/enc/backward_references_enc.h
index 0cadb11e11..3a19aa763e 100644
--- a/thirdparty/libwebp/enc/backward_references.h
+++ b/thirdparty/libwebp/enc/backward_references_enc.h
@@ -130,7 +130,8 @@ struct VP8LHashChain {
int VP8LHashChainInit(VP8LHashChain* const p, int size);
// Pre-compute the best matches for argb.
int VP8LHashChainFill(VP8LHashChain* const p, int quality,
- const uint32_t* const argb, int xsize, int ysize);
+ const uint32_t* const argb, int xsize, int ysize,
+ int low_effort);
void VP8LHashChainClear(VP8LHashChain* const p); // release memory
// -----------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/enc/config.c b/thirdparty/libwebp/enc/config_enc.c
index f9f7961d58..4589dc0619 100644
--- a/thirdparty/libwebp/enc/config.c
+++ b/thirdparty/libwebp/enc/config_enc.c
@@ -11,6 +11,10 @@
//
// Author: Skal (pascal.massimino@gmail.com)
+#ifdef HAVE_CONFIG_H
+#include "../webp/config.h"
+#endif
+
#include "../webp/encode.h"
//------------------------------------------------------------------------------
@@ -49,9 +53,8 @@ int WebPConfigInitInternal(WebPConfig* config,
config->thread_level = 0;
config->low_memory = 0;
config->near_lossless = 100;
-#ifdef WEBP_EXPERIMENTAL_FEATURES
- config->delta_palettization = 0;
-#endif // WEBP_EXPERIMENTAL_FEATURES
+ config->use_delta_palette = 0;
+ config->use_sharp_yuv = 0;
// TODO(skal): tune.
switch (preset) {
@@ -92,60 +95,36 @@ int WebPConfigInitInternal(WebPConfig* config,
int WebPValidateConfig(const WebPConfig* config) {
if (config == NULL) return 0;
- if (config->quality < 0 || config->quality > 100)
- return 0;
- if (config->target_size < 0)
- return 0;
- if (config->target_PSNR < 0)
- return 0;
- if (config->method < 0 || config->method > 6)
- return 0;
- if (config->segments < 1 || config->segments > 4)
- return 0;
- if (config->sns_strength < 0 || config->sns_strength > 100)
- return 0;
- if (config->filter_strength < 0 || config->filter_strength > 100)
- return 0;
- if (config->filter_sharpness < 0 || config->filter_sharpness > 7)
- return 0;
- if (config->filter_type < 0 || config->filter_type > 1)
- return 0;
- if (config->autofilter < 0 || config->autofilter > 1)
- return 0;
- if (config->pass < 1 || config->pass > 10)
- return 0;
- if (config->show_compressed < 0 || config->show_compressed > 1)
- return 0;
- if (config->preprocessing < 0 || config->preprocessing > 7)
- return 0;
- if (config->partitions < 0 || config->partitions > 3)
+ if (config->quality < 0 || config->quality > 100) return 0;
+ if (config->target_size < 0) return 0;
+ if (config->target_PSNR < 0) return 0;
+ if (config->method < 0 || config->method > 6) return 0;
+ if (config->segments < 1 || config->segments > 4) return 0;
+ if (config->sns_strength < 0 || config->sns_strength > 100) return 0;
+ if (config->filter_strength < 0 || config->filter_strength > 100) return 0;
+ if (config->filter_sharpness < 0 || config->filter_sharpness > 7) return 0;
+ if (config->filter_type < 0 || config->filter_type > 1) return 0;
+ if (config->autofilter < 0 || config->autofilter > 1) return 0;
+ if (config->pass < 1 || config->pass > 10) return 0;
+ if (config->show_compressed < 0 || config->show_compressed > 1) return 0;
+ if (config->preprocessing < 0 || config->preprocessing > 7) return 0;
+ if (config->partitions < 0 || config->partitions > 3) return 0;
+ if (config->partition_limit < 0 || config->partition_limit > 100) return 0;
+ if (config->alpha_compression < 0) return 0;
+ if (config->alpha_filtering < 0) return 0;
+ if (config->alpha_quality < 0 || config->alpha_quality > 100) return 0;
+ if (config->lossless < 0 || config->lossless > 1) return 0;
+ if (config->near_lossless < 0 || config->near_lossless > 100) return 0;
+ if (config->image_hint >= WEBP_HINT_LAST) return 0;
+ if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1) return 0;
+ if (config->thread_level < 0 || config->thread_level > 1) return 0;
+ if (config->low_memory < 0 || config->low_memory > 1) return 0;
+ if (config->exact < 0 || config->exact > 1) return 0;
+ if (config->use_delta_palette < 0 || config->use_delta_palette > 1) {
return 0;
- if (config->partition_limit < 0 || config->partition_limit > 100)
- return 0;
- if (config->alpha_compression < 0)
- return 0;
- if (config->alpha_filtering < 0)
- return 0;
- if (config->alpha_quality < 0 || config->alpha_quality > 100)
- return 0;
- if (config->lossless < 0 || config->lossless > 1)
- return 0;
- if (config->near_lossless < 0 || config->near_lossless > 100)
- return 0;
- if (config->image_hint >= WEBP_HINT_LAST)
- return 0;
- if (config->emulate_jpeg_size < 0 || config->emulate_jpeg_size > 1)
- return 0;
- if (config->thread_level < 0 || config->thread_level > 1)
- return 0;
- if (config->low_memory < 0 || config->low_memory > 1)
- return 0;
- if (config->exact < 0 || config->exact > 1)
- return 0;
-#ifdef WEBP_EXPERIMENTAL_FEATURES
- if (config->delta_palettization < 0 || config->delta_palettization > 1)
- return 0;
-#endif // WEBP_EXPERIMENTAL_FEATURES
+ }
+ if (config->use_sharp_yuv < 0 || config->use_sharp_yuv > 1) return 0;
+
return 1;
}
diff --git a/thirdparty/libwebp/enc/cost.c b/thirdparty/libwebp/enc/cost_enc.c
index 87f89378a7..c823f5a664 100644
--- a/thirdparty/libwebp/enc/cost.c
+++ b/thirdparty/libwebp/enc/cost_enc.c
@@ -11,7 +11,7 @@
//
// Author: Skal (pascal.massimino@gmail.com)
-#include "./cost.h"
+#include "./cost_enc.h"
//------------------------------------------------------------------------------
// Level cost tables
diff --git a/thirdparty/libwebp/enc/cost.h b/thirdparty/libwebp/enc/cost_enc.h
index ad7959feb4..99e4b37aa3 100644
--- a/thirdparty/libwebp/enc/cost.h
+++ b/thirdparty/libwebp/enc/cost_enc.h
@@ -16,7 +16,7 @@
#include <assert.h>
#include <stdlib.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#ifdef __cplusplus
extern "C" {
diff --git a/thirdparty/libwebp/enc/delta_palettization.c b/thirdparty/libwebp/enc/delta_palettization_enc.c
index 062e588d79..eaf0f050ea 100644
--- a/thirdparty/libwebp/enc/delta_palettization.c
+++ b/thirdparty/libwebp/enc/delta_palettization_enc.c
@@ -10,7 +10,7 @@
// Author: Mislav Bradac (mislavm@google.com)
//
-#include "./delta_palettization.h"
+#include "./delta_palettization_enc.h"
#ifdef WEBP_EXPERIMENTAL_FEATURES
#include "../webp/types.h"
diff --git a/thirdparty/libwebp/enc/delta_palettization.h b/thirdparty/libwebp/enc/delta_palettization_enc.h
index e41c0c5ab5..63048ec6e8 100644
--- a/thirdparty/libwebp/enc/delta_palettization.h
+++ b/thirdparty/libwebp/enc/delta_palettization_enc.h
@@ -14,7 +14,7 @@
#define WEBP_ENC_DELTA_PALETTIZATION_H_
#include "../webp/encode.h"
-#include "../enc/vp8li.h"
+#include "../enc/vp8li_enc.h"
// Replaces enc->argb_[] input by a palettizable approximation of it,
// and generates optimal enc->palette_[].
diff --git a/thirdparty/libwebp/enc/filter.c b/thirdparty/libwebp/enc/filter_enc.c
index e8ea8b4ff2..4bc367274c 100644
--- a/thirdparty/libwebp/enc/filter.c
+++ b/thirdparty/libwebp/enc/filter_enc.c
@@ -12,7 +12,7 @@
// Author: somnath@google.com (Somnath Banerjee)
#include <assert.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#include "../dsp/dsp.h"
// This table gives, for a given sharpness, the filtering strength to be
@@ -105,115 +105,28 @@ static void DoFilter(const VP8EncIterator* const it, int level) {
}
//------------------------------------------------------------------------------
-// SSIM metric
-
-static const double kMinValue = 1.e-10; // minimal threshold
-
-void VP8SSIMAddStats(const VP8DistoStats* const src, VP8DistoStats* const dst) {
- dst->w += src->w;
- dst->xm += src->xm;
- dst->ym += src->ym;
- dst->xxm += src->xxm;
- dst->xym += src->xym;
- dst->yym += src->yym;
-}
-
-double VP8SSIMGet(const VP8DistoStats* const stats) {
- const double xmxm = stats->xm * stats->xm;
- const double ymym = stats->ym * stats->ym;
- const double xmym = stats->xm * stats->ym;
- const double w2 = stats->w * stats->w;
- double sxx = stats->xxm * stats->w - xmxm;
- double syy = stats->yym * stats->w - ymym;
- double sxy = stats->xym * stats->w - xmym;
- double C1, C2;
- double fnum;
- double fden;
- // small errors are possible, due to rounding. Clamp to zero.
- if (sxx < 0.) sxx = 0.;
- if (syy < 0.) syy = 0.;
- C1 = 6.5025 * w2;
- C2 = 58.5225 * w2;
- fnum = (2 * xmym + C1) * (2 * sxy + C2);
- fden = (xmxm + ymym + C1) * (sxx + syy + C2);
- return (fden != 0.) ? fnum / fden : kMinValue;
-}
-
-double VP8SSIMGetSquaredError(const VP8DistoStats* const s) {
- if (s->w > 0.) {
- const double iw2 = 1. / (s->w * s->w);
- const double sxx = s->xxm * s->w - s->xm * s->xm;
- const double syy = s->yym * s->w - s->ym * s->ym;
- const double sxy = s->xym * s->w - s->xm * s->ym;
- const double SSE = iw2 * (sxx + syy - 2. * sxy);
- if (SSE > kMinValue) return SSE;
- }
- return kMinValue;
-}
-
-#define LIMIT(A, M) ((A) > (M) ? (M) : (A))
-static void VP8SSIMAccumulateRow(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int y, int W, int H,
- VP8DistoStats* const stats) {
- int x = 0;
- const int w0 = LIMIT(VP8_SSIM_KERNEL, W);
- for (x = 0; x < w0; ++x) {
- VP8SSIMAccumulateClipped(src1, stride1, src2, stride2, x, y, W, H, stats);
- }
- for (; x <= W - 8 + VP8_SSIM_KERNEL; ++x) {
- VP8SSIMAccumulate(
- src1 + (y - VP8_SSIM_KERNEL) * stride1 + (x - VP8_SSIM_KERNEL), stride1,
- src2 + (y - VP8_SSIM_KERNEL) * stride2 + (x - VP8_SSIM_KERNEL), stride2,
- stats);
- }
- for (; x < W; ++x) {
- VP8SSIMAccumulateClipped(src1, stride1, src2, stride2, x, y, W, H, stats);
- }
-}
-
-void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int W, int H, VP8DistoStats* const stats) {
- int x, y;
- const int h0 = LIMIT(VP8_SSIM_KERNEL, H);
- const int h1 = LIMIT(VP8_SSIM_KERNEL, H - VP8_SSIM_KERNEL);
- for (y = 0; y < h0; ++y) {
- for (x = 0; x < W; ++x) {
- VP8SSIMAccumulateClipped(src1, stride1, src2, stride2, x, y, W, H, stats);
- }
- }
- for (; y < h1; ++y) {
- VP8SSIMAccumulateRow(src1, stride1, src2, stride2, y, W, H, stats);
- }
- for (; y < H; ++y) {
- for (x = 0; x < W; ++x) {
- VP8SSIMAccumulateClipped(src1, stride1, src2, stride2, x, y, W, H, stats);
- }
- }
-}
-#undef LIMIT
+// SSIM metric for one macroblock
static double GetMBSSIM(const uint8_t* yuv1, const uint8_t* yuv2) {
int x, y;
- VP8DistoStats s = { .0, .0, .0, .0, .0, .0 };
+ double sum = 0.;
// compute SSIM in a 10 x 10 window
for (y = VP8_SSIM_KERNEL; y < 16 - VP8_SSIM_KERNEL; y++) {
for (x = VP8_SSIM_KERNEL; x < 16 - VP8_SSIM_KERNEL; x++) {
- VP8SSIMAccumulateClipped(yuv1 + Y_OFF_ENC, BPS, yuv2 + Y_OFF_ENC, BPS,
- x, y, 16, 16, &s);
+ sum += VP8SSIMGetClipped(yuv1 + Y_OFF_ENC, BPS, yuv2 + Y_OFF_ENC, BPS,
+ x, y, 16, 16);
}
}
for (x = 1; x < 7; x++) {
for (y = 1; y < 7; y++) {
- VP8SSIMAccumulateClipped(yuv1 + U_OFF_ENC, BPS, yuv2 + U_OFF_ENC, BPS,
- x, y, 8, 8, &s);
- VP8SSIMAccumulateClipped(yuv1 + V_OFF_ENC, BPS, yuv2 + V_OFF_ENC, BPS,
- x, y, 8, 8, &s);
+ sum += VP8SSIMGetClipped(yuv1 + U_OFF_ENC, BPS, yuv2 + U_OFF_ENC, BPS,
+ x, y, 8, 8);
+ sum += VP8SSIMGetClipped(yuv1 + V_OFF_ENC, BPS, yuv2 + V_OFF_ENC, BPS,
+ x, y, 8, 8);
}
}
- return VP8SSIMGet(&s);
+ return sum;
}
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/enc/frame.c b/thirdparty/libwebp/enc/frame_enc.c
index 57fc471d17..abef523bbf 100644
--- a/thirdparty/libwebp/enc/frame.c
+++ b/thirdparty/libwebp/enc/frame_enc.c
@@ -14,8 +14,8 @@
#include <string.h>
#include <math.h>
-#include "./cost.h"
-#include "./vp8enci.h"
+#include "./cost_enc.h"
+#include "./vp8i_enc.h"
#include "../dsp/dsp.h"
#include "../webp/format_constants.h" // RIFF constants
@@ -248,8 +248,9 @@ static int PutCoeffs(VP8BitWriter* const bw, int ctx, const VP8Residual* res) {
p = res->prob[VP8EncBands[n]][1];
} else {
if (!VP8PutBit(bw, v > 4, p[3])) {
- if (VP8PutBit(bw, v != 2, p[4]))
+ if (VP8PutBit(bw, v != 2, p[4])) {
VP8PutBit(bw, v == 4, p[5]);
+ }
} else if (!VP8PutBit(bw, v > 10, p[6])) {
if (!VP8PutBit(bw, v > 6, p[7])) {
VP8PutBit(bw, v == 6, 159);
@@ -557,8 +558,9 @@ static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
size += info.R + info.H;
size_p0 += info.H;
distortion += info.D;
- if (percent_delta && !VP8IteratorProgress(&it, percent_delta))
+ if (percent_delta && !VP8IteratorProgress(&it, percent_delta)) {
return 0;
+ }
VP8IteratorSaveBoundary(&it);
} while (VP8IteratorNext(&it) && --nb_mbs > 0);
diff --git a/thirdparty/libwebp/enc/histogram.c b/thirdparty/libwebp/enc/histogram_enc.c
index 36b7f22625..808b6f78ab 100644
--- a/thirdparty/libwebp/enc/histogram.c
+++ b/thirdparty/libwebp/enc/histogram_enc.c
@@ -15,9 +15,10 @@
#include <math.h>
-#include "./backward_references.h"
-#include "./histogram.h"
+#include "./backward_references_enc.h"
+#include "./histogram_enc.h"
#include "../dsp/lossless.h"
+#include "../dsp/lossless_common.h"
#include "../utils/utils.h"
#define MAX_COST 1.e38
@@ -213,10 +214,19 @@ static double InitialHuffmanCost(void) {
// Finalize the Huffman cost based on streak numbers and length type (<3 or >=3)
static double FinalHuffmanCost(const VP8LStreaks* const stats) {
+ // The constants in this function are experimental and got rounded from
+ // their original values in 1/8 when switched to 1/1024.
double retval = InitialHuffmanCost();
+ // Second coefficient: Many zeros in the histogram are covered efficiently
+ // by a run-length encode. Originally 2/8.
retval += stats->counts[0] * 1.5625 + 0.234375 * stats->streaks[0][1];
+ // Second coefficient: Constant values are encoded less efficiently, but still
+ // RLE'ed. Originally 6/8.
retval += stats->counts[1] * 2.578125 + 0.703125 * stats->streaks[1][1];
+ // 0s are usually encoded more efficiently than non-0s.
+ // Originally 15/8.
retval += 1.796875 * stats->streaks[0][0];
+ // Originally 26/8.
retval += 3.28125 * stats->streaks[1][0];
return retval;
}
@@ -236,14 +246,30 @@ static double PopulationCost(const uint32_t* const population, int length,
return BitsEntropyRefine(&bit_entropy) + FinalHuffmanCost(&stats);
}
+// trivial_at_end is 1 if the two histograms only have one element that is
+// non-zero: both the zero-th one, or both the last one.
static WEBP_INLINE double GetCombinedEntropy(const uint32_t* const X,
const uint32_t* const Y,
- int length) {
- VP8LBitEntropy bit_entropy;
+ int length, int trivial_at_end) {
VP8LStreaks stats;
- VP8LGetCombinedEntropyUnrefined(X, Y, length, &bit_entropy, &stats);
+ if (trivial_at_end) {
+ // This configuration is due to palettization that transforms an indexed
+ // pixel into 0xff000000 | (pixel << 8) in VP8LBundleColorMap.
+ // BitsEntropyRefine is 0 for histograms with only one non-zero value.
+ // Only FinalHuffmanCost needs to be evaluated.
+ memset(&stats, 0, sizeof(stats));
+ // Deal with the non-zero value at index 0 or length-1.
+ stats.streaks[1][0] += 1;
+ // Deal with the following/previous zero streak.
+ stats.counts[0] += 1;
+ stats.streaks[0][1] += length - 1;
+ return FinalHuffmanCost(&stats);
+ } else {
+ VP8LBitEntropy bit_entropy;
+ VP8LGetCombinedEntropyUnrefined(X, Y, length, &bit_entropy, &stats);
- return BitsEntropyRefine(&bit_entropy) + FinalHuffmanCost(&stats);
+ return BitsEntropyRefine(&bit_entropy) + FinalHuffmanCost(&stats);
+ }
}
// Estimates the Entropy + Huffman + other block overhead size cost.
@@ -267,24 +293,42 @@ static int GetCombinedHistogramEntropy(const VP8LHistogram* const a,
double cost_threshold,
double* cost) {
const int palette_code_bits = a->palette_code_bits_;
+ int trivial_at_end = 0;
assert(a->palette_code_bits_ == b->palette_code_bits_);
*cost += GetCombinedEntropy(a->literal_, b->literal_,
- VP8LHistogramNumCodes(palette_code_bits));
+ VP8LHistogramNumCodes(palette_code_bits), 0);
*cost += VP8LExtraCostCombined(a->literal_ + NUM_LITERAL_CODES,
b->literal_ + NUM_LITERAL_CODES,
NUM_LENGTH_CODES);
if (*cost > cost_threshold) return 0;
- *cost += GetCombinedEntropy(a->red_, b->red_, NUM_LITERAL_CODES);
+ if (a->trivial_symbol_ != VP8L_NON_TRIVIAL_SYM &&
+ a->trivial_symbol_ == b->trivial_symbol_) {
+ // A, R and B are all 0 or 0xff.
+ const uint32_t color_a = (a->trivial_symbol_ >> 24) & 0xff;
+ const uint32_t color_r = (a->trivial_symbol_ >> 16) & 0xff;
+ const uint32_t color_b = (a->trivial_symbol_ >> 0) & 0xff;
+ if ((color_a == 0 || color_a == 0xff) &&
+ (color_r == 0 || color_r == 0xff) &&
+ (color_b == 0 || color_b == 0xff)) {
+ trivial_at_end = 1;
+ }
+ }
+
+ *cost +=
+ GetCombinedEntropy(a->red_, b->red_, NUM_LITERAL_CODES, trivial_at_end);
if (*cost > cost_threshold) return 0;
- *cost += GetCombinedEntropy(a->blue_, b->blue_, NUM_LITERAL_CODES);
+ *cost +=
+ GetCombinedEntropy(a->blue_, b->blue_, NUM_LITERAL_CODES, trivial_at_end);
if (*cost > cost_threshold) return 0;
- *cost += GetCombinedEntropy(a->alpha_, b->alpha_, NUM_LITERAL_CODES);
+ *cost += GetCombinedEntropy(a->alpha_, b->alpha_, NUM_LITERAL_CODES,
+ trivial_at_end);
if (*cost > cost_threshold) return 0;
- *cost += GetCombinedEntropy(a->distance_, b->distance_, NUM_DISTANCE_CODES);
+ *cost +=
+ GetCombinedEntropy(a->distance_, b->distance_, NUM_DISTANCE_CODES, 0);
*cost +=
VP8LExtraCostCombined(a->distance_, b->distance_, NUM_DISTANCE_CODES);
if (*cost > cost_threshold) return 0;
@@ -292,6 +336,15 @@ static int GetCombinedHistogramEntropy(const VP8LHistogram* const a,
return 1;
}
+static WEBP_INLINE void HistogramAdd(const VP8LHistogram* const a,
+ const VP8LHistogram* const b,
+ VP8LHistogram* const out) {
+ VP8LHistogramAdd(a, b, out);
+ out->trivial_symbol_ = (a->trivial_symbol_ == b->trivial_symbol_)
+ ? a->trivial_symbol_
+ : VP8L_NON_TRIVIAL_SYM;
+}
+
// Performs out = a + b, computing the cost C(a+b) - C(a) - C(b) while comparing
// to the threshold value 'cost_threshold'. The score returned is
// Score = C(a+b) - C(a) - C(b), where C(a) + C(b) is known and fixed.
@@ -307,11 +360,9 @@ static double HistogramAddEval(const VP8LHistogram* const a,
cost_threshold += sum_cost;
if (GetCombinedHistogramEntropy(a, b, cost_threshold, &cost)) {
- VP8LHistogramAdd(a, b, out);
+ HistogramAdd(a, b, out);
out->bit_cost_ = cost;
out->palette_code_bits_ = a->palette_code_bits_;
- out->trivial_symbol_ = (a->trivial_symbol_ == b->trivial_symbol_) ?
- a->trivial_symbol_ : VP8L_NON_TRIVIAL_SYM;
}
return cost - sum_cost;
@@ -450,113 +501,103 @@ static void HistogramCopyAndAnalyze(
// Partition histograms to different entropy bins for three dominant (literal,
// red and blue) symbol costs and compute the histogram aggregate bit_cost.
static void HistogramAnalyzeEntropyBin(VP8LHistogramSet* const image_histo,
- int16_t* const bin_map, int low_effort) {
+ uint16_t* const bin_map,
+ int low_effort) {
int i;
VP8LHistogram** const histograms = image_histo->histograms;
const int histo_size = image_histo->size;
- const int bin_depth = histo_size + 1;
DominantCostRange cost_range;
DominantCostRangeInit(&cost_range);
// Analyze the dominant (literal, red and blue) entropy costs.
for (i = 0; i < histo_size; ++i) {
- VP8LHistogram* const histo = histograms[i];
- UpdateDominantCostRange(histo, &cost_range);
+ UpdateDominantCostRange(histograms[i], &cost_range);
}
// bin-hash histograms on three of the dominant (literal, red and blue)
- // symbol costs.
+ // symbol costs and store the resulting bin_id for each histogram.
for (i = 0; i < histo_size; ++i) {
- const VP8LHistogram* const histo = histograms[i];
- const int bin_id = GetHistoBinIndex(histo, &cost_range, low_effort);
- const int bin_offset = bin_id * bin_depth;
- // bin_map[n][0] for every bin 'n' maintains the counter for the number of
- // histograms in that bin.
- // Get and increment the num_histos in that bin.
- const int num_histos = ++bin_map[bin_offset];
- assert(bin_offset + num_histos < bin_depth * BIN_SIZE);
- // Add histogram i'th index at num_histos (last) position in the bin_map.
- bin_map[bin_offset + num_histos] = i;
- }
-}
-
-// Compact the histogram set by removing unused entries.
-static void HistogramCompactBins(VP8LHistogramSet* const image_histo) {
- VP8LHistogram** const histograms = image_histo->histograms;
- int i, j;
-
- for (i = 0, j = 0; i < image_histo->size; ++i) {
- if (histograms[i] != NULL && histograms[i]->bit_cost_ != 0.) {
- if (j < i) {
- histograms[j] = histograms[i];
- histograms[i] = NULL;
- }
- ++j;
- }
+ bin_map[i] = GetHistoBinIndex(histograms[i], &cost_range, low_effort);
}
- image_histo->size = j;
}
+// Compact image_histo[] by merging some histograms with same bin_id together if
+// it's advantageous.
static VP8LHistogram* HistogramCombineEntropyBin(
VP8LHistogramSet* const image_histo,
VP8LHistogram* cur_combo,
- int16_t* const bin_map, int bin_depth, int num_bins,
+ const uint16_t* const bin_map, int bin_map_size, int num_bins,
double combine_cost_factor, int low_effort) {
- int bin_id;
VP8LHistogram** const histograms = image_histo->histograms;
-
- for (bin_id = 0; bin_id < num_bins; ++bin_id) {
- const int bin_offset = bin_id * bin_depth;
- const int num_histos = bin_map[bin_offset];
- const int idx1 = bin_map[bin_offset + 1];
- int num_combine_failures = 0;
- int n;
- for (n = 2; n <= num_histos; ++n) {
- const int idx2 = bin_map[bin_offset + n];
- if (low_effort) {
- // Merge all histograms with the same bin index, irrespective of cost of
- // the merged histograms.
- VP8LHistogramAdd(histograms[idx1], histograms[idx2], histograms[idx1]);
- histograms[idx2]->bit_cost_ = 0.;
- } else {
- const double bit_cost_idx2 = histograms[idx2]->bit_cost_;
- if (bit_cost_idx2 > 0.) {
- const double bit_cost_thresh = -bit_cost_idx2 * combine_cost_factor;
- const double curr_cost_diff =
- HistogramAddEval(histograms[idx1], histograms[idx2],
- cur_combo, bit_cost_thresh);
- if (curr_cost_diff < bit_cost_thresh) {
- // Try to merge two histograms only if the combo is a trivial one or
- // the two candidate histograms are already non-trivial.
- // For some images, 'try_combine' turns out to be false for a lot of
- // histogram pairs. In that case, we fallback to combining
- // histograms as usual to avoid increasing the header size.
- const int try_combine =
- (cur_combo->trivial_symbol_ != VP8L_NON_TRIVIAL_SYM) ||
- ((histograms[idx1]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM) &&
- (histograms[idx2]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM));
- const int max_combine_failures = 32;
- if (try_combine || (num_combine_failures >= max_combine_failures)) {
- HistogramSwap(&cur_combo, &histograms[idx1]);
- histograms[idx2]->bit_cost_ = 0.;
- } else {
- ++num_combine_failures;
- }
- }
+ int idx;
+ // Work in-place: processed histograms are put at the beginning of
+ // image_histo[]. At the end, we just have to truncate the array.
+ int size = 0;
+ struct {
+ int16_t first; // position of the histogram that accumulates all
+ // histograms with the same bin_id
+ uint16_t num_combine_failures; // number of combine failures per bin_id
+ } bin_info[BIN_SIZE];
+
+ assert(num_bins <= BIN_SIZE);
+ for (idx = 0; idx < num_bins; ++idx) {
+ bin_info[idx].first = -1;
+ bin_info[idx].num_combine_failures = 0;
+ }
+
+ for (idx = 0; idx < bin_map_size; ++idx) {
+ const int bin_id = bin_map[idx];
+ const int first = bin_info[bin_id].first;
+ assert(size <= idx);
+ if (first == -1) {
+ // just move histogram #idx to its final position
+ histograms[size] = histograms[idx];
+ bin_info[bin_id].first = size++;
+ } else if (low_effort) {
+ HistogramAdd(histograms[idx], histograms[first], histograms[first]);
+ } else {
+ // try to merge #idx into #first (both share the same bin_id)
+ const double bit_cost = histograms[idx]->bit_cost_;
+ const double bit_cost_thresh = -bit_cost * combine_cost_factor;
+ const double curr_cost_diff =
+ HistogramAddEval(histograms[first], histograms[idx],
+ cur_combo, bit_cost_thresh);
+ if (curr_cost_diff < bit_cost_thresh) {
+ // Try to merge two histograms only if the combo is a trivial one or
+ // the two candidate histograms are already non-trivial.
+ // For some images, 'try_combine' turns out to be false for a lot of
+ // histogram pairs. In that case, we fallback to combining
+ // histograms as usual to avoid increasing the header size.
+ const int try_combine =
+ (cur_combo->trivial_symbol_ != VP8L_NON_TRIVIAL_SYM) ||
+ ((histograms[idx]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM) &&
+ (histograms[first]->trivial_symbol_ == VP8L_NON_TRIVIAL_SYM));
+ const int max_combine_failures = 32;
+ if (try_combine ||
+ bin_info[bin_id].num_combine_failures >= max_combine_failures) {
+ // move the (better) merged histogram to its final slot
+ HistogramSwap(&cur_combo, &histograms[first]);
+ } else {
+ histograms[size++] = histograms[idx];
+ ++bin_info[bin_id].num_combine_failures;
}
+ } else {
+ histograms[size++] = histograms[idx];
}
}
- if (low_effort) {
- // Update the bit_cost for the merged histograms (per bin index).
- UpdateHistogramCost(histograms[idx1]);
+ }
+ image_histo->size = size;
+ if (low_effort) {
+ // for low_effort case, update the final cost when everything is merged
+ for (idx = 0; idx < size; ++idx) {
+ UpdateHistogramCost(histograms[idx]);
}
}
- HistogramCompactBins(image_histo);
return cur_combo;
}
-static uint32_t MyRand(uint32_t *seed) {
- *seed *= 16807U;
+static uint32_t MyRand(uint32_t* const seed) {
+ *seed = (*seed * 16807ull) & 0xffffffffu;
if (*seed == 0) {
*seed = 1;
}
@@ -682,7 +723,7 @@ static int HistogramCombineGreedy(VP8LHistogramSet* const image_histo) {
HistogramPair* copy_to;
const int idx1 = histo_queue.queue[0].idx1;
const int idx2 = histo_queue.queue[0].idx2;
- VP8LHistogramAdd(histograms[idx2], histograms[idx1], histograms[idx1]);
+ HistogramAdd(histograms[idx2], histograms[idx1], histograms[idx1]);
histograms[idx1]->bit_cost_ = histo_queue.queue[0].cost_combo;
// Remove merged histogram.
for (i = 0; i + 1 < image_histo_size; ++i) {
@@ -748,6 +789,8 @@ static void HistogramCombineStochastic(VP8LHistogramSet* const image_histo,
const int outer_iters = image_histo_size * iter_mult;
const int num_pairs = image_histo_size / 2;
const int num_tries_no_success = outer_iters / 2;
+ int idx2_max = image_histo_size - 1;
+ int do_brute_dorce = 0;
VP8LHistogram** const histograms = image_histo->histograms;
// Collapse similar histograms in 'image_histo'.
@@ -758,43 +801,62 @@ static void HistogramCombineStochastic(VP8LHistogramSet* const image_histo,
double best_cost_diff = 0.;
int best_idx1 = -1, best_idx2 = 1;
int j;
- const int num_tries =
+ int num_tries =
(num_pairs < image_histo_size) ? num_pairs : image_histo_size;
+ // Use a brute force approach if:
+ // - stochastic has not worked for a while and
+ // - if the number of iterations for brute force is less than the number of
+ // iterations if we never find a match ever again stochastically (hence
+ // num_tries times the number of remaining outer iterations).
+ do_brute_dorce =
+ (tries_with_no_success > 10) &&
+ (idx2_max * (idx2_max + 1) < 2 * num_tries * (outer_iters - iter));
+ if (do_brute_dorce) num_tries = idx2_max;
+
seed += iter;
for (j = 0; j < num_tries; ++j) {
double curr_cost_diff;
// Choose two histograms at random and try to combine them.
- const uint32_t idx1 = MyRand(&seed) % image_histo_size;
- const uint32_t tmp = (j & 7) + 1;
- const uint32_t diff =
- (tmp < 3) ? tmp : MyRand(&seed) % (image_histo_size - 1);
- const uint32_t idx2 = (idx1 + diff + 1) % image_histo_size;
- if (idx1 == idx2) {
- continue;
+ uint32_t idx1, idx2;
+ if (do_brute_dorce) {
+ // Use a brute force approach.
+ idx1 = (uint32_t)j;
+ idx2 = (uint32_t)idx2_max;
+ } else {
+ const uint32_t tmp = (j & 7) + 1;
+ const uint32_t diff =
+ (tmp < 3) ? tmp : MyRand(&seed) % (image_histo_size - 1);
+ idx1 = MyRand(&seed) % image_histo_size;
+ idx2 = (idx1 + diff + 1) % image_histo_size;
+ if (idx1 == idx2) {
+ continue;
+ }
}
// Calculate cost reduction on combining.
curr_cost_diff = HistogramAddEval(histograms[idx1], histograms[idx2],
tmp_histo, best_cost_diff);
- if (curr_cost_diff < best_cost_diff) { // found a better pair?
+ if (curr_cost_diff < best_cost_diff) { // found a better pair?
HistogramSwap(&best_combo, &tmp_histo);
best_cost_diff = curr_cost_diff;
best_idx1 = idx1;
best_idx2 = idx2;
}
}
+ if (do_brute_dorce) --idx2_max;
if (best_idx1 >= 0) {
HistogramSwap(&best_combo, &histograms[best_idx1]);
// swap best_idx2 slot with last one (which is now unused)
--image_histo_size;
+ if (idx2_max >= image_histo_size) idx2_max = image_histo_size - 1;
if (best_idx2 != image_histo_size) {
HistogramSwap(&histograms[image_histo_size], &histograms[best_idx2]);
histograms[image_histo_size] = NULL;
}
tries_with_no_success = 0;
}
- if (++tries_with_no_success >= num_tries_no_success) {
+ if (++tries_with_no_success >= num_tries_no_success || idx2_max == 0) {
break;
}
}
@@ -843,7 +905,7 @@ static void HistogramRemap(const VP8LHistogramSet* const in,
for (i = 0; i < in_size; ++i) {
const int idx = symbols[i];
- VP8LHistogramAdd(in_histo[i], out_histo[idx], out_histo[idx]);
+ HistogramAdd(in_histo[i], out_histo[idx], out_histo[idx]);
}
}
@@ -869,32 +931,18 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
const int histo_xsize = histo_bits ? VP8LSubSampleSize(xsize, histo_bits) : 1;
const int histo_ysize = histo_bits ? VP8LSubSampleSize(ysize, histo_bits) : 1;
const int image_histo_raw_size = histo_xsize * histo_ysize;
- const int entropy_combine_num_bins = low_effort ? NUM_PARTITIONS : BIN_SIZE;
-
- // The bin_map for every bin follows following semantics:
- // bin_map[n][0] = num_histo; // The number of histograms in that bin.
- // bin_map[n][1] = index of first histogram in that bin;
- // bin_map[n][num_histo] = index of last histogram in that bin;
- // bin_map[n][num_histo + 1] ... bin_map[n][bin_depth - 1] = unused indices.
- const int bin_depth = image_histo_raw_size + 1;
- int16_t* bin_map = NULL;
VP8LHistogramSet* const orig_histo =
VP8LAllocateHistogramSet(image_histo_raw_size, cache_bits);
VP8LHistogram* cur_combo;
+ // Don't attempt linear bin-partition heuristic for
+ // histograms of small sizes (as bin_map will be very sparse) and
+ // maximum quality q==100 (to preserve the compression gains at that level).
+ const int entropy_combine_num_bins = low_effort ? NUM_PARTITIONS : BIN_SIZE;
const int entropy_combine =
(orig_histo->size > entropy_combine_num_bins * 2) && (quality < 100);
if (orig_histo == NULL) goto Error;
- // Don't attempt linear bin-partition heuristic for:
- // histograms of small sizes, as bin_map will be very sparse and;
- // Maximum quality (q==100), to preserve the compression gains at that level.
- if (entropy_combine) {
- const int bin_map_size = bin_depth * entropy_combine_num_bins;
- bin_map = (int16_t*)WebPSafeCalloc(bin_map_size, sizeof(*bin_map));
- if (bin_map == NULL) goto Error;
- }
-
// Construct the histograms from backward references.
HistogramBuild(xsize, histo_bits, refs, orig_histo);
// Copies the histograms and computes its bit_cost.
@@ -902,12 +950,17 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
cur_combo = tmp_histos->histograms[1]; // pick up working slot
if (entropy_combine) {
+ const int bin_map_size = orig_histo->size;
+ // Reuse histogram_symbols storage. By definition, it's guaranteed to be ok.
+ uint16_t* const bin_map = histogram_symbols;
const double combine_cost_factor =
GetCombineCostFactor(image_histo_raw_size, quality);
+
HistogramAnalyzeEntropyBin(orig_histo, bin_map, low_effort);
// Collapse histograms with similar entropy.
- cur_combo = HistogramCombineEntropyBin(image_histo, cur_combo, bin_map,
- bin_depth, entropy_combine_num_bins,
+ cur_combo = HistogramCombineEntropyBin(image_histo, cur_combo,
+ bin_map, bin_map_size,
+ entropy_combine_num_bins,
combine_cost_factor, low_effort);
}
@@ -932,7 +985,6 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
ok = 1;
Error:
- WebPSafeFree(bin_map);
VP8LFreeHistogramSet(orig_histo);
return ok;
}
diff --git a/thirdparty/libwebp/enc/histogram.h b/thirdparty/libwebp/enc/histogram_enc.h
index d303d1d58b..a9d258a166 100644
--- a/thirdparty/libwebp/enc/histogram.h
+++ b/thirdparty/libwebp/enc/histogram_enc.h
@@ -16,7 +16,7 @@
#include <string.h>
-#include "./backward_references.h"
+#include "./backward_references_enc.h"
#include "../webp/format_constants.h"
#include "../webp/types.h"
diff --git a/thirdparty/libwebp/enc/iterator.c b/thirdparty/libwebp/enc/iterator_enc.c
index 99d960a547..e48d30bd31 100644
--- a/thirdparty/libwebp/enc/iterator.c
+++ b/thirdparty/libwebp/enc/iterator_enc.c
@@ -13,7 +13,7 @@
#include <string.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
//------------------------------------------------------------------------------
// VP8Iterator
@@ -53,7 +53,6 @@ void VP8IteratorReset(VP8EncIterator* const it) {
VP8IteratorSetRow(it, 0);
VP8IteratorSetCountDown(it, enc->mb_w_ * enc->mb_h_); // default
InitTop(it);
- InitLeft(it);
memset(it->bit_count_, 0, sizeof(it->bit_count_));
it->do_trellis_ = 0;
}
@@ -68,8 +67,6 @@ int VP8IteratorIsDone(const VP8EncIterator* const it) {
void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) {
it->enc_ = enc;
- it->y_stride_ = enc->pic_->y_stride;
- it->uv_stride_ = enc->pic_->uv_stride;
it->yuv_in_ = (uint8_t*)WEBP_ALIGN(it->yuv_mem_);
it->yuv_out_ = it->yuv_in_ + YUV_SIZE_ENC;
it->yuv_out2_ = it->yuv_out_ + YUV_SIZE_ENC;
@@ -309,14 +306,14 @@ void VP8IteratorSaveBoundary(VP8EncIterator* const it) {
}
int VP8IteratorNext(VP8EncIterator* const it) {
- it->preds_ += 4;
- it->mb_ += 1;
- it->nz_ += 1;
- it->y_top_ += 16;
- it->uv_top_ += 16;
- it->x_ += 1;
- if (it->x_ == it->enc_->mb_w_) {
+ if (++it->x_ == it->enc_->mb_w_) {
VP8IteratorSetRow(it, ++it->y_);
+ } else {
+ it->preds_ += 4;
+ it->mb_ += 1;
+ it->nz_ += 1;
+ it->y_top_ += 16;
+ it->uv_top_ += 16;
}
return (0 < --it->count_down_);
}
diff --git a/thirdparty/libwebp/enc/near_lossless.c b/thirdparty/libwebp/enc/near_lossless_enc.c
index f4ab91f571..2bd03ab20d 100644
--- a/thirdparty/libwebp/enc/near_lossless.c
+++ b/thirdparty/libwebp/enc/near_lossless_enc.c
@@ -17,9 +17,9 @@
#include <assert.h>
#include <stdlib.h>
-#include "../dsp/lossless.h"
+#include "../dsp/lossless_common.h"
#include "../utils/utils.h"
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#define MIN_DIM_FOR_NEAR_LOSSLESS 64
#define MAX_LIMIT_BITS 5
diff --git a/thirdparty/libwebp/enc/picture_csp.c b/thirdparty/libwebp/enc/picture_csp_enc.c
index 188a3ca55b..e5d1c75a66 100644
--- a/thirdparty/libwebp/enc/picture_csp.c
+++ b/thirdparty/libwebp/enc/picture_csp_enc.c
@@ -15,8 +15,8 @@
#include <stdlib.h>
#include <math.h>
-#include "./vp8enci.h"
-#include "../utils/random.h"
+#include "./vp8i_enc.h"
+#include "../utils/random_utils.h"
#include "../utils/utils.h"
#include "../dsp/yuv.h"
@@ -153,9 +153,9 @@ static int RGBToV(int r, int g, int b, VP8Random* const rg) {
}
//------------------------------------------------------------------------------
-// Smart RGB->YUV conversion
+// Sharp RGB->YUV conversion
-static const int kNumIterations = 6;
+static const int kNumIterations = 4;
static const int kMinDimensionIterativeConversion = 4;
// We could use SFIX=0 and only uint8_t for fixed_y_t, but it produces some
@@ -171,9 +171,9 @@ typedef uint16_t fixed_y_t; // unsigned type with extra SFIX precision for W
#if defined(USE_GAMMA_COMPRESSION)
// float variant of gamma-correction
-// We use tables of different size and precision, along with a 'real-world'
-// Gamma value close to ~2.
-#define kGammaF 2.2
+// We use tables of different size and precision for the Rec709
+// transfer function.
+#define kGammaF (1./0.45)
static float kGammaToLinearTabF[MAX_Y_T + 1]; // size scales with Y_FIX
static float kLinearToGammaTabF[kGammaTabSize + 2];
static volatile int kGammaTablesFOk = 0;
@@ -183,11 +183,26 @@ static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTablesF(void) {
int v;
const double norm = 1. / MAX_Y_T;
const double scale = 1. / kGammaTabSize;
+ const double a = 0.099;
+ const double thresh = 0.018;
for (v = 0; v <= MAX_Y_T; ++v) {
- kGammaToLinearTabF[v] = (float)pow(norm * v, kGammaF);
+ const double g = norm * v;
+ if (g <= thresh * 4.5) {
+ kGammaToLinearTabF[v] = (float)(g / 4.5);
+ } else {
+ const double a_rec = 1. / (1. + a);
+ kGammaToLinearTabF[v] = (float)pow(a_rec * (g + a), kGammaF);
+ }
}
for (v = 0; v <= kGammaTabSize; ++v) {
- kLinearToGammaTabF[v] = (float)(MAX_Y_T * pow(scale * v, 1. / kGammaF));
+ const double g = scale * v;
+ double value;
+ if (g <= thresh) {
+ value = 4.5 * g;
+ } else {
+ value = (1. + a) * pow(g, 1. / kGammaF) - a;
+ }
+ kLinearToGammaTabF[v] = (float)(MAX_Y_T * value);
}
// to prevent small rounding errors to cause read-overflow:
kLinearToGammaTabF[kGammaTabSize + 1] = kLinearToGammaTabF[kGammaTabSize];
@@ -235,12 +250,12 @@ static fixed_y_t clip_y(int y) {
//------------------------------------------------------------------------------
static int RGBToGray(int r, int g, int b) {
- const int luma = 19595 * r + 38470 * g + 7471 * b + YUV_HALF;
+ const int luma = 13933 * r + 46871 * g + 4732 * b + YUV_HALF;
return (luma >> YUV_FIX);
}
static float RGBToGrayF(float r, float g, float b) {
- return 0.299f * r + 0.587f * g + 0.114f * b;
+ return (float)(0.2126 * r + 0.7152 * g + 0.0722 * b);
}
static int ScaleDown(int a, int b, int c, int d) {
@@ -251,58 +266,50 @@ static int ScaleDown(int a, int b, int c, int d) {
return LinearToGammaF(0.25f * (A + B + C + D));
}
-static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int len) {
- while (len-- > 0) {
- const float R = GammaToLinearF(src[0]);
- const float G = GammaToLinearF(src[1]);
- const float B = GammaToLinearF(src[2]);
+static WEBP_INLINE void UpdateW(const fixed_y_t* src, fixed_y_t* dst, int w) {
+ int i;
+ for (i = 0; i < w; ++i) {
+ const float R = GammaToLinearF(src[0 * w + i]);
+ const float G = GammaToLinearF(src[1 * w + i]);
+ const float B = GammaToLinearF(src[2 * w + i]);
const float Y = RGBToGrayF(R, G, B);
- *dst++ = (fixed_y_t)LinearToGammaF(Y);
- src += 3;
+ dst[i] = (fixed_y_t)LinearToGammaF(Y);
}
}
-static int UpdateChroma(const fixed_y_t* src1,
- const fixed_y_t* src2,
- fixed_t* dst, fixed_y_t* tmp, int len) {
- int diff = 0;
- while (len--> 0) {
- const int r = ScaleDown(src1[0], src1[3], src2[0], src2[3]);
- const int g = ScaleDown(src1[1], src1[4], src2[1], src2[4]);
- const int b = ScaleDown(src1[2], src1[5], src2[2], src2[5]);
+static void UpdateChroma(const fixed_y_t* src1, const fixed_y_t* src2,
+ fixed_t* dst, int uv_w) {
+ int i;
+ for (i = 0; i < uv_w; ++i) {
+ const int r = ScaleDown(src1[0 * uv_w + 0], src1[0 * uv_w + 1],
+ src2[0 * uv_w + 0], src2[0 * uv_w + 1]);
+ const int g = ScaleDown(src1[2 * uv_w + 0], src1[2 * uv_w + 1],
+ src2[2 * uv_w + 0], src2[2 * uv_w + 1]);
+ const int b = ScaleDown(src1[4 * uv_w + 0], src1[4 * uv_w + 1],
+ src2[4 * uv_w + 0], src2[4 * uv_w + 1]);
const int W = RGBToGray(r, g, b);
- const int r_avg = (src1[0] + src1[3] + src2[0] + src2[3] + 2) >> 2;
- const int g_avg = (src1[1] + src1[4] + src2[1] + src2[4] + 2) >> 2;
- const int b_avg = (src1[2] + src1[5] + src2[2] + src2[5] + 2) >> 2;
- dst[0] = (fixed_t)(r - W);
- dst[1] = (fixed_t)(g - W);
- dst[2] = (fixed_t)(b - W);
- dst += 3;
- src1 += 6;
- src2 += 6;
- if (tmp != NULL) {
- tmp[0] = tmp[1] = clip_y(W);
- tmp += 2;
- }
- diff += abs(RGBToGray(r_avg, g_avg, b_avg) - W);
+ dst[0 * uv_w] = (fixed_t)(r - W);
+ dst[1 * uv_w] = (fixed_t)(g - W);
+ dst[2 * uv_w] = (fixed_t)(b - W);
+ dst += 1;
+ src1 += 2;
+ src2 += 2;
}
- return diff;
}
-//------------------------------------------------------------------------------
-
-static WEBP_INLINE int Filter(const fixed_t* const A, const fixed_t* const B,
- int rightwise) {
- int v;
- if (!rightwise) {
- v = (A[0] * 9 + A[-3] * 3 + B[0] * 3 + B[-3]);
- } else {
- v = (A[0] * 9 + A[+3] * 3 + B[0] * 3 + B[+3]);
+static void StoreGray(const fixed_y_t* rgb, fixed_y_t* y, int w) {
+ int i;
+ for (i = 0; i < w; ++i) {
+ y[i] = RGBToGray(rgb[0 * w + i], rgb[1 * w + i], rgb[2 * w + i]);
}
- return (v + 8) >> 4;
}
-static WEBP_INLINE int Filter2(int A, int B) { return (A * 3 + B + 2) >> 2; }
+//------------------------------------------------------------------------------
+
+static WEBP_INLINE fixed_y_t Filter2(int A, int B, int W0) {
+ const int v0 = (A * 3 + B + 2) >> 2;
+ return clip_y(v0 + W0);
+}
//------------------------------------------------------------------------------
@@ -317,52 +324,50 @@ static void ImportOneRow(const uint8_t* const r_ptr,
int pic_width,
fixed_y_t* const dst) {
int i;
+ const int w = (pic_width + 1) & ~1;
for (i = 0; i < pic_width; ++i) {
const int off = i * step;
- dst[3 * i + 0] = UpLift(r_ptr[off]);
- dst[3 * i + 1] = UpLift(g_ptr[off]);
- dst[3 * i + 2] = UpLift(b_ptr[off]);
+ dst[i + 0 * w] = UpLift(r_ptr[off]);
+ dst[i + 1 * w] = UpLift(g_ptr[off]);
+ dst[i + 2 * w] = UpLift(b_ptr[off]);
}
if (pic_width & 1) { // replicate rightmost pixel
- memcpy(dst + 3 * pic_width, dst + 3 * (pic_width - 1), 3 * sizeof(*dst));
+ dst[pic_width + 0 * w] = dst[pic_width + 0 * w - 1];
+ dst[pic_width + 1 * w] = dst[pic_width + 1 * w - 1];
+ dst[pic_width + 2 * w] = dst[pic_width + 2 * w - 1];
}
}
static void InterpolateTwoRows(const fixed_y_t* const best_y,
- const fixed_t* const prev_uv,
- const fixed_t* const cur_uv,
- const fixed_t* const next_uv,
+ const fixed_t* prev_uv,
+ const fixed_t* cur_uv,
+ const fixed_t* next_uv,
int w,
- fixed_y_t* const out1,
- fixed_y_t* const out2) {
- int i, k;
- { // special boundary case for i==0
- const int W0 = best_y[0];
- const int W1 = best_y[w];
- for (k = 0; k <= 2; ++k) {
- out1[k] = clip_y(Filter2(cur_uv[k], prev_uv[k]) + W0);
- out2[k] = clip_y(Filter2(cur_uv[k], next_uv[k]) + W1);
- }
- }
- for (i = 1; i < w - 1; ++i) {
- const int W0 = best_y[i + 0];
- const int W1 = best_y[i + w];
- const int off = 3 * (i >> 1);
- for (k = 0; k <= 2; ++k) {
- const int tmp0 = Filter(cur_uv + off + k, prev_uv + off + k, i & 1);
- const int tmp1 = Filter(cur_uv + off + k, next_uv + off + k, i & 1);
- out1[3 * i + k] = clip_y(tmp0 + W0);
- out2[3 * i + k] = clip_y(tmp1 + W1);
- }
- }
- { // special boundary case for i == w - 1
- const int W0 = best_y[i + 0];
- const int W1 = best_y[i + w];
- const int off = 3 * (i >> 1);
- for (k = 0; k <= 2; ++k) {
- out1[3 * i + k] = clip_y(Filter2(cur_uv[off + k], prev_uv[off + k]) + W0);
- out2[3 * i + k] = clip_y(Filter2(cur_uv[off + k], next_uv[off + k]) + W1);
+ fixed_y_t* out1,
+ fixed_y_t* out2) {
+ const int uv_w = w >> 1;
+ const int len = (w - 1) >> 1; // length to filter
+ int k = 3;
+ while (k-- > 0) { // process each R/G/B segments in turn
+ // special boundary case for i==0
+ out1[0] = Filter2(cur_uv[0], prev_uv[0], best_y[0]);
+ out2[0] = Filter2(cur_uv[0], next_uv[0], best_y[w]);
+
+ WebPSharpYUVFilterRow(cur_uv, prev_uv, len, best_y + 0 + 1, out1 + 1);
+ WebPSharpYUVFilterRow(cur_uv, next_uv, len, best_y + w + 1, out2 + 1);
+
+ // special boundary case for i == w - 1 when w is even
+ if (!(w & 1)) {
+ out1[w - 1] = Filter2(cur_uv[uv_w - 1], prev_uv[uv_w - 1],
+ best_y[w - 1 + 0]);
+ out2[w - 1] = Filter2(cur_uv[uv_w - 1], next_uv[uv_w - 1],
+ best_y[w - 1 + w]);
}
+ out1 += w;
+ out2 += w;
+ prev_uv += uv_w;
+ cur_uv += uv_w;
+ next_uv += uv_w;
}
}
@@ -394,11 +399,11 @@ static int ConvertWRGBToYUV(const fixed_y_t* best_y, const fixed_t* best_uv,
const int uv_h = h >> 1;
for (best_uv = best_uv_base, j = 0; j < picture->height; ++j) {
for (i = 0; i < picture->width; ++i) {
- const int off = 3 * (i >> 1);
+ const int off = (i >> 1);
const int W = best_y[i];
- const int r = best_uv[off + 0] + W;
- const int g = best_uv[off + 1] + W;
- const int b = best_uv[off + 2] + W;
+ const int r = best_uv[off + 0 * uv_w] + W;
+ const int g = best_uv[off + 1 * uv_w] + W;
+ const int b = best_uv[off + 2 * uv_w] + W;
dst_y[i] = ConvertRGBToY(r, g, b);
}
best_y += w;
@@ -407,10 +412,10 @@ static int ConvertWRGBToYUV(const fixed_y_t* best_y, const fixed_t* best_uv,
}
for (best_uv = best_uv_base, j = 0; j < uv_h; ++j) {
for (i = 0; i < uv_w; ++i) {
- const int off = 3 * i;
- const int r = best_uv[off + 0];
- const int g = best_uv[off + 1];
- const int b = best_uv[off + 2];
+ const int off = i;
+ const int r = best_uv[off + 0 * uv_w];
+ const int g = best_uv[off + 1 * uv_w];
+ const int b = best_uv[off + 2 * uv_w];
dst_u[i] = ConvertRGBToU(r, g, b);
dst_v[i] = ConvertRGBToV(r, g, b);
}
@@ -436,7 +441,8 @@ static int PreprocessARGB(const uint8_t* r_ptr,
const int h = (picture->height + 1) & ~1;
const int uv_w = w >> 1;
const int uv_h = h >> 1;
- int i, j, iter;
+ uint64_t prev_diff_y_sum = ~0;
+ int j, iter;
// TODO(skal): allocate one big memory chunk. But for now, it's easier
// for valgrind debugging to have several chunks.
@@ -451,11 +457,8 @@ static int PreprocessARGB(const uint8_t* r_ptr,
fixed_y_t* target_y = target_y_base;
fixed_t* best_uv = best_uv_base;
fixed_t* target_uv = target_uv_base;
+ const uint64_t diff_y_threshold = (uint64_t)(3.0 * w * h);
int ok;
- int diff_sum = 0;
- const int first_diff_threshold = (int)(2.5 * w * h);
- const int min_improvement = 5; // stop if improvement is below this %
- const int min_first_improvement = 80;
if (best_y_base == NULL || best_uv_base == NULL ||
target_y_base == NULL || target_uv_base == NULL ||
@@ -467,10 +470,12 @@ static int PreprocessARGB(const uint8_t* r_ptr,
assert(picture->width >= kMinDimensionIterativeConversion);
assert(picture->height >= kMinDimensionIterativeConversion);
+ WebPInitConvertARGBToYUV();
+
// Import RGB samples to W/RGB representation.
for (j = 0; j < picture->height; j += 2) {
const int is_last_row = (j == picture->height - 1);
- fixed_y_t* const src1 = tmp_buffer;
+ fixed_y_t* const src1 = tmp_buffer + 0 * w;
fixed_y_t* const src2 = tmp_buffer + 3 * w;
// prepare two rows of input
@@ -481,11 +486,13 @@ static int PreprocessARGB(const uint8_t* r_ptr,
} else {
memcpy(src2, src1, 3 * w * sizeof(*src2));
}
+ StoreGray(src1, best_y + 0, w);
+ StoreGray(src2, best_y + w, w);
+
UpdateW(src1, target_y, w);
UpdateW(src2, target_y + w, w);
- diff_sum += UpdateChroma(src1, src2, target_uv, best_y, uv_w);
+ UpdateChroma(src1, src2, target_uv, uv_w);
memcpy(best_uv, target_uv, 3 * uv_w * sizeof(*best_uv));
- memcpy(best_y + w, best_y, w * sizeof(*best_y));
best_y += 2 * w;
best_uv += 3 * uv_w;
target_y += 2 * w;
@@ -497,18 +504,16 @@ static int PreprocessARGB(const uint8_t* r_ptr,
// Iterate and resolve clipping conflicts.
for (iter = 0; iter < kNumIterations; ++iter) {
- int k;
const fixed_t* cur_uv = best_uv_base;
const fixed_t* prev_uv = best_uv_base;
- const int old_diff_sum = diff_sum;
- diff_sum = 0;
+ uint64_t diff_y_sum = 0;
best_y = best_y_base;
best_uv = best_uv_base;
target_y = target_y_base;
target_uv = target_uv_base;
for (j = 0; j < h; j += 2) {
- fixed_y_t* const src1 = tmp_buffer;
+ fixed_y_t* const src1 = tmp_buffer + 0 * w;
fixed_y_t* const src2 = tmp_buffer + 3 * w;
{
const fixed_t* const next_uv = cur_uv + ((j < h - 2) ? 3 * uv_w : 0);
@@ -519,50 +524,24 @@ static int PreprocessARGB(const uint8_t* r_ptr,
UpdateW(src1, best_rgb_y + 0 * w, w);
UpdateW(src2, best_rgb_y + 1 * w, w);
- diff_sum += UpdateChroma(src1, src2, best_rgb_uv, NULL, uv_w);
+ UpdateChroma(src1, src2, best_rgb_uv, uv_w);
// update two rows of Y and one row of RGB
- for (i = 0; i < 2 * w; ++i) {
- const int diff_y = target_y[i] - best_rgb_y[i];
- const int new_y = (int)best_y[i] + diff_y;
- best_y[i] = clip_y(new_y);
- }
- for (i = 0; i < uv_w; ++i) {
- const int off = 3 * i;
- int W;
- for (k = 0; k <= 2; ++k) {
- const int diff_uv = (int)target_uv[off + k] - best_rgb_uv[off + k];
- best_uv[off + k] += diff_uv;
- }
- W = RGBToGray(best_uv[off + 0], best_uv[off + 1], best_uv[off + 2]);
- for (k = 0; k <= 2; ++k) {
- best_uv[off + k] -= W;
- }
- }
+ diff_y_sum += WebPSharpYUVUpdateY(target_y, best_rgb_y, best_y, 2 * w);
+ WebPSharpYUVUpdateRGB(target_uv, best_rgb_uv, best_uv, 3 * uv_w);
+
best_y += 2 * w;
best_uv += 3 * uv_w;
target_y += 2 * w;
target_uv += 3 * uv_w;
}
// test exit condition
- if (diff_sum > 0) {
- const int improvement = 100 * abs(diff_sum - old_diff_sum) / diff_sum;
- // Check if first iteration gave good result already, without a large
- // jump of improvement (otherwise it means we need to try few extra
- // iterations, just to be sure).
- if (iter == 0 && diff_sum < first_diff_threshold &&
- improvement < min_first_improvement) {
- break;
- }
- // then, check if improvement is stalling.
- if (improvement < min_improvement) {
- break;
- }
- } else {
- break;
+ if (iter > 0) {
+ if (diff_y_sum < diff_y_threshold) break;
+ if (diff_y_sum > prev_diff_y_sum) break;
}
+ prev_diff_y_sum = diff_y_sum;
}
-
// final reconstruction
ok = ConvertWRGBToYUV(best_y_base, best_uv_base, picture);
@@ -1032,9 +1011,13 @@ int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) {
return PictureARGBToYUVA(picture, colorspace, 0.f, 0);
}
-int WebPPictureSmartARGBToYUVA(WebPPicture* picture) {
+int WebPPictureSharpARGBToYUVA(WebPPicture* picture) {
return PictureARGBToYUVA(picture, WEBP_YUV420, 0.f, 1);
}
+// for backward compatibility
+int WebPPictureSmartARGBToYUVA(WebPPicture* picture) {
+ return WebPPictureSharpARGBToYUVA(picture);
+}
//------------------------------------------------------------------------------
// call for YUVA -> ARGB conversion
diff --git a/thirdparty/libwebp/enc/picture.c b/thirdparty/libwebp/enc/picture_enc.c
index 28c56cd6e5..dfa66510fb 100644
--- a/thirdparty/libwebp/enc/picture.c
+++ b/thirdparty/libwebp/enc/picture_enc.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include <stdlib.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#include "../dsp/dsp.h"
#include "../utils/utils.h"
diff --git a/thirdparty/libwebp/enc/picture_psnr.c b/thirdparty/libwebp/enc/picture_psnr.c
deleted file mode 100644
index 329757deb1..0000000000
--- a/thirdparty/libwebp/enc/picture_psnr.c
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Use of this source code is governed by a BSD-style license
-// that can be found in the COPYING file in the root of the source
-// tree. An additional intellectual property rights grant can be found
-// in the file PATENTS. All contributing project authors may
-// be found in the AUTHORS file in the root of the source tree.
-// -----------------------------------------------------------------------------
-//
-// WebPPicture tools for measuring distortion
-//
-// Author: Skal (pascal.massimino@gmail.com)
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "./vp8enci.h"
-#include "../utils/utils.h"
-
-//------------------------------------------------------------------------------
-// local-min distortion
-//
-// For every pixel in the *reference* picture, we search for the local best
-// match in the compressed image. This is not a symmetrical measure.
-
-#define RADIUS 2 // search radius. Shouldn't be too large.
-
-static void AccumulateLSIM(const uint8_t* src, int src_stride,
- const uint8_t* ref, int ref_stride,
- int w, int h, VP8DistoStats* stats) {
- int x, y;
- double total_sse = 0.;
- for (y = 0; y < h; ++y) {
- const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS;
- const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1;
- for (x = 0; x < w; ++x) {
- const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS;
- const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1;
- double best_sse = 255. * 255.;
- const double value = (double)ref[y * ref_stride + x];
- int i, j;
- for (j = y_0; j < y_1; ++j) {
- const uint8_t* const s = src + j * src_stride;
- for (i = x_0; i < x_1; ++i) {
- const double diff = s[i] - value;
- const double sse = diff * diff;
- if (sse < best_sse) best_sse = sse;
- }
- }
- total_sse += best_sse;
- }
- }
- stats->w = w * h;
- stats->xm = 0;
- stats->ym = 0;
- stats->xxm = total_sse;
- stats->yym = 0;
- stats->xxm = 0;
-}
-#undef RADIUS
-
-//------------------------------------------------------------------------------
-// Distortion
-
-// Max value returned in case of exact similarity.
-static const double kMinDistortion_dB = 99.;
-static float GetPSNR(const double v) {
- return (float)((v > 0.) ? -4.3429448 * log(v / (255 * 255.))
- : kMinDistortion_dB);
-}
-
-int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
- int type, float result[5]) {
- VP8DistoStats stats[5];
- int w, h;
-
- memset(stats, 0, sizeof(stats));
-
- VP8SSIMDspInit();
-
- if (src == NULL || ref == NULL ||
- src->width != ref->width || src->height != ref->height ||
- src->use_argb != ref->use_argb || result == NULL) {
- return 0;
- }
- w = src->width;
- h = src->height;
-
- if (src->use_argb == 1) {
- if (src->argb == NULL || ref->argb == NULL) {
- return 0;
- } else {
- int i, j, c;
- uint8_t* tmp1, *tmp2;
- uint8_t* const tmp_plane =
- (uint8_t*)WebPSafeMalloc(2ULL * w * h, sizeof(*tmp_plane));
- if (tmp_plane == NULL) return 0;
- tmp1 = tmp_plane;
- tmp2 = tmp_plane + w * h;
- for (c = 0; c < 4; ++c) {
- for (j = 0; j < h; ++j) {
- for (i = 0; i < w; ++i) {
- tmp1[j * w + i] = src->argb[i + j * src->argb_stride] >> (c * 8);
- tmp2[j * w + i] = ref->argb[i + j * ref->argb_stride] >> (c * 8);
- }
- }
- if (type >= 2) {
- AccumulateLSIM(tmp1, w, tmp2, w, w, h, &stats[c]);
- } else {
- VP8SSIMAccumulatePlane(tmp1, w, tmp2, w, w, h, &stats[c]);
- }
- }
- WebPSafeFree(tmp_plane);
- }
- } else {
- int has_alpha, uv_w, uv_h;
- if (src->y == NULL || ref->y == NULL ||
- src->u == NULL || ref->u == NULL ||
- src->v == NULL || ref->v == NULL) {
- return 0;
- }
- has_alpha = !!(src->colorspace & WEBP_CSP_ALPHA_BIT);
- if (has_alpha != !!(ref->colorspace & WEBP_CSP_ALPHA_BIT) ||
- (has_alpha && (src->a == NULL || ref->a == NULL))) {
- return 0;
- }
-
- uv_w = (src->width + 1) >> 1;
- uv_h = (src->height + 1) >> 1;
- if (type >= 2) {
- AccumulateLSIM(src->y, src->y_stride, ref->y, ref->y_stride,
- w, h, &stats[0]);
- AccumulateLSIM(src->u, src->uv_stride, ref->u, ref->uv_stride,
- uv_w, uv_h, &stats[1]);
- AccumulateLSIM(src->v, src->uv_stride, ref->v, ref->uv_stride,
- uv_w, uv_h, &stats[2]);
- if (has_alpha) {
- AccumulateLSIM(src->a, src->a_stride, ref->a, ref->a_stride,
- w, h, &stats[3]);
- }
- } else {
- VP8SSIMAccumulatePlane(src->y, src->y_stride,
- ref->y, ref->y_stride,
- w, h, &stats[0]);
- VP8SSIMAccumulatePlane(src->u, src->uv_stride,
- ref->u, ref->uv_stride,
- uv_w, uv_h, &stats[1]);
- VP8SSIMAccumulatePlane(src->v, src->uv_stride,
- ref->v, ref->uv_stride,
- uv_w, uv_h, &stats[2]);
- if (has_alpha) {
- VP8SSIMAccumulatePlane(src->a, src->a_stride,
- ref->a, ref->a_stride,
- w, h, &stats[3]);
- }
- }
- }
- // Final stat calculations.
- {
- int c;
- for (c = 0; c <= 4; ++c) {
- if (type == 1) {
- const double v = VP8SSIMGet(&stats[c]);
- result[c] = (float)((v < 1.) ? -10.0 * log10(1. - v)
- : kMinDistortion_dB);
- } else {
- const double v = VP8SSIMGetSquaredError(&stats[c]);
- result[c] = GetPSNR(v);
- }
- // Accumulate forward
- if (c < 4) VP8SSIMAddStats(&stats[c], &stats[4]);
- }
- }
- return 1;
-}
-
-//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/enc/picture_psnr_enc.c b/thirdparty/libwebp/enc/picture_psnr_enc.c
new file mode 100644
index 0000000000..9c0b229507
--- /dev/null
+++ b/thirdparty/libwebp/enc/picture_psnr_enc.c
@@ -0,0 +1,213 @@
+// Copyright 2014 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// WebPPicture tools for measuring distortion
+//
+// Author: Skal (pascal.massimino@gmail.com)
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "./vp8i_enc.h"
+#include "../utils/utils.h"
+
+typedef double (*AccumulateFunc)(const uint8_t* src, int src_stride,
+ const uint8_t* ref, int ref_stride,
+ int w, int h);
+
+//------------------------------------------------------------------------------
+// local-min distortion
+//
+// For every pixel in the *reference* picture, we search for the local best
+// match in the compressed image. This is not a symmetrical measure.
+
+#define RADIUS 2 // search radius. Shouldn't be too large.
+
+static double AccumulateLSIM(const uint8_t* src, int src_stride,
+ const uint8_t* ref, int ref_stride,
+ int w, int h) {
+ int x, y;
+ double total_sse = 0.;
+ for (y = 0; y < h; ++y) {
+ const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS;
+ const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1;
+ for (x = 0; x < w; ++x) {
+ const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS;
+ const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1;
+ double best_sse = 255. * 255.;
+ const double value = (double)ref[y * ref_stride + x];
+ int i, j;
+ for (j = y_0; j < y_1; ++j) {
+ const uint8_t* const s = src + j * src_stride;
+ for (i = x_0; i < x_1; ++i) {
+ const double diff = s[i] - value;
+ const double sse = diff * diff;
+ if (sse < best_sse) best_sse = sse;
+ }
+ }
+ total_sse += best_sse;
+ }
+ }
+ return total_sse;
+}
+#undef RADIUS
+
+static double AccumulateSSE(const uint8_t* src, int src_stride,
+ const uint8_t* ref, int ref_stride,
+ int w, int h) {
+ int y;
+ double total_sse = 0.;
+ for (y = 0; y < h; ++y) {
+ total_sse += VP8AccumulateSSE(src, ref, w);
+ src += src_stride;
+ ref += ref_stride;
+ }
+ return total_sse;
+}
+
+//------------------------------------------------------------------------------
+
+static double AccumulateSSIM(const uint8_t* src, int src_stride,
+ const uint8_t* ref, int ref_stride,
+ int w, int h) {
+ const int w0 = (w < VP8_SSIM_KERNEL) ? w : VP8_SSIM_KERNEL;
+ const int w1 = w - VP8_SSIM_KERNEL - 1;
+ const int h0 = (h < VP8_SSIM_KERNEL) ? h : VP8_SSIM_KERNEL;
+ const int h1 = h - VP8_SSIM_KERNEL - 1;
+ int x, y;
+ double sum = 0.;
+ for (y = 0; y < h0; ++y) {
+ for (x = 0; x < w; ++x) {
+ sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
+ }
+ }
+ for (; y < h1; ++y) {
+ for (x = 0; x < w0; ++x) {
+ sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
+ }
+ for (; x < w1; ++x) {
+ const int off1 = x - VP8_SSIM_KERNEL + (y - VP8_SSIM_KERNEL) * src_stride;
+ const int off2 = x - VP8_SSIM_KERNEL + (y - VP8_SSIM_KERNEL) * ref_stride;
+ sum += VP8SSIMGet(src + off1, src_stride, ref + off2, ref_stride);
+ }
+ for (; x < w; ++x) {
+ sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
+ }
+ }
+ for (; y < h; ++y) {
+ for (x = 0; x < w; ++x) {
+ sum += VP8SSIMGetClipped(src, src_stride, ref, ref_stride, x, y, w, h);
+ }
+ }
+ return sum;
+}
+
+//------------------------------------------------------------------------------
+// Distortion
+
+// Max value returned in case of exact similarity.
+static const double kMinDistortion_dB = 99.;
+
+static double GetPSNR(double v, double size) {
+ return (v > 0. && size > 0.) ? -4.3429448 * log(v / (size * 255 * 255.))
+ : kMinDistortion_dB;
+}
+
+static double GetLogSSIM(double v, double size) {
+ v = (size > 0.) ? v / size : 1.;
+ return (v < 1.) ? -10.0 * log10(1. - v) : kMinDistortion_dB;
+}
+
+int WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
+ const uint8_t* ref, size_t ref_stride,
+ int width, int height, size_t x_step,
+ int type, float* distortion, float* result) {
+ uint8_t* allocated = NULL;
+ const AccumulateFunc metric = (type == 0) ? AccumulateSSE :
+ (type == 1) ? AccumulateSSIM :
+ AccumulateLSIM;
+ if (src == NULL || ref == NULL ||
+ src_stride < x_step * width || ref_stride < x_step * width ||
+ result == NULL || distortion == NULL) {
+ return 0;
+ }
+
+ VP8SSIMDspInit();
+ if (x_step != 1) { // extract a packed plane if needed
+ int x, y;
+ uint8_t* tmp1;
+ uint8_t* tmp2;
+ allocated =
+ (uint8_t*)WebPSafeMalloc(2ULL * width * height, sizeof(*allocated));
+ if (allocated == NULL) return 0;
+ tmp1 = allocated;
+ tmp2 = tmp1 + (size_t)width * height;
+ for (y = 0; y < height; ++y) {
+ for (x = 0; x < width; ++x) {
+ tmp1[x + y * width] = src[x * x_step + y * src_stride];
+ tmp2[x + y * width] = ref[x * x_step + y * ref_stride];
+ }
+ }
+ src = tmp1;
+ ref = tmp2;
+ }
+ *distortion = (float)metric(src, width, ref, width, width, height);
+ WebPSafeFree(allocated);
+
+ *result = (type == 1) ? (float)GetLogSSIM(*distortion, (double)width * height)
+ : (float)GetPSNR(*distortion, (double)width * height);
+ return 1;
+}
+
+int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
+ int type, float results[5]) {
+ int w, h, c;
+ int ok = 0;
+ WebPPicture p0, p1;
+ double total_size = 0., total_distortion = 0.;
+ if (src == NULL || ref == NULL ||
+ src->width != ref->width || src->height != ref->height ||
+ results == NULL) {
+ return 0;
+ }
+
+ VP8SSIMDspInit();
+ if (!WebPPictureInit(&p0) || !WebPPictureInit(&p1)) return 0;
+ w = src->width;
+ h = src->height;
+ if (!WebPPictureView(src, 0, 0, w, h, &p0)) goto Error;
+ if (!WebPPictureView(ref, 0, 0, w, h, &p1)) goto Error;
+
+ // We always measure distortion in ARGB space.
+ if (p0.use_argb == 0 && !WebPPictureYUVAToARGB(&p0)) goto Error;
+ if (p1.use_argb == 0 && !WebPPictureYUVAToARGB(&p1)) goto Error;
+ for (c = 0; c < 4; ++c) {
+ float distortion;
+ const size_t stride0 = 4 * (size_t)p0.argb_stride;
+ const size_t stride1 = 4 * (size_t)p1.argb_stride;
+ if (!WebPPlaneDistortion((const uint8_t*)p0.argb + c, stride0,
+ (const uint8_t*)p1.argb + c, stride1,
+ w, h, 4, type, &distortion, results + c)) {
+ goto Error;
+ }
+ total_distortion += distortion;
+ total_size += w * h;
+ }
+
+ results[4] = (type == 1) ? (float)GetLogSSIM(total_distortion, total_size)
+ : (float)GetPSNR(total_distortion, total_size);
+ ok = 1;
+
+ Error:
+ WebPPictureFree(&p0);
+ WebPPictureFree(&p1);
+ return ok;
+}
+
+//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/enc/picture_rescale.c b/thirdparty/libwebp/enc/picture_rescale_enc.c
index 9f19e8e80f..0b7181c0d7 100644
--- a/thirdparty/libwebp/enc/picture_rescale.c
+++ b/thirdparty/libwebp/enc/picture_rescale_enc.c
@@ -14,8 +14,8 @@
#include <assert.h>
#include <stdlib.h>
-#include "./vp8enci.h"
-#include "../utils/rescaler.h"
+#include "./vp8i_enc.h"
+#include "../utils/rescaler_utils.h"
#include "../utils/utils.h"
#define HALVE(x) (((x) + 1) >> 1)
diff --git a/thirdparty/libwebp/enc/picture_tools.c b/thirdparty/libwebp/enc/picture_tools_enc.c
index bf97af8408..895df51156 100644
--- a/thirdparty/libwebp/enc/picture_tools.c
+++ b/thirdparty/libwebp/enc/picture_tools_enc.c
@@ -13,7 +13,7 @@
#include <assert.h>
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
#include "../dsp/yuv.h"
static WEBP_INLINE uint32_t MakeARGB32(int r, int g, int b) {
diff --git a/thirdparty/libwebp/enc/predictor_enc.c b/thirdparty/libwebp/enc/predictor_enc.c
new file mode 100644
index 0000000000..0639b74f1c
--- /dev/null
+++ b/thirdparty/libwebp/enc/predictor_enc.c
@@ -0,0 +1,750 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// Image transform methods for lossless encoder.
+//
+// Authors: Vikas Arora (vikaas.arora@gmail.com)
+// Jyrki Alakuijala (jyrki@google.com)
+// Urvang Joshi (urvang@google.com)
+// Vincent Rabaud (vrabaud@google.com)
+
+#include "../dsp/lossless.h"
+#include "../dsp/lossless_common.h"
+#include "./vp8li_enc.h"
+
+#define MAX_DIFF_COST (1e30f)
+
+static const float kSpatialPredictorBias = 15.f;
+static const int kPredLowEffort = 11;
+static const uint32_t kMaskAlpha = 0xff000000;
+
+// Mostly used to reduce code size + readability
+static WEBP_INLINE int GetMin(int a, int b) { return (a > b) ? b : a; }
+static WEBP_INLINE int GetMax(int a, int b) { return (a < b) ? b : a; }
+
+//------------------------------------------------------------------------------
+// Methods to calculate Entropy (Shannon).
+
+static float PredictionCostSpatial(const int counts[256], int weight_0,
+ double exp_val) {
+ const int significant_symbols = 256 >> 4;
+ const double exp_decay_factor = 0.6;
+ double bits = weight_0 * counts[0];
+ int i;
+ for (i = 1; i < significant_symbols; ++i) {
+ bits += exp_val * (counts[i] + counts[256 - i]);
+ exp_val *= exp_decay_factor;
+ }
+ return (float)(-0.1 * bits);
+}
+
+static float PredictionCostSpatialHistogram(const int accumulated[4][256],
+ const int tile[4][256]) {
+ int i;
+ double retval = 0;
+ for (i = 0; i < 4; ++i) {
+ const double kExpValue = 0.94;
+ retval += PredictionCostSpatial(tile[i], 1, kExpValue);
+ retval += VP8LCombinedShannonEntropy(tile[i], accumulated[i]);
+ }
+ return (float)retval;
+}
+
+static WEBP_INLINE void UpdateHisto(int histo_argb[4][256], uint32_t argb) {
+ ++histo_argb[0][argb >> 24];
+ ++histo_argb[1][(argb >> 16) & 0xff];
+ ++histo_argb[2][(argb >> 8) & 0xff];
+ ++histo_argb[3][argb & 0xff];
+}
+
+//------------------------------------------------------------------------------
+// Spatial transform functions.
+
+static WEBP_INLINE void PredictBatch(int mode, int x_start, int y,
+ int num_pixels, const uint32_t* current,
+ const uint32_t* upper, uint32_t* out) {
+ if (x_start == 0) {
+ if (y == 0) {
+ // ARGB_BLACK.
+ VP8LPredictorsSub[0](current, NULL, 1, out);
+ } else {
+ // Top one.
+ VP8LPredictorsSub[2](current, upper, 1, out);
+ }
+ ++x_start;
+ ++out;
+ --num_pixels;
+ }
+ if (y == 0) {
+ // Left one.
+ VP8LPredictorsSub[1](current + x_start, NULL, num_pixels, out);
+ } else {
+ VP8LPredictorsSub[mode](current + x_start, upper + x_start, num_pixels,
+ out);
+ }
+}
+
+static int MaxDiffBetweenPixels(uint32_t p1, uint32_t p2) {
+ const int diff_a = abs((int)(p1 >> 24) - (int)(p2 >> 24));
+ const int diff_r = abs((int)((p1 >> 16) & 0xff) - (int)((p2 >> 16) & 0xff));
+ const int diff_g = abs((int)((p1 >> 8) & 0xff) - (int)((p2 >> 8) & 0xff));
+ const int diff_b = abs((int)(p1 & 0xff) - (int)(p2 & 0xff));
+ return GetMax(GetMax(diff_a, diff_r), GetMax(diff_g, diff_b));
+}
+
+static int MaxDiffAroundPixel(uint32_t current, uint32_t up, uint32_t down,
+ uint32_t left, uint32_t right) {
+ const int diff_up = MaxDiffBetweenPixels(current, up);
+ const int diff_down = MaxDiffBetweenPixels(current, down);
+ const int diff_left = MaxDiffBetweenPixels(current, left);
+ const int diff_right = MaxDiffBetweenPixels(current, right);
+ return GetMax(GetMax(diff_up, diff_down), GetMax(diff_left, diff_right));
+}
+
+static uint32_t AddGreenToBlueAndRed(uint32_t argb) {
+ const uint32_t green = (argb >> 8) & 0xff;
+ uint32_t red_blue = argb & 0x00ff00ffu;
+ red_blue += (green << 16) | green;
+ red_blue &= 0x00ff00ffu;
+ return (argb & 0xff00ff00u) | red_blue;
+}
+
+static void MaxDiffsForRow(int width, int stride, const uint32_t* const argb,
+ uint8_t* const max_diffs, int used_subtract_green) {
+ uint32_t current, up, down, left, right;
+ int x;
+ if (width <= 2) return;
+ current = argb[0];
+ right = argb[1];
+ if (used_subtract_green) {
+ current = AddGreenToBlueAndRed(current);
+ right = AddGreenToBlueAndRed(right);
+ }
+ // max_diffs[0] and max_diffs[width - 1] are never used.
+ for (x = 1; x < width - 1; ++x) {
+ up = argb[-stride + x];
+ down = argb[stride + x];
+ left = current;
+ current = right;
+ right = argb[x + 1];
+ if (used_subtract_green) {
+ up = AddGreenToBlueAndRed(up);
+ down = AddGreenToBlueAndRed(down);
+ right = AddGreenToBlueAndRed(right);
+ }
+ max_diffs[x] = MaxDiffAroundPixel(current, up, down, left, right);
+ }
+}
+
+// Quantize the difference between the actual component value and its prediction
+// to a multiple of quantization, working modulo 256, taking care not to cross
+// a boundary (inclusive upper limit).
+static uint8_t NearLosslessComponent(uint8_t value, uint8_t predict,
+ uint8_t boundary, int quantization) {
+ const int residual = (value - predict) & 0xff;
+ const int boundary_residual = (boundary - predict) & 0xff;
+ const int lower = residual & ~(quantization - 1);
+ const int upper = lower + quantization;
+ // Resolve ties towards a value closer to the prediction (i.e. towards lower
+ // if value comes after prediction and towards upper otherwise).
+ const int bias = ((boundary - value) & 0xff) < boundary_residual;
+ if (residual - lower < upper - residual + bias) {
+ // lower is closer to residual than upper.
+ if (residual > boundary_residual && lower <= boundary_residual) {
+ // Halve quantization step to avoid crossing boundary. This midpoint is
+ // on the same side of boundary as residual because midpoint >= residual
+ // (since lower is closer than upper) and residual is above the boundary.
+ return lower + (quantization >> 1);
+ }
+ return lower;
+ } else {
+ // upper is closer to residual than lower.
+ if (residual <= boundary_residual && upper > boundary_residual) {
+ // Halve quantization step to avoid crossing boundary. This midpoint is
+ // on the same side of boundary as residual because midpoint <= residual
+ // (since upper is closer than lower) and residual is below the boundary.
+ return lower + (quantization >> 1);
+ }
+ return upper & 0xff;
+ }
+}
+
+// Quantize every component of the difference between the actual pixel value and
+// its prediction to a multiple of a quantization (a power of 2, not larger than
+// max_quantization which is a power of 2, smaller than max_diff). Take care if
+// value and predict have undergone subtract green, which means that red and
+// blue are represented as offsets from green.
+static uint32_t NearLossless(uint32_t value, uint32_t predict,
+ int max_quantization, int max_diff,
+ int used_subtract_green) {
+ int quantization;
+ uint8_t new_green = 0;
+ uint8_t green_diff = 0;
+ uint8_t a, r, g, b;
+ if (max_diff <= 2) {
+ return VP8LSubPixels(value, predict);
+ }
+ quantization = max_quantization;
+ while (quantization >= max_diff) {
+ quantization >>= 1;
+ }
+ if ((value >> 24) == 0 || (value >> 24) == 0xff) {
+ // Preserve transparency of fully transparent or fully opaque pixels.
+ a = ((value >> 24) - (predict >> 24)) & 0xff;
+ } else {
+ a = NearLosslessComponent(value >> 24, predict >> 24, 0xff, quantization);
+ }
+ g = NearLosslessComponent((value >> 8) & 0xff, (predict >> 8) & 0xff, 0xff,
+ quantization);
+ if (used_subtract_green) {
+ // The green offset will be added to red and blue components during decoding
+ // to obtain the actual red and blue values.
+ new_green = ((predict >> 8) + g) & 0xff;
+ // The amount by which green has been adjusted during quantization. It is
+ // subtracted from red and blue for compensation, to avoid accumulating two
+ // quantization errors in them.
+ green_diff = (new_green - (value >> 8)) & 0xff;
+ }
+ r = NearLosslessComponent(((value >> 16) - green_diff) & 0xff,
+ (predict >> 16) & 0xff, 0xff - new_green,
+ quantization);
+ b = NearLosslessComponent((value - green_diff) & 0xff, predict & 0xff,
+ 0xff - new_green, quantization);
+ return ((uint32_t)a << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
+}
+
+// Stores the difference between the pixel and its prediction in "out".
+// In case of a lossy encoding, updates the source image to avoid propagating
+// the deviation further to pixels which depend on the current pixel for their
+// predictions.
+static WEBP_INLINE void GetResidual(
+ int width, int height, uint32_t* const upper_row,
+ uint32_t* const current_row, const uint8_t* const max_diffs, int mode,
+ int x_start, int x_end, int y, int max_quantization, int exact,
+ int used_subtract_green, uint32_t* const out) {
+ if (exact) {
+ PredictBatch(mode, x_start, y, x_end - x_start, current_row, upper_row,
+ out);
+ } else {
+ const VP8LPredictorFunc pred_func = VP8LPredictors[mode];
+ int x;
+ for (x = x_start; x < x_end; ++x) {
+ uint32_t predict;
+ uint32_t residual;
+ if (y == 0) {
+ predict = (x == 0) ? ARGB_BLACK : current_row[x - 1]; // Left.
+ } else if (x == 0) {
+ predict = upper_row[x]; // Top.
+ } else {
+ predict = pred_func(current_row[x - 1], upper_row + x);
+ }
+ if (max_quantization == 1 || mode == 0 || y == 0 || y == height - 1 ||
+ x == 0 || x == width - 1) {
+ residual = VP8LSubPixels(current_row[x], predict);
+ } else {
+ residual = NearLossless(current_row[x], predict, max_quantization,
+ max_diffs[x], used_subtract_green);
+ // Update the source image.
+ current_row[x] = VP8LAddPixels(predict, residual);
+ // x is never 0 here so we do not need to update upper_row like below.
+ }
+ if ((current_row[x] & kMaskAlpha) == 0) {
+ // If alpha is 0, cleanup RGB. We can choose the RGB values of the
+ // residual for best compression. The prediction of alpha itself can be
+ // non-zero and must be kept though. We choose RGB of the residual to be
+ // 0.
+ residual &= kMaskAlpha;
+ // Update the source image.
+ current_row[x] = predict & ~kMaskAlpha;
+ // The prediction for the rightmost pixel in a row uses the leftmost
+ // pixel
+ // in that row as its top-right context pixel. Hence if we change the
+ // leftmost pixel of current_row, the corresponding change must be
+ // applied
+ // to upper_row as well where top-right context is being read from.
+ if (x == 0 && y != 0) upper_row[width] = current_row[0];
+ }
+ out[x - x_start] = residual;
+ }
+ }
+}
+
+// Returns best predictor and updates the accumulated histogram.
+// If max_quantization > 1, assumes that near lossless processing will be
+// applied, quantizing residuals to multiples of quantization levels up to
+// max_quantization (the actual quantization level depends on smoothness near
+// the given pixel).
+static int GetBestPredictorForTile(int width, int height,
+ int tile_x, int tile_y, int bits,
+ int accumulated[4][256],
+ uint32_t* const argb_scratch,
+ const uint32_t* const argb,
+ int max_quantization,
+ int exact, int used_subtract_green,
+ const uint32_t* const modes) {
+ const int kNumPredModes = 14;
+ const int start_x = tile_x << bits;
+ const int start_y = tile_y << bits;
+ const int tile_size = 1 << bits;
+ const int max_y = GetMin(tile_size, height - start_y);
+ const int max_x = GetMin(tile_size, width - start_x);
+ // Whether there exist columns just outside the tile.
+ const int have_left = (start_x > 0);
+ const int have_right = (max_x < width - start_x);
+ // Position and size of the strip covering the tile and adjacent columns if
+ // they exist.
+ const int context_start_x = start_x - have_left;
+ const int context_width = max_x + have_left + have_right;
+ const int tiles_per_row = VP8LSubSampleSize(width, bits);
+ // Prediction modes of the left and above neighbor tiles.
+ const int left_mode = (tile_x > 0) ?
+ (modes[tile_y * tiles_per_row + tile_x - 1] >> 8) & 0xff : 0xff;
+ const int above_mode = (tile_y > 0) ?
+ (modes[(tile_y - 1) * tiles_per_row + tile_x] >> 8) & 0xff : 0xff;
+ // The width of upper_row and current_row is one pixel larger than image width
+ // to allow the top right pixel to point to the leftmost pixel of the next row
+ // when at the right edge.
+ uint32_t* upper_row = argb_scratch;
+ uint32_t* current_row = upper_row + width + 1;
+ uint8_t* const max_diffs = (uint8_t*)(current_row + width + 1);
+ float best_diff = MAX_DIFF_COST;
+ int best_mode = 0;
+ int mode;
+ int histo_stack_1[4][256];
+ int histo_stack_2[4][256];
+ // Need pointers to be able to swap arrays.
+ int (*histo_argb)[256] = histo_stack_1;
+ int (*best_histo)[256] = histo_stack_2;
+ int i, j;
+ uint32_t residuals[1 << MAX_TRANSFORM_BITS];
+ assert(bits <= MAX_TRANSFORM_BITS);
+ assert(max_x <= (1 << MAX_TRANSFORM_BITS));
+
+ for (mode = 0; mode < kNumPredModes; ++mode) {
+ float cur_diff;
+ int relative_y;
+ memset(histo_argb, 0, sizeof(histo_stack_1));
+ if (start_y > 0) {
+ // Read the row above the tile which will become the first upper_row.
+ // Include a pixel to the left if it exists; include a pixel to the right
+ // in all cases (wrapping to the leftmost pixel of the next row if it does
+ // not exist).
+ memcpy(current_row + context_start_x,
+ argb + (start_y - 1) * width + context_start_x,
+ sizeof(*argb) * (max_x + have_left + 1));
+ }
+ for (relative_y = 0; relative_y < max_y; ++relative_y) {
+ const int y = start_y + relative_y;
+ int relative_x;
+ uint32_t* tmp = upper_row;
+ upper_row = current_row;
+ current_row = tmp;
+ // Read current_row. Include a pixel to the left if it exists; include a
+ // pixel to the right in all cases except at the bottom right corner of
+ // the image (wrapping to the leftmost pixel of the next row if it does
+ // not exist in the current row).
+ memcpy(current_row + context_start_x,
+ argb + y * width + context_start_x,
+ sizeof(*argb) * (max_x + have_left + (y + 1 < height)));
+ if (max_quantization > 1 && y >= 1 && y + 1 < height) {
+ MaxDiffsForRow(context_width, width, argb + y * width + context_start_x,
+ max_diffs + context_start_x, used_subtract_green);
+ }
+
+ GetResidual(width, height, upper_row, current_row, max_diffs, mode,
+ start_x, start_x + max_x, y, max_quantization, exact,
+ used_subtract_green, residuals);
+ for (relative_x = 0; relative_x < max_x; ++relative_x) {
+ UpdateHisto(histo_argb, residuals[relative_x]);
+ }
+ }
+ cur_diff = PredictionCostSpatialHistogram(
+ (const int (*)[256])accumulated, (const int (*)[256])histo_argb);
+ // Favor keeping the areas locally similar.
+ if (mode == left_mode) cur_diff -= kSpatialPredictorBias;
+ if (mode == above_mode) cur_diff -= kSpatialPredictorBias;
+
+ if (cur_diff < best_diff) {
+ int (*tmp)[256] = histo_argb;
+ histo_argb = best_histo;
+ best_histo = tmp;
+ best_diff = cur_diff;
+ best_mode = mode;
+ }
+ }
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 256; j++) {
+ accumulated[i][j] += best_histo[i][j];
+ }
+ }
+
+ return best_mode;
+}
+
+// Converts pixels of the image to residuals with respect to predictions.
+// If max_quantization > 1, applies near lossless processing, quantizing
+// residuals to multiples of quantization levels up to max_quantization
+// (the actual quantization level depends on smoothness near the given pixel).
+static void CopyImageWithPrediction(int width, int height,
+ int bits, uint32_t* const modes,
+ uint32_t* const argb_scratch,
+ uint32_t* const argb,
+ int low_effort, int max_quantization,
+ int exact, int used_subtract_green) {
+ const int tiles_per_row = VP8LSubSampleSize(width, bits);
+ // The width of upper_row and current_row is one pixel larger than image width
+ // to allow the top right pixel to point to the leftmost pixel of the next row
+ // when at the right edge.
+ uint32_t* upper_row = argb_scratch;
+ uint32_t* current_row = upper_row + width + 1;
+ uint8_t* current_max_diffs = (uint8_t*)(current_row + width + 1);
+ uint8_t* lower_max_diffs = current_max_diffs + width;
+ int y;
+
+ for (y = 0; y < height; ++y) {
+ int x;
+ uint32_t* const tmp32 = upper_row;
+ upper_row = current_row;
+ current_row = tmp32;
+ memcpy(current_row, argb + y * width,
+ sizeof(*argb) * (width + (y + 1 < height)));
+
+ if (low_effort) {
+ PredictBatch(kPredLowEffort, 0, y, width, current_row, upper_row,
+ argb + y * width);
+ } else {
+ if (max_quantization > 1) {
+ // Compute max_diffs for the lower row now, because that needs the
+ // contents of argb for the current row, which we will overwrite with
+ // residuals before proceeding with the next row.
+ uint8_t* const tmp8 = current_max_diffs;
+ current_max_diffs = lower_max_diffs;
+ lower_max_diffs = tmp8;
+ if (y + 2 < height) {
+ MaxDiffsForRow(width, width, argb + (y + 1) * width, lower_max_diffs,
+ used_subtract_green);
+ }
+ }
+ for (x = 0; x < width;) {
+ const int mode =
+ (modes[(y >> bits) * tiles_per_row + (x >> bits)] >> 8) & 0xff;
+ int x_end = x + (1 << bits);
+ if (x_end > width) x_end = width;
+ GetResidual(width, height, upper_row, current_row, current_max_diffs,
+ mode, x, x_end, y, max_quantization, exact,
+ used_subtract_green, argb + y * width + x);
+ x = x_end;
+ }
+ }
+ }
+}
+
+// Finds the best predictor for each tile, and converts the image to residuals
+// with respect to predictions. If near_lossless_quality < 100, applies
+// near lossless processing, shaving off more bits of residuals for lower
+// qualities.
+void VP8LResidualImage(int width, int height, int bits, int low_effort,
+ uint32_t* const argb, uint32_t* const argb_scratch,
+ uint32_t* const image, int near_lossless_quality,
+ int exact, int used_subtract_green) {
+ const int tiles_per_row = VP8LSubSampleSize(width, bits);
+ const int tiles_per_col = VP8LSubSampleSize(height, bits);
+ int tile_y;
+ int histo[4][256];
+ const int max_quantization = 1 << VP8LNearLosslessBits(near_lossless_quality);
+ if (low_effort) {
+ int i;
+ for (i = 0; i < tiles_per_row * tiles_per_col; ++i) {
+ image[i] = ARGB_BLACK | (kPredLowEffort << 8);
+ }
+ } else {
+ memset(histo, 0, sizeof(histo));
+ for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) {
+ int tile_x;
+ for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) {
+ const int pred = GetBestPredictorForTile(width, height, tile_x, tile_y,
+ bits, histo, argb_scratch, argb, max_quantization, exact,
+ used_subtract_green, image);
+ image[tile_y * tiles_per_row + tile_x] = ARGB_BLACK | (pred << 8);
+ }
+ }
+ }
+
+ CopyImageWithPrediction(width, height, bits, image, argb_scratch, argb,
+ low_effort, max_quantization, exact,
+ used_subtract_green);
+}
+
+//------------------------------------------------------------------------------
+// Color transform functions.
+
+static WEBP_INLINE void MultipliersClear(VP8LMultipliers* const m) {
+ m->green_to_red_ = 0;
+ m->green_to_blue_ = 0;
+ m->red_to_blue_ = 0;
+}
+
+static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
+ VP8LMultipliers* const m) {
+ m->green_to_red_ = (color_code >> 0) & 0xff;
+ m->green_to_blue_ = (color_code >> 8) & 0xff;
+ m->red_to_blue_ = (color_code >> 16) & 0xff;
+}
+
+static WEBP_INLINE uint32_t MultipliersToColorCode(
+ const VP8LMultipliers* const m) {
+ return 0xff000000u |
+ ((uint32_t)(m->red_to_blue_) << 16) |
+ ((uint32_t)(m->green_to_blue_) << 8) |
+ m->green_to_red_;
+}
+
+static float PredictionCostCrossColor(const int accumulated[256],
+ const int counts[256]) {
+ // Favor low entropy, locally and globally.
+ // Favor small absolute values for PredictionCostSpatial
+ static const double kExpValue = 2.4;
+ return VP8LCombinedShannonEntropy(counts, accumulated) +
+ PredictionCostSpatial(counts, 3, kExpValue);
+}
+
+static float GetPredictionCostCrossColorRed(
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y, int green_to_red,
+ const int accumulated_red_histo[256]) {
+ int histo[256] = { 0 };
+ float cur_diff;
+
+ VP8LCollectColorRedTransforms(argb, stride, tile_width, tile_height,
+ green_to_red, histo);
+
+ cur_diff = PredictionCostCrossColor(accumulated_red_histo, histo);
+ if ((uint8_t)green_to_red == prev_x.green_to_red_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if ((uint8_t)green_to_red == prev_y.green_to_red_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if (green_to_red == 0) {
+ cur_diff -= 3;
+ }
+ return cur_diff;
+}
+
+static void GetBestGreenToRed(
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
+ const int accumulated_red_histo[256], VP8LMultipliers* const best_tx) {
+ const int kMaxIters = 4 + ((7 * quality) >> 8); // in range [4..6]
+ int green_to_red_best = 0;
+ int iter, offset;
+ float best_diff = GetPredictionCostCrossColorRed(
+ argb, stride, tile_width, tile_height, prev_x, prev_y,
+ green_to_red_best, accumulated_red_histo);
+ for (iter = 0; iter < kMaxIters; ++iter) {
+ // ColorTransformDelta is a 3.5 bit fixed point, so 32 is equal to
+ // one in color computation. Having initial delta here as 1 is sufficient
+ // to explore the range of (-2, 2).
+ const int delta = 32 >> iter;
+ // Try a negative and a positive delta from the best known value.
+ for (offset = -delta; offset <= delta; offset += 2 * delta) {
+ const int green_to_red_cur = offset + green_to_red_best;
+ const float cur_diff = GetPredictionCostCrossColorRed(
+ argb, stride, tile_width, tile_height, prev_x, prev_y,
+ green_to_red_cur, accumulated_red_histo);
+ if (cur_diff < best_diff) {
+ best_diff = cur_diff;
+ green_to_red_best = green_to_red_cur;
+ }
+ }
+ }
+ best_tx->green_to_red_ = green_to_red_best;
+}
+
+static float GetPredictionCostCrossColorBlue(
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y,
+ int green_to_blue, int red_to_blue, const int accumulated_blue_histo[256]) {
+ int histo[256] = { 0 };
+ float cur_diff;
+
+ VP8LCollectColorBlueTransforms(argb, stride, tile_width, tile_height,
+ green_to_blue, red_to_blue, histo);
+
+ cur_diff = PredictionCostCrossColor(accumulated_blue_histo, histo);
+ if ((uint8_t)green_to_blue == prev_x.green_to_blue_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if ((uint8_t)green_to_blue == prev_y.green_to_blue_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if ((uint8_t)red_to_blue == prev_x.red_to_blue_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if ((uint8_t)red_to_blue == prev_y.red_to_blue_) {
+ cur_diff -= 3; // favor keeping the areas locally similar
+ }
+ if (green_to_blue == 0) {
+ cur_diff -= 3;
+ }
+ if (red_to_blue == 0) {
+ cur_diff -= 3;
+ }
+ return cur_diff;
+}
+
+#define kGreenRedToBlueNumAxis 8
+#define kGreenRedToBlueMaxIters 7
+static void GetBestGreenRedToBlue(
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
+ const int accumulated_blue_histo[256],
+ VP8LMultipliers* const best_tx) {
+ const int8_t offset[kGreenRedToBlueNumAxis][2] =
+ {{0, -1}, {0, 1}, {-1, 0}, {1, 0}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
+ const int8_t delta_lut[kGreenRedToBlueMaxIters] = { 16, 16, 8, 4, 2, 2, 2 };
+ const int iters =
+ (quality < 25) ? 1 : (quality > 50) ? kGreenRedToBlueMaxIters : 4;
+ int green_to_blue_best = 0;
+ int red_to_blue_best = 0;
+ int iter;
+ // Initial value at origin:
+ float best_diff = GetPredictionCostCrossColorBlue(
+ argb, stride, tile_width, tile_height, prev_x, prev_y,
+ green_to_blue_best, red_to_blue_best, accumulated_blue_histo);
+ for (iter = 0; iter < iters; ++iter) {
+ const int delta = delta_lut[iter];
+ int axis;
+ for (axis = 0; axis < kGreenRedToBlueNumAxis; ++axis) {
+ const int green_to_blue_cur =
+ offset[axis][0] * delta + green_to_blue_best;
+ const int red_to_blue_cur = offset[axis][1] * delta + red_to_blue_best;
+ const float cur_diff = GetPredictionCostCrossColorBlue(
+ argb, stride, tile_width, tile_height, prev_x, prev_y,
+ green_to_blue_cur, red_to_blue_cur, accumulated_blue_histo);
+ if (cur_diff < best_diff) {
+ best_diff = cur_diff;
+ green_to_blue_best = green_to_blue_cur;
+ red_to_blue_best = red_to_blue_cur;
+ }
+ if (quality < 25 && iter == 4) {
+ // Only axis aligned diffs for lower quality.
+ break; // next iter.
+ }
+ }
+ if (delta == 2 && green_to_blue_best == 0 && red_to_blue_best == 0) {
+ // Further iterations would not help.
+ break; // out of iter-loop.
+ }
+ }
+ best_tx->green_to_blue_ = green_to_blue_best;
+ best_tx->red_to_blue_ = red_to_blue_best;
+}
+#undef kGreenRedToBlueMaxIters
+#undef kGreenRedToBlueNumAxis
+
+static VP8LMultipliers GetBestColorTransformForTile(
+ int tile_x, int tile_y, int bits,
+ VP8LMultipliers prev_x,
+ VP8LMultipliers prev_y,
+ int quality, int xsize, int ysize,
+ const int accumulated_red_histo[256],
+ const int accumulated_blue_histo[256],
+ const uint32_t* const argb) {
+ const int max_tile_size = 1 << bits;
+ const int tile_y_offset = tile_y * max_tile_size;
+ const int tile_x_offset = tile_x * max_tile_size;
+ const int all_x_max = GetMin(tile_x_offset + max_tile_size, xsize);
+ const int all_y_max = GetMin(tile_y_offset + max_tile_size, ysize);
+ const int tile_width = all_x_max - tile_x_offset;
+ const int tile_height = all_y_max - tile_y_offset;
+ const uint32_t* const tile_argb = argb + tile_y_offset * xsize
+ + tile_x_offset;
+ VP8LMultipliers best_tx;
+ MultipliersClear(&best_tx);
+
+ GetBestGreenToRed(tile_argb, xsize, tile_width, tile_height,
+ prev_x, prev_y, quality, accumulated_red_histo, &best_tx);
+ GetBestGreenRedToBlue(tile_argb, xsize, tile_width, tile_height,
+ prev_x, prev_y, quality, accumulated_blue_histo,
+ &best_tx);
+ return best_tx;
+}
+
+static void CopyTileWithColorTransform(int xsize, int ysize,
+ int tile_x, int tile_y,
+ int max_tile_size,
+ VP8LMultipliers color_transform,
+ uint32_t* argb) {
+ const int xscan = GetMin(max_tile_size, xsize - tile_x);
+ int yscan = GetMin(max_tile_size, ysize - tile_y);
+ argb += tile_y * xsize + tile_x;
+ while (yscan-- > 0) {
+ VP8LTransformColor(&color_transform, argb, xscan);
+ argb += xsize;
+ }
+}
+
+void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
+ uint32_t* const argb, uint32_t* image) {
+ const int max_tile_size = 1 << bits;
+ const int tile_xsize = VP8LSubSampleSize(width, bits);
+ const int tile_ysize = VP8LSubSampleSize(height, bits);
+ int accumulated_red_histo[256] = { 0 };
+ int accumulated_blue_histo[256] = { 0 };
+ int tile_x, tile_y;
+ VP8LMultipliers prev_x, prev_y;
+ MultipliersClear(&prev_y);
+ MultipliersClear(&prev_x);
+ for (tile_y = 0; tile_y < tile_ysize; ++tile_y) {
+ for (tile_x = 0; tile_x < tile_xsize; ++tile_x) {
+ int y;
+ const int tile_x_offset = tile_x * max_tile_size;
+ const int tile_y_offset = tile_y * max_tile_size;
+ const int all_x_max = GetMin(tile_x_offset + max_tile_size, width);
+ const int all_y_max = GetMin(tile_y_offset + max_tile_size, height);
+ const int offset = tile_y * tile_xsize + tile_x;
+ if (tile_y != 0) {
+ ColorCodeToMultipliers(image[offset - tile_xsize], &prev_y);
+ }
+ prev_x = GetBestColorTransformForTile(tile_x, tile_y, bits,
+ prev_x, prev_y,
+ quality, width, height,
+ accumulated_red_histo,
+ accumulated_blue_histo,
+ argb);
+ image[offset] = MultipliersToColorCode(&prev_x);
+ CopyTileWithColorTransform(width, height, tile_x_offset, tile_y_offset,
+ max_tile_size, prev_x, argb);
+
+ // Gather accumulated histogram data.
+ for (y = tile_y_offset; y < all_y_max; ++y) {
+ int ix = y * width + tile_x_offset;
+ const int ix_end = ix + all_x_max - tile_x_offset;
+ for (; ix < ix_end; ++ix) {
+ const uint32_t pix = argb[ix];
+ if (ix >= 2 &&
+ pix == argb[ix - 2] &&
+ pix == argb[ix - 1]) {
+ continue; // repeated pixels are handled by backward references
+ }
+ if (ix >= width + 2 &&
+ argb[ix - 2] == argb[ix - width - 2] &&
+ argb[ix - 1] == argb[ix - width - 1] &&
+ pix == argb[ix - width]) {
+ continue; // repeated pixels are handled by backward references
+ }
+ ++accumulated_red_histo[(pix >> 16) & 0xff];
+ ++accumulated_blue_histo[(pix >> 0) & 0xff];
+ }
+ }
+ }
+ }
+}
diff --git a/thirdparty/libwebp/enc/quant.c b/thirdparty/libwebp/enc/quant_enc.c
index 07ffaf0aeb..b118fb2a13 100644
--- a/thirdparty/libwebp/enc/quant.c
+++ b/thirdparty/libwebp/enc/quant_enc.c
@@ -15,8 +15,8 @@
#include <math.h>
#include <stdlib.h> // for abs()
-#include "./vp8enci.h"
-#include "./cost.h"
+#include "./vp8i_enc.h"
+#include "./cost_enc.h"
#define DO_TRELLIS_I4 1
#define DO_TRELLIS_I16 1 // not a huge gain, but ok at low bitrate.
@@ -643,6 +643,8 @@ static int TrellisQuantizeBlock(const VP8Encoder* const enc,
const int sign = (in[j] < 0);
const uint32_t coeff0 = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
int level0 = QUANTDIV(coeff0, iQ, B);
+ int thresh_level = QUANTDIV(coeff0, iQ, BIAS(0x80));
+ if (thresh_level > MAX_LEVEL) thresh_level = MAX_LEVEL;
if (level0 > MAX_LEVEL) level0 = MAX_LEVEL;
{ // Swap current and previous score states
@@ -657,23 +659,17 @@ static int TrellisQuantizeBlock(const VP8Encoder* const enc,
int level = level0 + m;
const int ctx = (level > 2) ? 2 : level;
const int band = VP8EncBands[n + 1];
- score_t base_score, last_pos_score;
+ score_t base_score;
score_t best_cur_score = MAX_COST;
int best_prev = 0; // default, in case
ss_cur[m].score = MAX_COST;
ss_cur[m].costs = costs[n + 1][ctx];
- if (level > MAX_LEVEL || level < 0) { // node is dead?
+ if (level < 0 || level > thresh_level) {
+ // Node is dead.
continue;
}
- // Compute extra rate cost if last coeff's position is < 15
- {
- const score_t last_pos_cost =
- (n < 15) ? VP8BitCost(0, probas[band][ctx][0]) : 0;
- last_pos_score = RDScoreTrellis(lambda, last_pos_cost, 0);
- }
-
{
// Compute delta_error = how much coding this level will
// subtract to max_error as distortion.
@@ -705,6 +701,9 @@ static int TrellisQuantizeBlock(const VP8Encoder* const enc,
// Now, record best terminal node (and thus best entry in the graph).
if (level != 0) {
+ const score_t last_pos_cost =
+ (n < 15) ? VP8BitCost(0, probas[band][ctx][0]) : 0;
+ const score_t last_pos_score = RDScoreTrellis(lambda, last_pos_cost, 0);
const score_t score = best_cur_score + last_pos_score;
if (score < best_score) {
best_score = score;
diff --git a/thirdparty/libwebp/enc/syntax.c b/thirdparty/libwebp/enc/syntax_enc.c
index a0e79ef404..90665bd7e5 100644
--- a/thirdparty/libwebp/enc/syntax.c
+++ b/thirdparty/libwebp/enc/syntax_enc.c
@@ -16,7 +16,7 @@
#include "../utils/utils.h"
#include "../webp/format_constants.h" // RIFF constants
#include "../webp/mux_types.h" // ALPHA_FLAG
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
//------------------------------------------------------------------------------
// Helper functions
@@ -362,8 +362,7 @@ int VP8EncWrite(VP8Encoder* const enc) {
for (p = 0; p < enc->num_parts_; ++p) {
const uint8_t* const buf = VP8BitWriterBuf(enc->parts_ + p);
const size_t size = VP8BitWriterSize(enc->parts_ + p);
- if (size)
- ok = ok && pic->writer(buf, size, pic);
+ if (size) ok = ok && pic->writer(buf, size, pic);
VP8BitWriterWipeOut(enc->parts_ + p); // will free the internal buffer.
ok = ok && WebPReportProgress(pic, enc->percent_ + percent_per_part,
&enc->percent_);
diff --git a/thirdparty/libwebp/enc/token.c b/thirdparty/libwebp/enc/token_enc.c
index 087940e5ff..02a0d72cc6 100644
--- a/thirdparty/libwebp/enc/token.c
+++ b/thirdparty/libwebp/enc/token_enc.c
@@ -20,8 +20,8 @@
#include <stdlib.h>
#include <string.h>
-#include "./cost.h"
-#include "./vp8enci.h"
+#include "./cost_enc.h"
+#include "./vp8i_enc.h"
#include "../utils/utils.h"
#if !defined(DISABLE_TOKEN_BUFFER)
@@ -137,8 +137,9 @@ int VP8RecordCoeffTokens(int ctx, const struct VP8Residual* const res,
s = res->stats[VP8EncBands[n]][1];
} else {
if (!AddToken(tokens, v > 4, base_id + 3, s + 3)) {
- if (AddToken(tokens, v != 2, base_id + 4, s + 4))
+ if (AddToken(tokens, v != 2, base_id + 4, s + 4)) {
AddToken(tokens, v == 4, base_id + 5, s + 5);
+ }
} else if (!AddToken(tokens, v > 10, base_id + 6, s + 6)) {
if (!AddToken(tokens, v > 6, base_id + 7, s + 7)) {
AddConstantToken(tokens, v == 6, 159);
diff --git a/thirdparty/libwebp/enc/tree.c b/thirdparty/libwebp/enc/tree_enc.c
index f141006d19..2c40fe7f3d 100644
--- a/thirdparty/libwebp/enc/tree.c
+++ b/thirdparty/libwebp/enc/tree_enc.c
@@ -11,7 +11,7 @@
//
// Author: Skal (pascal.massimino@gmail.com)
-#include "./vp8enci.h"
+#include "./vp8i_enc.h"
//------------------------------------------------------------------------------
// Default probabilities
diff --git a/thirdparty/libwebp/enc/vp8enci.h b/thirdparty/libwebp/enc/vp8i_enc.h
index 5b4e162a58..93c95ecbfb 100644
--- a/thirdparty/libwebp/enc/vp8enci.h
+++ b/thirdparty/libwebp/enc/vp8i_enc.h
@@ -15,10 +15,10 @@
#define WEBP_ENC_VP8ENCI_H_
#include <string.h> // for memcpy()
-#include "../dec/common.h"
+#include "../dec/common_dec.h"
#include "../dsp/dsp.h"
-#include "../utils/bit_writer.h"
-#include "../utils/thread.h"
+#include "../utils/bit_writer_utils.h"
+#include "../utils/thread_utils.h"
#include "../utils/utils.h"
#include "../webp/encode.h"
@@ -31,8 +31,8 @@ extern "C" {
// version numbers
#define ENC_MAJ_VERSION 0
-#define ENC_MIN_VERSION 5
-#define ENC_REV_VERSION 2
+#define ENC_MIN_VERSION 6
+#define ENC_REV_VERSION 0
enum { MAX_LF_LEVELS = 64, // Maximum loop filter level
MAX_VARIABLE_LEVEL = 67, // last (inclusive) level with variable cost
@@ -219,7 +219,6 @@ typedef struct {
// right neighbouring data (samples, predictions, contexts, ...)
typedef struct {
int x_, y_; // current macroblock
- int y_stride_, uv_stride_; // respective strides
uint8_t* yuv_in_; // input samples
uint8_t* yuv_out_; // output samples
uint8_t* yuv_out2_; // secondary buffer swapped with yuv_out_.
@@ -474,14 +473,6 @@ int VP8EncStartAlpha(VP8Encoder* const enc); // start alpha coding process
int VP8EncFinishAlpha(VP8Encoder* const enc); // finalize compressed data
int VP8EncDeleteAlpha(VP8Encoder* const enc); // delete compressed data
- // in filter.c
-void VP8SSIMAddStats(const VP8DistoStats* const src, VP8DistoStats* const dst);
-void VP8SSIMAccumulatePlane(const uint8_t* src1, int stride1,
- const uint8_t* src2, int stride2,
- int W, int H, VP8DistoStats* const stats);
-double VP8SSIMGet(const VP8DistoStats* const stats);
-double VP8SSIMGetSquaredError(const VP8DistoStats* const stats);
-
// autofilter
void VP8InitFilter(VP8EncIterator* const it);
void VP8StoreFilterStats(VP8EncIterator* const it);
diff --git a/thirdparty/libwebp/enc/vp8l.c b/thirdparty/libwebp/enc/vp8l_enc.c
index e4ad2959b8..b1a793d956 100644
--- a/thirdparty/libwebp/enc/vp8l.c
+++ b/thirdparty/libwebp/enc/vp8l_enc.c
@@ -15,17 +15,18 @@
#include <assert.h>
#include <stdlib.h>
-#include "./backward_references.h"
-#include "./histogram.h"
-#include "./vp8enci.h"
-#include "./vp8li.h"
+#include "./backward_references_enc.h"
+#include "./histogram_enc.h"
+#include "./vp8i_enc.h"
+#include "./vp8li_enc.h"
#include "../dsp/lossless.h"
-#include "../utils/bit_writer.h"
-#include "../utils/huffman_encode.h"
+#include "../dsp/lossless_common.h"
+#include "../utils/bit_writer_utils.h"
+#include "../utils/huffman_encode_utils.h"
#include "../utils/utils.h"
#include "../webp/format_constants.h"
-#include "./delta_palettization.h"
+#include "./delta_palettization_enc.h"
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
// Maximum number of histogram images (sub-blocks).
@@ -163,18 +164,25 @@ typedef enum {
kHistoTotal // Must be last.
} HistoIx;
-static void AddSingleSubGreen(uint32_t p, uint32_t* r, uint32_t* b) {
- const uint32_t green = p >> 8; // The upper bits are masked away later.
+static void AddSingleSubGreen(int p, uint32_t* const r, uint32_t* const b) {
+ const int green = p >> 8; // The upper bits are masked away later.
++r[((p >> 16) - green) & 0xff];
- ++b[(p - green) & 0xff];
+ ++b[((p >> 0) - green) & 0xff];
}
static void AddSingle(uint32_t p,
- uint32_t* a, uint32_t* r, uint32_t* g, uint32_t* b) {
- ++a[p >> 24];
+ uint32_t* const a, uint32_t* const r,
+ uint32_t* const g, uint32_t* const b) {
+ ++a[(p >> 24) & 0xff];
++r[(p >> 16) & 0xff];
- ++g[(p >> 8) & 0xff];
- ++b[(p & 0xff)];
+ ++g[(p >> 8) & 0xff];
+ ++b[(p >> 0) & 0xff];
+}
+
+static WEBP_INLINE uint32_t HashPix(uint32_t pix) {
+ // Note that masking with 0xffffffffu is for preventing an
+ // 'unsigned int overflow' warning. Doesn't impact the compiled code.
+ return ((((uint64_t)pix + (pix >> 19)) * 0x39c5fba7ull) & 0xffffffffu) >> 24;
}
static int AnalyzeEntropy(const uint32_t* argb,
@@ -214,8 +222,8 @@ static int AnalyzeEntropy(const uint32_t* argb,
&histo[kHistoBluePredSubGreen * 256]);
{
// Approximate the palette by the entropy of the multiplicative hash.
- const int hash = ((pix + (pix >> 19)) * 0x39c5fba7) >> 24;
- ++histo[kHistoPalette * 256 + (hash & 0xff)];
+ const uint32_t hash = HashPix(pix);
+ ++histo[kHistoPalette * 256 + hash];
}
}
prev_row = curr_row;
@@ -311,7 +319,10 @@ static int GetHistoBits(int method, int use_palette, int width, int height) {
static int GetTransformBits(int method, int histo_bits) {
const int max_transform_bits = (method < 4) ? 6 : (method > 4) ? 4 : 5;
- return (histo_bits > max_transform_bits) ? max_transform_bits : histo_bits;
+ const int res =
+ (histo_bits > max_transform_bits) ? max_transform_bits : histo_bits;
+ assert(res <= MAX_TRANSFORM_BITS);
+ return res;
}
static int AnalyzeAndInit(VP8LEncoder* const enc) {
@@ -696,7 +707,7 @@ static WebPEncodingError EncodeImageNoHuffman(VP8LBitWriter* const bw,
VP8LHashChain* const hash_chain,
VP8LBackwardRefs refs_array[2],
int width, int height,
- int quality) {
+ int quality, int low_effort) {
int i;
int max_tokens = 0;
WebPEncodingError err = VP8_ENC_OK;
@@ -714,7 +725,8 @@ static WebPEncodingError EncodeImageNoHuffman(VP8LBitWriter* const bw,
}
// Calculate backward references from ARGB image.
- if (VP8LHashChainFill(hash_chain, quality, argb, width, height) == 0) {
+ if (!VP8LHashChainFill(hash_chain, quality, argb, width, height,
+ low_effort)) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
goto Error;
}
@@ -814,11 +826,18 @@ static WebPEncodingError EncodeImageInternal(VP8LBitWriter* const bw,
goto Error;
}
- *cache_bits = use_cache ? MAX_COLOR_CACHE_BITS : 0;
+ if (use_cache) {
+ // If the value is different from zero, it has been set during the
+ // palette analysis.
+ if (*cache_bits == 0) *cache_bits = MAX_COLOR_CACHE_BITS;
+ } else {
+ *cache_bits = 0;
+ }
// 'best_refs' is the reference to the best backward refs and points to one
// of refs_array[0] or refs_array[1].
// Calculate backward references from ARGB image.
- if (VP8LHashChainFill(hash_chain, quality, argb, width, height) == 0) {
+ if (!VP8LHashChainFill(hash_chain, quality, argb, width, height,
+ low_effort)) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
goto Error;
}
@@ -899,7 +918,7 @@ static WebPEncodingError EncodeImageInternal(VP8LBitWriter* const bw,
err = EncodeImageNoHuffman(bw, histogram_argb, hash_chain, refs_array,
VP8LSubSampleSize(width, histogram_bits),
VP8LSubSampleSize(height, histogram_bits),
- quality);
+ quality, low_effort);
WebPSafeFree(histogram_argb);
if (err != VP8_ENC_OK) goto Error;
}
@@ -990,12 +1009,12 @@ static WebPEncodingError ApplyPredictFilter(const VP8LEncoder* const enc,
(VP8LHashChain*)&enc->hash_chain_,
(VP8LBackwardRefs*)enc->refs_, // cast const away
transform_width, transform_height,
- quality);
+ quality, low_effort);
}
static WebPEncodingError ApplyCrossColorFilter(const VP8LEncoder* const enc,
int width, int height,
- int quality,
+ int quality, int low_effort,
VP8LBitWriter* const bw) {
const int ccolor_transform_bits = enc->transform_bits_;
const int transform_width = VP8LSubSampleSize(width, ccolor_transform_bits);
@@ -1011,7 +1030,7 @@ static WebPEncodingError ApplyCrossColorFilter(const VP8LEncoder* const enc,
(VP8LHashChain*)&enc->hash_chain_,
(VP8LBackwardRefs*)enc->refs_, // cast const away
transform_width, transform_height,
- quality);
+ quality, low_effort);
}
// -----------------------------------------------------------------------------
@@ -1156,7 +1175,8 @@ static WebPEncodingError MakeInputImageCopy(VP8LEncoder* const enc) {
// -----------------------------------------------------------------------------
-static int SearchColor(const uint32_t sorted[], uint32_t color, int hi) {
+static WEBP_INLINE int SearchColorNoIdx(const uint32_t sorted[], uint32_t color,
+ int hi) {
int low = 0;
if (sorted[low] == color) return low; // loop invariant: sorted[low] != color
while (1) {
@@ -1171,35 +1191,68 @@ static int SearchColor(const uint32_t sorted[], uint32_t color, int hi) {
}
}
+#define APPLY_PALETTE_GREEDY_MAX 4
+
+static WEBP_INLINE uint32_t SearchColorGreedy(const uint32_t palette[],
+ int palette_size,
+ uint32_t color) {
+ (void)palette_size;
+ assert(palette_size < APPLY_PALETTE_GREEDY_MAX);
+ assert(3 == APPLY_PALETTE_GREEDY_MAX - 1);
+ if (color == palette[0]) return 0;
+ if (color == palette[1]) return 1;
+ if (color == palette[2]) return 2;
+ return 3;
+}
+
+static WEBP_INLINE uint32_t ApplyPaletteHash0(uint32_t color) {
+ // Focus on the green color.
+ return (color >> 8) & 0xff;
+}
+
+#define PALETTE_INV_SIZE_BITS 11
+#define PALETTE_INV_SIZE (1 << PALETTE_INV_SIZE_BITS)
+
+static WEBP_INLINE uint32_t ApplyPaletteHash1(uint32_t color) {
+ // Forget about alpha.
+ return ((color & 0x00ffffffu) * 4222244071u) >> (32 - PALETTE_INV_SIZE_BITS);
+}
+
+static WEBP_INLINE uint32_t ApplyPaletteHash2(uint32_t color) {
+ // Forget about alpha.
+ return (color & 0x00ffffffu) * ((1u << 31) - 1) >>
+ (32 - PALETTE_INV_SIZE_BITS);
+}
+
// Sort palette in increasing order and prepare an inverse mapping array.
static void PrepareMapToPalette(const uint32_t palette[], int num_colors,
- uint32_t sorted[], int idx_map[]) {
+ uint32_t sorted[], uint32_t idx_map[]) {
int i;
memcpy(sorted, palette, num_colors * sizeof(*sorted));
qsort(sorted, num_colors, sizeof(*sorted), PaletteCompareColorsForQsort);
for (i = 0; i < num_colors; ++i) {
- idx_map[SearchColor(sorted, palette[i], num_colors)] = i;
+ idx_map[SearchColorNoIdx(sorted, palette[i], num_colors)] = i;
}
}
-static void MapToPalette(const uint32_t sorted_palette[], int num_colors,
- uint32_t* const last_pix, int* const last_idx,
- const int idx_map[],
- const uint32_t* src, uint8_t* dst, int width) {
- int x;
- int prev_idx = *last_idx;
- uint32_t prev_pix = *last_pix;
- for (x = 0; x < width; ++x) {
- const uint32_t pix = src[x];
- if (pix != prev_pix) {
- prev_idx = idx_map[SearchColor(sorted_palette, pix, num_colors)];
- prev_pix = pix;
- }
- dst[x] = prev_idx;
- }
- *last_idx = prev_idx;
- *last_pix = prev_pix;
-}
+// Use 1 pixel cache for ARGB pixels.
+#define APPLY_PALETTE_FOR(COLOR_INDEX) do { \
+ uint32_t prev_pix = palette[0]; \
+ uint32_t prev_idx = 0; \
+ for (y = 0; y < height; ++y) { \
+ for (x = 0; x < width; ++x) { \
+ const uint32_t pix = src[x]; \
+ if (pix != prev_pix) { \
+ prev_idx = COLOR_INDEX; \
+ prev_pix = pix; \
+ } \
+ tmp_row[x] = prev_idx; \
+ } \
+ VP8LBundleColorMap(tmp_row, width, xbits, dst); \
+ src += src_stride; \
+ dst += dst_stride; \
+ } \
+} while (0)
// Remap argb values in src[] to packed palettes entries in dst[]
// using 'row' as a temporary buffer of size 'width'.
@@ -1212,52 +1265,59 @@ static WebPEncodingError ApplyPalette(const uint32_t* src, uint32_t src_stride,
// TODO(skal): this tmp buffer is not needed if VP8LBundleColorMap() can be
// made to work in-place.
uint8_t* const tmp_row = (uint8_t*)WebPSafeMalloc(width, sizeof(*tmp_row));
- int i, x, y;
- int use_LUT = 1;
+ int x, y;
if (tmp_row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
- for (i = 0; i < palette_size; ++i) {
- if ((palette[i] & 0xffff00ffu) != 0) {
- use_LUT = 0;
- break;
- }
- }
- if (use_LUT) {
- uint8_t inv_palette[MAX_PALETTE_SIZE] = { 0 };
- for (i = 0; i < palette_size; ++i) {
- const int color = (palette[i] >> 8) & 0xff;
- inv_palette[color] = i;
- }
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- const int color = (src[x] >> 8) & 0xff;
- tmp_row[x] = inv_palette[color];
+ if (palette_size < APPLY_PALETTE_GREEDY_MAX) {
+ APPLY_PALETTE_FOR(SearchColorGreedy(palette, palette_size, pix));
+ } else {
+ int i, j;
+ uint16_t buffer[PALETTE_INV_SIZE];
+ uint32_t (*const hash_functions[])(uint32_t) = {
+ ApplyPaletteHash0, ApplyPaletteHash1, ApplyPaletteHash2
+ };
+
+ // Try to find a perfect hash function able to go from a color to an index
+ // within 1 << PALETTE_INV_SIZE_BITS in order to build a hash map to go
+ // from color to index in palette.
+ for (i = 0; i < 3; ++i) {
+ int use_LUT = 1;
+ // Set each element in buffer to max uint16_t.
+ memset(buffer, 0xff, sizeof(buffer));
+ for (j = 0; j < palette_size; ++j) {
+ const uint32_t ind = hash_functions[i](palette[j]);
+ if (buffer[ind] != 0xffffu) {
+ use_LUT = 0;
+ break;
+ } else {
+ buffer[ind] = j;
+ }
}
- VP8LBundleColorMap(tmp_row, width, xbits, dst);
- src += src_stride;
- dst += dst_stride;
+ if (use_LUT) break;
}
- } else {
- // Use 1 pixel cache for ARGB pixels.
- uint32_t last_pix;
- int last_idx;
- uint32_t sorted[MAX_PALETTE_SIZE];
- int idx_map[MAX_PALETTE_SIZE];
- PrepareMapToPalette(palette, palette_size, sorted, idx_map);
- last_pix = palette[0];
- last_idx = 0;
- for (y = 0; y < height; ++y) {
- MapToPalette(sorted, palette_size, &last_pix, &last_idx,
- idx_map, src, tmp_row, width);
- VP8LBundleColorMap(tmp_row, width, xbits, dst);
- src += src_stride;
- dst += dst_stride;
+
+ if (i == 0) {
+ APPLY_PALETTE_FOR(buffer[ApplyPaletteHash0(pix)]);
+ } else if (i == 1) {
+ APPLY_PALETTE_FOR(buffer[ApplyPaletteHash1(pix)]);
+ } else if (i == 2) {
+ APPLY_PALETTE_FOR(buffer[ApplyPaletteHash2(pix)]);
+ } else {
+ uint32_t idx_map[MAX_PALETTE_SIZE];
+ uint32_t palette_sorted[MAX_PALETTE_SIZE];
+ PrepareMapToPalette(palette, palette_size, palette_sorted, idx_map);
+ APPLY_PALETTE_FOR(
+ idx_map[SearchColorNoIdx(palette_sorted, pix, palette_size)]);
}
}
WebPSafeFree(tmp_row);
return VP8_ENC_OK;
}
+#undef APPLY_PALETTE_FOR
+#undef PALETTE_INV_SIZE_BITS
+#undef PALETTE_INV_SIZE
+#undef APPLY_PALETTE_GREEDY_MAX
// Note: Expects "enc->palette_" to be set properly.
static WebPEncodingError MapImageFromPalette(VP8LEncoder* const enc,
@@ -1290,7 +1350,7 @@ static WebPEncodingError MapImageFromPalette(VP8LEncoder* const enc,
}
// Save palette_[] to bitstream.
-static WebPEncodingError EncodePalette(VP8LBitWriter* const bw,
+static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort,
VP8LEncoder* const enc) {
int i;
uint32_t tmp_palette[MAX_PALETTE_SIZE];
@@ -1305,13 +1365,14 @@ static WebPEncodingError EncodePalette(VP8LBitWriter* const bw,
}
tmp_palette[0] = palette[0];
return EncodeImageNoHuffman(bw, tmp_palette, &enc->hash_chain_, enc->refs_,
- palette_size, 1, 20 /* quality */);
+ palette_size, 1, 20 /* quality */, low_effort);
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
static WebPEncodingError EncodeDeltaPalettePredictorImage(
- VP8LBitWriter* const bw, VP8LEncoder* const enc, int quality) {
+ VP8LBitWriter* const bw, VP8LEncoder* const enc, int quality,
+ int low_effort) {
const WebPPicture* const pic = enc->pic_;
const int width = pic->width;
const int height = pic->height;
@@ -1342,7 +1403,7 @@ static WebPEncodingError EncodeDeltaPalettePredictorImage(
err = EncodeImageNoHuffman(bw, predictors, &enc->hash_chain_,
(VP8LBackwardRefs*)enc->refs_, // cast const away
transform_width, transform_height,
- quality);
+ quality, low_effort);
WebPSafeFree(predictors);
return err;
}
@@ -1393,7 +1454,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
int use_near_lossless = 0;
int hdr_size = 0;
int data_size = 0;
- int use_delta_palettization = 0;
+ int use_delta_palette = 0;
if (enc == NULL) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
@@ -1420,7 +1481,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
}
#ifdef WEBP_EXPERIMENTAL_FEATURES
- if (config->delta_palettization) {
+ if (config->use_delta_palette) {
enc->use_predict_ = 1;
enc->use_cross_color_ = 0;
enc->use_subtract_green_ = 0;
@@ -1432,21 +1493,25 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
if (enc->use_palette_) {
err = AllocateTransformBuffer(enc, width, height);
if (err != VP8_ENC_OK) goto Error;
- err = EncodeDeltaPalettePredictorImage(bw, enc, quality);
+ err = EncodeDeltaPalettePredictorImage(bw, enc, quality, low_effort);
if (err != VP8_ENC_OK) goto Error;
- use_delta_palettization = 1;
+ use_delta_palette = 1;
}
}
#endif // WEBP_EXPERIMENTAL_FEATURES
// Encode palette
if (enc->use_palette_) {
- err = EncodePalette(bw, enc);
+ err = EncodePalette(bw, low_effort, enc);
if (err != VP8_ENC_OK) goto Error;
- err = MapImageFromPalette(enc, use_delta_palettization);
+ err = MapImageFromPalette(enc, use_delta_palette);
if (err != VP8_ENC_OK) goto Error;
+ // If using a color cache, do not have it bigger than the number of colors.
+ if (use_cache && enc->palette_size_ < (1 << MAX_COLOR_CACHE_BITS)) {
+ enc->cache_bits_ = BitsLog2Floor(enc->palette_size_) + 1;
+ }
}
- if (!use_delta_palettization) {
+ if (!use_delta_palette) {
// In case image is not packed.
if (enc->argb_ == NULL) {
err = MakeInputImageCopy(enc);
@@ -1468,7 +1533,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
if (enc->use_cross_color_) {
err = ApplyCrossColorFilter(enc, enc->current_width_,
- height, quality, bw);
+ height, quality, low_effort, bw);
if (err != VP8_ENC_OK) goto Error;
}
}
diff --git a/thirdparty/libwebp/enc/vp8li.h b/thirdparty/libwebp/enc/vp8li_enc.h
index 371e276ee0..8c5fbcbb2e 100644
--- a/thirdparty/libwebp/enc/vp8li.h
+++ b/thirdparty/libwebp/enc/vp8li_enc.h
@@ -14,9 +14,9 @@
#ifndef WEBP_ENC_VP8LI_H_
#define WEBP_ENC_VP8LI_H_
-#include "./backward_references.h"
-#include "./histogram.h"
-#include "../utils/bit_writer.h"
+#include "./backward_references_enc.h"
+#include "./histogram_enc.h"
+#include "../utils/bit_writer_utils.h"
#include "../webp/encode.h"
#include "../webp/format_constants.h"
@@ -24,6 +24,9 @@
extern "C" {
#endif
+// maximum value of transform_bits_ in VP8LEncoder.
+#define MAX_TRANSFORM_BITS 6
+
typedef struct {
const WebPConfig* config_; // user configuration and parameters
const WebPPicture* pic_; // input picture.
@@ -39,7 +42,7 @@ typedef struct {
// Encoding parameters derived from quality parameter.
int histo_bits_;
- int transform_bits_;
+ int transform_bits_; // <= MAX_TRANSFORM_BITS.
int cache_bits_; // If equal to 0, don't use color cache.
// Encoding parameters derived from image characteristics.
@@ -73,6 +76,17 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
VP8LBitWriter* const bw, int use_cache);
//------------------------------------------------------------------------------
+// Image transforms in predictor.c.
+
+void VP8LResidualImage(int width, int height, int bits, int low_effort,
+ uint32_t* const argb, uint32_t* const argb_scratch,
+ uint32_t* const image, int near_lossless, int exact,
+ int used_subtract_green);
+
+void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
+ uint32_t* const argb, uint32_t* image);
+
+//------------------------------------------------------------------------------
#ifdef __cplusplus
} // extern "C"
diff --git a/thirdparty/libwebp/enc/webpenc.c b/thirdparty/libwebp/enc/webp_enc.c
index a7d04ea2ce..f18461ef92 100644
--- a/thirdparty/libwebp/enc/webpenc.c
+++ b/thirdparty/libwebp/enc/webp_enc.c
@@ -16,9 +16,9 @@
#include <string.h>
#include <math.h>
-#include "./cost.h"
-#include "./vp8enci.h"
-#include "./vp8li.h"
+#include "./cost_enc.h"
+#include "./vp8i_enc.h"
+#include "./vp8li_enc.h"
#include "../utils/utils.h"
// #define PRINT_MEMORY_INFO
@@ -75,7 +75,7 @@ static void ResetBoundaryPredictions(VP8Encoder* const enc) {
//-------------------+---+---+---+---+---+---+---+
// dynamic proba | ~ | x | x | x | x | x | x |
//-------------------+---+---+---+---+---+---+---+
-// fast mode analysis| | | | | x | x | x |
+// fast mode analysis|[x]|[x]| | | x | x | x |
//-------------------+---+---+---+---+---+---+---+
// basic rd-opt | | | | x | x | x | x |
//-------------------+---+---+---+---+---+---+---+
@@ -315,18 +315,21 @@ int WebPReportProgress(const WebPPicture* const pic,
int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
int ok = 0;
+ if (pic == NULL) return 0;
- if (pic == NULL)
- return 0;
WebPEncodingSetError(pic, VP8_ENC_OK); // all ok so far
- if (config == NULL) // bad params
+ if (config == NULL) { // bad params
return WebPEncodingSetError(pic, VP8_ENC_ERROR_NULL_PARAMETER);
- if (!WebPValidateConfig(config))
+ }
+ if (!WebPValidateConfig(config)) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_INVALID_CONFIGURATION);
- if (pic->width <= 0 || pic->height <= 0)
+ }
+ if (pic->width <= 0 || pic->height <= 0) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
- if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION)
+ }
+ if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION) {
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
+ }
if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats));
@@ -339,8 +342,8 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
if (pic->use_argb || pic->y == NULL || pic->u == NULL || pic->v == NULL) {
// Make sure we have YUVA samples.
- if (config->preprocessing & 4) {
- if (!WebPPictureSmartARGBToYUVA(pic)) {
+ if (config->use_sharp_yuv || (config->preprocessing & 4)) {
+ if (!WebPPictureSharpARGBToYUVA(pic)) {
return 0;
}
} else {
diff --git a/thirdparty/libwebp/mux/anim_encode.c b/thirdparty/libwebp/mux/anim_encode.c
index 398ba8d850..6066388727 100644
--- a/thirdparty/libwebp/mux/anim_encode.c
+++ b/thirdparty/libwebp/mux/anim_encode.c
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h> // for abs()
+#include "../mux/animi.h"
#include "../utils/utils.h"
#include "../webp/decode.h"
#include "../webp/encode.h"
@@ -128,14 +129,13 @@ static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
DisableKeyframes(enc_options);
}
- if (enc_options->kmin <= 0) {
- DisableKeyframes(enc_options);
- print_warning = 0;
- }
- if (enc_options->kmax <= 0) { // All frames will be key-frames.
+ if (enc_options->kmax == 1) { // All frames will be key-frames.
enc_options->kmin = 0;
enc_options->kmax = 0;
return;
+ } else if (enc_options->kmax <= 0) {
+ DisableKeyframes(enc_options);
+ print_warning = 0;
}
if (enc_options->kmin >= enc_options->kmax) {
@@ -378,10 +378,10 @@ static WEBP_INLINE int PixelsAreSimilar(uint32_t src, uint32_t dst,
const int dst_g = (dst >> 8) & 0xff;
const int dst_b = (dst >> 0) & 0xff;
- return (abs(src_r * src_a - dst_r * dst_a) <= (max_allowed_diff * 255)) &&
- (abs(src_g * src_a - dst_g * dst_a) <= (max_allowed_diff * 255)) &&
- (abs(src_b * src_a - dst_b * dst_a) <= (max_allowed_diff * 255)) &&
- (abs(src_a - dst_a) <= max_allowed_diff);
+ return (src_a == dst_a) &&
+ (abs(src_r - dst_r) * dst_a <= (max_allowed_diff * 255)) &&
+ (abs(src_g - dst_g) * dst_a <= (max_allowed_diff * 255)) &&
+ (abs(src_b - dst_b) * dst_a <= (max_allowed_diff * 255));
}
// Returns true if 'length' number of pixels in 'src' and 'dst' are within an
@@ -586,6 +586,39 @@ static int GetSubRects(const WebPPicture* const prev_canvas,
&params->rect_lossy_, &params->sub_frame_lossy_);
}
+static WEBP_INLINE int clip(int v, int min_v, int max_v) {
+ return (v < min_v) ? min_v : (v > max_v) ? max_v : v;
+}
+
+int WebPAnimEncoderRefineRect(
+ const WebPPicture* const prev_canvas, const WebPPicture* const curr_canvas,
+ int is_lossless, float quality, int* const x_offset, int* const y_offset,
+ int* const width, int* const height) {
+ FrameRect rect;
+ const int right = clip(*x_offset + *width, 0, curr_canvas->width);
+ const int left = clip(*x_offset, 0, curr_canvas->width - 1);
+ const int bottom = clip(*y_offset + *height, 0, curr_canvas->height);
+ const int top = clip(*y_offset, 0, curr_canvas->height - 1);
+ if (prev_canvas == NULL || curr_canvas == NULL ||
+ prev_canvas->width != curr_canvas->width ||
+ prev_canvas->height != curr_canvas->height ||
+ !prev_canvas->use_argb || !curr_canvas->use_argb) {
+ return 0;
+ }
+ rect.x_offset_ = left;
+ rect.y_offset_ = top;
+ rect.width_ = clip(right - left, 0, curr_canvas->width - rect.x_offset_);
+ rect.height_ = clip(bottom - top, 0, curr_canvas->height - rect.y_offset_);
+ MinimizeChangeRectangle(prev_canvas, curr_canvas, &rect, is_lossless,
+ quality);
+ SnapToEvenOffsets(&rect);
+ *x_offset = rect.x_offset_;
+ *y_offset = rect.y_offset_;
+ *width = rect.width_;
+ *height = rect.height_;
+ return 1;
+}
+
static void DisposeFrameRectangle(int dispose_method,
const FrameRect* const rect,
WebPPicture* const curr_canvas) {
diff --git a/thirdparty/libwebp/mux/animi.h b/thirdparty/libwebp/mux/animi.h
new file mode 100644
index 0000000000..cecaf1fee5
--- /dev/null
+++ b/thirdparty/libwebp/mux/animi.h
@@ -0,0 +1,43 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the COPYING file in the root of the source
+// tree. An additional intellectual property rights grant can be found
+// in the file PATENTS. All contributing project authors may
+// be found in the AUTHORS file in the root of the source tree.
+// -----------------------------------------------------------------------------
+//
+// Internal header for animation related functions.
+//
+// Author: Hui Su (huisu@google.com)
+
+#ifndef WEBP_MUX_ANIMI_H_
+#define WEBP_MUX_ANIMI_H_
+
+#include "../webp/mux.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Picks the optimal rectangle between two pictures, starting with initial
+// values of offsets and dimensions that are passed in. The initial
+// values will be clipped, if necessary, to make sure the rectangle is
+// within the canvas. "use_argb" must be true for both pictures.
+// Parameters:
+// prev_canvas, curr_canvas - (in) two input pictures to compare.
+// is_lossless, quality - (in) encoding settings.
+// x_offset, y_offset, width, height - (in/out) rectangle between the two
+// input pictures.
+// Returns true on success.
+int WebPAnimEncoderRefineRect(
+ const struct WebPPicture* const prev_canvas,
+ const struct WebPPicture* const curr_canvas,
+ int is_lossless, float quality, int* const x_offset, int* const y_offset,
+ int* const width, int* const height);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* WEBP_MUX_ANIMI_H_ */
diff --git a/thirdparty/libwebp/mux/muxedit.c b/thirdparty/libwebp/mux/muxedit.c
index 9bbed42b1a..d2c5305372 100644
--- a/thirdparty/libwebp/mux/muxedit.c
+++ b/thirdparty/libwebp/mux/muxedit.c
@@ -93,34 +93,32 @@ static WebPMuxError MuxSet(WebPMux* const mux, uint32_t tag, uint32_t nth,
}
#undef SWITCH_ID_LIST
-// Create data for frame/fragment given image data, offsets and duration.
-static WebPMuxError CreateFrameFragmentData(
- int width, int height, const WebPMuxFrameInfo* const info, int is_frame,
- WebPData* const frame_frgm) {
- uint8_t* frame_frgm_bytes;
- const size_t frame_frgm_size = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].size;
+// Create data for frame given image data, offsets and duration.
+static WebPMuxError CreateFrameData(
+ int width, int height, const WebPMuxFrameInfo* const info,
+ WebPData* const frame) {
+ uint8_t* frame_bytes;
+ const size_t frame_size = kChunks[IDX_ANMF].size;
assert(width > 0 && height > 0 && info->duration >= 0);
assert(info->dispose_method == (info->dispose_method & 1));
// Note: assertion on upper bounds is done in PutLE24().
- frame_frgm_bytes = (uint8_t*)WebPSafeMalloc(1ULL, frame_frgm_size);
- if (frame_frgm_bytes == NULL) return WEBP_MUX_MEMORY_ERROR;
+ frame_bytes = (uint8_t*)WebPSafeMalloc(1ULL, frame_size);
+ if (frame_bytes == NULL) return WEBP_MUX_MEMORY_ERROR;
- PutLE24(frame_frgm_bytes + 0, info->x_offset / 2);
- PutLE24(frame_frgm_bytes + 3, info->y_offset / 2);
+ PutLE24(frame_bytes + 0, info->x_offset / 2);
+ PutLE24(frame_bytes + 3, info->y_offset / 2);
- if (is_frame) {
- PutLE24(frame_frgm_bytes + 6, width - 1);
- PutLE24(frame_frgm_bytes + 9, height - 1);
- PutLE24(frame_frgm_bytes + 12, info->duration);
- frame_frgm_bytes[15] =
- (info->blend_method == WEBP_MUX_NO_BLEND ? 2 : 0) |
- (info->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? 1 : 0);
- }
+ PutLE24(frame_bytes + 6, width - 1);
+ PutLE24(frame_bytes + 9, height - 1);
+ PutLE24(frame_bytes + 12, info->duration);
+ frame_bytes[15] =
+ (info->blend_method == WEBP_MUX_NO_BLEND ? 2 : 0) |
+ (info->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? 1 : 0);
- frame_frgm->bytes = frame_frgm_bytes;
- frame_frgm->size = frame_frgm_size;
+ frame->bytes = frame_bytes;
+ frame->size = frame_size;
return WEBP_MUX_OK;
}
@@ -264,23 +262,16 @@ WebPMuxError WebPMuxSetImage(WebPMux* mux, const WebPData* bitstream,
return err;
}
-WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
+WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* info,
int copy_data) {
WebPMuxImage wpi;
WebPMuxError err;
- int is_frame;
- const WebPData* const bitstream = &frame->bitstream;
+ const WebPData* const bitstream = &info->bitstream;
// Sanity checks.
- if (mux == NULL || frame == NULL) return WEBP_MUX_INVALID_ARGUMENT;
+ if (mux == NULL || info == NULL) return WEBP_MUX_INVALID_ARGUMENT;
- is_frame = (frame->id == WEBP_CHUNK_ANMF);
- if (!(is_frame || (frame->id == WEBP_CHUNK_FRGM))) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
- if (frame->id == WEBP_CHUNK_FRGM) { // Dead experiment.
- return WEBP_MUX_INVALID_ARGUMENT;
- }
+ if (info->id != WEBP_CHUNK_ANMF) return WEBP_MUX_INVALID_ARGUMENT;
if (bitstream->bytes == NULL || bitstream->size > MAX_CHUNK_PAYLOAD) {
return WEBP_MUX_INVALID_ARGUMENT;
@@ -290,7 +281,7 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
const WebPMuxImage* const image = mux->images_;
const uint32_t image_id = (image->header_ != NULL) ?
ChunkGetIdFromTag(image->header_->tag_) : WEBP_CHUNK_IMAGE;
- if (image_id != frame->id) {
+ if (image_id != info->id) {
return WEBP_MUX_INVALID_ARGUMENT; // Conflicting frame types.
}
}
@@ -301,16 +292,11 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
assert(wpi.img_ != NULL); // As SetAlphaAndImageChunks() was successful.
{
- WebPData frame_frgm;
- const uint32_t tag = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].tag;
- WebPMuxFrameInfo tmp = *frame;
+ WebPData frame;
+ const uint32_t tag = kChunks[IDX_ANMF].tag;
+ WebPMuxFrameInfo tmp = *info;
tmp.x_offset &= ~1; // Snap offsets to even.
tmp.y_offset &= ~1;
- if (!is_frame) { // Reset unused values.
- tmp.duration = 1;
- tmp.dispose_method = WEBP_MUX_DISPOSE_NONE;
- tmp.blend_method = WEBP_MUX_BLEND;
- }
if (tmp.x_offset < 0 || tmp.x_offset >= MAX_POSITION_OFFSET ||
tmp.y_offset < 0 || tmp.y_offset >= MAX_POSITION_OFFSET ||
(tmp.duration < 0 || tmp.duration >= MAX_DURATION) ||
@@ -318,12 +304,11 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
err = WEBP_MUX_INVALID_ARGUMENT;
goto Err;
}
- err = CreateFrameFragmentData(wpi.width_, wpi.height_, &tmp, is_frame,
- &frame_frgm);
+ err = CreateFrameData(wpi.width_, wpi.height_, &tmp, &frame);
if (err != WEBP_MUX_OK) goto Err;
- // Add frame/fragment chunk (with copy_data = 1).
- err = AddDataToChunkList(&frame_frgm, 1, tag, &wpi.header_);
- WebPDataClear(&frame_frgm); // frame_frgm owned by wpi.header_ now.
+ // Add frame chunk (with copy_data = 1).
+ err = AddDataToChunkList(&frame, 1, tag, &wpi.header_);
+ WebPDataClear(&frame); // frame owned by wpi.header_ now.
if (err != WEBP_MUX_OK) goto Err;
}
@@ -402,21 +387,18 @@ WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth) {
//------------------------------------------------------------------------------
// Assembly of the WebP RIFF file.
-static WebPMuxError GetFrameFragmentInfo(
- const WebPChunk* const frame_frgm_chunk,
+static WebPMuxError GetFrameInfo(
+ const WebPChunk* const frame_chunk,
int* const x_offset, int* const y_offset, int* const duration) {
- const uint32_t tag = frame_frgm_chunk->tag_;
- const int is_frame = (tag == kChunks[IDX_ANMF].tag);
- const WebPData* const data = &frame_frgm_chunk->data_;
- const size_t expected_data_size =
- is_frame ? ANMF_CHUNK_SIZE : FRGM_CHUNK_SIZE;
- assert(frame_frgm_chunk != NULL);
- assert(tag == kChunks[IDX_ANMF].tag || tag == kChunks[IDX_FRGM].tag);
+ const WebPData* const data = &frame_chunk->data_;
+ const size_t expected_data_size = ANMF_CHUNK_SIZE;
+ assert(frame_chunk->tag_ == kChunks[IDX_ANMF].tag);
+ assert(frame_chunk != NULL);
if (data->size != expected_data_size) return WEBP_MUX_INVALID_ARGUMENT;
*x_offset = 2 * GetLE24(data->bytes + 0);
*y_offset = 2 * GetLE24(data->bytes + 3);
- if (is_frame) *duration = GetLE24(data->bytes + 12);
+ *duration = GetLE24(data->bytes + 12);
return WEBP_MUX_OK;
}
@@ -424,13 +406,13 @@ static WebPMuxError GetImageInfo(const WebPMuxImage* const wpi,
int* const x_offset, int* const y_offset,
int* const duration,
int* const width, int* const height) {
- const WebPChunk* const frame_frgm_chunk = wpi->header_;
+ const WebPChunk* const frame_chunk = wpi->header_;
WebPMuxError err;
assert(wpi != NULL);
- assert(frame_frgm_chunk != NULL);
+ assert(frame_chunk != NULL);
- // Get offsets and duration from ANMF/FRGM chunk.
- err = GetFrameFragmentInfo(frame_frgm_chunk, x_offset, y_offset, duration);
+ // Get offsets and duration from ANMF chunk.
+ err = GetFrameInfo(frame_chunk, x_offset, y_offset, duration);
if (err != WEBP_MUX_OK) return err;
// Get width and height from VP8/VP8L chunk.
@@ -441,7 +423,6 @@ static WebPMuxError GetImageInfo(const WebPMuxImage* const wpi,
// Returns the tightest dimension for the canvas considering the image list.
static WebPMuxError GetAdjustedCanvasSize(const WebPMux* const mux,
- uint32_t flags,
int* const width, int* const height) {
WebPMuxImage* wpi = NULL;
assert(mux != NULL);
@@ -452,12 +433,10 @@ static WebPMuxError GetAdjustedCanvasSize(const WebPMux* const mux,
assert(wpi->img_ != NULL);
if (wpi->next_ != NULL) {
- int max_x = 0;
- int max_y = 0;
- int64_t image_area = 0;
+ int max_x = 0, max_y = 0;
// if we have a chain of wpi's, header_ is necessarily set
assert(wpi->header_ != NULL);
- // Aggregate the bounding box for animation frames & fragmented images.
+ // Aggregate the bounding box for animation frames.
for (; wpi != NULL; wpi = wpi->next_) {
int x_offset = 0, y_offset = 0, duration = 0, w = 0, h = 0;
const WebPMuxError err = GetImageInfo(wpi, &x_offset, &y_offset,
@@ -470,19 +449,9 @@ static WebPMuxError GetAdjustedCanvasSize(const WebPMux* const mux,
if (max_x_pos > max_x) max_x = max_x_pos;
if (max_y_pos > max_y) max_y = max_y_pos;
- image_area += w * h;
}
*width = max_x;
*height = max_y;
- // Crude check to validate that there are no image overlaps/holes for
- // fragmented images. Check that the aggregated image area for individual
- // fragments exactly matches the image area of the constructed canvas.
- // However, the area-match is necessary but not sufficient condition.
- if ((flags & FRAGMENTS_FLAG) && (image_area != (max_x * max_y))) {
- *width = 0;
- *height = 0;
- return WEBP_MUX_INVALID_ARGUMENT;
- }
} else {
// For a single image, canvas dimensions are same as image dimensions.
*width = wpi->width_;
@@ -528,10 +497,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
flags |= XMP_FLAG;
}
if (images->header_ != NULL) {
- if (images->header_->tag_ == kChunks[IDX_FRGM].tag) {
- // This is a fragmented image.
- flags |= FRAGMENTS_FLAG;
- } else if (images->header_->tag_ == kChunks[IDX_ANMF].tag) {
+ if (images->header_->tag_ == kChunks[IDX_ANMF].tag) {
// This is an image with animation.
flags |= ANIMATION_FLAG;
}
@@ -540,7 +506,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
flags |= ALPHA_FLAG; // Some images have an alpha channel.
}
- err = GetAdjustedCanvasSize(mux, flags, &width, &height);
+ err = GetAdjustedCanvasSize(mux, &width, &height);
if (err != WEBP_MUX_OK) return err;
if (width <= 0 || height <= 0) {
@@ -580,31 +546,26 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
// Cleans up 'mux' by removing any unnecessary chunks.
static WebPMuxError MuxCleanup(WebPMux* const mux) {
int num_frames;
- int num_fragments;
int num_anim_chunks;
- // If we have an image with a single fragment or frame, and its rectangle
- // covers the whole canvas, convert it to a non-animated non-fragmented image
- // (to avoid writing FRGM/ANMF chunk unnecessarily).
+ // If we have an image with a single frame, and its rectangle
+ // covers the whole canvas, convert it to a non-animated image
+ // (to avoid writing ANMF chunk unnecessarily).
WebPMuxError err = WebPMuxNumChunks(mux, kChunks[IDX_ANMF].id, &num_frames);
if (err != WEBP_MUX_OK) return err;
- err = WebPMuxNumChunks(mux, kChunks[IDX_FRGM].id, &num_fragments);
- if (err != WEBP_MUX_OK) return err;
- if (num_frames == 1 || num_fragments == 1) {
- WebPMuxImage* frame_frag;
- err = MuxImageGetNth((const WebPMuxImage**)&mux->images_, 1, &frame_frag);
- assert(err == WEBP_MUX_OK); // We know that one frame/fragment does exist.
- assert(frame_frag != NULL);
- if (frame_frag->header_ != NULL &&
+ if (num_frames == 1) {
+ WebPMuxImage* frame = NULL;
+ err = MuxImageGetNth((const WebPMuxImage**)&mux->images_, 1, &frame);
+ assert(err == WEBP_MUX_OK); // We know that one frame does exist.
+ assert(frame != NULL);
+ if (frame->header_ != NULL &&
((mux->canvas_width_ == 0 && mux->canvas_height_ == 0) ||
- (frame_frag->width_ == mux->canvas_width_ &&
- frame_frag->height_ == mux->canvas_height_))) {
- assert(frame_frag->header_->tag_ == kChunks[IDX_ANMF].tag ||
- frame_frag->header_->tag_ == kChunks[IDX_FRGM].tag);
- ChunkDelete(frame_frag->header_); // Removes ANMF/FRGM chunk.
- frame_frag->header_ = NULL;
+ (frame->width_ == mux->canvas_width_ &&
+ frame->height_ == mux->canvas_height_))) {
+ assert(frame->header_->tag_ == kChunks[IDX_ANMF].tag);
+ ChunkDelete(frame->header_); // Removes ANMF chunk.
+ frame->header_ = NULL;
num_frames = 0;
- num_fragments = 0;
}
}
// Remove ANIM chunk if this is a non-animated image.
diff --git a/thirdparty/libwebp/mux/muxi.h b/thirdparty/libwebp/mux/muxi.h
index b4865fe36f..e6606aa5d1 100644
--- a/thirdparty/libwebp/mux/muxi.h
+++ b/thirdparty/libwebp/mux/muxi.h
@@ -15,8 +15,8 @@
#define WEBP_MUX_MUXI_H_
#include <stdlib.h>
-#include "../dec/vp8i.h"
-#include "../dec/vp8li.h"
+#include "../dec/vp8i_dec.h"
+#include "../dec/vp8li_dec.h"
#include "../webp/mux.h"
#ifdef __cplusplus
@@ -27,8 +27,8 @@ extern "C" {
// Defines and constants.
#define MUX_MAJ_VERSION 0
-#define MUX_MIN_VERSION 3
-#define MUX_REV_VERSION 2
+#define MUX_MIN_VERSION 4
+#define MUX_REV_VERSION 0
// Chunk object.
typedef struct WebPChunk WebPChunk;
@@ -36,16 +36,16 @@ struct WebPChunk {
uint32_t tag_;
int owner_; // True if *data_ memory is owned internally.
// VP8X, ANIM, and other internally created chunks
- // like ANMF/FRGM are always owned.
+ // like ANMF are always owned.
WebPData data_;
WebPChunk* next_;
};
-// MuxImage object. Store a full WebP image (including ANMF/FRGM chunk, ALPH
+// MuxImage object. Store a full WebP image (including ANMF chunk, ALPH
// chunk and VP8/VP8L chunk),
typedef struct WebPMuxImage WebPMuxImage;
struct WebPMuxImage {
- WebPChunk* header_; // Corresponds to WEBP_CHUNK_ANMF/WEBP_CHUNK_FRGM.
+ WebPChunk* header_; // Corresponds to WEBP_CHUNK_ANMF.
WebPChunk* alpha_; // Corresponds to WEBP_CHUNK_ALPHA.
WebPChunk* img_; // Corresponds to WEBP_CHUNK_IMAGE.
WebPChunk* unknown_; // Corresponds to WEBP_CHUNK_UNKNOWN.
@@ -79,7 +79,6 @@ typedef enum {
IDX_ICCP,
IDX_ANIM,
IDX_ANMF,
- IDX_FRGM,
IDX_ALPHA,
IDX_VP8,
IDX_VP8L,
@@ -185,7 +184,6 @@ int MuxImageFinalize(WebPMuxImage* const wpi);
static WEBP_INLINE int IsWPI(WebPChunkId id) {
switch (id) {
case WEBP_CHUNK_ANMF:
- case WEBP_CHUNK_FRGM:
case WEBP_CHUNK_ALPHA:
case WEBP_CHUNK_IMAGE: return 1;
default: return 0;
diff --git a/thirdparty/libwebp/mux/muxinternal.c b/thirdparty/libwebp/mux/muxinternal.c
index 372c6a9674..387b57e8fe 100644
--- a/thirdparty/libwebp/mux/muxinternal.c
+++ b/thirdparty/libwebp/mux/muxinternal.c
@@ -23,7 +23,6 @@ const ChunkInfo kChunks[] = {
{ MKFOURCC('I', 'C', 'C', 'P'), WEBP_CHUNK_ICCP, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('A', 'N', 'I', 'M'), WEBP_CHUNK_ANIM, ANIM_CHUNK_SIZE },
{ MKFOURCC('A', 'N', 'M', 'F'), WEBP_CHUNK_ANMF, ANMF_CHUNK_SIZE },
- { MKFOURCC('F', 'R', 'G', 'M'), WEBP_CHUNK_FRGM, FRGM_CHUNK_SIZE },
{ MKFOURCC('A', 'L', 'P', 'H'), WEBP_CHUNK_ALPHA, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('V', 'P', '8', ' '), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('V', 'P', '8', 'L'), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
@@ -251,8 +250,7 @@ static WebPChunk** GetChunkListFromId(const WebPMuxImage* const wpi,
WebPChunkId id) {
assert(wpi != NULL);
switch (id) {
- case WEBP_CHUNK_ANMF:
- case WEBP_CHUNK_FRGM: return (WebPChunk**)&wpi->header_;
+ case WEBP_CHUNK_ANMF: return (WebPChunk**)&wpi->header_;
case WEBP_CHUNK_ALPHA: return (WebPChunk**)&wpi->alpha_;
case WEBP_CHUNK_IMAGE: return (WebPChunk**)&wpi->img_;
default: return NULL;
@@ -372,13 +370,12 @@ size_t MuxImageDiskSize(const WebPMuxImage* const wpi) {
return size;
}
-// Special case as ANMF/FRGM chunk encapsulates other image chunks.
+// Special case as ANMF chunk encapsulates other image chunks.
static uint8_t* ChunkEmitSpecial(const WebPChunk* const header,
size_t total_size, uint8_t* dst) {
const size_t header_size = header->data_.size;
const size_t offset_to_next = total_size - CHUNK_HEADER_SIZE;
- assert(header->tag_ == kChunks[IDX_ANMF].tag ||
- header->tag_ == kChunks[IDX_FRGM].tag);
+ assert(header->tag_ == kChunks[IDX_ANMF].tag);
PutLE32(dst + 0, header->tag_);
PutLE32(dst + TAG_SIZE, (uint32_t)offset_to_next);
assert(header_size == (uint32_t)header_size);
@@ -391,7 +388,7 @@ static uint8_t* ChunkEmitSpecial(const WebPChunk* const header,
uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst) {
// Ordering of chunks to be emitted is strictly as follows:
- // 1. ANMF/FRGM chunk (if present).
+ // 1. ANMF chunk (if present).
// 2. ALPH chunk (if present).
// 3. VP8/VP8L chunk.
assert(wpi);
@@ -465,7 +462,6 @@ WebPMuxError MuxValidate(const WebPMux* const mux) {
int num_xmp;
int num_anim;
int num_frames;
- int num_fragments;
int num_vp8x;
int num_images;
int num_alpha;
@@ -510,10 +506,6 @@ WebPMuxError MuxValidate(const WebPMux* const mux) {
}
}
- // Fragmentation: FRAGMENTS_FLAG and FRGM chunk(s) are consistent.
- err = ValidateChunk(mux, IDX_FRGM, FRAGMENTS_FLAG, flags, -1, &num_fragments);
- if (err != WEBP_MUX_OK) return err;
-
// Verify either VP8X chunk is present OR there is only one elem in
// mux->images_.
err = ValidateChunk(mux, IDX_VP8X, NO_FLAG, flags, 1, &num_vp8x);
@@ -537,11 +529,6 @@ WebPMuxError MuxValidate(const WebPMux* const mux) {
if (flags & ALPHA_FLAG) return WEBP_MUX_INVALID_ARGUMENT;
}
- // num_fragments & num_images are consistent.
- if (num_fragments > 0 && num_images != num_fragments) {
- return WEBP_MUX_INVALID_ARGUMENT;
- }
-
return WEBP_MUX_OK;
}
diff --git a/thirdparty/libwebp/mux/muxread.c b/thirdparty/libwebp/mux/muxread.c
index 8957a1e46e..410acd9119 100644
--- a/thirdparty/libwebp/mux/muxread.c
+++ b/thirdparty/libwebp/mux/muxread.c
@@ -104,17 +104,15 @@ static int MuxImageParse(const WebPChunk* const chunk, int copy_data,
size_t subchunk_size;
ChunkInit(&subchunk);
- assert(chunk->tag_ == kChunks[IDX_ANMF].tag ||
- chunk->tag_ == kChunks[IDX_FRGM].tag);
+ assert(chunk->tag_ == kChunks[IDX_ANMF].tag);
assert(!wpi->is_partial_);
- // ANMF/FRGM.
+ // ANMF.
{
- const size_t hdr_size = (chunk->tag_ == kChunks[IDX_ANMF].tag) ?
- ANMF_CHUNK_SIZE : FRGM_CHUNK_SIZE;
+ const size_t hdr_size = ANMF_CHUNK_SIZE;
const WebPData temp = { bytes, hdr_size };
- // Each of ANMF and FRGM chunk contain a header at the beginning. So, its
- // size should at least be 'hdr_size'.
+ // Each of ANMF chunk contain a header at the beginning. So, its size should
+ // be at least 'hdr_size'.
if (size < hdr_size) goto Fail;
ChunkAssignData(&subchunk, &temp, copy_data, chunk->tag_);
}
@@ -292,16 +290,15 @@ WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
static WebPMuxError ValidateForSingleImage(const WebPMux* const mux) {
const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE);
const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_ANMF);
- const int num_fragments = MuxImageCount(mux->images_, WEBP_CHUNK_FRGM);
if (num_images == 0) {
// No images in mux.
return WEBP_MUX_NOT_FOUND;
- } else if (num_images == 1 && num_frames == 0 && num_fragments == 0) {
+ } else if (num_images == 1 && num_frames == 0) {
// Valid case (single image).
return WEBP_MUX_OK;
} else {
- // Frame/Fragment case OR an invalid mux.
+ // Frame case OR an invalid mux.
return WEBP_MUX_INVALID_ARGUMENT;
}
}
@@ -379,7 +376,7 @@ static WebPMuxError SynthesizeBitstream(const WebPMuxImage* const wpi,
const int need_vp8x = (wpi->alpha_ != NULL);
const size_t vp8x_size = need_vp8x ? CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE : 0;
const size_t alpha_size = need_vp8x ? ChunkDiskSize(wpi->alpha_) : 0;
- // Note: No need to output ANMF/FRGM chunk for a single image.
+ // Note: No need to output ANMF chunk for a single image.
const size_t size = RIFF_HEADER_SIZE + vp8x_size + alpha_size +
ChunkDiskSize(wpi->img_);
uint8_t* const data = (uint8_t*)WebPSafeMalloc(1ULL, size);
@@ -436,29 +433,24 @@ static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
return SynthesizeBitstream(wpi, &info->bitstream);
}
-static WebPMuxError MuxGetFrameFragmentInternal(const WebPMuxImage* const wpi,
- WebPMuxFrameInfo* const frame) {
+static WebPMuxError MuxGetFrameInternal(const WebPMuxImage* const wpi,
+ WebPMuxFrameInfo* const frame) {
const int is_frame = (wpi->header_->tag_ == kChunks[IDX_ANMF].tag);
- const CHUNK_INDEX idx = is_frame ? IDX_ANMF : IDX_FRGM;
- const WebPData* frame_frgm_data;
+ const WebPData* frame_data;
if (!is_frame) return WEBP_MUX_INVALID_ARGUMENT;
assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame().
- // Get frame/fragment chunk.
- frame_frgm_data = &wpi->header_->data_;
- if (frame_frgm_data->size < kChunks[idx].size) return WEBP_MUX_BAD_DATA;
+ // Get frame chunk.
+ frame_data = &wpi->header_->data_;
+ if (frame_data->size < kChunks[IDX_ANMF].size) return WEBP_MUX_BAD_DATA;
// Extract info.
- frame->x_offset = 2 * GetLE24(frame_frgm_data->bytes + 0);
- frame->y_offset = 2 * GetLE24(frame_frgm_data->bytes + 3);
- if (is_frame) {
- const uint8_t bits = frame_frgm_data->bytes[15];
- frame->duration = GetLE24(frame_frgm_data->bytes + 12);
+ frame->x_offset = 2 * GetLE24(frame_data->bytes + 0);
+ frame->y_offset = 2 * GetLE24(frame_data->bytes + 3);
+ {
+ const uint8_t bits = frame_data->bytes[15];
+ frame->duration = GetLE24(frame_data->bytes + 12);
frame->dispose_method =
(bits & 1) ? WEBP_MUX_DISPOSE_BACKGROUND : WEBP_MUX_DISPOSE_NONE;
frame->blend_method = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
- } else { // Defaults for unused values.
- frame->duration = 1;
- frame->dispose_method = WEBP_MUX_DISPOSE_NONE;
- frame->blend_method = WEBP_MUX_BLEND;
}
frame->id = ChunkGetIdFromTag(wpi->header_->tag_);
return SynthesizeBitstream(wpi, &frame->bitstream);
@@ -482,7 +474,7 @@ WebPMuxError WebPMuxGetFrame(
if (wpi->header_ == NULL) {
return MuxGetImageInternal(wpi, frame);
} else {
- return MuxGetFrameFragmentInternal(wpi, frame);
+ return MuxGetFrameInternal(wpi, frame);
}
}
diff --git a/thirdparty/libwebp/utils/bit_reader_inl.h b/thirdparty/libwebp/utils/bit_reader_inl_utils.h
index 99ed3137d2..fd7fb0446c 100644
--- a/thirdparty/libwebp/utils/bit_reader_inl.h
+++ b/thirdparty/libwebp/utils/bit_reader_inl_utils.h
@@ -20,13 +20,12 @@
#include "../webp/config.h"
#endif
-#ifdef WEBP_FORCE_ALIGNED
-#include <string.h> // memcpy
-#endif
+#include <string.h> // for memcpy
#include "../dsp/dsp.h"
-#include "./bit_reader.h"
-#include "./endian_inl.h"
+#include "./bit_reader_utils.h"
+#include "./endian_inl_utils.h"
+#include "./utils.h"
#ifdef __cplusplus
extern "C" {
@@ -62,10 +61,7 @@ void VP8LoadNewBytes(VP8BitReader* const br) {
if (br->buf_ < br->buf_max_) {
// convert memory type to register type (with some zero'ing!)
bit_t bits;
-#if defined(WEBP_FORCE_ALIGNED)
- lbit_t in_bits;
- memcpy(&in_bits, br->buf_, sizeof(in_bits));
-#elif defined(WEBP_USE_MIPS32)
+#if defined(WEBP_USE_MIPS32)
// This is needed because of un-aligned read.
lbit_t in_bits;
lbit_t* p_buf_ = (lbit_t*)br->buf_;
@@ -80,7 +76,8 @@ void VP8LoadNewBytes(VP8BitReader* const br) {
: "memory", "at"
);
#else
- const lbit_t in_bits = *(const lbit_t*)br->buf_;
+ lbit_t in_bits;
+ memcpy(&in_bits, br->buf_, sizeof(in_bits));
#endif
br->buf_ += BITS >> 3;
#if !defined(WORDS_BIGENDIAN)
@@ -119,37 +116,26 @@ static WEBP_INLINE int VP8GetBit(VP8BitReader* const br, int prob) {
const int pos = br->bits_;
const range_t split = (range * prob) >> 8;
const range_t value = (range_t)(br->value_ >> pos);
-#if defined(__arm__) || defined(_M_ARM) // ARM-specific
- const int bit = ((int)(split - value) >> 31) & 1;
- if (value > split) {
- range -= split + 1;
- br->value_ -= (bit_t)(split + 1) << pos;
- } else {
- range = split;
- }
-#else // faster version on x86
- int bit; // Don't use 'const int bit = (value > split);", it's slower.
- if (value > split) {
- range -= split + 1;
+ const int bit = (value > split);
+ if (bit) {
+ range -= split;
br->value_ -= (bit_t)(split + 1) << pos;
- bit = 1;
} else {
- range = split;
- bit = 0;
+ range = split + 1;
}
-#endif
- if (range <= (range_t)0x7e) {
- const int shift = kVP8Log2Range[range];
- range = kVP8NewRange[range];
+ {
+ const int shift = 7 ^ BitsLog2Floor(range);
+ range <<= shift;
br->bits_ -= shift;
}
- br->range_ = range;
+ br->range_ = range - 1;
return bit;
}
}
// simplified version of VP8GetBit() for prob=0x80 (note shift is always 1 here)
-static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
+static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
+int VP8GetSigned(VP8BitReader* const br, int v) {
if (br->bits_ < 0) {
VP8LoadNewBytes(br);
}
@@ -166,6 +152,37 @@ static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
}
}
+static WEBP_INLINE int VP8GetBitAlt(VP8BitReader* const br, int prob) {
+ // Don't move this declaration! It makes a big speed difference to store
+ // 'range' *before* calling VP8LoadNewBytes(), even if this function doesn't
+ // alter br->range_ value.
+ range_t range = br->range_;
+ if (br->bits_ < 0) {
+ VP8LoadNewBytes(br);
+ }
+ {
+ const int pos = br->bits_;
+ const range_t split = (range * prob) >> 8;
+ const range_t value = (range_t)(br->value_ >> pos);
+ int bit; // Don't use 'const int bit = (value > split);", it's slower.
+ if (value > split) {
+ range -= split + 1;
+ br->value_ -= (bit_t)(split + 1) << pos;
+ bit = 1;
+ } else {
+ range = split;
+ bit = 0;
+ }
+ if (range <= (range_t)0x7e) {
+ const int shift = kVP8Log2Range[range];
+ range = kVP8NewRange[range];
+ br->bits_ -= shift;
+ }
+ br->range_ = range;
+ return bit;
+ }
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/thirdparty/libwebp/utils/bit_reader.c b/thirdparty/libwebp/utils/bit_reader_utils.c
index 2eb46e0b4b..053b710bb8 100644
--- a/thirdparty/libwebp/utils/bit_reader.c
+++ b/thirdparty/libwebp/utils/bit_reader_utils.c
@@ -15,7 +15,7 @@
#include "../webp/config.h"
#endif
-#include "./bit_reader_inl.h"
+#include "./bit_reader_inl_utils.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/bit_reader.h b/thirdparty/libwebp/utils/bit_reader_utils.h
index ea5c584eb4..ea5c584eb4 100644
--- a/thirdparty/libwebp/utils/bit_reader.h
+++ b/thirdparty/libwebp/utils/bit_reader_utils.h
diff --git a/thirdparty/libwebp/utils/bit_writer.c b/thirdparty/libwebp/utils/bit_writer_utils.c
index 064428691b..ab0c49dce8 100644
--- a/thirdparty/libwebp/utils/bit_writer.c
+++ b/thirdparty/libwebp/utils/bit_writer_utils.c
@@ -16,8 +16,8 @@
#include <string.h> // for memcpy()
#include <stdlib.h>
-#include "./bit_writer.h"
-#include "./endian_inl.h"
+#include "./bit_writer_utils.h"
+#include "./endian_inl_utils.h"
#include "./utils.h"
//------------------------------------------------------------------------------
@@ -143,13 +143,13 @@ int VP8PutBitUniform(VP8BitWriter* const bw, int bit) {
void VP8PutBits(VP8BitWriter* const bw, uint32_t value, int nb_bits) {
uint32_t mask;
assert(nb_bits > 0 && nb_bits < 32);
- for (mask = 1u << (nb_bits - 1); mask; mask >>= 1)
+ for (mask = 1u << (nb_bits - 1); mask; mask >>= 1) {
VP8PutBitUniform(bw, value & mask);
+ }
}
void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits) {
- if (!VP8PutBitUniform(bw, value != 0))
- return;
+ if (!VP8PutBitUniform(bw, value != 0)) return;
if (value < 0) {
VP8PutBits(bw, ((-value) << 1) | 1, nb_bits + 1);
} else {
diff --git a/thirdparty/libwebp/utils/bit_writer.h b/thirdparty/libwebp/utils/bit_writer_utils.h
index ef360d1dc6..9c02bbc06d 100644
--- a/thirdparty/libwebp/utils/bit_writer.h
+++ b/thirdparty/libwebp/utils/bit_writer_utils.h
@@ -54,7 +54,8 @@ int VP8BitWriterAppend(VP8BitWriter* const bw,
// return approximate write position (in bits)
static WEBP_INLINE uint64_t VP8BitWriterPos(const VP8BitWriter* const bw) {
- return (uint64_t)(bw->pos_ + bw->run_) * 8 + 8 + bw->nb_bits_;
+ const uint64_t nb_bits = 8 + bw->nb_bits_; // bw->nb_bits_ is <= 0, note
+ return (bw->pos_ + bw->run_) * 8 + nb_bits;
}
// Returns a pointer to the internal buffer.
diff --git a/thirdparty/libwebp/utils/color_cache.c b/thirdparty/libwebp/utils/color_cache_utils.c
index c34b2e7f1a..0172590c48 100644
--- a/thirdparty/libwebp/utils/color_cache.c
+++ b/thirdparty/libwebp/utils/color_cache_utils.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "./color_cache.h"
+#include "./color_cache_utils.h"
#include "./utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/color_cache.h b/thirdparty/libwebp/utils/color_cache_utils.h
index a9a9f64270..c373e6b361 100644
--- a/thirdparty/libwebp/utils/color_cache.h
+++ b/thirdparty/libwebp/utils/color_cache_utils.h
@@ -28,7 +28,11 @@ typedef struct {
int hash_bits_;
} VP8LColorCache;
-static const uint32_t kHashMul = 0x1e35a7bd;
+static const uint64_t kHashMul = 0x1e35a7bdull;
+
+static WEBP_INLINE int HashPix(uint32_t argb, int shift) {
+ return (int)(((argb * kHashMul) & 0xffffffffu) >> shift);
+}
static WEBP_INLINE uint32_t VP8LColorCacheLookup(
const VP8LColorCache* const cc, uint32_t key) {
@@ -44,19 +48,20 @@ static WEBP_INLINE void VP8LColorCacheSet(const VP8LColorCache* const cc,
static WEBP_INLINE void VP8LColorCacheInsert(const VP8LColorCache* const cc,
uint32_t argb) {
- const uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
+ const int key = HashPix(argb, cc->hash_shift_);
cc->colors_[key] = argb;
}
static WEBP_INLINE int VP8LColorCacheGetIndex(const VP8LColorCache* const cc,
uint32_t argb) {
- return (kHashMul * argb) >> cc->hash_shift_;
+ return HashPix(argb, cc->hash_shift_);
}
+// Return the key if cc contains argb, and -1 otherwise.
static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc,
uint32_t argb) {
- const uint32_t key = (kHashMul * argb) >> cc->hash_shift_;
- return (cc->colors_[key] == argb);
+ const int key = HashPix(argb, cc->hash_shift_);
+ return (cc->colors_[key] == argb) ? key : -1;
}
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/endian_inl.h b/thirdparty/libwebp/utils/endian_inl_utils.h
index e11260ff7d..e11260ff7d 100644
--- a/thirdparty/libwebp/utils/endian_inl.h
+++ b/thirdparty/libwebp/utils/endian_inl_utils.h
diff --git a/thirdparty/libwebp/utils/filters.c b/thirdparty/libwebp/utils/filters_utils.c
index 15543b1271..49c1d18a22 100644
--- a/thirdparty/libwebp/utils/filters.c
+++ b/thirdparty/libwebp/utils/filters_utils.c
@@ -11,7 +11,7 @@
//
// Author: Urvang (urvang@google.com)
-#include "./filters.h"
+#include "./filters_utils.h"
#include <stdlib.h>
#include <string.h>
diff --git a/thirdparty/libwebp/utils/filters.h b/thirdparty/libwebp/utils/filters_utils.h
index 088b132fc5..088b132fc5 100644
--- a/thirdparty/libwebp/utils/filters.h
+++ b/thirdparty/libwebp/utils/filters_utils.h
diff --git a/thirdparty/libwebp/utils/huffman_encode.c b/thirdparty/libwebp/utils/huffman_encode_utils.c
index 4e5ef6b447..f9504658ea 100644
--- a/thirdparty/libwebp/utils/huffman_encode.c
+++ b/thirdparty/libwebp/utils/huffman_encode_utils.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "./huffman_encode.h"
+#include "./huffman_encode_utils.h"
#include "./utils.h"
#include "../webp/format_constants.h"
diff --git a/thirdparty/libwebp/utils/huffman_encode.h b/thirdparty/libwebp/utils/huffman_encode_utils.h
index a157165148..a157165148 100644
--- a/thirdparty/libwebp/utils/huffman_encode.h
+++ b/thirdparty/libwebp/utils/huffman_encode_utils.h
diff --git a/thirdparty/libwebp/utils/huffman.c b/thirdparty/libwebp/utils/huffman_utils.c
index 36e5502836..008b5d746f 100644
--- a/thirdparty/libwebp/utils/huffman.c
+++ b/thirdparty/libwebp/utils/huffman_utils.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "./huffman.h"
+#include "./huffman_utils.h"
#include "./utils.h"
#include "../webp/format_constants.h"
@@ -45,7 +45,7 @@ static WEBP_INLINE uint32_t GetNextKey(uint32_t key, int len) {
while (key & step) {
step >>= 1;
}
- return (key & (step - 1)) + step;
+ return step ? (key & (step - 1)) + step : key;
}
// Stores code in table[0], table[step], table[2*step], ..., table[end].
@@ -75,11 +75,13 @@ static WEBP_INLINE int NextTableBitSize(const int* const count,
return len - root_bits;
}
-int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
- const int code_lengths[], int code_lengths_size) {
+// sorted[code_lengths_size] is a pre-allocated array for sorting symbols
+// by code length.
+static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
+ const int code_lengths[], int code_lengths_size,
+ uint16_t sorted[]) {
HuffmanCode* table = root_table; // next available space in table
int total_size = 1 << root_bits; // total size root table + 2nd level table
- int* sorted = NULL; // symbols sorted by code length
int len; // current code length
int symbol; // symbol index in original or sorted table
// number of codes of each length:
@@ -114,11 +116,6 @@ int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
offset[len + 1] = offset[len] + count[len];
}
- sorted = (int*)WebPSafeMalloc(code_lengths_size, sizeof(*sorted));
- if (sorted == NULL) {
- return 0;
- }
-
// Sort symbols by length, by symbol order within each length.
for (symbol = 0; symbol < code_lengths_size; ++symbol) {
const int symbol_code_length = code_lengths[symbol];
@@ -133,7 +130,6 @@ int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
code.bits = 0;
code.value = (uint16_t)sorted[0];
ReplicateValue(table, 1, total_size, code);
- WebPSafeFree(sorted);
return total_size;
}
@@ -153,7 +149,6 @@ int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
num_nodes += num_open;
num_open -= count[len];
if (num_open < 0) {
- WebPSafeFree(sorted);
return 0;
}
for (; count[len] > 0; --count[len]) {
@@ -172,7 +167,6 @@ int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
num_nodes += num_open;
num_open -= count[len];
if (num_open < 0) {
- WebPSafeFree(sorted);
return 0;
}
for (; count[len] > 0; --count[len]) {
@@ -195,11 +189,35 @@ int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
// Check if tree is full.
if (num_nodes != 2 * offset[MAX_ALLOWED_CODE_LENGTH] - 1) {
- WebPSafeFree(sorted);
return 0;
}
}
- WebPSafeFree(sorted);
+ return total_size;
+}
+
+// Maximum code_lengths_size is 2328 (reached for 11-bit color_cache_bits).
+// More commonly, the value is around ~280.
+#define MAX_CODE_LENGTHS_SIZE \
+ ((1 << MAX_CACHE_BITS) + NUM_LITERAL_CODES + NUM_LENGTH_CODES)
+// Cut-off value for switching between heap and stack allocation.
+#define SORTED_SIZE_CUTOFF 512
+int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits,
+ const int code_lengths[], int code_lengths_size) {
+ int total_size;
+ assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE);
+ if (code_lengths_size <= SORTED_SIZE_CUTOFF) {
+ // use local stack-allocated array.
+ uint16_t sorted[SORTED_SIZE_CUTOFF];
+ total_size = BuildHuffmanTable(root_table, root_bits,
+ code_lengths, code_lengths_size, sorted);
+ } else { // rare case. Use heap allocation.
+ uint16_t* const sorted =
+ (uint16_t*)WebPSafeMalloc(code_lengths_size, sizeof(*sorted));
+ if (sorted == NULL) return 0;
+ total_size = BuildHuffmanTable(root_table, root_bits,
+ code_lengths, code_lengths_size, sorted);
+ WebPSafeFree(sorted);
+ }
return total_size;
}
diff --git a/thirdparty/libwebp/utils/huffman.h b/thirdparty/libwebp/utils/huffman_utils.h
index c6dd6aaa45..c6dd6aaa45 100644
--- a/thirdparty/libwebp/utils/huffman.h
+++ b/thirdparty/libwebp/utils/huffman_utils.h
diff --git a/thirdparty/libwebp/utils/quant_levels_dec.c b/thirdparty/libwebp/utils/quant_levels_dec_utils.c
index ee0a3fe127..d4d23d3147 100644
--- a/thirdparty/libwebp/utils/quant_levels_dec.c
+++ b/thirdparty/libwebp/utils/quant_levels_dec_utils.c
@@ -14,7 +14,7 @@
//
// Author: Skal (pascal.massimino@gmail.com)
-#include "./quant_levels_dec.h"
+#include "./quant_levels_dec_utils.h"
#include <string.h> // for memset
diff --git a/thirdparty/libwebp/utils/quant_levels_dec.h b/thirdparty/libwebp/utils/quant_levels_dec_utils.h
index 59a13495d3..59a13495d3 100644
--- a/thirdparty/libwebp/utils/quant_levels_dec.h
+++ b/thirdparty/libwebp/utils/quant_levels_dec_utils.h
diff --git a/thirdparty/libwebp/utils/quant_levels.c b/thirdparty/libwebp/utils/quant_levels_utils.c
index d7c8aab922..73174e8ab9 100644
--- a/thirdparty/libwebp/utils/quant_levels.c
+++ b/thirdparty/libwebp/utils/quant_levels_utils.c
@@ -14,7 +14,7 @@
#include <assert.h>
-#include "./quant_levels.h"
+#include "./quant_levels_utils.h"
#define NUM_SYMBOLS 256
diff --git a/thirdparty/libwebp/utils/quant_levels.h b/thirdparty/libwebp/utils/quant_levels_utils.h
index 1cb5a32cae..1cb5a32cae 100644
--- a/thirdparty/libwebp/utils/quant_levels.h
+++ b/thirdparty/libwebp/utils/quant_levels_utils.h
diff --git a/thirdparty/libwebp/utils/random.c b/thirdparty/libwebp/utils/random_utils.c
index 24e96ad648..9f1e4154a6 100644
--- a/thirdparty/libwebp/utils/random.c
+++ b/thirdparty/libwebp/utils/random_utils.c
@@ -12,7 +12,7 @@
// Author: Skal (pascal.massimino@gmail.com)
#include <string.h>
-#include "./random.h"
+#include "./random_utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/random.h b/thirdparty/libwebp/utils/random_utils.h
index c392a615ca..c392a615ca 100644
--- a/thirdparty/libwebp/utils/random.h
+++ b/thirdparty/libwebp/utils/random_utils.h
diff --git a/thirdparty/libwebp/utils/rescaler.c b/thirdparty/libwebp/utils/rescaler_utils.c
index d2278a52ff..0d1f80da24 100644
--- a/thirdparty/libwebp/utils/rescaler.c
+++ b/thirdparty/libwebp/utils/rescaler_utils.c
@@ -15,7 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include "../dsp/dsp.h"
-#include "./rescaler.h"
+#include "./rescaler_utils.h"
//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/rescaler.h b/thirdparty/libwebp/utils/rescaler_utils.h
index 98b01a76d0..98b01a76d0 100644
--- a/thirdparty/libwebp/utils/rescaler.h
+++ b/thirdparty/libwebp/utils/rescaler_utils.h
diff --git a/thirdparty/libwebp/utils/thread.c b/thirdparty/libwebp/utils/thread_utils.c
index 93f7622797..1729060c70 100644
--- a/thirdparty/libwebp/utils/thread.c
+++ b/thirdparty/libwebp/utils/thread_utils.c
@@ -13,7 +13,7 @@
#include <assert.h>
#include <string.h> // for memset()
-#include "./thread.h"
+#include "./thread_utils.h"
#include "./utils.h"
#ifdef WEBP_USE_THREAD
@@ -183,8 +183,7 @@ static int pthread_cond_wait(pthread_cond_t* const condition,
#else
// note that there is a consumer available so the signal isn't dropped in
// pthread_cond_signal
- if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL))
- return 1;
+ if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL)) return 1;
// now unlock the mutex so pthread_cond_signal may be issued
pthread_mutex_unlock(mutex);
ok = (WaitForSingleObject(condition->signal_event_, INFINITE) ==
@@ -226,8 +225,7 @@ static THREADFN ThreadLoop(void* ptr) {
}
// main thread state control
-static void ChangeState(WebPWorker* const worker,
- WebPWorkerStatus new_status) {
+static void ChangeState(WebPWorker* const worker, WebPWorkerStatus new_status) {
// No-op when attempting to change state on a thread that didn't come up.
// Checking status_ without acquiring the lock first would result in a data
// race.
diff --git a/thirdparty/libwebp/utils/thread.h b/thirdparty/libwebp/utils/thread_utils.h
index 8408311855..8408311855 100644
--- a/thirdparty/libwebp/utils/thread.h
+++ b/thirdparty/libwebp/utils/thread_utils.h
diff --git a/thirdparty/libwebp/utils/utils.c b/thirdparty/libwebp/utils/utils.c
index 82dbf8d5e5..504d924b60 100644
--- a/thirdparty/libwebp/utils/utils.c
+++ b/thirdparty/libwebp/utils/utils.c
@@ -25,7 +25,7 @@
// http://valgrind.org/docs/manual/ms-manual.html
// Here is an example command line:
/* valgrind --tool=massif --massif-out-file=massif.out \
- --stacks=yes --alloc-fn=WebPSafeAlloc --alloc-fn=WebPSafeCalloc
+ --stacks=yes --alloc-fn=WebPSafeMalloc --alloc-fn=WebPSafeCalloc
ms_print massif.out
*/
// In addition:
@@ -243,8 +243,7 @@ void WebPCopyPixels(const WebPPicture* const src, WebPPicture* const dst) {
//------------------------------------------------------------------------------
-#define MAX_COLOR_COUNT MAX_PALETTE_SIZE
-#define COLOR_HASH_SIZE (MAX_COLOR_COUNT * 4)
+#define COLOR_HASH_SIZE (MAX_PALETTE_SIZE * 4)
#define COLOR_HASH_RIGHT_SHIFT 22 // 32 - log2(COLOR_HASH_SIZE).
int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
@@ -253,7 +252,7 @@ int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
int num_colors = 0;
uint8_t in_use[COLOR_HASH_SIZE] = { 0 };
uint32_t colors[COLOR_HASH_SIZE];
- static const uint32_t kHashMul = 0x1e35a7bdU;
+ static const uint64_t kHashMul = 0x1e35a7bdull;
const uint32_t* argb = pic->argb;
const int width = pic->width;
const int height = pic->height;
@@ -268,14 +267,14 @@ int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
continue;
}
last_pix = argb[x];
- key = (kHashMul * last_pix) >> COLOR_HASH_RIGHT_SHIFT;
+ key = ((last_pix * kHashMul) & 0xffffffffu) >> COLOR_HASH_RIGHT_SHIFT;
while (1) {
if (!in_use[key]) {
colors[key] = last_pix;
in_use[key] = 1;
++num_colors;
- if (num_colors > MAX_COLOR_COUNT) {
- return MAX_COLOR_COUNT + 1; // Exact count not needed.
+ if (num_colors > MAX_PALETTE_SIZE) {
+ return MAX_PALETTE_SIZE + 1; // Exact count not needed.
}
break;
} else if (colors[key] == last_pix) {
@@ -302,8 +301,30 @@ int WebPGetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
return num_colors;
}
-#undef MAX_COLOR_COUNT
#undef COLOR_HASH_SIZE
#undef COLOR_HASH_RIGHT_SHIFT
//------------------------------------------------------------------------------
+
+#if defined(WEBP_NEED_LOG_TABLE_8BIT)
+const uint8_t WebPLogTable8bit[256] = { // 31 ^ clz(i)
+ 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
+};
+#endif
+
+//------------------------------------------------------------------------------
diff --git a/thirdparty/libwebp/utils/utils.h b/thirdparty/libwebp/utils/utils.h
index 3a5d4e6a78..3ab459050a 100644
--- a/thirdparty/libwebp/utils/utils.h
+++ b/thirdparty/libwebp/utils/utils.h
@@ -62,7 +62,6 @@ WEBP_EXTERN(void) WebPSafeFree(void* const ptr);
#define WEBP_ALIGN_CST 31
#define WEBP_ALIGN(PTR) (((uintptr_t)(PTR) + WEBP_ALIGN_CST) & ~WEBP_ALIGN_CST)
-#if defined(WEBP_FORCE_ALIGNED)
#include <string.h>
// memcpy() is the safe way of moving potentially unaligned 32b memory.
static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
@@ -73,16 +72,6 @@ static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
static WEBP_INLINE void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
memcpy(ptr, &val, sizeof(val));
}
-#else
-static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
-uint32_t WebPMemToUint32(const uint8_t* const ptr) {
- return *(const uint32_t*)ptr;
-}
-static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
-void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
- *(uint32_t*)ptr = val;
-}
-#endif
//------------------------------------------------------------------------------
// Reading/writing data.
@@ -118,6 +107,19 @@ static WEBP_INLINE void PutLE32(uint8_t* const data, uint32_t val) {
PutLE16(data + 2, (int)(val >> 16));
}
+// Returns 31 ^ clz(n) = log2(n). This is the default C-implementation, either
+// based on table or not. Can be used as fallback if clz() is not available.
+#define WEBP_NEED_LOG_TABLE_8BIT
+extern const uint8_t WebPLogTable8bit[256];
+static WEBP_INLINE int WebPLog2FloorC(uint32_t n) {
+ int log = 0;
+ while (n >= 256) {
+ log += 8;
+ n >>= 8;
+ }
+ return log + WebPLogTable8bit[n];
+}
+
// Returns (int)floor(log2(n)). n must be > 0.
// use GNU builtins where available.
#if defined(__GNUC__) && \
@@ -135,22 +137,8 @@ static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
_BitScanReverse(&first_set_bit, n);
return first_set_bit;
}
-#else
-static WEBP_INLINE int BitsLog2Floor(uint32_t n) {
- int log = 0;
- uint32_t value = n;
- int i;
-
- for (i = 4; i >= 0; --i) {
- const int shift = (1 << i);
- const uint32_t x = value >> shift;
- if (x != 0) {
- value = x;
- log += shift;
- }
- }
- return log;
-}
+#else // default: use the C-version.
+static WEBP_INLINE int BitsLog2Floor(uint32_t n) { return WebPLog2FloorC(n); }
#endif
//------------------------------------------------------------------------------
@@ -172,12 +160,12 @@ WEBP_EXTERN(void) WebPCopyPixels(const struct WebPPicture* const src,
// Unique colors.
// Returns count of unique colors in 'pic', assuming pic->use_argb is true.
-// If the unique color count is more than MAX_COLOR_COUNT, returns
-// MAX_COLOR_COUNT+1.
+// If the unique color count is more than MAX_PALETTE_SIZE, returns
+// MAX_PALETTE_SIZE+1.
// If 'palette' is not NULL and number of unique colors is less than or equal to
-// MAX_COLOR_COUNT, also outputs the actual unique colors into 'palette'.
+// MAX_PALETTE_SIZE, also outputs the actual unique colors into 'palette'.
// Note: 'palette' is assumed to be an array already allocated with at least
-// MAX_COLOR_COUNT elements.
+// MAX_PALETTE_SIZE elements.
WEBP_EXTERN(int) WebPGetColorPalette(const struct WebPPicture* const pic,
uint32_t* const palette);
diff --git a/thirdparty/libwebp/webp/config.h b/thirdparty/libwebp/webp/config.h
deleted file mode 100644
index 0ce1c7064d..0000000000
--- a/thirdparty/libwebp/webp/config.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* src/webp/config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define if building universal (internal helper macro) */
-#undef AC_APPLE_UNIVERSAL_BUILD
-
-/* Set to 1 if __builtin_bswap16 is available */
-#undef HAVE_BUILTIN_BSWAP16
-
-/* Set to 1 if __builtin_bswap32 is available */
-#undef HAVE_BUILTIN_BSWAP32
-
-/* Set to 1 if __builtin_bswap64 is available */
-#undef HAVE_BUILTIN_BSWAP64
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <GLUT/glut.h> header file. */
-#undef HAVE_GLUT_GLUT_H
-
-/* Define to 1 if you have the <GL/glut.h> header file. */
-#undef HAVE_GL_GLUT_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <OpenGL/glut.h> header file. */
-#undef HAVE_OPENGL_GLUT_H
-
-/* Have PTHREAD_PRIO_INHERIT. */
-#undef HAVE_PTHREAD_PRIO_INHERIT
-
-/* Define to 1 if you have the <shlwapi.h> header file. */
-#undef HAVE_SHLWAPI_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the <wincodec.h> header file. */
-#undef HAVE_WINCODEC_H
-
-/* Define to 1 if you have the <windows.h> header file. */
-#undef HAVE_WINDOWS_H
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to necessary symbol if this constant uses a non-standard name on
- your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Enable experimental code */
-#undef WEBP_EXPERIMENTAL_FEATURES
-
-/* Define to 1 to force aligned memory operations */
-#undef WEBP_FORCE_ALIGNED
-
-/* Set to 1 if AVX2 is supported */
-#undef WEBP_HAVE_AVX2
-
-/* Set to 1 if GIF library is installed */
-#undef WEBP_HAVE_GIF
-
-/* Set to 1 if OpenGL is supported */
-#undef WEBP_HAVE_GL
-
-/* Set to 1 if JPEG library is installed */
-#undef WEBP_HAVE_JPEG
-
-/* Set to 1 if NEON is supported */
-#undef WEBP_HAVE_NEON
-
-/* Set to 1 if runtime detection of NEON is enabled */
-#undef WEBP_HAVE_NEON_RTCD
-
-/* Set to 1 if PNG library is installed */
-#undef WEBP_HAVE_PNG
-
-/* Set to 1 if SSE2 is supported */
-#undef WEBP_HAVE_SSE2
-
-/* Set to 1 if SSE4.1 is supported */
-#undef WEBP_HAVE_SSE41
-
-/* Set to 1 if TIFF library is installed */
-#undef WEBP_HAVE_TIFF
-
-/* Undefine this to disable thread support. */
-#undef WEBP_USE_THREAD
-
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
- significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# undef WORDS_BIGENDIAN
-# endif
-#endif
diff --git a/thirdparty/libwebp/webp/encode.h b/thirdparty/libwebp/webp/encode.h
index b65e27e7fd..35fde1d052 100644
--- a/thirdparty/libwebp/webp/encode.h
+++ b/thirdparty/libwebp/webp/encode.h
@@ -20,7 +20,7 @@
extern "C" {
#endif
-#define WEBP_ENCODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b)
+#define WEBP_ENCODER_ABI_VERSION 0x020e // MAJOR(8b) + MINOR(8b)
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
// the types are left here for reference.
@@ -141,12 +141,10 @@ struct WebPConfig {
// RGB information for better compression. The default
// value is 0.
-#ifdef WEBP_EXPERIMENTAL_FEATURES
- int delta_palettization;
+ int use_delta_palette; // reserved for future lossless feature
+ int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion
+
uint32_t pad[2]; // padding for later use
-#else
- uint32_t pad[3]; // padding for later use
-#endif // WEBP_EXPERIMENTAL_FEATURES
};
// Enumerate some predefined settings for WebPConfig, depending on the type
@@ -388,9 +386,24 @@ WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
// Returns false in case of memory allocation error.
WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
+// Compute the single distortion for packed planes of samples.
+// 'src' will be compared to 'ref', and the raw distortion stored into
+// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
+// stored in '*result'.
+// 'x_step' is the horizontal stride (in bytes) between samples.
+// 'src/ref_stride' is the byte distance between rows.
+// Returns false in case of error (bad parameter, memory allocation error, ...).
+WEBP_EXTERN(int) WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
+ const uint8_t* ref, size_t ref_stride,
+ int width, int height,
+ size_t x_step,
+ int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM
+ float* distortion, float* result);
+
// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
-// are in dB, stored in result[] in the Y/U/V/Alpha/All or B/G/R/A/All order.
-// Returns false in case of error (src and ref don't have same dimension, ...)
+// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
+// always performed using ARGB samples. Hence if the input is YUV(A), the
+// picture will be internally converted to ARGB (just for the measurement).
// Warning: this function is rather CPU-intensive.
WEBP_EXTERN(int) WebPPictureDistortion(
const WebPPicture* src, const WebPPicture* ref,
@@ -473,11 +486,13 @@ WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
WEBP_EXTERN(int) WebPPictureARGBToYUVADithered(
WebPPicture* picture, WebPEncCSP colorspace, float dithering);
-// Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion.
+// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
// Downsampling is handled with extra care in case of color clipping. This
// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
-// YUV representation.
+// and sharper YUV representation.
// Returns false in case of error.
+WEBP_EXTERN(int) WebPPictureSharpARGBToYUVA(WebPPicture* picture);
+// kept for backward compatibility:
WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture);
// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
diff --git a/thirdparty/libwebp/webp/format_constants.h b/thirdparty/libwebp/webp/format_constants.h
index b6e78a643e..329fc8a3b0 100644
--- a/thirdparty/libwebp/webp/format_constants.h
+++ b/thirdparty/libwebp/webp/format_constants.h
@@ -72,14 +72,13 @@ typedef enum {
#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").
#define ANMF_CHUNK_SIZE 16 // Size of an ANMF chunk.
#define ANIM_CHUNK_SIZE 6 // Size of an ANIM chunk.
-#define FRGM_CHUNK_SIZE 6 // Size of a FRGM chunk.
#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.
#define MAX_CANVAS_SIZE (1 << 24) // 24-bit max for VP8X width/height.
#define MAX_IMAGE_AREA (1ULL << 32) // 32-bit max for width x height.
#define MAX_LOOP_COUNT (1 << 16) // maximum value for loop-count
#define MAX_DURATION (1 << 24) // maximum duration
-#define MAX_POSITION_OFFSET (1 << 24) // maximum frame/fragment x/y offset
+#define MAX_POSITION_OFFSET (1 << 24) // maximum frame x/y offset
// Maximum chunk payload is such that adding the header and padding won't
// overflow a uint32_t.
diff --git a/thirdparty/libwebp/webp/mux.h b/thirdparty/libwebp/webp/mux.h
index b72658c741..daccc65e86 100644
--- a/thirdparty/libwebp/webp/mux.h
+++ b/thirdparty/libwebp/webp/mux.h
@@ -21,13 +21,13 @@
extern "C" {
#endif
-#define WEBP_MUX_ABI_VERSION 0x0106 // MAJOR(8b) + MINOR(8b)
+#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
//------------------------------------------------------------------------------
// Mux API
//
// This API allows manipulation of WebP container images containing features
-// like color profile, metadata, animation and fragmented images.
+// like color profile, metadata, animation.
//
// Code Example#1: Create a WebPMux object with image data, color profile and
// XMP metadata.
@@ -81,16 +81,16 @@ typedef enum WebPMuxError {
// IDs for different types of chunks.
typedef enum WebPChunkId {
- WEBP_CHUNK_VP8X, // VP8X
- WEBP_CHUNK_ICCP, // ICCP
- WEBP_CHUNK_ANIM, // ANIM
- WEBP_CHUNK_ANMF, // ANMF
- WEBP_CHUNK_FRGM, // FRGM
- WEBP_CHUNK_ALPHA, // ALPH
- WEBP_CHUNK_IMAGE, // VP8/VP8L
- WEBP_CHUNK_EXIF, // EXIF
- WEBP_CHUNK_XMP, // XMP
- WEBP_CHUNK_UNKNOWN, // Other chunks.
+ WEBP_CHUNK_VP8X, // VP8X
+ WEBP_CHUNK_ICCP, // ICCP
+ WEBP_CHUNK_ANIM, // ANIM
+ WEBP_CHUNK_ANMF, // ANMF
+ WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM)
+ WEBP_CHUNK_ALPHA, // ALPH
+ WEBP_CHUNK_IMAGE, // VP8/VP8L
+ WEBP_CHUNK_EXIF, // EXIF
+ WEBP_CHUNK_XMP, // XMP
+ WEBP_CHUNK_UNKNOWN, // Other chunks.
WEBP_CHUNK_NIL
} WebPChunkId;
@@ -142,7 +142,7 @@ static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
// Non-image chunks.
// Note: Only non-image related chunks should be managed through chunk APIs.
-// (Image related chunks are: "ANMF", "FRGM", "VP8 ", "VP8L" and "ALPH").
+// (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
// To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(),
// WebPMuxGetFrame() and WebPMuxDeleteFrame().
@@ -195,7 +195,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteChunk(
//------------------------------------------------------------------------------
// Images.
-// Encapsulates data about a single frame/fragment.
+// Encapsulates data about a single frame.
struct WebPMuxFrameInfo {
WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream
// or a single-image WebP file.
@@ -203,19 +203,19 @@ struct WebPMuxFrameInfo {
int y_offset; // y-offset of the frame.
int duration; // duration of the frame (in milliseconds).
- WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF,
- // WEBP_CHUNK_FRGM or WEBP_CHUNK_IMAGE
+ WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF
+ // or WEBP_CHUNK_IMAGE
WebPMuxAnimDispose dispose_method; // Disposal method for the frame.
WebPMuxAnimBlend blend_method; // Blend operation for the frame.
uint32_t pad[1]; // padding for later use
};
-// Sets the (non-animated and non-fragmented) image in the mux object.
-// Note: Any existing images (including frames/fragments) will be removed.
+// Sets the (non-animated) image in the mux object.
+// Note: Any existing images (including frames) will be removed.
// Parameters:
// mux - (in/out) object in which the image is to be set
// bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
-// WebP file (non-animated and non-fragmented)
+// WebP file (non-animated)
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
// object and value 0 indicates data will NOT be copied.
// Returns:
@@ -226,9 +226,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
WebPMux* mux, const WebPData* bitstream, int copy_data);
// Adds a frame at the end of the mux object.
-// Notes: (1) frame.id should be one of WEBP_CHUNK_ANMF or WEBP_CHUNK_FRGM
-// (2) For setting a non-animated non-fragmented image, use
-// WebPMuxSetImage() instead.
+// Notes: (1) frame.id should be WEBP_CHUNK_ANMF
+// (2) For setting a non-animated image, use WebPMuxSetImage() instead.
// (3) Type of frame being pushed must be same as the frames in mux.
// (4) As WebP only supports even offsets, any odd offset will be snapped
// to an even location using: offset &= ~1
@@ -431,9 +430,10 @@ struct WebPAnimEncoderOptions {
// frames in the output. The library may insert some key
// frames as needed to satisfy this criteria.
// Note that these conditions should hold: kmax > kmin
- // and kmin >= kmax / 2 + 1. Also, if kmin == 0, then
- // key-frame insertion is disabled; and if kmax == 0,
- // then all frames will be key-frames.
+ // and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then
+ // key-frame insertion is disabled; and if kmax == 1,
+ // then all frames will be key-frames (kmin value does
+ // not matter for these special cases).
int allow_mixed; // If true, use mixed compression mode; may choose
// either lossy and lossless for each frame.
int verbose; // If true, print info and warning messages to stderr.
diff --git a/thirdparty/libwebp/webp/mux_types.h b/thirdparty/libwebp/webp/mux_types.h
index c94043a3c0..b37e2c67aa 100644
--- a/thirdparty/libwebp/webp/mux_types.h
+++ b/thirdparty/libwebp/webp/mux_types.h
@@ -31,12 +31,13 @@ typedef struct WebPData WebPData;
// VP8X Feature Flags.
typedef enum WebPFeatureFlags {
- FRAGMENTS_FLAG = 0x00000001,
ANIMATION_FLAG = 0x00000002,
XMP_FLAG = 0x00000004,
EXIF_FLAG = 0x00000008,
ALPHA_FLAG = 0x00000010,
- ICCP_FLAG = 0x00000020
+ ICCP_FLAG = 0x00000020,
+
+ ALL_VALID_FLAGS = 0x0000003e
} WebPFeatureFlags;
// Dispose method (animation only). Indicates how the area used by the current
diff --git a/thirdparty/stb_vorbis/stb_vorbis.c b/thirdparty/stb_vorbis/stb_vorbis.c
new file mode 100644
index 0000000000..c4f24d5898
--- /dev/null
+++ b/thirdparty/stb_vorbis/stb_vorbis.c
@@ -0,0 +1,5399 @@
+// Ogg Vorbis audio decoder - v1.09 - public domain
+// http://nothings.org/stb_vorbis/
+//
+// Original version written by Sean Barrett in 2007.
+//
+// Originally sponsored by RAD Game Tools. Seeking sponsored
+// by Phillip Bennefall, Marc Andersen, Aaron Baker, Elias Software,
+// Aras Pranckevicius, and Sean Barrett.
+//
+// LICENSE
+//
+// This software is dual-licensed to the public domain and under the following
+// license: you are granted a perpetual, irrevocable license to copy, modify,
+// publish, and distribute this file as you see fit.
+//
+// No warranty for any purpose is expressed or implied by the author (nor
+// by RAD Game Tools). Report bugs and send enhancements to the author.
+//
+// Limitations:
+//
+// - floor 0 not supported (used in old ogg vorbis files pre-2004)
+// - lossless sample-truncation at beginning ignored
+// - cannot concatenate multiple vorbis streams
+// - sample positions are 32-bit, limiting seekable 192Khz
+// files to around 6 hours (Ogg supports 64-bit)
+//
+// Feature contributors:
+// Dougall Johnson (sample-exact seeking)
+//
+// Bugfix/warning contributors:
+// Terje Mathisen Niklas Frykholm Andy Hill
+// Casey Muratori John Bolton Gargaj
+// Laurent Gomila Marc LeBlanc Ronny Chevalier
+// Bernhard Wodo Evan Balster alxprd@github
+// Tom Beaumont Ingo Leitgeb Nicolas Guillemot
+// Phillip Bennefall Rohit Thiago Goulart
+// manxorist@github saga musix
+//
+// Partial history:
+// 1.09 - 2016/04/04 - back out 'truncation of last frame' fix from previous version
+// 1.08 - 2016/04/02 - warnings; setup memory leaks; truncation of last frame
+// 1.07 - 2015/01/16 - fixes for crashes on invalid files; warning fixes; const
+// 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson)
+// some crash fixes when out of memory or with corrupt files
+// fix some inappropriately signed shifts
+// 1.05 - 2015/04/19 - don't define __forceinline if it's redundant
+// 1.04 - 2014/08/27 - fix missing const-correct case in API
+// 1.03 - 2014/08/07 - warning fixes
+// 1.02 - 2014/07/09 - declare qsort comparison as explicitly _cdecl in Windows
+// 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float (interleaved was correct)
+// 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in >2-channel;
+// (API change) report sample rate for decode-full-file funcs
+//
+// See end of file for full version history.
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// HEADER BEGINS HERE
+//
+
+#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H
+#define STB_VORBIS_INCLUDE_STB_VORBIS_H
+
+#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
+#define STB_VORBIS_NO_STDIO 1
+#endif
+
+#ifndef STB_VORBIS_NO_STDIO
+#include <stdio.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/////////// THREAD SAFETY
+
+// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
+// them from multiple threads at the same time. However, you can have multiple
+// stb_vorbis* handles and decode from them independently in multiple thrads.
+
+
+/////////// MEMORY ALLOCATION
+
+// normally stb_vorbis uses malloc() to allocate memory at startup,
+// and alloca() to allocate temporary memory during a frame on the
+// stack. (Memory consumption will depend on the amount of setup
+// data in the file and how you set the compile flags for speed
+// vs. size. In my test files the maximal-size usage is ~150KB.)
+//
+// You can modify the wrapper functions in the source (setup_malloc,
+// setup_temp_malloc, temp_malloc) to change this behavior, or you
+// can use a simpler allocation model: you pass in a buffer from
+// which stb_vorbis will allocate _all_ its memory (including the
+// temp memory). "open" may fail with a VORBIS_outofmem if you
+// do not pass in enough data; there is no way to determine how
+// much you do need except to succeed (at which point you can
+// query get_info to find the exact amount required. yes I know
+// this is lame).
+//
+// If you pass in a non-NULL buffer of the type below, allocation
+// will occur from it as described above. Otherwise just pass NULL
+// to use malloc()/alloca()
+
+typedef struct
+{
+ char *alloc_buffer;
+ int alloc_buffer_length_in_bytes;
+} stb_vorbis_alloc;
+
+
+/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES
+
+typedef struct stb_vorbis stb_vorbis;
+
+typedef struct
+{
+ unsigned int sample_rate;
+ int channels;
+
+ unsigned int setup_memory_required;
+ unsigned int setup_temp_memory_required;
+ unsigned int temp_memory_required;
+
+ int max_frame_size;
+} stb_vorbis_info;
+
+// get general information about the file
+extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
+
+// get the last error detected (clears it, too)
+extern int stb_vorbis_get_error(stb_vorbis *f);
+
+// close an ogg vorbis file and free all memory in use
+extern void stb_vorbis_close(stb_vorbis *f);
+
+// this function returns the offset (in samples) from the beginning of the
+// file that will be returned by the next decode, if it is known, or -1
+// otherwise. after a flush_pushdata() call, this may take a while before
+// it becomes valid again.
+// NOT WORKING YET after a seek with PULLDATA API
+extern int stb_vorbis_get_sample_offset(stb_vorbis *f);
+
+// returns the current seek point within the file, or offset from the beginning
+// of the memory buffer. In pushdata mode it returns 0.
+extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
+
+/////////// PUSHDATA API
+
+#ifndef STB_VORBIS_NO_PUSHDATA_API
+
+// this API allows you to get blocks of data from any source and hand
+// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
+// you how much it used, and you have to give it the rest next time;
+// and stb_vorbis may not have enough data to work with and you will
+// need to give it the same data again PLUS more. Note that the Vorbis
+// specification does not bound the size of an individual frame.
+
+extern stb_vorbis *stb_vorbis_open_pushdata(
+ const unsigned char * datablock, int datablock_length_in_bytes,
+ int *datablock_memory_consumed_in_bytes,
+ int *error,
+ const stb_vorbis_alloc *alloc_buffer);
+// create a vorbis decoder by passing in the initial data block containing
+// the ogg&vorbis headers (you don't need to do parse them, just provide
+// the first N bytes of the file--you're told if it's not enough, see below)
+// on success, returns an stb_vorbis *, does not set error, returns the amount of
+// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
+// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
+// if returns NULL and *error is VORBIS_need_more_data, then the input block was
+// incomplete and you need to pass in a larger block from the start of the file
+
+extern int stb_vorbis_decode_frame_pushdata(
+ stb_vorbis *f,
+ const unsigned char *datablock, int datablock_length_in_bytes,
+ int *channels, // place to write number of float * buffers
+ float ***output, // place to write float ** array of float * buffers
+ int *samples // place to write number of output samples
+ );
+// decode a frame of audio sample data if possible from the passed-in data block
+//
+// return value: number of bytes we used from datablock
+//
+// possible cases:
+// 0 bytes used, 0 samples output (need more data)
+// N bytes used, 0 samples output (resynching the stream, keep going)
+// N bytes used, M samples output (one frame of data)
+// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
+// frame, because Vorbis always "discards" the first frame.
+//
+// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
+// instead only datablock_length_in_bytes-3 or less. This is because it wants
+// to avoid missing parts of a page header if they cross a datablock boundary,
+// without writing state-machiney code to record a partial detection.
+//
+// The number of channels returned are stored in *channels (which can be
+// NULL--it is always the same as the number of channels reported by
+// get_info). *output will contain an array of float* buffers, one per
+// channel. In other words, (*output)[0][0] contains the first sample from
+// the first channel, and (*output)[1][0] contains the first sample from
+// the second channel.
+
+extern void stb_vorbis_flush_pushdata(stb_vorbis *f);
+// inform stb_vorbis that your next datablock will not be contiguous with
+// previous ones (e.g. you've seeked in the data); future attempts to decode
+// frames will cause stb_vorbis to resynchronize (as noted above), and
+// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it
+// will begin decoding the _next_ frame.
+//
+// if you want to seek using pushdata, you need to seek in your file, then
+// call stb_vorbis_flush_pushdata(), then start calling decoding, then once
+// decoding is returning you data, call stb_vorbis_get_sample_offset, and
+// if you don't like the result, seek your file again and repeat.
+#endif
+
+
+////////// PULLING INPUT API
+
+#ifndef STB_VORBIS_NO_PULLDATA_API
+// This API assumes stb_vorbis is allowed to pull data from a source--
+// either a block of memory containing the _entire_ vorbis stream, or a
+// FILE * that you or it create, or possibly some other reading mechanism
+// if you go modify the source to replace the FILE * case with some kind
+// of callback to your code. (But if you don't support seeking, you may
+// just want to go ahead and use pushdata.)
+
+#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
+extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
+#endif
+#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
+extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
+#endif
+// decode an entire file and output the data interleaved into a malloc()ed
+// buffer stored in *output. The return value is the number of samples
+// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
+// When you're done with it, just free() the pointer returned in *output.
+
+extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
+ int *error, const stb_vorbis_alloc *alloc_buffer);
+// create an ogg vorbis decoder from an ogg vorbis stream in memory (note
+// this must be the entire stream!). on failure, returns NULL and sets *error
+
+#ifndef STB_VORBIS_NO_STDIO
+extern stb_vorbis * stb_vorbis_open_filename(const char *filename,
+ int *error, const stb_vorbis_alloc *alloc_buffer);
+// create an ogg vorbis decoder from a filename via fopen(). on failure,
+// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
+
+extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
+ int *error, const stb_vorbis_alloc *alloc_buffer);
+// create an ogg vorbis decoder from an open FILE *, looking for a stream at
+// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
+// note that stb_vorbis must "own" this stream; if you seek it in between
+// calls to stb_vorbis, it will become confused. Morever, if you attempt to
+// perform stb_vorbis_seek_*() operations on this file, it will assume it
+// owns the _entire_ rest of the file after the start point. Use the next
+// function, stb_vorbis_open_file_section(), to limit it.
+
+extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
+ int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len);
+// create an ogg vorbis decoder from an open FILE *, looking for a stream at
+// the _current_ seek point (ftell); the stream will be of length 'len' bytes.
+// on failure, returns NULL and sets *error. note that stb_vorbis must "own"
+// this stream; if you seek it in between calls to stb_vorbis, it will become
+// confused.
+#endif
+
+extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
+extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
+// these functions seek in the Vorbis file to (approximately) 'sample_number'.
+// after calling seek_frame(), the next call to get_frame_*() will include
+// the specified sample. after calling stb_vorbis_seek(), the next call to
+// stb_vorbis_get_samples_* will start with the specified sample. If you
+// do not need to seek to EXACTLY the target sample when using get_samples_*,
+// you can also use seek_frame().
+
+extern void stb_vorbis_seek_start(stb_vorbis *f);
+// this function is equivalent to stb_vorbis_seek(f,0)
+
+extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
+extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
+// these functions return the total length of the vorbis stream
+
+extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
+// decode the next frame and return the number of samples. the number of
+// channels returned are stored in *channels (which can be NULL--it is always
+// the same as the number of channels reported by get_info). *output will
+// contain an array of float* buffers, one per channel. These outputs will
+// be overwritten on the next call to stb_vorbis_get_frame_*.
+//
+// You generally should not intermix calls to stb_vorbis_get_frame_*()
+// and stb_vorbis_get_samples_*(), since the latter calls the former.
+
+#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
+extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
+extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples);
+#endif
+// decode the next frame and return the number of *samples* per channel.
+// Note that for interleaved data, you pass in the number of shorts (the
+// size of your array), but the return value is the number of samples per
+// channel, not the total number of samples.
+//
+// The data is coerced to the number of channels you request according to the
+// channel coercion rules (see below). You must pass in the size of your
+// buffer(s) so that stb_vorbis will not overwrite the end of the buffer.
+// The maximum buffer size needed can be gotten from get_info(); however,
+// the Vorbis I specification implies an absolute maximum of 4096 samples
+// per channel.
+
+// Channel coercion rules:
+// Let M be the number of channels requested, and N the number of channels present,
+// and Cn be the nth channel; let stereo L be the sum of all L and center channels,
+// and stereo R be the sum of all R and center channels (channel assignment from the
+// vorbis spec).
+// M N output
+// 1 k sum(Ck) for all k
+// 2 * stereo L, stereo R
+// k l k > l, the first l channels, then 0s
+// k l k <= l, the first k channels
+// Note that this is not _good_ surround etc. mixing at all! It's just so
+// you get something useful.
+
+extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
+extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
+// gets num_samples samples, not necessarily on a frame boundary--this requires
+// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES.
+// Returns the number of samples stored per channel; it may be less than requested
+// at the end of the file. If there are no more samples in the file, returns 0.
+
+#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
+extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
+extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
+#endif
+// gets num_samples samples, not necessarily on a frame boundary--this requires
+// buffering so you have to supply the buffers. Applies the coercion rules above
+// to produce 'channels' channels. Returns the number of samples stored per channel;
+// it may be less than requested at the end of the file. If there are no more
+// samples in the file, returns 0.
+
+#endif
+
+//////// ERROR CODES
+
+enum STBVorbisError
+{
+ VORBIS__no_error,
+
+ VORBIS_need_more_data=1, // not a real error
+
+ VORBIS_invalid_api_mixing, // can't mix API modes
+ VORBIS_outofmem, // not enough memory
+ VORBIS_feature_not_supported, // uses floor 0
+ VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small
+ VORBIS_file_open_failure, // fopen() failed
+ VORBIS_seek_without_length, // can't seek in unknown-length file
+
+ VORBIS_unexpected_eof=10, // file is truncated?
+ VORBIS_seek_invalid, // seek past EOF
+
+ // decoding errors (corrupt/invalid stream) -- you probably
+ // don't care about the exact details of these
+
+ // vorbis errors:
+ VORBIS_invalid_setup=20,
+ VORBIS_invalid_stream,
+
+ // ogg errors:
+ VORBIS_missing_capture_pattern=30,
+ VORBIS_invalid_stream_structure_version,
+ VORBIS_continued_packet_flag_invalid,
+ VORBIS_incorrect_stream_serial_number,
+ VORBIS_invalid_first_page,
+ VORBIS_bad_packet_type,
+ VORBIS_cant_find_last_page,
+ VORBIS_seek_failed
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H
+//
+// HEADER ENDS HERE
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef STB_VORBIS_HEADER_ONLY
+
+// global configuration settings (e.g. set these in the project/makefile),
+// or just set them in this file at the top (although ideally the first few
+// should be visible when the header file is compiled too, although it's not
+// crucial)
+
+// STB_VORBIS_NO_PUSHDATA_API
+// does not compile the code for the various stb_vorbis_*_pushdata()
+// functions
+// #define STB_VORBIS_NO_PUSHDATA_API
+
+// STB_VORBIS_NO_PULLDATA_API
+// does not compile the code for the non-pushdata APIs
+// #define STB_VORBIS_NO_PULLDATA_API
+
+// STB_VORBIS_NO_STDIO
+// does not compile the code for the APIs that use FILE *s internally
+// or externally (implied by STB_VORBIS_NO_PULLDATA_API)
+// #define STB_VORBIS_NO_STDIO
+
+// STB_VORBIS_NO_INTEGER_CONVERSION
+// does not compile the code for converting audio sample data from
+// float to integer (implied by STB_VORBIS_NO_PULLDATA_API)
+// #define STB_VORBIS_NO_INTEGER_CONVERSION
+
+// STB_VORBIS_NO_FAST_SCALED_FLOAT
+// does not use a fast float-to-int trick to accelerate float-to-int on
+// most platforms which requires endianness be defined correctly.
+//#define STB_VORBIS_NO_FAST_SCALED_FLOAT
+
+
+// STB_VORBIS_MAX_CHANNELS [number]
+// globally define this to the maximum number of channels you need.
+// The spec does not put a restriction on channels except that
+// the count is stored in a byte, so 255 is the hard limit.
+// Reducing this saves about 16 bytes per value, so using 16 saves
+// (255-16)*16 or around 4KB. Plus anything other memory usage
+// I forgot to account for. Can probably go as low as 8 (7.1 audio),
+// 6 (5.1 audio), or 2 (stereo only).
+#ifndef STB_VORBIS_MAX_CHANNELS
+#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone?
+#endif
+
+// STB_VORBIS_PUSHDATA_CRC_COUNT [number]
+// after a flush_pushdata(), stb_vorbis begins scanning for the
+// next valid page, without backtracking. when it finds something
+// that looks like a page, it streams through it and verifies its
+// CRC32. Should that validation fail, it keeps scanning. But it's
+// possible that _while_ streaming through to check the CRC32 of
+// one candidate page, it sees another candidate page. This #define
+// determines how many "overlapping" candidate pages it can search
+// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas
+// garbage pages could be as big as 64KB, but probably average ~16KB.
+// So don't hose ourselves by scanning an apparent 64KB page and
+// missing a ton of real ones in the interim; so minimum of 2
+#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT
+#define STB_VORBIS_PUSHDATA_CRC_COUNT 4
+#endif
+
+// STB_VORBIS_FAST_HUFFMAN_LENGTH [number]
+// sets the log size of the huffman-acceleration table. Maximum
+// supported value is 24. with larger numbers, more decodings are O(1),
+// but the table size is larger so worse cache missing, so you'll have
+// to probe (and try multiple ogg vorbis files) to find the sweet spot.
+#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH
+#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10
+#endif
+
+// STB_VORBIS_FAST_BINARY_LENGTH [number]
+// sets the log size of the binary-search acceleration table. this
+// is used in similar fashion to the fast-huffman size to set initial
+// parameters for the binary search
+
+// STB_VORBIS_FAST_HUFFMAN_INT
+// The fast huffman tables are much more efficient if they can be
+// stored as 16-bit results instead of 32-bit results. This restricts
+// the codebooks to having only 65535 possible outcomes, though.
+// (At least, accelerated by the huffman table.)
+#ifndef STB_VORBIS_FAST_HUFFMAN_INT
+#define STB_VORBIS_FAST_HUFFMAN_SHORT
+#endif
+
+// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
+// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls
+// back on binary searching for the correct one. This requires storing
+// extra tables with the huffman codes in sorted order. Defining this
+// symbol trades off space for speed by forcing a linear search in the
+// non-fast case, except for "sparse" codebooks.
+// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
+
+// STB_VORBIS_DIVIDES_IN_RESIDUE
+// stb_vorbis precomputes the result of the scalar residue decoding
+// that would otherwise require a divide per chunk. you can trade off
+// space for time by defining this symbol.
+// #define STB_VORBIS_DIVIDES_IN_RESIDUE
+
+// STB_VORBIS_DIVIDES_IN_CODEBOOK
+// vorbis VQ codebooks can be encoded two ways: with every case explicitly
+// stored, or with all elements being chosen from a small range of values,
+// and all values possible in all elements. By default, stb_vorbis expands
+// this latter kind out to look like the former kind for ease of decoding,
+// because otherwise an integer divide-per-vector-element is required to
+// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can
+// trade off storage for speed.
+//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
+
+#ifdef STB_VORBIS_CODEBOOK_SHORTS
+#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
+#endif
+
+// STB_VORBIS_DIVIDE_TABLE
+// this replaces small integer divides in the floor decode loop with
+// table lookups. made less than 1% difference, so disabled by default.
+
+// STB_VORBIS_NO_INLINE_DECODE
+// disables the inlining of the scalar codebook fast-huffman decode.
+// might save a little codespace; useful for debugging
+// #define STB_VORBIS_NO_INLINE_DECODE
+
+// STB_VORBIS_NO_DEFER_FLOOR
+// Normally we only decode the floor without synthesizing the actual
+// full curve. We can instead synthesize the curve immediately. This
+// requires more memory and is very likely slower, so I don't think
+// you'd ever want to do it except for debugging.
+// #define STB_VORBIS_NO_DEFER_FLOOR
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+#ifdef STB_VORBIS_NO_PULLDATA_API
+ #define STB_VORBIS_NO_INTEGER_CONVERSION
+ #define STB_VORBIS_NO_STDIO
+#endif
+
+#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
+ #define STB_VORBIS_NO_STDIO 1
+#endif
+
+#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
+#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
+
+ // only need endianness for fast-float-to-int, which we don't
+ // use for pushdata
+
+ #ifndef STB_VORBIS_BIG_ENDIAN
+ #define STB_VORBIS_ENDIAN 0
+ #else
+ #define STB_VORBIS_ENDIAN 1
+ #endif
+
+#endif
+#endif
+
+
+#ifndef STB_VORBIS_NO_STDIO
+#include <stdio.h>
+#endif
+
+#ifndef STB_VORBIS_NO_CRT
+ #include <stdlib.h>
+ #include <string.h>
+ #include <assert.h>
+ #include <math.h>
+
+ // find definition of alloca if it's not in stdlib.h:
+ #ifdef _MSC_VER
+ #include <malloc.h>
+ #endif
+ #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
+ #include <alloca.h>
+ #endif
+#else // STB_VORBIS_NO_CRT
+ #define NULL 0
+ #define malloc(s) 0
+ #define free(s) ((void) 0)
+ #define realloc(s) 0
+#endif // STB_VORBIS_NO_CRT
+
+#include <limits.h>
+
+#ifdef __MINGW32__
+ // eff you mingw:
+ // "fixed":
+ // http://sourceforge.net/p/mingw-w64/mailman/message/32882927/
+ // "no that broke the build, reverted, who cares about C":
+ // http://sourceforge.net/p/mingw-w64/mailman/message/32890381/
+ #ifdef __forceinline
+ #undef __forceinline
+ #endif
+ #define __forceinline
+#elif !defined(_MSC_VER)
+ #if __GNUC__
+ #define __forceinline inline
+ #else
+ #define __forceinline
+ #endif
+#endif
+
+#if STB_VORBIS_MAX_CHANNELS > 256
+#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range"
+#endif
+
+#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24
+#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range"
+#endif
+
+
+#if 0
+#include <crtdbg.h>
+#define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1])
+#else
+#define CHECK(f) ((void) 0)
+#endif
+
+#define MAX_BLOCKSIZE_LOG 13 // from specification
+#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG)
+
+
+typedef unsigned char uint8;
+typedef signed char int8;
+typedef unsigned short uint16;
+typedef signed short int16;
+typedef unsigned int uint32;
+typedef signed int int32;
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+typedef float codetype;
+
+// @NOTE
+//
+// Some arrays below are tagged "//varies", which means it's actually
+// a variable-sized piece of data, but rather than malloc I assume it's
+// small enough it's better to just allocate it all together with the
+// main thing
+//
+// Most of the variables are specified with the smallest size I could pack
+// them into. It might give better performance to make them all full-sized
+// integers. It should be safe to freely rearrange the structures or change
+// the sizes larger--nothing relies on silently truncating etc., nor the
+// order of variables.
+
+#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
+#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1)
+
+typedef struct
+{
+ int dimensions, entries;
+ uint8 *codeword_lengths;
+ float minimum_value;
+ float delta_value;
+ uint8 value_bits;
+ uint8 lookup_type;
+ uint8 sequence_p;
+ uint8 sparse;
+ uint32 lookup_values;
+ codetype *multiplicands;
+ uint32 *codewords;
+ #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
+ int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
+ #else
+ int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
+ #endif
+ uint32 *sorted_codewords;
+ int *sorted_values;
+ int sorted_entries;
+} Codebook;
+
+typedef struct
+{
+ uint8 order;
+ uint16 rate;
+ uint16 bark_map_size;
+ uint8 amplitude_bits;
+ uint8 amplitude_offset;
+ uint8 number_of_books;
+ uint8 book_list[16]; // varies
+} Floor0;
+
+typedef struct
+{
+ uint8 partitions;
+ uint8 partition_class_list[32]; // varies
+ uint8 class_dimensions[16]; // varies
+ uint8 class_subclasses[16]; // varies
+ uint8 class_masterbooks[16]; // varies
+ int16 subclass_books[16][8]; // varies
+ uint16 Xlist[31*8+2]; // varies
+ uint8 sorted_order[31*8+2];
+ uint8 neighbors[31*8+2][2];
+ uint8 floor1_multiplier;
+ uint8 rangebits;
+ int values;
+} Floor1;
+
+typedef union
+{
+ Floor0 floor0;
+ Floor1 floor1;
+} Floor;
+
+typedef struct
+{
+ uint32 begin, end;
+ uint32 part_size;
+ uint8 classifications;
+ uint8 classbook;
+ uint8 **classdata;
+ int16 (*residue_books)[8];
+} Residue;
+
+typedef struct
+{
+ uint8 magnitude;
+ uint8 angle;
+ uint8 mux;
+} MappingChannel;
+
+typedef struct
+{
+ uint16 coupling_steps;
+ MappingChannel *chan;
+ uint8 submaps;
+ uint8 submap_floor[15]; // varies
+ uint8 submap_residue[15]; // varies
+} Mapping;
+
+typedef struct
+{
+ uint8 blockflag;
+ uint8 mapping;
+ uint16 windowtype;
+ uint16 transformtype;
+} Mode;
+
+typedef struct
+{
+ uint32 goal_crc; // expected crc if match
+ int bytes_left; // bytes left in packet
+ uint32 crc_so_far; // running crc
+ int bytes_done; // bytes processed in _current_ chunk
+ uint32 sample_loc; // granule pos encoded in page
+} CRCscan;
+
+typedef struct
+{
+ uint32 page_start, page_end;
+ uint32 last_decoded_sample;
+} ProbedPage;
+
+struct stb_vorbis
+{
+ // user-accessible info
+ unsigned int sample_rate;
+ int channels;
+
+ unsigned int setup_memory_required;
+ unsigned int temp_memory_required;
+ unsigned int setup_temp_memory_required;
+
+ // input config
+#ifndef STB_VORBIS_NO_STDIO
+ FILE *f;
+ uint32 f_start;
+ int close_on_free;
+#endif
+
+ uint8 *stream;
+ uint8 *stream_start;
+ uint8 *stream_end;
+
+ uint32 stream_len;
+
+ uint8 push_mode;
+
+ uint32 first_audio_page_offset;
+
+ ProbedPage p_first, p_last;
+
+ // memory management
+ stb_vorbis_alloc alloc;
+ int setup_offset;
+ int temp_offset;
+
+ // run-time results
+ int eof;
+ enum STBVorbisError error;
+
+ // user-useful data
+
+ // header info
+ int blocksize[2];
+ int blocksize_0, blocksize_1;
+ int codebook_count;
+ Codebook *codebooks;
+ int floor_count;
+ uint16 floor_types[64]; // varies
+ Floor *floor_config;
+ int residue_count;
+ uint16 residue_types[64]; // varies
+ Residue *residue_config;
+ int mapping_count;
+ Mapping *mapping;
+ int mode_count;
+ Mode mode_config[64]; // varies
+
+ uint32 total_samples;
+
+ // decode buffer
+ float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
+ float *outputs [STB_VORBIS_MAX_CHANNELS];
+
+ float *previous_window[STB_VORBIS_MAX_CHANNELS];
+ int previous_length;
+
+ #ifndef STB_VORBIS_NO_DEFER_FLOOR
+ int16 *finalY[STB_VORBIS_MAX_CHANNELS];
+ #else
+ float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
+ #endif
+
+ uint32 current_loc; // sample location of next frame to decode
+ int current_loc_valid;
+
+ // per-blocksize precomputed data
+
+ // twiddle factors
+ float *A[2],*B[2],*C[2];
+ float *window[2];
+ uint16 *bit_reverse[2];
+
+ // current page/packet/segment streaming info
+ uint32 serial; // stream serial number for verification
+ int last_page;
+ int segment_count;
+ uint8 segments[255];
+ uint8 page_flag;
+ uint8 bytes_in_seg;
+ uint8 first_decode;
+ int next_seg;
+ int last_seg; // flag that we're on the last segment
+ int last_seg_which; // what was the segment number of the last seg?
+ uint32 acc;
+ int valid_bits;
+ int packet_bytes;
+ int end_seg_with_known_loc;
+ uint32 known_loc_for_packet;
+ int discard_samples_deferred;
+ uint32 samples_output;
+
+ // push mode scanning
+ int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching
+#ifndef STB_VORBIS_NO_PUSHDATA_API
+ CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
+#endif
+
+ // sample-access
+ int channel_buffer_start;
+ int channel_buffer_end;
+};
+
+#if defined(STB_VORBIS_NO_PUSHDATA_API)
+ #define IS_PUSH_MODE(f) FALSE
+#elif defined(STB_VORBIS_NO_PULLDATA_API)
+ #define IS_PUSH_MODE(f) TRUE
+#else
+ #define IS_PUSH_MODE(f) ((f)->push_mode)
+#endif
+
+typedef struct stb_vorbis vorb;
+
+static int error(vorb *f, enum STBVorbisError e)
+{
+ f->error = e;
+ if (!f->eof && e != VORBIS_need_more_data) {
+ f->error=e; // breakpoint for debugging
+ }
+ return 0;
+}
+
+
+// these functions are used for allocating temporary memory
+// while decoding. if you can afford the stack space, use
+// alloca(); otherwise, provide a temp buffer and it will
+// allocate out of those.
+
+#define array_size_required(count,size) (count*(sizeof(void *)+(size)))
+
+#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
+#ifdef dealloca
+#define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size))
+#else
+#define temp_free(f,p) 0
+#endif
+#define temp_alloc_save(f) ((f)->temp_offset)
+#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))
+
+#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size)
+
+// given a sufficiently large block of memory, make an array of pointers to subblocks of it
+static void *make_block_array(void *mem, int count, int size)
+{
+ int i;
+ void ** p = (void **) mem;
+ char *q = (char *) (p + count);
+ for (i=0; i < count; ++i) {
+ p[i] = q;
+ q += size;
+ }
+ return p;
+}
+
+static void *setup_malloc(vorb *f, int sz)
+{
+ sz = (sz+3) & ~3;
+ f->setup_memory_required += sz;
+ if (f->alloc.alloc_buffer) {
+ void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
+ if (f->setup_offset + sz > f->temp_offset) return NULL;
+ f->setup_offset += sz;
+ return p;
+ }
+ return sz ? malloc(sz) : NULL;
+}
+
+static void setup_free(vorb *f, void *p)
+{
+ if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
+ free(p);
+}
+
+static void *setup_temp_malloc(vorb *f, int sz)
+{
+ sz = (sz+3) & ~3;
+ if (f->alloc.alloc_buffer) {
+ if (f->temp_offset - sz < f->setup_offset) return NULL;
+ f->temp_offset -= sz;
+ return (char *) f->alloc.alloc_buffer + f->temp_offset;
+ }
+ return malloc(sz);
+}
+
+static void setup_temp_free(vorb *f, void *p, int sz)
+{
+ if (f->alloc.alloc_buffer) {
+ f->temp_offset += (sz+3)&~3;
+ return;
+ }
+ free(p);
+}
+
+#define CRC32_POLY 0x04c11db7 // from spec
+
+static uint32 crc_table[256];
+static void crc32_init(void)
+{
+ int i,j;
+ uint32 s;
+ for(i=0; i < 256; i++) {
+ for (s=(uint32) i << 24, j=0; j < 8; ++j)
+ s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0);
+ crc_table[i] = s;
+ }
+}
+
+static __forceinline uint32 crc32_update(uint32 crc, uint8 byte)
+{
+ return (crc << 8) ^ crc_table[byte ^ (crc >> 24)];
+}
+
+
+// used in setup, and for huffman that doesn't go fast path
+static unsigned int bit_reverse(unsigned int n)
+{
+ n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1);
+ n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2);
+ n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4);
+ n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8);
+ return (n >> 16) | (n << 16);
+}
+
+static float square(float x)
+{
+ return x*x;
+}
+
+// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3
+// as required by the specification. fast(?) implementation from stb.h
+// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup
+static int ilog(int32 n)
+{
+ static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
+
+ // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
+ if (n < (1 << 14))
+ if (n < (1 << 4)) return 0 + log2_4[n ];
+ else if (n < (1 << 9)) return 5 + log2_4[n >> 5];
+ else return 10 + log2_4[n >> 10];
+ else if (n < (1 << 24))
+ if (n < (1 << 19)) return 15 + log2_4[n >> 15];
+ else return 20 + log2_4[n >> 20];
+ else if (n < (1 << 29)) return 25 + log2_4[n >> 25];
+ else if (n < (1 << 31)) return 30 + log2_4[n >> 30];
+ else return 0; // signed n returns 0
+}
+
+#ifndef M_PI
+ #define M_PI 3.14159265358979323846264f // from CRC
+#endif
+
+// code length assigned to a value with no huffman encoding
+#define NO_CODE 255
+
+/////////////////////// LEAF SETUP FUNCTIONS //////////////////////////
+//
+// these functions are only called at setup, and only a few times
+// per file
+
+static float float32_unpack(uint32 x)
+{
+ // from the specification
+ uint32 mantissa = x & 0x1fffff;
+ uint32 sign = x & 0x80000000;
+ uint32 exp = (x & 0x7fe00000) >> 21;
+ double res = sign ? -(double)mantissa : (double)mantissa;
+ return (float) ldexp((float)res, exp-788);
+}
+
+
+// zlib & jpeg huffman tables assume that the output symbols
+// can either be arbitrarily arranged, or have monotonically
+// increasing frequencies--they rely on the lengths being sorted;
+// this makes for a very simple generation algorithm.
+// vorbis allows a huffman table with non-sorted lengths. This
+// requires a more sophisticated construction, since symbols in
+// order do not map to huffman codes "in order".
+static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values)
+{
+ if (!c->sparse) {
+ c->codewords [symbol] = huff_code;
+ } else {
+ c->codewords [count] = huff_code;
+ c->codeword_lengths[count] = len;
+ values [count] = symbol;
+ }
+}
+
+static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values)
+{
+ int i,k,m=0;
+ uint32 available[32];
+
+ memset(available, 0, sizeof(available));
+ // find the first entry
+ for (k=0; k < n; ++k) if (len[k] < NO_CODE) break;
+ if (k == n) { assert(c->sorted_entries == 0); return TRUE; }
+ // add to the list
+ add_entry(c, 0, k, m++, len[k], values);
+ // add all available leaves
+ for (i=1; i <= len[k]; ++i)
+ available[i] = 1U << (32-i);
+ // note that the above code treats the first case specially,
+ // but it's really the same as the following code, so they
+ // could probably be combined (except the initial code is 0,
+ // and I use 0 in available[] to mean 'empty')
+ for (i=k+1; i < n; ++i) {
+ uint32 res;
+ int z = len[i], y;
+ if (z == NO_CODE) continue;
+ // find lowest available leaf (should always be earliest,
+ // which is what the specification calls for)
+ // note that this property, and the fact we can never have
+ // more than one free leaf at a given level, isn't totally
+ // trivial to prove, but it seems true and the assert never
+ // fires, so!
+ while (z > 0 && !available[z]) --z;
+ if (z == 0) { return FALSE; }
+ res = available[z];
+ assert(z >= 0 && z < 32);
+ available[z] = 0;
+ add_entry(c, bit_reverse(res), i, m++, len[i], values);
+ // propogate availability up the tree
+ if (z != len[i]) {
+ assert(len[i] >= 0 && len[i] < 32);
+ for (y=len[i]; y > z; --y) {
+ assert(available[y] == 0);
+ available[y] = res + (1 << (32-y));
+ }
+ }
+ }
+ return TRUE;
+}
+
+// accelerated huffman table allows fast O(1) match of all symbols
+// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
+static void compute_accelerated_huffman(Codebook *c)
+{
+ int i, len;
+ for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i)
+ c->fast_huffman[i] = -1;
+
+ len = c->sparse ? c->sorted_entries : c->entries;
+ #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
+ if (len > 32767) len = 32767; // largest possible value we can encode!
+ #endif
+ for (i=0; i < len; ++i) {
+ if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
+ uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
+ // set table entries for all bit combinations in the higher bits
+ while (z < FAST_HUFFMAN_TABLE_SIZE) {
+ c->fast_huffman[z] = i;
+ z += 1 << c->codeword_lengths[i];
+ }
+ }
+ }
+}
+
+#ifdef _MSC_VER
+#define STBV_CDECL __cdecl
+#else
+#define STBV_CDECL
+#endif
+
+static int STBV_CDECL uint32_compare(const void *p, const void *q)
+{
+ uint32 x = * (uint32 *) p;
+ uint32 y = * (uint32 *) q;
+ return x < y ? -1 : x > y;
+}
+
+static int include_in_sort(Codebook *c, uint8 len)
+{
+ if (c->sparse) { assert(len != NO_CODE); return TRUE; }
+ if (len == NO_CODE) return FALSE;
+ if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE;
+ return FALSE;
+}
+
+// if the fast table above doesn't work, we want to binary
+// search them... need to reverse the bits
+static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values)
+{
+ int i, len;
+ // build a list of all the entries
+ // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN.
+ // this is kind of a frivolous optimization--I don't see any performance improvement,
+ // but it's like 4 extra lines of code, so.
+ if (!c->sparse) {
+ int k = 0;
+ for (i=0; i < c->entries; ++i)
+ if (include_in_sort(c, lengths[i]))
+ c->sorted_codewords[k++] = bit_reverse(c->codewords[i]);
+ assert(k == c->sorted_entries);
+ } else {
+ for (i=0; i < c->sorted_entries; ++i)
+ c->sorted_codewords[i] = bit_reverse(c->codewords[i]);
+ }
+
+ qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare);
+ c->sorted_codewords[c->sorted_entries] = 0xffffffff;
+
+ len = c->sparse ? c->sorted_entries : c->entries;
+ // now we need to indicate how they correspond; we could either
+ // #1: sort a different data structure that says who they correspond to
+ // #2: for each sorted entry, search the original list to find who corresponds
+ // #3: for each original entry, find the sorted entry
+ // #1 requires extra storage, #2 is slow, #3 can use binary search!
+ for (i=0; i < len; ++i) {
+ int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
+ if (include_in_sort(c,huff_len)) {
+ uint32 code = bit_reverse(c->codewords[i]);
+ int x=0, n=c->sorted_entries;
+ while (n > 1) {
+ // invariant: sc[x] <= code < sc[x+n]
+ int m = x + (n >> 1);
+ if (c->sorted_codewords[m] <= code) {
+ x = m;
+ n -= (n>>1);
+ } else {
+ n >>= 1;
+ }
+ }
+ assert(c->sorted_codewords[x] == code);
+ if (c->sparse) {
+ c->sorted_values[x] = values[i];
+ c->codeword_lengths[x] = huff_len;
+ } else {
+ c->sorted_values[x] = i;
+ }
+ }
+ }
+}
+
+// only run while parsing the header (3 times)
+static int vorbis_validate(uint8 *data)
+{
+ static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
+ return memcmp(data, vorbis, 6) == 0;
+}
+
+// called from setup only, once per code book
+// (formula implied by specification)
+static int lookup1_values(int entries, int dim)
+{
+ int r = (int) floor(exp((float) log((float) entries) / dim));
+ if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning;
+ ++r; // floor() to avoid _ftol() when non-CRT
+ assert(pow((float) r+1, dim) > entries);
+ assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above
+ return r;
+}
+
+// called twice per file
+static void compute_twiddle_factors(int n, float *A, float *B, float *C)
+{
+ int n4 = n >> 2, n8 = n >> 3;
+ int k,k2;
+
+ for (k=k2=0; k < n4; ++k,k2+=2) {
+ A[k2 ] = (float) cos(4*k*M_PI/n);
+ A[k2+1] = (float) -sin(4*k*M_PI/n);
+ B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f;
+ B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f;
+ }
+ for (k=k2=0; k < n8; ++k,k2+=2) {
+ C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
+ C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
+ }
+}
+
+static void compute_window(int n, float *window)
+{
+ int n2 = n >> 1, i;
+ for (i=0; i < n2; ++i)
+ window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
+}
+
+static void compute_bitreverse(int n, uint16 *rev)
+{
+ int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
+ int i, n8 = n >> 3;
+ for (i=0; i < n8; ++i)
+ rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2;
+}
+
+static int init_blocksize(vorb *f, int b, int n)
+{
+ int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
+ f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2);
+ f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2);
+ f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4);
+ if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem);
+ compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
+ f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2);
+ if (!f->window[b]) return error(f, VORBIS_outofmem);
+ compute_window(n, f->window[b]);
+ f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8);
+ if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem);
+ compute_bitreverse(n, f->bit_reverse[b]);
+ return TRUE;
+}
+
+static void neighbors(uint16 *x, int n, int *plow, int *phigh)
+{
+ int low = -1;
+ int high = 65536;
+ int i;
+ for (i=0; i < n; ++i) {
+ if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; }
+ if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; }
+ }
+}
+
+// this has been repurposed so y is now the original index instead of y
+typedef struct
+{
+ uint16 x,y;
+} Point;
+
+static int STBV_CDECL point_compare(const void *p, const void *q)
+{
+ Point *a = (Point *) p;
+ Point *b = (Point *) q;
+ return a->x < b->x ? -1 : a->x > b->x;
+}
+
+//
+/////////////////////// END LEAF SETUP FUNCTIONS //////////////////////////
+
+
+#if defined(STB_VORBIS_NO_STDIO)
+ #define USE_MEMORY(z) TRUE
+#else
+ #define USE_MEMORY(z) ((z)->stream)
+#endif
+
+static uint8 get8(vorb *z)
+{
+ if (USE_MEMORY(z)) {
+ if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
+ return *z->stream++;
+ }
+
+ #ifndef STB_VORBIS_NO_STDIO
+ {
+ int c = fgetc(z->f);
+ if (c == EOF) { z->eof = TRUE; return 0; }
+ return c;
+ }
+ #endif
+}
+
+static uint32 get32(vorb *f)
+{
+ uint32 x;
+ x = get8(f);
+ x += get8(f) << 8;
+ x += get8(f) << 16;
+ x += (uint32) get8(f) << 24;
+ return x;
+}
+
+static int getn(vorb *z, uint8 *data, int n)
+{
+ if (USE_MEMORY(z)) {
+ if (z->stream+n > z->stream_end) { z->eof = 1; return 0; }
+ memcpy(data, z->stream, n);
+ z->stream += n;
+ return 1;
+ }
+
+ #ifndef STB_VORBIS_NO_STDIO
+ if (fread(data, n, 1, z->f) == 1)
+ return 1;
+ else {
+ z->eof = 1;
+ return 0;
+ }
+ #endif
+}
+
+static void skip(vorb *z, int n)
+{
+ if (USE_MEMORY(z)) {
+ z->stream += n;
+ if (z->stream >= z->stream_end) z->eof = 1;
+ return;
+ }
+ #ifndef STB_VORBIS_NO_STDIO
+ {
+ long x = ftell(z->f);
+ fseek(z->f, x+n, SEEK_SET);
+ }
+ #endif
+}
+
+static int set_file_offset(stb_vorbis *f, unsigned int loc)
+{
+ #ifndef STB_VORBIS_NO_PUSHDATA_API
+ if (f->push_mode) return 0;
+ #endif
+ f->eof = 0;
+ if (USE_MEMORY(f)) {
+ if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
+ f->stream = f->stream_end;
+ f->eof = 1;
+ return 0;
+ } else {
+ f->stream = f->stream_start + loc;
+ return 1;
+ }
+ }
+ #ifndef STB_VORBIS_NO_STDIO
+ if (loc + f->f_start < loc || loc >= 0x80000000) {
+ loc = 0x7fffffff;
+ f->eof = 1;
+ } else {
+ loc += f->f_start;
+ }
+ if (!fseek(f->f, loc, SEEK_SET))
+ return 1;
+ f->eof = 1;
+ fseek(f->f, f->f_start, SEEK_END);
+ return 0;
+ #endif
+}
+
+
+static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
+
+static int capture_pattern(vorb *f)
+{
+ if (0x4f != get8(f)) return FALSE;
+ if (0x67 != get8(f)) return FALSE;
+ if (0x67 != get8(f)) return FALSE;
+ if (0x53 != get8(f)) return FALSE;
+ return TRUE;
+}
+
+#define PAGEFLAG_continued_packet 1
+#define PAGEFLAG_first_page 2
+#define PAGEFLAG_last_page 4
+
+static int start_page_no_capturepattern(vorb *f)
+{
+ uint32 loc0,loc1,n;
+ // stream structure version
+ if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version);
+ // header flag
+ f->page_flag = get8(f);
+ // absolute granule position
+ loc0 = get32(f);
+ loc1 = get32(f);
+ // @TODO: validate loc0,loc1 as valid positions?
+ // stream serial number -- vorbis doesn't interleave, so discard
+ get32(f);
+ //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number);
+ // page sequence number
+ n = get32(f);
+ f->last_page = n;
+ // CRC32
+ get32(f);
+ // page_segments
+ f->segment_count = get8(f);
+ if (!getn(f, f->segments, f->segment_count))
+ return error(f, VORBIS_unexpected_eof);
+ // assume we _don't_ know any the sample position of any segments
+ f->end_seg_with_known_loc = -2;
+ if (loc0 != ~0U || loc1 != ~0U) {
+ int i;
+ // determine which packet is the last one that will complete
+ for (i=f->segment_count-1; i >= 0; --i)
+ if (f->segments[i] < 255)
+ break;
+ // 'i' is now the index of the _last_ segment of a packet that ends
+ if (i >= 0) {
+ f->end_seg_with_known_loc = i;
+ f->known_loc_for_packet = loc0;
+ }
+ }
+ if (f->first_decode) {
+ int i,len;
+ ProbedPage p;
+ len = 0;
+ for (i=0; i < f->segment_count; ++i)
+ len += f->segments[i];
+ len += 27 + f->segment_count;
+ p.page_start = f->first_audio_page_offset;
+ p.page_end = p.page_start + len;
+ p.last_decoded_sample = loc0;
+ f->p_first = p;
+ }
+ f->next_seg = 0;
+ return TRUE;
+}
+
+static int start_page(vorb *f)
+{
+ if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern);
+ return start_page_no_capturepattern(f);
+}
+
+static int start_packet(vorb *f)
+{
+ while (f->next_seg == -1) {
+ if (!start_page(f)) return FALSE;
+ if (f->page_flag & PAGEFLAG_continued_packet)
+ return error(f, VORBIS_continued_packet_flag_invalid);
+ }
+ f->last_seg = FALSE;
+ f->valid_bits = 0;
+ f->packet_bytes = 0;
+ f->bytes_in_seg = 0;
+ // f->next_seg is now valid
+ return TRUE;
+}
+
+static int maybe_start_packet(vorb *f)
+{
+ if (f->next_seg == -1) {
+ int x = get8(f);
+ if (f->eof) return FALSE; // EOF at page boundary is not an error!
+ if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern);
+ if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
+ if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
+ if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
+ if (!start_page_no_capturepattern(f)) return FALSE;
+ if (f->page_flag & PAGEFLAG_continued_packet) {
+ // set up enough state that we can read this packet if we want,
+ // e.g. during recovery
+ f->last_seg = FALSE;
+ f->bytes_in_seg = 0;
+ return error(f, VORBIS_continued_packet_flag_invalid);
+ }
+ }
+ return start_packet(f);
+}
+
+static int next_segment(vorb *f)
+{
+ int len;
+ if (f->last_seg) return 0;
+ if (f->next_seg == -1) {
+ f->last_seg_which = f->segment_count-1; // in case start_page fails
+ if (!start_page(f)) { f->last_seg = 1; return 0; }
+ if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid);
+ }
+ len = f->segments[f->next_seg++];
+ if (len < 255) {
+ f->last_seg = TRUE;
+ f->last_seg_which = f->next_seg-1;
+ }
+ if (f->next_seg >= f->segment_count)
+ f->next_seg = -1;
+ assert(f->bytes_in_seg == 0);
+ f->bytes_in_seg = len;
+ return len;
+}
+
+#define EOP (-1)
+#define INVALID_BITS (-1)
+
+static int get8_packet_raw(vorb *f)
+{
+ if (!f->bytes_in_seg) { // CLANG!
+ if (f->last_seg) return EOP;
+ else if (!next_segment(f)) return EOP;
+ }
+ assert(f->bytes_in_seg > 0);
+ --f->bytes_in_seg;
+ ++f->packet_bytes;
+ return get8(f);
+}
+
+static int get8_packet(vorb *f)
+{
+ int x = get8_packet_raw(f);
+ f->valid_bits = 0;
+ return x;
+}
+
+static void flush_packet(vorb *f)
+{
+ while (get8_packet_raw(f) != EOP);
+}
+
+// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important
+// as the huffman decoder?
+static uint32 get_bits(vorb *f, int n)
+{
+ uint32 z;
+
+ if (f->valid_bits < 0) return 0;
+ if (f->valid_bits < n) {
+ if (n > 24) {
+ // the accumulator technique below would not work correctly in this case
+ z = get_bits(f, 24);
+ z += get_bits(f, n-24) << 24;
+ return z;
+ }
+ if (f->valid_bits == 0) f->acc = 0;
+ while (f->valid_bits < n) {
+ int z = get8_packet_raw(f);
+ if (z == EOP) {
+ f->valid_bits = INVALID_BITS;
+ return 0;
+ }
+ f->acc += z << f->valid_bits;
+ f->valid_bits += 8;
+ }
+ }
+ if (f->valid_bits < 0) return 0;
+ z = f->acc & ((1 << n)-1);
+ f->acc >>= n;
+ f->valid_bits -= n;
+ return z;
+}
+
+// @OPTIMIZE: primary accumulator for huffman
+// expand the buffer to as many bits as possible without reading off end of packet
+// it might be nice to allow f->valid_bits and f->acc to be stored in registers,
+// e.g. cache them locally and decode locally
+static __forceinline void prep_huffman(vorb *f)
+{
+ if (f->valid_bits <= 24) {
+ if (f->valid_bits == 0) f->acc = 0;
+ do {
+ int z;
+ if (f->last_seg && !f->bytes_in_seg) return;
+ z = get8_packet_raw(f);
+ if (z == EOP) return;
+ f->acc += (unsigned) z << f->valid_bits;
+ f->valid_bits += 8;
+ } while (f->valid_bits <= 24);
+ }
+}
+
+enum
+{
+ VORBIS_packet_id = 1,
+ VORBIS_packet_comment = 3,
+ VORBIS_packet_setup = 5
+};
+
+static int codebook_decode_scalar_raw(vorb *f, Codebook *c)
+{
+ int i;
+ prep_huffman(f);
+
+ if (c->codewords == NULL && c->sorted_codewords == NULL)
+ return -1;
+
+ // cases to use binary search: sorted_codewords && !c->codewords
+ // sorted_codewords && c->entries > 8
+ if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
+ // binary search
+ uint32 code = bit_reverse(f->acc);
+ int x=0, n=c->sorted_entries, len;
+
+ while (n > 1) {
+ // invariant: sc[x] <= code < sc[x+n]
+ int m = x + (n >> 1);
+ if (c->sorted_codewords[m] <= code) {
+ x = m;
+ n -= (n>>1);
+ } else {
+ n >>= 1;
+ }
+ }
+ // x is now the sorted index
+ if (!c->sparse) x = c->sorted_values[x];
+ // x is now sorted index if sparse, or symbol otherwise
+ len = c->codeword_lengths[x];
+ if (f->valid_bits >= len) {
+ f->acc >>= len;
+ f->valid_bits -= len;
+ return x;
+ }
+
+ f->valid_bits = 0;
+ return -1;
+ }
+
+ // if small, linear search
+ assert(!c->sparse);
+ for (i=0; i < c->entries; ++i) {
+ if (c->codeword_lengths[i] == NO_CODE) continue;
+ if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) {
+ if (f->valid_bits >= c->codeword_lengths[i]) {
+ f->acc >>= c->codeword_lengths[i];
+ f->valid_bits -= c->codeword_lengths[i];
+ return i;
+ }
+ f->valid_bits = 0;
+ return -1;
+ }
+ }
+
+ error(f, VORBIS_invalid_stream);
+ f->valid_bits = 0;
+ return -1;
+}
+
+#ifndef STB_VORBIS_NO_INLINE_DECODE
+
+#define DECODE_RAW(var, f,c) \
+ if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \
+ prep_huffman(f); \
+ var = f->acc & FAST_HUFFMAN_TABLE_MASK; \
+ var = c->fast_huffman[var]; \
+ if (var >= 0) { \
+ int n = c->codeword_lengths[var]; \
+ f->acc >>= n; \
+ f->valid_bits -= n; \
+ if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
+ } else { \
+ var = codebook_decode_scalar_raw(f,c); \
+ }
+
+#else
+
+static int codebook_decode_scalar(vorb *f, Codebook *c)
+{
+ int i;
+ if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
+ prep_huffman(f);
+ // fast huffman table lookup
+ i = f->acc & FAST_HUFFMAN_TABLE_MASK;
+ i = c->fast_huffman[i];
+ if (i >= 0) {
+ f->acc >>= c->codeword_lengths[i];
+ f->valid_bits -= c->codeword_lengths[i];
+ if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
+ return i;
+ }
+ return codebook_decode_scalar_raw(f,c);
+}
+
+#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c);
+
+#endif
+
+#define DECODE(var,f,c) \
+ DECODE_RAW(var,f,c) \
+ if (c->sparse) var = c->sorted_values[var];
+
+#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c)
+#else
+ #define DECODE_VQ(var,f,c) DECODE(var,f,c)
+#endif
+
+
+
+
+
+
+// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
+// where we avoid one addition
+#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off])
+#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off])
+#define CODEBOOK_ELEMENT_BASE(c) (0)
+
+static int codebook_decode_start(vorb *f, Codebook *c)
+{
+ int z = -1;
+
+ // type 0 is only legal in a scalar context
+ if (c->lookup_type == 0)
+ error(f, VORBIS_invalid_stream);
+ else {
+ DECODE_VQ(z,f,c);
+ if (c->sparse) assert(z < c->sorted_entries);
+ if (z < 0) { // check for EOP
+ if (!f->bytes_in_seg)
+ if (f->last_seg)
+ return z;
+ error(f, VORBIS_invalid_stream);
+ }
+ }
+ return z;
+}
+
+static int codebook_decode(vorb *f, Codebook *c, float *output, int len)
+{
+ int i,z = codebook_decode_start(f,c);
+ if (z < 0) return FALSE;
+ if (len > c->dimensions) len = c->dimensions;
+
+#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ if (c->lookup_type == 1) {
+ float last = CODEBOOK_ELEMENT_BASE(c);
+ int div = 1;
+ for (i=0; i < len; ++i) {
+ int off = (z / div) % c->lookup_values;
+ float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
+ output[i] += val;
+ if (c->sequence_p) last = val + c->minimum_value;
+ div *= c->lookup_values;
+ }
+ return TRUE;
+ }
+#endif
+
+ z *= c->dimensions;
+ if (c->sequence_p) {
+ float last = CODEBOOK_ELEMENT_BASE(c);
+ for (i=0; i < len; ++i) {
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ output[i] += val;
+ last = val + c->minimum_value;
+ }
+ } else {
+ float last = CODEBOOK_ELEMENT_BASE(c);
+ for (i=0; i < len; ++i) {
+ output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ }
+ }
+
+ return TRUE;
+}
+
+static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step)
+{
+ int i,z = codebook_decode_start(f,c);
+ float last = CODEBOOK_ELEMENT_BASE(c);
+ if (z < 0) return FALSE;
+ if (len > c->dimensions) len = c->dimensions;
+
+#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ if (c->lookup_type == 1) {
+ int div = 1;
+ for (i=0; i < len; ++i) {
+ int off = (z / div) % c->lookup_values;
+ float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
+ output[i*step] += val;
+ if (c->sequence_p) last = val;
+ div *= c->lookup_values;
+ }
+ return TRUE;
+ }
+#endif
+
+ z *= c->dimensions;
+ for (i=0; i < len; ++i) {
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ output[i*step] += val;
+ if (c->sequence_p) last = val;
+ }
+
+ return TRUE;
+}
+
+static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
+{
+ int c_inter = *c_inter_p;
+ int p_inter = *p_inter_p;
+ int i,z, effective = c->dimensions;
+
+ // type 0 is only legal in a scalar context
+ if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
+
+ while (total_decode > 0) {
+ float last = CODEBOOK_ELEMENT_BASE(c);
+ DECODE_VQ(z,f,c);
+ #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ assert(!c->sparse || z < c->sorted_entries);
+ #endif
+ if (z < 0) {
+ if (!f->bytes_in_seg)
+ if (f->last_seg) return FALSE;
+ return error(f, VORBIS_invalid_stream);
+ }
+
+ // if this will take us off the end of the buffers, stop short!
+ // we check by computing the length of the virtual interleaved
+ // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
+ // and the length we'll be using (effective)
+ if (c_inter + p_inter*ch + effective > len * ch) {
+ effective = len*ch - (p_inter*ch - c_inter);
+ }
+
+ #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ if (c->lookup_type == 1) {
+ int div = 1;
+ for (i=0; i < effective; ++i) {
+ int off = (z / div) % c->lookup_values;
+ float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
+ if (outputs[c_inter])
+ outputs[c_inter][p_inter] += val;
+ if (++c_inter == ch) { c_inter = 0; ++p_inter; }
+ if (c->sequence_p) last = val;
+ div *= c->lookup_values;
+ }
+ } else
+ #endif
+ {
+ z *= c->dimensions;
+ if (c->sequence_p) {
+ for (i=0; i < effective; ++i) {
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ if (outputs[c_inter])
+ outputs[c_inter][p_inter] += val;
+ if (++c_inter == ch) { c_inter = 0; ++p_inter; }
+ last = val;
+ }
+ } else {
+ for (i=0; i < effective; ++i) {
+ float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
+ if (outputs[c_inter])
+ outputs[c_inter][p_inter] += val;
+ if (++c_inter == ch) { c_inter = 0; ++p_inter; }
+ }
+ }
+ }
+
+ total_decode -= effective;
+ }
+ *c_inter_p = c_inter;
+ *p_inter_p = p_inter;
+ return TRUE;
+}
+
+static int predict_point(int x, int x0, int x1, int y0, int y1)
+{
+ int dy = y1 - y0;
+ int adx = x1 - x0;
+ // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86?
+ int err = abs(dy) * (x - x0);
+ int off = err / adx;
+ return dy < 0 ? y0 - off : y0 + off;
+}
+
+// the following table is block-copied from the specification
+static float inverse_db_table[256] =
+{
+ 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f,
+ 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f,
+ 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f,
+ 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f,
+ 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f,
+ 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f,
+ 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f,
+ 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f,
+ 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f,
+ 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f,
+ 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f,
+ 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f,
+ 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f,
+ 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f,
+ 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f,
+ 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f,
+ 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f,
+ 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f,
+ 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f,
+ 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f,
+ 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f,
+ 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f,
+ 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f,
+ 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f,
+ 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f,
+ 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f,
+ 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f,
+ 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f,
+ 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f,
+ 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f,
+ 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f,
+ 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f,
+ 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f,
+ 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f,
+ 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f,
+ 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f,
+ 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f,
+ 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f,
+ 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f,
+ 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f,
+ 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f,
+ 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f,
+ 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f,
+ 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f,
+ 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f,
+ 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f,
+ 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f,
+ 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f,
+ 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f,
+ 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f,
+ 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f,
+ 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f,
+ 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f,
+ 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f,
+ 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f,
+ 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f,
+ 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f,
+ 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f,
+ 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f,
+ 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f,
+ 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f,
+ 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f,
+ 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f,
+ 0.82788260f, 0.88168307f, 0.9389798f, 1.0f
+};
+
+
+// @OPTIMIZE: if you want to replace this bresenham line-drawing routine,
+// note that you must produce bit-identical output to decode correctly;
+// this specific sequence of operations is specified in the spec (it's
+// drawing integer-quantized frequency-space lines that the encoder
+// expects to be exactly the same)
+// ... also, isn't the whole point of Bresenham's algorithm to NOT
+// have to divide in the setup? sigh.
+#ifndef STB_VORBIS_NO_DEFER_FLOOR
+#define LINE_OP(a,b) a *= b
+#else
+#define LINE_OP(a,b) a = b
+#endif
+
+#ifdef STB_VORBIS_DIVIDE_TABLE
+#define DIVTAB_NUMER 32
+#define DIVTAB_DENOM 64
+int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB
+#endif
+
+static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)
+{
+ int dy = y1 - y0;
+ int adx = x1 - x0;
+ int ady = abs(dy);
+ int base;
+ int x=x0,y=y0;
+ int err = 0;
+ int sy;
+
+#ifdef STB_VORBIS_DIVIDE_TABLE
+ if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {
+ if (dy < 0) {
+ base = -integer_divide_table[ady][adx];
+ sy = base-1;
+ } else {
+ base = integer_divide_table[ady][adx];
+ sy = base+1;
+ }
+ } else {
+ base = dy / adx;
+ if (dy < 0)
+ sy = base - 1;
+ else
+ sy = base+1;
+ }
+#else
+ base = dy / adx;
+ if (dy < 0)
+ sy = base - 1;
+ else
+ sy = base+1;
+#endif
+ ady -= abs(base) * adx;
+ if (x1 > n) x1 = n;
+ if (x < x1) {
+ LINE_OP(output[x], inverse_db_table[y]);
+ for (++x; x < x1; ++x) {
+ err += ady;
+ if (err >= adx) {
+ err -= adx;
+ y += sy;
+ } else
+ y += base;
+ LINE_OP(output[x], inverse_db_table[y]);
+ }
+ }
+}
+
+static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype)
+{
+ int k;
+ if (rtype == 0) {
+ int step = n / book->dimensions;
+ for (k=0; k < step; ++k)
+ if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
+ return FALSE;
+ } else {
+ for (k=0; k < n; ) {
+ if (!codebook_decode(f, book, target+offset, n-k))
+ return FALSE;
+ k += book->dimensions;
+ offset += book->dimensions;
+ }
+ }
+ return TRUE;
+}
+
+static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode)
+{
+ int i,j,pass;
+ Residue *r = f->residue_config + rn;
+ int rtype = f->residue_types[rn];
+ int c = r->classbook;
+ int classwords = f->codebooks[c].dimensions;
+ int n_read = r->end - r->begin;
+ int part_read = n_read / r->part_size;
+ int temp_alloc_point = temp_alloc_save(f);
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
+ #else
+ int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications));
+ #endif
+
+ CHECK(f);
+
+ for (i=0; i < ch; ++i)
+ if (!do_not_decode[i])
+ memset(residue_buffers[i], 0, sizeof(float) * n);
+
+ if (rtype == 2 && ch != 1) {
+ for (j=0; j < ch; ++j)
+ if (!do_not_decode[j])
+ break;
+ if (j == ch)
+ goto done;
+
+ for (pass=0; pass < 8; ++pass) {
+ int pcount = 0, class_set = 0;
+ if (ch == 2) {
+ while (pcount < part_read) {
+ int z = r->begin + pcount*r->part_size;
+ int c_inter = (z & 1), p_inter = z>>1;
+ if (pass == 0) {
+ Codebook *c = f->codebooks+r->classbook;
+ int q;
+ DECODE(q,f,c);
+ if (q == EOP) goto done;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ part_classdata[0][class_set] = r->classdata[q];
+ #else
+ for (i=classwords-1; i >= 0; --i) {
+ classifications[0][i+pcount] = q % r->classifications;
+ q /= r->classifications;
+ }
+ #endif
+ }
+ for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
+ int z = r->begin + pcount*r->part_size;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ int c = part_classdata[0][class_set][i];
+ #else
+ int c = classifications[0][pcount];
+ #endif
+ int b = r->residue_books[c][pass];
+ if (b >= 0) {
+ Codebook *book = f->codebooks + b;
+ #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ goto done;
+ #else
+ // saves 1%
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ goto done;
+ #endif
+ } else {
+ z += r->part_size;
+ c_inter = z & 1;
+ p_inter = z >> 1;
+ }
+ }
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ ++class_set;
+ #endif
+ }
+ } else if (ch == 1) {
+ while (pcount < part_read) {
+ int z = r->begin + pcount*r->part_size;
+ int c_inter = 0, p_inter = z;
+ if (pass == 0) {
+ Codebook *c = f->codebooks+r->classbook;
+ int q;
+ DECODE(q,f,c);
+ if (q == EOP) goto done;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ part_classdata[0][class_set] = r->classdata[q];
+ #else
+ for (i=classwords-1; i >= 0; --i) {
+ classifications[0][i+pcount] = q % r->classifications;
+ q /= r->classifications;
+ }
+ #endif
+ }
+ for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
+ int z = r->begin + pcount*r->part_size;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ int c = part_classdata[0][class_set][i];
+ #else
+ int c = classifications[0][pcount];
+ #endif
+ int b = r->residue_books[c][pass];
+ if (b >= 0) {
+ Codebook *book = f->codebooks + b;
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ goto done;
+ } else {
+ z += r->part_size;
+ c_inter = 0;
+ p_inter = z;
+ }
+ }
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ ++class_set;
+ #endif
+ }
+ } else {
+ while (pcount < part_read) {
+ int z = r->begin + pcount*r->part_size;
+ int c_inter = z % ch, p_inter = z/ch;
+ if (pass == 0) {
+ Codebook *c = f->codebooks+r->classbook;
+ int q;
+ DECODE(q,f,c);
+ if (q == EOP) goto done;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ part_classdata[0][class_set] = r->classdata[q];
+ #else
+ for (i=classwords-1; i >= 0; --i) {
+ classifications[0][i+pcount] = q % r->classifications;
+ q /= r->classifications;
+ }
+ #endif
+ }
+ for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
+ int z = r->begin + pcount*r->part_size;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ int c = part_classdata[0][class_set][i];
+ #else
+ int c = classifications[0][pcount];
+ #endif
+ int b = r->residue_books[c][pass];
+ if (b >= 0) {
+ Codebook *book = f->codebooks + b;
+ if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
+ goto done;
+ } else {
+ z += r->part_size;
+ c_inter = z % ch;
+ p_inter = z / ch;
+ }
+ }
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ ++class_set;
+ #endif
+ }
+ }
+ }
+ goto done;
+ }
+ CHECK(f);
+
+ for (pass=0; pass < 8; ++pass) {
+ int pcount = 0, class_set=0;
+ while (pcount < part_read) {
+ if (pass == 0) {
+ for (j=0; j < ch; ++j) {
+ if (!do_not_decode[j]) {
+ Codebook *c = f->codebooks+r->classbook;
+ int temp;
+ DECODE(temp,f,c);
+ if (temp == EOP) goto done;
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ part_classdata[j][class_set] = r->classdata[temp];
+ #else
+ for (i=classwords-1; i >= 0; --i) {
+ classifications[j][i+pcount] = temp % r->classifications;
+ temp /= r->classifications;
+ }
+ #endif
+ }
+ }
+ }
+ for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
+ for (j=0; j < ch; ++j) {
+ if (!do_not_decode[j]) {
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ int c = part_classdata[j][class_set][i];
+ #else
+ int c = classifications[j][pcount];
+ #endif
+ int b = r->residue_books[c][pass];
+ if (b >= 0) {
+ float *target = residue_buffers[j];
+ int offset = r->begin + pcount * r->part_size;
+ int n = r->part_size;
+ Codebook *book = f->codebooks + b;
+ if (!residue_decode(f, book, target, offset, n, rtype))
+ goto done;
+ }
+ }
+ }
+ }
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ ++class_set;
+ #endif
+ }
+ }
+ done:
+ CHECK(f);
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ temp_free(f,part_classdata);
+ #else
+ temp_free(f,classifications);
+ #endif
+ temp_alloc_restore(f,temp_alloc_point);
+}
+
+
+#if 0
+// slow way for debugging
+void inverse_mdct_slow(float *buffer, int n)
+{
+ int i,j;
+ int n2 = n >> 1;
+ float *x = (float *) malloc(sizeof(*x) * n2);
+ memcpy(x, buffer, sizeof(*x) * n2);
+ for (i=0; i < n; ++i) {
+ float acc = 0;
+ for (j=0; j < n2; ++j)
+ // formula from paper:
+ //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
+ // formula from wikipedia
+ //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
+ // these are equivalent, except the formula from the paper inverts the multiplier!
+ // however, what actually works is NO MULTIPLIER!?!
+ //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
+ acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
+ buffer[i] = acc;
+ }
+ free(x);
+}
+#elif 0
+// same as above, but just barely able to run in real time on modern machines
+void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
+{
+ float mcos[16384];
+ int i,j;
+ int n2 = n >> 1, nmask = (n << 2) -1;
+ float *x = (float *) malloc(sizeof(*x) * n2);
+ memcpy(x, buffer, sizeof(*x) * n2);
+ for (i=0; i < 4*n; ++i)
+ mcos[i] = (float) cos(M_PI / 2 * i / n);
+
+ for (i=0; i < n; ++i) {
+ float acc = 0;
+ for (j=0; j < n2; ++j)
+ acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask];
+ buffer[i] = acc;
+ }
+ free(x);
+}
+#elif 0
+// transform to use a slow dct-iv; this is STILL basically trivial,
+// but only requires half as many ops
+void dct_iv_slow(float *buffer, int n)
+{
+ float mcos[16384];
+ float x[2048];
+ int i,j;
+ int n2 = n >> 1, nmask = (n << 3) - 1;
+ memcpy(x, buffer, sizeof(*x) * n);
+ for (i=0; i < 8*n; ++i)
+ mcos[i] = (float) cos(M_PI / 4 * i / n);
+ for (i=0; i < n; ++i) {
+ float acc = 0;
+ for (j=0; j < n; ++j)
+ acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask];
+ buffer[i] = acc;
+ }
+}
+
+void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
+{
+ int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4;
+ float temp[4096];
+
+ memcpy(temp, buffer, n2 * sizeof(float));
+ dct_iv_slow(temp, n2); // returns -c'-d, a-b'
+
+ for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b'
+ for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d'
+ for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d
+}
+#endif
+
+#ifndef LIBVORBIS_MDCT
+#define LIBVORBIS_MDCT 0
+#endif
+
+#if LIBVORBIS_MDCT
+// directly call the vorbis MDCT using an interface documented
+// by Jeff Roberts... useful for performance comparison
+typedef struct
+{
+ int n;
+ int log2n;
+
+ float *trig;
+ int *bitrev;
+
+ float scale;
+} mdct_lookup;
+
+extern void mdct_init(mdct_lookup *lookup, int n);
+extern void mdct_clear(mdct_lookup *l);
+extern void mdct_backward(mdct_lookup *init, float *in, float *out);
+
+mdct_lookup M1,M2;
+
+void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
+{
+ mdct_lookup *M;
+ if (M1.n == n) M = &M1;
+ else if (M2.n == n) M = &M2;
+ else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; }
+ else {
+ if (M2.n) __asm int 3;
+ mdct_init(&M2, n);
+ M = &M2;
+ }
+
+ mdct_backward(M, buffer, buffer);
+}
+#endif
+
+
+// the following were split out into separate functions while optimizing;
+// they could be pushed back up but eh. __forceinline showed no change;
+// they're probably already being inlined.
+static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
+{
+ float *ee0 = e + i_off;
+ float *ee2 = ee0 + k_off;
+ int i;
+
+ assert((n & 3) == 0);
+ for (i=(n>>2); i > 0; --i) {
+ float k00_20, k01_21;
+ k00_20 = ee0[ 0] - ee2[ 0];
+ k01_21 = ee0[-1] - ee2[-1];
+ ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0];
+ ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1];
+ ee2[ 0] = k00_20 * A[0] - k01_21 * A[1];
+ ee2[-1] = k01_21 * A[0] + k00_20 * A[1];
+ A += 8;
+
+ k00_20 = ee0[-2] - ee2[-2];
+ k01_21 = ee0[-3] - ee2[-3];
+ ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2];
+ ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3];
+ ee2[-2] = k00_20 * A[0] - k01_21 * A[1];
+ ee2[-3] = k01_21 * A[0] + k00_20 * A[1];
+ A += 8;
+
+ k00_20 = ee0[-4] - ee2[-4];
+ k01_21 = ee0[-5] - ee2[-5];
+ ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4];
+ ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5];
+ ee2[-4] = k00_20 * A[0] - k01_21 * A[1];
+ ee2[-5] = k01_21 * A[0] + k00_20 * A[1];
+ A += 8;
+
+ k00_20 = ee0[-6] - ee2[-6];
+ k01_21 = ee0[-7] - ee2[-7];
+ ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6];
+ ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7];
+ ee2[-6] = k00_20 * A[0] - k01_21 * A[1];
+ ee2[-7] = k01_21 * A[0] + k00_20 * A[1];
+ A += 8;
+ ee0 -= 8;
+ ee2 -= 8;
+ }
+}
+
+static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
+{
+ int i;
+ float k00_20, k01_21;
+
+ float *e0 = e + d0;
+ float *e2 = e0 + k_off;
+
+ for (i=lim >> 2; i > 0; --i) {
+ k00_20 = e0[-0] - e2[-0];
+ k01_21 = e0[-1] - e2[-1];
+ e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0];
+ e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1];
+ e2[-0] = (k00_20)*A[0] - (k01_21) * A[1];
+ e2[-1] = (k01_21)*A[0] + (k00_20) * A[1];
+
+ A += k1;
+
+ k00_20 = e0[-2] - e2[-2];
+ k01_21 = e0[-3] - e2[-3];
+ e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2];
+ e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3];
+ e2[-2] = (k00_20)*A[0] - (k01_21) * A[1];
+ e2[-3] = (k01_21)*A[0] + (k00_20) * A[1];
+
+ A += k1;
+
+ k00_20 = e0[-4] - e2[-4];
+ k01_21 = e0[-5] - e2[-5];
+ e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4];
+ e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5];
+ e2[-4] = (k00_20)*A[0] - (k01_21) * A[1];
+ e2[-5] = (k01_21)*A[0] + (k00_20) * A[1];
+
+ A += k1;
+
+ k00_20 = e0[-6] - e2[-6];
+ k01_21 = e0[-7] - e2[-7];
+ e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6];
+ e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7];
+ e2[-6] = (k00_20)*A[0] - (k01_21) * A[1];
+ e2[-7] = (k01_21)*A[0] + (k00_20) * A[1];
+
+ e0 -= 8;
+ e2 -= 8;
+
+ A += k1;
+ }
+}
+
+static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
+{
+ int i;
+ float A0 = A[0];
+ float A1 = A[0+1];
+ float A2 = A[0+a_off];
+ float A3 = A[0+a_off+1];
+ float A4 = A[0+a_off*2+0];
+ float A5 = A[0+a_off*2+1];
+ float A6 = A[0+a_off*3+0];
+ float A7 = A[0+a_off*3+1];
+
+ float k00,k11;
+
+ float *ee0 = e +i_off;
+ float *ee2 = ee0+k_off;
+
+ for (i=n; i > 0; --i) {
+ k00 = ee0[ 0] - ee2[ 0];
+ k11 = ee0[-1] - ee2[-1];
+ ee0[ 0] = ee0[ 0] + ee2[ 0];
+ ee0[-1] = ee0[-1] + ee2[-1];
+ ee2[ 0] = (k00) * A0 - (k11) * A1;
+ ee2[-1] = (k11) * A0 + (k00) * A1;
+
+ k00 = ee0[-2] - ee2[-2];
+ k11 = ee0[-3] - ee2[-3];
+ ee0[-2] = ee0[-2] + ee2[-2];
+ ee0[-3] = ee0[-3] + ee2[-3];
+ ee2[-2] = (k00) * A2 - (k11) * A3;
+ ee2[-3] = (k11) * A2 + (k00) * A3;
+
+ k00 = ee0[-4] - ee2[-4];
+ k11 = ee0[-5] - ee2[-5];
+ ee0[-4] = ee0[-4] + ee2[-4];
+ ee0[-5] = ee0[-5] + ee2[-5];
+ ee2[-4] = (k00) * A4 - (k11) * A5;
+ ee2[-5] = (k11) * A4 + (k00) * A5;
+
+ k00 = ee0[-6] - ee2[-6];
+ k11 = ee0[-7] - ee2[-7];
+ ee0[-6] = ee0[-6] + ee2[-6];
+ ee0[-7] = ee0[-7] + ee2[-7];
+ ee2[-6] = (k00) * A6 - (k11) * A7;
+ ee2[-7] = (k11) * A6 + (k00) * A7;
+
+ ee0 -= k0;
+ ee2 -= k0;
+ }
+}
+
+static __forceinline void iter_54(float *z)
+{
+ float k00,k11,k22,k33;
+ float y0,y1,y2,y3;
+
+ k00 = z[ 0] - z[-4];
+ y0 = z[ 0] + z[-4];
+ y2 = z[-2] + z[-6];
+ k22 = z[-2] - z[-6];
+
+ z[-0] = y0 + y2; // z0 + z4 + z2 + z6
+ z[-2] = y0 - y2; // z0 + z4 - z2 - z6
+
+ // done with y0,y2
+
+ k33 = z[-3] - z[-7];
+
+ z[-4] = k00 + k33; // z0 - z4 + z3 - z7
+ z[-6] = k00 - k33; // z0 - z4 - z3 + z7
+
+ // done with k33
+
+ k11 = z[-1] - z[-5];
+ y1 = z[-1] + z[-5];
+ y3 = z[-3] + z[-7];
+
+ z[-1] = y1 + y3; // z1 + z5 + z3 + z7
+ z[-3] = y1 - y3; // z1 + z5 - z3 - z7
+ z[-5] = k11 - k22; // z1 - z5 + z2 - z6
+ z[-7] = k11 + k22; // z1 - z5 - z2 + z6
+}
+
+static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
+{
+ int a_off = base_n >> 3;
+ float A2 = A[0+a_off];
+ float *z = e + i_off;
+ float *base = z - 16 * n;
+
+ while (z > base) {
+ float k00,k11;
+
+ k00 = z[-0] - z[-8];
+ k11 = z[-1] - z[-9];
+ z[-0] = z[-0] + z[-8];
+ z[-1] = z[-1] + z[-9];
+ z[-8] = k00;
+ z[-9] = k11 ;
+
+ k00 = z[ -2] - z[-10];
+ k11 = z[ -3] - z[-11];
+ z[ -2] = z[ -2] + z[-10];
+ z[ -3] = z[ -3] + z[-11];
+ z[-10] = (k00+k11) * A2;
+ z[-11] = (k11-k00) * A2;
+
+ k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation
+ k11 = z[ -5] - z[-13];
+ z[ -4] = z[ -4] + z[-12];
+ z[ -5] = z[ -5] + z[-13];
+ z[-12] = k11;
+ z[-13] = k00;
+
+ k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation
+ k11 = z[ -7] - z[-15];
+ z[ -6] = z[ -6] + z[-14];
+ z[ -7] = z[ -7] + z[-15];
+ z[-14] = (k00+k11) * A2;
+ z[-15] = (k00-k11) * A2;
+
+ iter_54(z);
+ iter_54(z-8);
+ z -= 16;
+ }
+}
+
+static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
+{
+ int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
+ int ld;
+ // @OPTIMIZE: reduce register pressure by using fewer variables?
+ int save_point = temp_alloc_save(f);
+ float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2));
+ float *u=NULL,*v=NULL;
+ // twiddle factors
+ float *A = f->A[blocktype];
+
+ // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
+ // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function.
+
+ // kernel from paper
+
+
+ // merged:
+ // copy and reflect spectral data
+ // step 0
+
+ // note that it turns out that the items added together during
+ // this step are, in fact, being added to themselves (as reflected
+ // by step 0). inexplicable inefficiency! this became obvious
+ // once I combined the passes.
+
+ // so there's a missing 'times 2' here (for adding X to itself).
+ // this propogates through linearly to the end, where the numbers
+ // are 1/2 too small, and need to be compensated for.
+
+ {
+ float *d,*e, *AA, *e_stop;
+ d = &buf2[n2-2];
+ AA = A;
+ e = &buffer[0];
+ e_stop = &buffer[n2];
+ while (e != e_stop) {
+ d[1] = (e[0] * AA[0] - e[2]*AA[1]);
+ d[0] = (e[0] * AA[1] + e[2]*AA[0]);
+ d -= 2;
+ AA += 2;
+ e += 4;
+ }
+
+ e = &buffer[n2-3];
+ while (d >= buf2) {
+ d[1] = (-e[2] * AA[0] - -e[0]*AA[1]);
+ d[0] = (-e[2] * AA[1] + -e[0]*AA[0]);
+ d -= 2;
+ AA += 2;
+ e -= 4;
+ }
+ }
+
+ // now we use symbolic names for these, so that we can
+ // possibly swap their meaning as we change which operations
+ // are in place
+
+ u = buffer;
+ v = buf2;
+
+ // step 2 (paper output is w, now u)
+ // this could be in place, but the data ends up in the wrong
+ // place... _somebody_'s got to swap it, so this is nominated
+ {
+ float *AA = &A[n2-8];
+ float *d0,*d1, *e0, *e1;
+
+ e0 = &v[n4];
+ e1 = &v[0];
+
+ d0 = &u[n4];
+ d1 = &u[0];
+
+ while (AA >= A) {
+ float v40_20, v41_21;
+
+ v41_21 = e0[1] - e1[1];
+ v40_20 = e0[0] - e1[0];
+ d0[1] = e0[1] + e1[1];
+ d0[0] = e0[0] + e1[0];
+ d1[1] = v41_21*AA[4] - v40_20*AA[5];
+ d1[0] = v40_20*AA[4] + v41_21*AA[5];
+
+ v41_21 = e0[3] - e1[3];
+ v40_20 = e0[2] - e1[2];
+ d0[3] = e0[3] + e1[3];
+ d0[2] = e0[2] + e1[2];
+ d1[3] = v41_21*AA[0] - v40_20*AA[1];
+ d1[2] = v40_20*AA[0] + v41_21*AA[1];
+
+ AA -= 8;
+
+ d0 += 4;
+ d1 += 4;
+ e0 += 4;
+ e1 += 4;
+ }
+ }
+
+ // step 3
+ ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
+
+ // optimized step 3:
+
+ // the original step3 loop can be nested r inside s or s inside r;
+ // it's written originally as s inside r, but this is dumb when r
+ // iterates many times, and s few. So I have two copies of it and
+ // switch between them halfway.
+
+ // this is iteration 0 of step 3
+ imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
+ imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
+
+ // this is iteration 1 of step 3
+ imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
+ imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
+ imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
+ imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
+
+ l=2;
+ for (; l < (ld-3)>>1; ++l) {
+ int k0 = n >> (l+2), k0_2 = k0>>1;
+ int lim = 1 << (l+1);
+ int i;
+ for (i=0; i < lim; ++i)
+ imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
+ }
+
+ for (; l < ld-6; ++l) {
+ int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1;
+ int rlim = n >> (l+6), r;
+ int lim = 1 << (l+1);
+ int i_off;
+ float *A0 = A;
+ i_off = n2-1;
+ for (r=rlim; r > 0; --r) {
+ imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
+ A0 += k1*4;
+ i_off -= 8;
+ }
+ }
+
+ // iterations with count:
+ // ld-6,-5,-4 all interleaved together
+ // the big win comes from getting rid of needless flops
+ // due to the constants on pass 5 & 4 being all 1 and 0;
+ // combining them to be simultaneous to improve cache made little difference
+ imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
+
+ // output is u
+
+ // step 4, 5, and 6
+ // cannot be in-place because of step 5
+ {
+ uint16 *bitrev = f->bit_reverse[blocktype];
+ // weirdly, I'd have thought reading sequentially and writing
+ // erratically would have been better than vice-versa, but in
+ // fact that's not what my testing showed. (That is, with
+ // j = bitreverse(i), do you read i and write j, or read j and write i.)
+
+ float *d0 = &v[n4-4];
+ float *d1 = &v[n2-4];
+ while (d0 >= v) {
+ int k4;
+
+ k4 = bitrev[0];
+ d1[3] = u[k4+0];
+ d1[2] = u[k4+1];
+ d0[3] = u[k4+2];
+ d0[2] = u[k4+3];
+
+ k4 = bitrev[1];
+ d1[1] = u[k4+0];
+ d1[0] = u[k4+1];
+ d0[1] = u[k4+2];
+ d0[0] = u[k4+3];
+
+ d0 -= 4;
+ d1 -= 4;
+ bitrev += 2;
+ }
+ }
+ // (paper output is u, now v)
+
+
+ // data must be in buf2
+ assert(v == buf2);
+
+ // step 7 (paper output is v, now v)
+ // this is now in place
+ {
+ float *C = f->C[blocktype];
+ float *d, *e;
+
+ d = v;
+ e = v + n2 - 4;
+
+ while (d < e) {
+ float a02,a11,b0,b1,b2,b3;
+
+ a02 = d[0] - e[2];
+ a11 = d[1] + e[3];
+
+ b0 = C[1]*a02 + C[0]*a11;
+ b1 = C[1]*a11 - C[0]*a02;
+
+ b2 = d[0] + e[ 2];
+ b3 = d[1] - e[ 3];
+
+ d[0] = b2 + b0;
+ d[1] = b3 + b1;
+ e[2] = b2 - b0;
+ e[3] = b1 - b3;
+
+ a02 = d[2] - e[0];
+ a11 = d[3] + e[1];
+
+ b0 = C[3]*a02 + C[2]*a11;
+ b1 = C[3]*a11 - C[2]*a02;
+
+ b2 = d[2] + e[ 0];
+ b3 = d[3] - e[ 1];
+
+ d[2] = b2 + b0;
+ d[3] = b3 + b1;
+ e[0] = b2 - b0;
+ e[1] = b1 - b3;
+
+ C += 4;
+ d += 4;
+ e -= 4;
+ }
+ }
+
+ // data must be in buf2
+
+
+ // step 8+decode (paper output is X, now buffer)
+ // this generates pairs of data a la 8 and pushes them directly through
+ // the decode kernel (pushing rather than pulling) to avoid having
+ // to make another pass later
+
+ // this cannot POSSIBLY be in place, so we refer to the buffers directly
+
+ {
+ float *d0,*d1,*d2,*d3;
+
+ float *B = f->B[blocktype] + n2 - 8;
+ float *e = buf2 + n2 - 8;
+ d0 = &buffer[0];
+ d1 = &buffer[n2-4];
+ d2 = &buffer[n2];
+ d3 = &buffer[n-4];
+ while (e >= v) {
+ float p0,p1,p2,p3;
+
+ p3 = e[6]*B[7] - e[7]*B[6];
+ p2 = -e[6]*B[6] - e[7]*B[7];
+
+ d0[0] = p3;
+ d1[3] = - p3;
+ d2[0] = p2;
+ d3[3] = p2;
+
+ p1 = e[4]*B[5] - e[5]*B[4];
+ p0 = -e[4]*B[4] - e[5]*B[5];
+
+ d0[1] = p1;
+ d1[2] = - p1;
+ d2[1] = p0;
+ d3[2] = p0;
+
+ p3 = e[2]*B[3] - e[3]*B[2];
+ p2 = -e[2]*B[2] - e[3]*B[3];
+
+ d0[2] = p3;
+ d1[1] = - p3;
+ d2[2] = p2;
+ d3[1] = p2;
+
+ p1 = e[0]*B[1] - e[1]*B[0];
+ p0 = -e[0]*B[0] - e[1]*B[1];
+
+ d0[3] = p1;
+ d1[0] = - p1;
+ d2[3] = p0;
+ d3[0] = p0;
+
+ B -= 8;
+ e -= 8;
+ d0 += 4;
+ d2 += 4;
+ d1 -= 4;
+ d3 -= 4;
+ }
+ }
+
+ temp_free(f,buf2);
+ temp_alloc_restore(f,save_point);
+}
+
+#if 0
+// this is the original version of the above code, if you want to optimize it from scratch
+void inverse_mdct_naive(float *buffer, int n)
+{
+ float s;
+ float A[1 << 12], B[1 << 12], C[1 << 11];
+ int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
+ int n3_4 = n - n4, ld;
+ // how can they claim this only uses N words?!
+ // oh, because they're only used sparsely, whoops
+ float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13];
+ // set up twiddle factors
+
+ for (k=k2=0; k < n4; ++k,k2+=2) {
+ A[k2 ] = (float) cos(4*k*M_PI/n);
+ A[k2+1] = (float) -sin(4*k*M_PI/n);
+ B[k2 ] = (float) cos((k2+1)*M_PI/n/2);
+ B[k2+1] = (float) sin((k2+1)*M_PI/n/2);
+ }
+ for (k=k2=0; k < n8; ++k,k2+=2) {
+ C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
+ C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
+ }
+
+ // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
+ // Note there are bugs in that pseudocode, presumably due to them attempting
+ // to rename the arrays nicely rather than representing the way their actual
+ // implementation bounces buffers back and forth. As a result, even in the
+ // "some formulars corrected" version, a direct implementation fails. These
+ // are noted below as "paper bug".
+
+ // copy and reflect spectral data
+ for (k=0; k < n2; ++k) u[k] = buffer[k];
+ for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1];
+ // kernel from paper
+ // step 1
+ for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) {
+ v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1];
+ v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2];
+ }
+ // step 2
+ for (k=k4=0; k < n8; k+=1, k4+=4) {
+ w[n2+3+k4] = v[n2+3+k4] + v[k4+3];
+ w[n2+1+k4] = v[n2+1+k4] + v[k4+1];
+ w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4];
+ w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4];
+ }
+ // step 3
+ ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
+ for (l=0; l < ld-3; ++l) {
+ int k0 = n >> (l+2), k1 = 1 << (l+3);
+ int rlim = n >> (l+4), r4, r;
+ int s2lim = 1 << (l+2), s2;
+ for (r=r4=0; r < rlim; r4+=4,++r) {
+ for (s2=0; s2 < s2lim; s2+=2) {
+ u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4];
+ u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4];
+ u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1]
+ - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1];
+ u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1]
+ + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1];
+ }
+ }
+ if (l+1 < ld-3) {
+ // paper bug: ping-ponging of u&w here is omitted
+ memcpy(w, u, sizeof(u));
+ }
+ }
+
+ // step 4
+ for (i=0; i < n8; ++i) {
+ int j = bit_reverse(i) >> (32-ld+3);
+ assert(j < n8);
+ if (i == j) {
+ // paper bug: original code probably swapped in place; if copying,
+ // need to directly copy in this case
+ int i8 = i << 3;
+ v[i8+1] = u[i8+1];
+ v[i8+3] = u[i8+3];
+ v[i8+5] = u[i8+5];
+ v[i8+7] = u[i8+7];
+ } else if (i < j) {
+ int i8 = i << 3, j8 = j << 3;
+ v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1];
+ v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3];
+ v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5];
+ v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7];
+ }
+ }
+ // step 5
+ for (k=0; k < n2; ++k) {
+ w[k] = v[k*2+1];
+ }
+ // step 6
+ for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) {
+ u[n-1-k2] = w[k4];
+ u[n-2-k2] = w[k4+1];
+ u[n3_4 - 1 - k2] = w[k4+2];
+ u[n3_4 - 2 - k2] = w[k4+3];
+ }
+ // step 7
+ for (k=k2=0; k < n8; ++k, k2 += 2) {
+ v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
+ v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
+ v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
+ v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
+ }
+ // step 8
+ for (k=k2=0; k < n4; ++k,k2 += 2) {
+ X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1];
+ X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ];
+ }
+
+ // decode kernel to output
+ // determined the following value experimentally
+ // (by first figuring out what made inverse_mdct_slow work); then matching that here
+ // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?)
+ s = 0.5; // theoretically would be n4
+
+ // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code,
+ // so it needs to use the "old" B values to behave correctly, or else
+ // set s to 1.0 ]]]
+ for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4];
+ for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1];
+ for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4];
+}
+#endif
+
+static float *get_window(vorb *f, int len)
+{
+ len <<= 1;
+ if (len == f->blocksize_0) return f->window[0];
+ if (len == f->blocksize_1) return f->window[1];
+ assert(0);
+ return NULL;
+}
+
+#ifndef STB_VORBIS_NO_DEFER_FLOOR
+typedef int16 YTYPE;
+#else
+typedef int YTYPE;
+#endif
+static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag)
+{
+ int n2 = n >> 1;
+ int s = map->chan[i].mux, floor;
+ floor = map->submap_floor[s];
+ if (f->floor_types[floor] == 0) {
+ return error(f, VORBIS_invalid_stream);
+ } else {
+ Floor1 *g = &f->floor_config[floor].floor1;
+ int j,q;
+ int lx = 0, ly = finalY[0] * g->floor1_multiplier;
+ for (q=1; q < g->values; ++q) {
+ j = g->sorted_order[q];
+ #ifndef STB_VORBIS_NO_DEFER_FLOOR
+ if (finalY[j] >= 0)
+ #else
+ if (step2_flag[j])
+ #endif
+ {
+ int hy = finalY[j] * g->floor1_multiplier;
+ int hx = g->Xlist[j];
+ if (lx != hx)
+ draw_line(target, lx,ly, hx,hy, n2);
+ CHECK(f);
+ lx = hx, ly = hy;
+ }
+ }
+ if (lx < n2) {
+ // optimization of: draw_line(target, lx,ly, n,ly, n2);
+ for (j=lx; j < n2; ++j)
+ LINE_OP(target[j], inverse_db_table[ly]);
+ CHECK(f);
+ }
+ }
+ return TRUE;
+}
+
+// The meaning of "left" and "right"
+//
+// For a given frame:
+// we compute samples from 0..n
+// window_center is n/2
+// we'll window and mix the samples from left_start to left_end with data from the previous frame
+// all of the samples from left_end to right_start can be output without mixing; however,
+// this interval is 0-length except when transitioning between short and long frames
+// all of the samples from right_start to right_end need to be mixed with the next frame,
+// which we don't have, so those get saved in a buffer
+// frame N's right_end-right_start, the number of samples to mix with the next frame,
+// has to be the same as frame N+1's left_end-left_start (which they are by
+// construction)
+
+static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
+{
+ Mode *m;
+ int i, n, prev, next, window_center;
+ f->channel_buffer_start = f->channel_buffer_end = 0;
+
+ retry:
+ if (f->eof) return FALSE;
+ if (!maybe_start_packet(f))
+ return FALSE;
+ // check packet type
+ if (get_bits(f,1) != 0) {
+ if (IS_PUSH_MODE(f))
+ return error(f,VORBIS_bad_packet_type);
+ while (EOP != get8_packet(f));
+ goto retry;
+ }
+
+ if (f->alloc.alloc_buffer)
+ assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
+
+ i = get_bits(f, ilog(f->mode_count-1));
+ if (i == EOP) return FALSE;
+ if (i >= f->mode_count) return FALSE;
+ *mode = i;
+ m = f->mode_config + i;
+ if (m->blockflag) {
+ n = f->blocksize_1;
+ prev = get_bits(f,1);
+ next = get_bits(f,1);
+ } else {
+ prev = next = 0;
+ n = f->blocksize_0;
+ }
+
+// WINDOWING
+
+ window_center = n >> 1;
+ if (m->blockflag && !prev) {
+ *p_left_start = (n - f->blocksize_0) >> 2;
+ *p_left_end = (n + f->blocksize_0) >> 2;
+ } else {
+ *p_left_start = 0;
+ *p_left_end = window_center;
+ }
+ if (m->blockflag && !next) {
+ *p_right_start = (n*3 - f->blocksize_0) >> 2;
+ *p_right_end = (n*3 + f->blocksize_0) >> 2;
+ } else {
+ *p_right_start = window_center;
+ *p_right_end = n;
+ }
+
+ return TRUE;
+}
+
+static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
+{
+ Mapping *map;
+ int i,j,k,n,n2;
+ int zero_channel[256];
+ int really_zero_channel[256];
+
+// WINDOWING
+
+ n = f->blocksize[m->blockflag];
+ map = &f->mapping[m->mapping];
+
+// FLOORS
+ n2 = n >> 1;
+
+ CHECK(f);
+
+ for (i=0; i < f->channels; ++i) {
+ int s = map->chan[i].mux, floor;
+ zero_channel[i] = FALSE;
+ floor = map->submap_floor[s];
+ if (f->floor_types[floor] == 0) {
+ return error(f, VORBIS_invalid_stream);
+ } else {
+ Floor1 *g = &f->floor_config[floor].floor1;
+ if (get_bits(f, 1)) {
+ short *finalY;
+ uint8 step2_flag[256];
+ static int range_list[4] = { 256, 128, 86, 64 };
+ int range = range_list[g->floor1_multiplier-1];
+ int offset = 2;
+ finalY = f->finalY[i];
+ finalY[0] = get_bits(f, ilog(range)-1);
+ finalY[1] = get_bits(f, ilog(range)-1);
+ for (j=0; j < g->partitions; ++j) {
+ int pclass = g->partition_class_list[j];
+ int cdim = g->class_dimensions[pclass];
+ int cbits = g->class_subclasses[pclass];
+ int csub = (1 << cbits)-1;
+ int cval = 0;
+ if (cbits) {
+ Codebook *c = f->codebooks + g->class_masterbooks[pclass];
+ DECODE(cval,f,c);
+ }
+ for (k=0; k < cdim; ++k) {
+ int book = g->subclass_books[pclass][cval & csub];
+ cval = cval >> cbits;
+ if (book >= 0) {
+ int temp;
+ Codebook *c = f->codebooks + book;
+ DECODE(temp,f,c);
+ finalY[offset++] = temp;
+ } else
+ finalY[offset++] = 0;
+ }
+ }
+ if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec
+ step2_flag[0] = step2_flag[1] = 1;
+ for (j=2; j < g->values; ++j) {
+ int low, high, pred, highroom, lowroom, room, val;
+ low = g->neighbors[j][0];
+ high = g->neighbors[j][1];
+ //neighbors(g->Xlist, j, &low, &high);
+ pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
+ val = finalY[j];
+ highroom = range - pred;
+ lowroom = pred;
+ if (highroom < lowroom)
+ room = highroom * 2;
+ else
+ room = lowroom * 2;
+ if (val) {
+ step2_flag[low] = step2_flag[high] = 1;
+ step2_flag[j] = 1;
+ if (val >= room)
+ if (highroom > lowroom)
+ finalY[j] = val - lowroom + pred;
+ else
+ finalY[j] = pred - val + highroom - 1;
+ else
+ if (val & 1)
+ finalY[j] = pred - ((val+1)>>1);
+ else
+ finalY[j] = pred + (val>>1);
+ } else {
+ step2_flag[j] = 0;
+ finalY[j] = pred;
+ }
+ }
+
+#ifdef STB_VORBIS_NO_DEFER_FLOOR
+ do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
+#else
+ // defer final floor computation until _after_ residue
+ for (j=0; j < g->values; ++j) {
+ if (!step2_flag[j])
+ finalY[j] = -1;
+ }
+#endif
+ } else {
+ error:
+ zero_channel[i] = TRUE;
+ }
+ // So we just defer everything else to later
+
+ // at this point we've decoded the floor into buffer
+ }
+ }
+ CHECK(f);
+ // at this point we've decoded all floors
+
+ if (f->alloc.alloc_buffer)
+ assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
+
+ // re-enable coupled channels if necessary
+ memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels);
+ for (i=0; i < map->coupling_steps; ++i)
+ if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) {
+ zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
+ }
+
+ CHECK(f);
+// RESIDUE DECODE
+ for (i=0; i < map->submaps; ++i) {
+ float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
+ int r;
+ uint8 do_not_decode[256];
+ int ch = 0;
+ for (j=0; j < f->channels; ++j) {
+ if (map->chan[j].mux == i) {
+ if (zero_channel[j]) {
+ do_not_decode[ch] = TRUE;
+ residue_buffers[ch] = NULL;
+ } else {
+ do_not_decode[ch] = FALSE;
+ residue_buffers[ch] = f->channel_buffers[j];
+ }
+ ++ch;
+ }
+ }
+ r = map->submap_residue[i];
+ decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
+ }
+
+ if (f->alloc.alloc_buffer)
+ assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
+ CHECK(f);
+
+// INVERSE COUPLING
+ for (i = map->coupling_steps-1; i >= 0; --i) {
+ int n2 = n >> 1;
+ float *m = f->channel_buffers[map->chan[i].magnitude];
+ float *a = f->channel_buffers[map->chan[i].angle ];
+ for (j=0; j < n2; ++j) {
+ float a2,m2;
+ if (m[j] > 0)
+ if (a[j] > 0)
+ m2 = m[j], a2 = m[j] - a[j];
+ else
+ a2 = m[j], m2 = m[j] + a[j];
+ else
+ if (a[j] > 0)
+ m2 = m[j], a2 = m[j] + a[j];
+ else
+ a2 = m[j], m2 = m[j] - a[j];
+ m[j] = m2;
+ a[j] = a2;
+ }
+ }
+ CHECK(f);
+
+ // finish decoding the floors
+#ifndef STB_VORBIS_NO_DEFER_FLOOR
+ for (i=0; i < f->channels; ++i) {
+ if (really_zero_channel[i]) {
+ memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
+ } else {
+ do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
+ }
+ }
+#else
+ for (i=0; i < f->channels; ++i) {
+ if (really_zero_channel[i]) {
+ memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
+ } else {
+ for (j=0; j < n2; ++j)
+ f->channel_buffers[i][j] *= f->floor_buffers[i][j];
+ }
+ }
+#endif
+
+// INVERSE MDCT
+ CHECK(f);
+ for (i=0; i < f->channels; ++i)
+ inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
+ CHECK(f);
+
+ // this shouldn't be necessary, unless we exited on an error
+ // and want to flush to get to the next packet
+ flush_packet(f);
+
+ if (f->first_decode) {
+ // assume we start so first non-discarded sample is sample 0
+ // this isn't to spec, but spec would require us to read ahead
+ // and decode the size of all current frames--could be done,
+ // but presumably it's not a commonly used feature
+ f->current_loc = -n2; // start of first frame is positioned for discard
+ // we might have to discard samples "from" the next frame too,
+ // if we're lapping a large block then a small at the start?
+ f->discard_samples_deferred = n - right_end;
+ f->current_loc_valid = TRUE;
+ f->first_decode = FALSE;
+ } else if (f->discard_samples_deferred) {
+ if (f->discard_samples_deferred >= right_start - left_start) {
+ f->discard_samples_deferred -= (right_start - left_start);
+ left_start = right_start;
+ *p_left = left_start;
+ } else {
+ left_start += f->discard_samples_deferred;
+ *p_left = left_start;
+ f->discard_samples_deferred = 0;
+ }
+ } else if (f->previous_length == 0 && f->current_loc_valid) {
+ // we're recovering from a seek... that means we're going to discard
+ // the samples from this packet even though we know our position from
+ // the last page header, so we need to update the position based on
+ // the discarded samples here
+ // but wait, the code below is going to add this in itself even
+ // on a discard, so we don't need to do it here...
+ }
+
+ // check if we have ogg information about the sample # for this packet
+ if (f->last_seg_which == f->end_seg_with_known_loc) {
+ // if we have a valid current loc, and this is final:
+ if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) {
+ uint32 current_end = f->known_loc_for_packet - (n-right_end);
+ // then let's infer the size of the (probably) short final frame
+ if (current_end < f->current_loc + (right_end-left_start)) {
+ if (current_end < f->current_loc) {
+ // negative truncation, that's impossible!
+ *len = 0;
+ } else {
+ *len = current_end - f->current_loc;
+ }
+ *len += left_start;
+ if (*len > right_end) *len = right_end; // this should never happen
+ f->current_loc += *len;
+ return TRUE;
+ }
+ }
+ // otherwise, just set our sample loc
+ // guess that the ogg granule pos refers to the _middle_ of the
+ // last frame?
+ // set f->current_loc to the position of left_start
+ f->current_loc = f->known_loc_for_packet - (n2-left_start);
+ f->current_loc_valid = TRUE;
+ }
+ if (f->current_loc_valid)
+ f->current_loc += (right_start - left_start);
+
+ if (f->alloc.alloc_buffer)
+ assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
+ *len = right_end; // ignore samples after the window goes to 0
+ CHECK(f);
+
+ return TRUE;
+}
+
+static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right)
+{
+ int mode, left_end, right_end;
+ if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
+ return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
+}
+
+static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
+{
+ int prev,i,j;
+ // we use right&left (the start of the right- and left-window sin()-regions)
+ // to determine how much to return, rather than inferring from the rules
+ // (same result, clearer code); 'left' indicates where our sin() window
+ // starts, therefore where the previous window's right edge starts, and
+ // therefore where to start mixing from the previous buffer. 'right'
+ // indicates where our sin() ending-window starts, therefore that's where
+ // we start saving, and where our returned-data ends.
+
+ // mixin from previous window
+ if (f->previous_length) {
+ int i,j, n = f->previous_length;
+ float *w = get_window(f, n);
+ for (i=0; i < f->channels; ++i) {
+ for (j=0; j < n; ++j)
+ f->channel_buffers[i][left+j] =
+ f->channel_buffers[i][left+j]*w[ j] +
+ f->previous_window[i][ j]*w[n-1-j];
+ }
+ }
+
+ prev = f->previous_length;
+
+ // last half of this data becomes previous window
+ f->previous_length = len - right;
+
+ // @OPTIMIZE: could avoid this copy by double-buffering the
+ // output (flipping previous_window with channel_buffers), but
+ // then previous_window would have to be 2x as large, and
+ // channel_buffers couldn't be temp mem (although they're NOT
+ // currently temp mem, they could be (unless we want to level
+ // performance by spreading out the computation))
+ for (i=0; i < f->channels; ++i)
+ for (j=0; right+j < len; ++j)
+ f->previous_window[i][j] = f->channel_buffers[i][right+j];
+
+ if (!prev)
+ // there was no previous packet, so this data isn't valid...
+ // this isn't entirely true, only the would-have-overlapped data
+ // isn't valid, but this seems to be what the spec requires
+ return 0;
+
+ // truncate a short frame
+ if (len < right) right = len;
+
+ f->samples_output += right-left;
+
+ return right - left;
+}
+
+static void vorbis_pump_first_frame(stb_vorbis *f)
+{
+ int len, right, left;
+ if (vorbis_decode_packet(f, &len, &left, &right))
+ vorbis_finish_frame(f, len, left, right);
+}
+
+#ifndef STB_VORBIS_NO_PUSHDATA_API
+static int is_whole_packet_present(stb_vorbis *f, int end_page)
+{
+ // make sure that we have the packet available before continuing...
+ // this requires a full ogg parse, but we know we can fetch from f->stream
+
+ // instead of coding this out explicitly, we could save the current read state,
+ // read the next packet with get8() until end-of-packet, check f->eof, then
+ // reset the state? but that would be slower, esp. since we'd have over 256 bytes
+ // of state to restore (primarily the page segment table)
+
+ int s = f->next_seg, first = TRUE;
+ uint8 *p = f->stream;
+
+ if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag
+ for (; s < f->segment_count; ++s) {
+ p += f->segments[s];
+ if (f->segments[s] < 255) // stop at first short segment
+ break;
+ }
+ // either this continues, or it ends it...
+ if (end_page)
+ if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream);
+ if (s == f->segment_count)
+ s = -1; // set 'crosses page' flag
+ if (p > f->stream_end) return error(f, VORBIS_need_more_data);
+ first = FALSE;
+ }
+ for (; s == -1;) {
+ uint8 *q;
+ int n;
+
+ // check that we have the page header ready
+ if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data);
+ // validate the page
+ if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream);
+ if (p[4] != 0) return error(f, VORBIS_invalid_stream);
+ if (first) { // the first segment must NOT have 'continued_packet', later ones MUST
+ if (f->previous_length)
+ if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
+ // if no previous length, we're resynching, so we can come in on a continued-packet,
+ // which we'll just drop
+ } else {
+ if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
+ }
+ n = p[26]; // segment counts
+ q = p+27; // q points to segment table
+ p = q + n; // advance past header
+ // make sure we've read the segment table
+ if (p > f->stream_end) return error(f, VORBIS_need_more_data);
+ for (s=0; s < n; ++s) {
+ p += q[s];
+ if (q[s] < 255)
+ break;
+ }
+ if (end_page)
+ if (s < n-1) return error(f, VORBIS_invalid_stream);
+ if (s == n)
+ s = -1; // set 'crosses page' flag
+ if (p > f->stream_end) return error(f, VORBIS_need_more_data);
+ first = FALSE;
+ }
+ return TRUE;
+}
+#endif // !STB_VORBIS_NO_PUSHDATA_API
+
+static int start_decoder(vorb *f)
+{
+ uint8 header[6], x,y;
+ int len,i,j,k, max_submaps = 0;
+ int longest_floorlist=0;
+
+ // first page, first packet
+
+ if (!start_page(f)) return FALSE;
+ // validate page flag
+ if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page);
+ if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page);
+ if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
+ // check for expected packet length
+ if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
+ if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
+ // read packet
+ // check packet header
+ if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
+ if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof);
+ if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page);
+ // vorbis_version
+ if (get32(f) != 0) return error(f, VORBIS_invalid_first_page);
+ f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page);
+ if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels);
+ f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page);
+ get32(f); // bitrate_maximum
+ get32(f); // bitrate_nominal
+ get32(f); // bitrate_minimum
+ x = get8(f);
+ {
+ int log0,log1;
+ log0 = x & 15;
+ log1 = x >> 4;
+ f->blocksize_0 = 1 << log0;
+ f->blocksize_1 = 1 << log1;
+ if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup);
+ if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup);
+ if (log0 > log1) return error(f, VORBIS_invalid_setup);
+ }
+
+ // framing_flag
+ x = get8(f);
+ if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
+
+ // second packet!
+ if (!start_page(f)) return FALSE;
+
+ if (!start_packet(f)) return FALSE;
+ do {
+ len = next_segment(f);
+ skip(f, len);
+ f->bytes_in_seg = 0;
+ } while (len);
+
+ // third packet!
+ if (!start_packet(f)) return FALSE;
+
+ #ifndef STB_VORBIS_NO_PUSHDATA_API
+ if (IS_PUSH_MODE(f)) {
+ if (!is_whole_packet_present(f, TRUE)) {
+ // convert error in ogg header to write type
+ if (f->error == VORBIS_invalid_stream)
+ f->error = VORBIS_invalid_setup;
+ return FALSE;
+ }
+ }
+ #endif
+
+ crc32_init(); // always init it, to avoid multithread race conditions
+
+ if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup);
+ for (i=0; i < 6; ++i) header[i] = get8_packet(f);
+ if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);
+
+ // codebooks
+
+ f->codebook_count = get_bits(f,8) + 1;
+ f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
+ if (f->codebooks == NULL) return error(f, VORBIS_outofmem);
+ memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
+ for (i=0; i < f->codebook_count; ++i) {
+ uint32 *values;
+ int ordered, sorted_count;
+ int total=0;
+ uint8 *lengths;
+ Codebook *c = f->codebooks+i;
+ CHECK(f);
+ x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup);
+ x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup);
+ x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup);
+ x = get_bits(f, 8);
+ c->dimensions = (get_bits(f, 8)<<8) + x;
+ x = get_bits(f, 8);
+ y = get_bits(f, 8);
+ c->entries = (get_bits(f, 8)<<16) + (y<<8) + x;
+ ordered = get_bits(f,1);
+ c->sparse = ordered ? 0 : get_bits(f,1);
+
+ if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup);
+
+ if (c->sparse)
+ lengths = (uint8 *) setup_temp_malloc(f, c->entries);
+ else
+ lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
+
+ if (!lengths) return error(f, VORBIS_outofmem);
+
+ if (ordered) {
+ int current_entry = 0;
+ int current_length = get_bits(f,5) + 1;
+ while (current_entry < c->entries) {
+ int limit = c->entries - current_entry;
+ int n = get_bits(f, ilog(limit));
+ if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); }
+ memset(lengths + current_entry, current_length, n);
+ current_entry += n;
+ ++current_length;
+ }
+ } else {
+ for (j=0; j < c->entries; ++j) {
+ int present = c->sparse ? get_bits(f,1) : 1;
+ if (present) {
+ lengths[j] = get_bits(f, 5) + 1;
+ ++total;
+ if (lengths[j] == 32)
+ return error(f, VORBIS_invalid_setup);
+ } else {
+ lengths[j] = NO_CODE;
+ }
+ }
+ }
+
+ if (c->sparse && total >= c->entries >> 2) {
+ // convert sparse items to non-sparse!
+ if (c->entries > (int) f->setup_temp_memory_required)
+ f->setup_temp_memory_required = c->entries;
+
+ c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
+ if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem);
+ memcpy(c->codeword_lengths, lengths, c->entries);
+ setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
+ lengths = c->codeword_lengths;
+ c->sparse = 0;
+ }
+
+ // compute the size of the sorted tables
+ if (c->sparse) {
+ sorted_count = total;
+ } else {
+ sorted_count = 0;
+ #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
+ for (j=0; j < c->entries; ++j)
+ if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
+ ++sorted_count;
+ #endif
+ }
+
+ c->sorted_entries = sorted_count;
+ values = NULL;
+
+ CHECK(f);
+ if (!c->sparse) {
+ c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
+ if (!c->codewords) return error(f, VORBIS_outofmem);
+ } else {
+ unsigned int size;
+ if (c->sorted_entries) {
+ c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries);
+ if (!c->codeword_lengths) return error(f, VORBIS_outofmem);
+ c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
+ if (!c->codewords) return error(f, VORBIS_outofmem);
+ values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
+ if (!values) return error(f, VORBIS_outofmem);
+ }
+ size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
+ if (size > f->setup_temp_memory_required)
+ f->setup_temp_memory_required = size;
+ }
+
+ if (!compute_codewords(c, lengths, c->entries, values)) {
+ if (c->sparse) setup_temp_free(f, values, 0);
+ return error(f, VORBIS_invalid_setup);
+ }
+
+ if (c->sorted_entries) {
+ // allocate an extra slot for sentinels
+ c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
+ if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem);
+ // allocate an extra slot at the front so that c->sorted_values[-1] is defined
+ // so that we can catch that case without an extra if
+ c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1));
+ if (c->sorted_values == NULL) return error(f, VORBIS_outofmem);
+ ++c->sorted_values;
+ c->sorted_values[-1] = -1;
+ compute_sorted_huffman(c, lengths, values);
+ }
+
+ if (c->sparse) {
+ setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
+ setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
+ setup_temp_free(f, lengths, c->entries);
+ c->codewords = NULL;
+ }
+
+ compute_accelerated_huffman(c);
+
+ CHECK(f);
+ c->lookup_type = get_bits(f, 4);
+ if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup);
+ if (c->lookup_type > 0) {
+ uint16 *mults;
+ c->minimum_value = float32_unpack(get_bits(f, 32));
+ c->delta_value = float32_unpack(get_bits(f, 32));
+ c->value_bits = get_bits(f, 4)+1;
+ c->sequence_p = get_bits(f,1);
+ if (c->lookup_type == 1) {
+ c->lookup_values = lookup1_values(c->entries, c->dimensions);
+ } else {
+ c->lookup_values = c->entries * c->dimensions;
+ }
+ if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup);
+ mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
+ if (mults == NULL) return error(f, VORBIS_outofmem);
+ for (j=0; j < (int) c->lookup_values; ++j) {
+ int q = get_bits(f, c->value_bits);
+ if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); }
+ mults[j] = q;
+ }
+
+#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ if (c->lookup_type == 1) {
+ int len, sparse = c->sparse;
+ float last=0;
+ // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
+ if (sparse) {
+ if (c->sorted_entries == 0) goto skip;
+ c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
+ } else
+ c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
+ if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
+ len = sparse ? c->sorted_entries : c->entries;
+ for (j=0; j < len; ++j) {
+ unsigned int z = sparse ? c->sorted_values[j] : j;
+ unsigned int div=1;
+ for (k=0; k < c->dimensions; ++k) {
+ int off = (z / div) % c->lookup_values;
+ float val = mults[off];
+ val = mults[off]*c->delta_value + c->minimum_value + last;
+ c->multiplicands[j*c->dimensions + k] = val;
+ if (c->sequence_p)
+ last = val;
+ if (k+1 < c->dimensions) {
+ if (div > UINT_MAX / (unsigned int) c->lookup_values) {
+ setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
+ return error(f, VORBIS_invalid_setup);
+ }
+ div *= c->lookup_values;
+ }
+ }
+ }
+ c->lookup_type = 2;
+ }
+ else
+#endif
+ {
+ float last=0;
+ CHECK(f);
+ c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
+ if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
+ for (j=0; j < (int) c->lookup_values; ++j) {
+ float val = mults[j] * c->delta_value + c->minimum_value + last;
+ c->multiplicands[j] = val;
+ if (c->sequence_p)
+ last = val;
+ }
+ }
+#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
+ skip:;
+#endif
+ setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
+
+ CHECK(f);
+ }
+ CHECK(f);
+ }
+
+ // time domain transfers (notused)
+
+ x = get_bits(f, 6) + 1;
+ for (i=0; i < x; ++i) {
+ uint32 z = get_bits(f, 16);
+ if (z != 0) return error(f, VORBIS_invalid_setup);
+ }
+
+ // Floors
+ f->floor_count = get_bits(f, 6)+1;
+ f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
+ if (f->floor_config == NULL) return error(f, VORBIS_outofmem);
+ for (i=0; i < f->floor_count; ++i) {
+ f->floor_types[i] = get_bits(f, 16);
+ if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup);
+ if (f->floor_types[i] == 0) {
+ Floor0 *g = &f->floor_config[i].floor0;
+ g->order = get_bits(f,8);
+ g->rate = get_bits(f,16);
+ g->bark_map_size = get_bits(f,16);
+ g->amplitude_bits = get_bits(f,6);
+ g->amplitude_offset = get_bits(f,8);
+ g->number_of_books = get_bits(f,4) + 1;
+ for (j=0; j < g->number_of_books; ++j)
+ g->book_list[j] = get_bits(f,8);
+ return error(f, VORBIS_feature_not_supported);
+ } else {
+ Point p[31*8+2];
+ Floor1 *g = &f->floor_config[i].floor1;
+ int max_class = -1;
+ g->partitions = get_bits(f, 5);
+ for (j=0; j < g->partitions; ++j) {
+ g->partition_class_list[j] = get_bits(f, 4);
+ if (g->partition_class_list[j] > max_class)
+ max_class = g->partition_class_list[j];
+ }
+ for (j=0; j <= max_class; ++j) {
+ g->class_dimensions[j] = get_bits(f, 3)+1;
+ g->class_subclasses[j] = get_bits(f, 2);
+ if (g->class_subclasses[j]) {
+ g->class_masterbooks[j] = get_bits(f, 8);
+ if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
+ }
+ for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
+ g->subclass_books[j][k] = get_bits(f,8)-1;
+ if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
+ }
+ }
+ g->floor1_multiplier = get_bits(f,2)+1;
+ g->rangebits = get_bits(f,4);
+ g->Xlist[0] = 0;
+ g->Xlist[1] = 1 << g->rangebits;
+ g->values = 2;
+ for (j=0; j < g->partitions; ++j) {
+ int c = g->partition_class_list[j];
+ for (k=0; k < g->class_dimensions[c]; ++k) {
+ g->Xlist[g->values] = get_bits(f, g->rangebits);
+ ++g->values;
+ }
+ }
+ // precompute the sorting
+ for (j=0; j < g->values; ++j) {
+ p[j].x = g->Xlist[j];
+ p[j].y = j;
+ }
+ qsort(p, g->values, sizeof(p[0]), point_compare);
+ for (j=0; j < g->values; ++j)
+ g->sorted_order[j] = (uint8) p[j].y;
+ // precompute the neighbors
+ for (j=2; j < g->values; ++j) {
+ int low,hi;
+ neighbors(g->Xlist, j, &low,&hi);
+ g->neighbors[j][0] = low;
+ g->neighbors[j][1] = hi;
+ }
+
+ if (g->values > longest_floorlist)
+ longest_floorlist = g->values;
+ }
+ }
+
+ // Residue
+ f->residue_count = get_bits(f, 6)+1;
+ f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
+ if (f->residue_config == NULL) return error(f, VORBIS_outofmem);
+ memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
+ for (i=0; i < f->residue_count; ++i) {
+ uint8 residue_cascade[64];
+ Residue *r = f->residue_config+i;
+ f->residue_types[i] = get_bits(f, 16);
+ if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup);
+ r->begin = get_bits(f, 24);
+ r->end = get_bits(f, 24);
+ if (r->end < r->begin) return error(f, VORBIS_invalid_setup);
+ r->part_size = get_bits(f,24)+1;
+ r->classifications = get_bits(f,6)+1;
+ r->classbook = get_bits(f,8);
+ if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup);
+ for (j=0; j < r->classifications; ++j) {
+ uint8 high_bits=0;
+ uint8 low_bits=get_bits(f,3);
+ if (get_bits(f,1))
+ high_bits = get_bits(f,5);
+ residue_cascade[j] = high_bits*8 + low_bits;
+ }
+ r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
+ if (r->residue_books == NULL) return error(f, VORBIS_outofmem);
+ for (j=0; j < r->classifications; ++j) {
+ for (k=0; k < 8; ++k) {
+ if (residue_cascade[j] & (1 << k)) {
+ r->residue_books[j][k] = get_bits(f, 8);
+ if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
+ } else {
+ r->residue_books[j][k] = -1;
+ }
+ }
+ }
+ // precompute the classifications[] array to avoid inner-loop mod/divide
+ // call it 'classdata' since we already have r->classifications
+ r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
+ if (!r->classdata) return error(f, VORBIS_outofmem);
+ memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
+ for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
+ int classwords = f->codebooks[r->classbook].dimensions;
+ int temp = j;
+ r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
+ if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem);
+ for (k=classwords-1; k >= 0; --k) {
+ r->classdata[j][k] = temp % r->classifications;
+ temp /= r->classifications;
+ }
+ }
+ }
+
+ f->mapping_count = get_bits(f,6)+1;
+ f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
+ if (f->mapping == NULL) return error(f, VORBIS_outofmem);
+ memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
+ for (i=0; i < f->mapping_count; ++i) {
+ Mapping *m = f->mapping + i;
+ int mapping_type = get_bits(f,16);
+ if (mapping_type != 0) return error(f, VORBIS_invalid_setup);
+ m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan));
+ if (m->chan == NULL) return error(f, VORBIS_outofmem);
+ if (get_bits(f,1))
+ m->submaps = get_bits(f,4)+1;
+ else
+ m->submaps = 1;
+ if (m->submaps > max_submaps)
+ max_submaps = m->submaps;
+ if (get_bits(f,1)) {
+ m->coupling_steps = get_bits(f,8)+1;
+ for (k=0; k < m->coupling_steps; ++k) {
+ m->chan[k].magnitude = get_bits(f, ilog(f->channels-1));
+ m->chan[k].angle = get_bits(f, ilog(f->channels-1));
+ if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup);
+ if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup);
+ if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup);
+ }
+ } else
+ m->coupling_steps = 0;
+
+ // reserved field
+ if (get_bits(f,2)) return error(f, VORBIS_invalid_setup);
+ if (m->submaps > 1) {
+ for (j=0; j < f->channels; ++j) {
+ m->chan[j].mux = get_bits(f, 4);
+ if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup);
+ }
+ } else
+ // @SPECIFICATION: this case is missing from the spec
+ for (j=0; j < f->channels; ++j)
+ m->chan[j].mux = 0;
+
+ for (j=0; j < m->submaps; ++j) {
+ get_bits(f,8); // discard
+ m->submap_floor[j] = get_bits(f,8);
+ m->submap_residue[j] = get_bits(f,8);
+ if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup);
+ if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup);
+ }
+ }
+
+ // Modes
+ f->mode_count = get_bits(f, 6)+1;
+ for (i=0; i < f->mode_count; ++i) {
+ Mode *m = f->mode_config+i;
+ m->blockflag = get_bits(f,1);
+ m->windowtype = get_bits(f,16);
+ m->transformtype = get_bits(f,16);
+ m->mapping = get_bits(f,8);
+ if (m->windowtype != 0) return error(f, VORBIS_invalid_setup);
+ if (m->transformtype != 0) return error(f, VORBIS_invalid_setup);
+ if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup);
+ }
+
+ flush_packet(f);
+
+ f->previous_length = 0;
+
+ for (i=0; i < f->channels; ++i) {
+ f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1);
+ f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
+ f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist);
+ if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem);
+ #ifdef STB_VORBIS_NO_DEFER_FLOOR
+ f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
+ if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem);
+ #endif
+ }
+
+ if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE;
+ if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE;
+ f->blocksize[0] = f->blocksize_0;
+ f->blocksize[1] = f->blocksize_1;
+
+#ifdef STB_VORBIS_DIVIDE_TABLE
+ if (integer_divide_table[1][1]==0)
+ for (i=0; i < DIVTAB_NUMER; ++i)
+ for (j=1; j < DIVTAB_DENOM; ++j)
+ integer_divide_table[i][j] = i / j;
+#endif
+
+ // compute how much temporary memory is needed
+
+ // 1.
+ {
+ uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
+ uint32 classify_mem;
+ int i,max_part_read=0;
+ for (i=0; i < f->residue_count; ++i) {
+ Residue *r = f->residue_config + i;
+ int n_read = r->end - r->begin;
+ int part_read = n_read / r->part_size;
+ if (part_read > max_part_read)
+ max_part_read = part_read;
+ }
+ #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
+ classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *));
+ #else
+ classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
+ #endif
+
+ f->temp_memory_required = classify_mem;
+ if (imdct_mem > f->temp_memory_required)
+ f->temp_memory_required = imdct_mem;
+ }
+
+ f->first_decode = TRUE;
+
+ if (f->alloc.alloc_buffer) {
+ assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
+ // check if there's enough temp memory so we don't error later
+ if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
+ return error(f, VORBIS_outofmem);
+ }
+
+ f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
+
+ return TRUE;
+}
+
+static void vorbis_deinit(stb_vorbis *p)
+{
+ int i,j;
+ if (p->residue_config) {
+ for (i=0; i < p->residue_count; ++i) {
+ Residue *r = p->residue_config+i;
+ if (r->classdata) {
+ for (j=0; j < p->codebooks[r->classbook].entries; ++j)
+ setup_free(p, r->classdata[j]);
+ setup_free(p, r->classdata);
+ }
+ setup_free(p, r->residue_books);
+ }
+ }
+
+ if (p->codebooks) {
+ CHECK(p);
+ for (i=0; i < p->codebook_count; ++i) {
+ Codebook *c = p->codebooks + i;
+ setup_free(p, c->codeword_lengths);
+ setup_free(p, c->multiplicands);
+ setup_free(p, c->codewords);
+ setup_free(p, c->sorted_codewords);
+ // c->sorted_values[-1] is the first entry in the array
+ setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
+ }
+ setup_free(p, p->codebooks);
+ }
+ setup_free(p, p->floor_config);
+ setup_free(p, p->residue_config);
+ if (p->mapping) {
+ for (i=0; i < p->mapping_count; ++i)
+ setup_free(p, p->mapping[i].chan);
+ setup_free(p, p->mapping);
+ }
+ CHECK(p);
+ for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
+ setup_free(p, p->channel_buffers[i]);
+ setup_free(p, p->previous_window[i]);
+ #ifdef STB_VORBIS_NO_DEFER_FLOOR
+ setup_free(p, p->floor_buffers[i]);
+ #endif
+ setup_free(p, p->finalY[i]);
+ }
+ for (i=0; i < 2; ++i) {
+ setup_free(p, p->A[i]);
+ setup_free(p, p->B[i]);
+ setup_free(p, p->C[i]);
+ setup_free(p, p->window[i]);
+ setup_free(p, p->bit_reverse[i]);
+ }
+ #ifndef STB_VORBIS_NO_STDIO
+ if (p->close_on_free) fclose(p->f);
+ #endif
+}
+
+void stb_vorbis_close(stb_vorbis *p)
+{
+ if (p == NULL) return;
+ vorbis_deinit(p);
+ setup_free(p,p);
+}
+
+static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
+{
+ memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
+ if (z) {
+ p->alloc = *z;
+ p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
+ p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
+ }
+ p->eof = 0;
+ p->error = VORBIS__no_error;
+ p->stream = NULL;
+ p->codebooks = NULL;
+ p->page_crc_tests = -1;
+ #ifndef STB_VORBIS_NO_STDIO
+ p->close_on_free = FALSE;
+ p->f = NULL;
+ #endif
+}
+
+int stb_vorbis_get_sample_offset(stb_vorbis *f)
+{
+ if (f->current_loc_valid)
+ return f->current_loc;
+ else
+ return -1;
+}
+
+stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
+{
+ stb_vorbis_info d;
+ d.channels = f->channels;
+ d.sample_rate = f->sample_rate;
+ d.setup_memory_required = f->setup_memory_required;
+ d.setup_temp_memory_required = f->setup_temp_memory_required;
+ d.temp_memory_required = f->temp_memory_required;
+ d.max_frame_size = f->blocksize_1 >> 1;
+ return d;
+}
+
+int stb_vorbis_get_error(stb_vorbis *f)
+{
+ int e = f->error;
+ f->error = VORBIS__no_error;
+ return e;
+}
+
+static stb_vorbis * vorbis_alloc(stb_vorbis *f)
+{
+ stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p));
+ return p;
+}
+
+#ifndef STB_VORBIS_NO_PUSHDATA_API
+
+void stb_vorbis_flush_pushdata(stb_vorbis *f)
+{
+ f->previous_length = 0;
+ f->page_crc_tests = 0;
+ f->discard_samples_deferred = 0;
+ f->current_loc_valid = FALSE;
+ f->first_decode = FALSE;
+ f->samples_output = 0;
+ f->channel_buffer_start = 0;
+ f->channel_buffer_end = 0;
+}
+
+static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len)
+{
+ int i,n;
+ for (i=0; i < f->page_crc_tests; ++i)
+ f->scan[i].bytes_done = 0;
+
+ // if we have room for more scans, search for them first, because
+ // they may cause us to stop early if their header is incomplete
+ if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) {
+ if (data_len < 4) return 0;
+ data_len -= 3; // need to look for 4-byte sequence, so don't miss
+ // one that straddles a boundary
+ for (i=0; i < data_len; ++i) {
+ if (data[i] == 0x4f) {
+ if (0==memcmp(data+i, ogg_page_header, 4)) {
+ int j,len;
+ uint32 crc;
+ // make sure we have the whole page header
+ if (i+26 >= data_len || i+27+data[i+26] >= data_len) {
+ // only read up to this page start, so hopefully we'll
+ // have the whole page header start next time
+ data_len = i;
+ break;
+ }
+ // ok, we have it all; compute the length of the page
+ len = 27 + data[i+26];
+ for (j=0; j < data[i+26]; ++j)
+ len += data[i+27+j];
+ // scan everything up to the embedded crc (which we must 0)
+ crc = 0;
+ for (j=0; j < 22; ++j)
+ crc = crc32_update(crc, data[i+j]);
+ // now process 4 0-bytes
+ for ( ; j < 26; ++j)
+ crc = crc32_update(crc, 0);
+ // len is the total number of bytes we need to scan
+ n = f->page_crc_tests++;
+ f->scan[n].bytes_left = len-j;
+ f->scan[n].crc_so_far = crc;
+ f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24);
+ // if the last frame on a page is continued to the next, then
+ // we can't recover the sample_loc immediately
+ if (data[i+27+data[i+26]-1] == 255)
+ f->scan[n].sample_loc = ~0;
+ else
+ f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24);
+ f->scan[n].bytes_done = i+j;
+ if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT)
+ break;
+ // keep going if we still have room for more
+ }
+ }
+ }
+ }
+
+ for (i=0; i < f->page_crc_tests;) {
+ uint32 crc;
+ int j;
+ int n = f->scan[i].bytes_done;
+ int m = f->scan[i].bytes_left;
+ if (m > data_len - n) m = data_len - n;
+ // m is the bytes to scan in the current chunk
+ crc = f->scan[i].crc_so_far;
+ for (j=0; j < m; ++j)
+ crc = crc32_update(crc, data[n+j]);
+ f->scan[i].bytes_left -= m;
+ f->scan[i].crc_so_far = crc;
+ if (f->scan[i].bytes_left == 0) {
+ // does it match?
+ if (f->scan[i].crc_so_far == f->scan[i].goal_crc) {
+ // Houston, we have page
+ data_len = n+m; // consumption amount is wherever that scan ended
+ f->page_crc_tests = -1; // drop out of page scan mode
+ f->previous_length = 0; // decode-but-don't-output one frame
+ f->next_seg = -1; // start a new page
+ f->current_loc = f->scan[i].sample_loc; // set the current sample location
+ // to the amount we'd have decoded had we decoded this page
+ f->current_loc_valid = f->current_loc != ~0U;
+ return data_len;
+ }
+ // delete entry
+ f->scan[i] = f->scan[--f->page_crc_tests];
+ } else {
+ ++i;
+ }
+ }
+
+ return data_len;
+}
+
+// return value: number of bytes we used
+int stb_vorbis_decode_frame_pushdata(
+ stb_vorbis *f, // the file we're decoding
+ const uint8 *data, int data_len, // the memory available for decoding
+ int *channels, // place to write number of float * buffers
+ float ***output, // place to write float ** array of float * buffers
+ int *samples // place to write number of output samples
+ )
+{
+ int i;
+ int len,right,left;
+
+ if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
+
+ if (f->page_crc_tests >= 0) {
+ *samples = 0;
+ return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len);
+ }
+
+ f->stream = (uint8 *) data;
+ f->stream_end = (uint8 *) data + data_len;
+ f->error = VORBIS__no_error;
+
+ // check that we have the entire packet in memory
+ if (!is_whole_packet_present(f, FALSE)) {
+ *samples = 0;
+ return 0;
+ }
+
+ if (!vorbis_decode_packet(f, &len, &left, &right)) {
+ // save the actual error we encountered
+ enum STBVorbisError error = f->error;
+ if (error == VORBIS_bad_packet_type) {
+ // flush and resynch
+ f->error = VORBIS__no_error;
+ while (get8_packet(f) != EOP)
+ if (f->eof) break;
+ *samples = 0;
+ return (int) (f->stream - data);
+ }
+ if (error == VORBIS_continued_packet_flag_invalid) {
+ if (f->previous_length == 0) {
+ // we may be resynching, in which case it's ok to hit one
+ // of these; just discard the packet
+ f->error = VORBIS__no_error;
+ while (get8_packet(f) != EOP)
+ if (f->eof) break;
+ *samples = 0;
+ return (int) (f->stream - data);
+ }
+ }
+ // if we get an error while parsing, what to do?
+ // well, it DEFINITELY won't work to continue from where we are!
+ stb_vorbis_flush_pushdata(f);
+ // restore the error that actually made us bail
+ f->error = error;
+ *samples = 0;
+ return 1;
+ }
+
+ // success!
+ len = vorbis_finish_frame(f, len, left, right);
+ for (i=0; i < f->channels; ++i)
+ f->outputs[i] = f->channel_buffers[i] + left;
+
+ if (channels) *channels = f->channels;
+ *samples = len;
+ *output = f->outputs;
+ return (int) (f->stream - data);
+}
+
+stb_vorbis *stb_vorbis_open_pushdata(
+ const unsigned char *data, int data_len, // the memory available for decoding
+ int *data_used, // only defined if result is not NULL
+ int *error, const stb_vorbis_alloc *alloc)
+{
+ stb_vorbis *f, p;
+ vorbis_init(&p, alloc);
+ p.stream = (uint8 *) data;
+ p.stream_end = (uint8 *) data + data_len;
+ p.push_mode = TRUE;
+ if (!start_decoder(&p)) {
+ if (p.eof)
+ *error = VORBIS_need_more_data;
+ else
+ *error = p.error;
+ return NULL;
+ }
+ f = vorbis_alloc(&p);
+ if (f) {
+ *f = p;
+ *data_used = (int) (f->stream - data);
+ *error = 0;
+ return f;
+ } else {
+ vorbis_deinit(&p);
+ return NULL;
+ }
+}
+#endif // STB_VORBIS_NO_PUSHDATA_API
+
+unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
+{
+ #ifndef STB_VORBIS_NO_PUSHDATA_API
+ if (f->push_mode) return 0;
+ #endif
+ if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
+ #ifndef STB_VORBIS_NO_STDIO
+ return (unsigned int) (ftell(f->f) - f->f_start);
+ #endif
+}
+
+#ifndef STB_VORBIS_NO_PULLDATA_API
+//
+// DATA-PULLING API
+//
+
+static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
+{
+ for(;;) {
+ int n;
+ if (f->eof) return 0;
+ n = get8(f);
+ if (n == 0x4f) { // page header candidate
+ unsigned int retry_loc = stb_vorbis_get_file_offset(f);
+ int i;
+ // check if we're off the end of a file_section stream
+ if (retry_loc - 25 > f->stream_len)
+ return 0;
+ // check the rest of the header
+ for (i=1; i < 4; ++i)
+ if (get8(f) != ogg_page_header[i])
+ break;
+ if (f->eof) return 0;
+ if (i == 4) {
+ uint8 header[27];
+ uint32 i, crc, goal, len;
+ for (i=0; i < 4; ++i)
+ header[i] = ogg_page_header[i];
+ for (; i < 27; ++i)
+ header[i] = get8(f);
+ if (f->eof) return 0;
+ if (header[4] != 0) goto invalid;
+ goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24);
+ for (i=22; i < 26; ++i)
+ header[i] = 0;
+ crc = 0;
+ for (i=0; i < 27; ++i)
+ crc = crc32_update(crc, header[i]);
+ len = 0;
+ for (i=0; i < header[26]; ++i) {
+ int s = get8(f);
+ crc = crc32_update(crc, s);
+ len += s;
+ }
+ if (len && f->eof) return 0;
+ for (i=0; i < len; ++i)
+ crc = crc32_update(crc, get8(f));
+ // finished parsing probable page
+ if (crc == goal) {
+ // we could now check that it's either got the last
+ // page flag set, OR it's followed by the capture
+ // pattern, but I guess TECHNICALLY you could have
+ // a file with garbage between each ogg page and recover
+ // from it automatically? So even though that paranoia
+ // might decrease the chance of an invalid decode by
+ // another 2^32, not worth it since it would hose those
+ // invalid-but-useful files?
+ if (end)
+ *end = stb_vorbis_get_file_offset(f);
+ if (last) {
+ if (header[5] & 0x04)
+ *last = 1;
+ else
+ *last = 0;
+ }
+ set_file_offset(f, retry_loc-1);
+ return 1;
+ }
+ }
+ invalid:
+ // not a valid page, so rewind and look for next one
+ set_file_offset(f, retry_loc);
+ }
+ }
+}
+
+
+#define SAMPLE_unknown 0xffffffff
+
+// seeking is implemented with a binary search, which narrows down the range to
+// 64K, before using a linear search (because finding the synchronization
+// pattern can be expensive, and the chance we'd find the end page again is
+// relatively high for small ranges)
+//
+// two initial interpolation-style probes are used at the start of the search
+// to try to bound either side of the binary search sensibly, while still
+// working in O(log n) time if they fail.
+
+static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
+{
+ uint8 header[27], lacing[255];
+ int i,len;
+
+ // record where the page starts
+ z->page_start = stb_vorbis_get_file_offset(f);
+
+ // parse the header
+ getn(f, header, 27);
+ if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
+ return 0;
+ getn(f, lacing, header[26]);
+
+ // determine the length of the payload
+ len = 0;
+ for (i=0; i < header[26]; ++i)
+ len += lacing[i];
+
+ // this implies where the page ends
+ z->page_end = z->page_start + 27 + header[26] + len;
+
+ // read the last-decoded sample out of the data
+ z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
+
+ // restore file state to where we were
+ set_file_offset(f, z->page_start);
+ return 1;
+}
+
+// rarely used function to seek back to the preceeding page while finding the
+// start of a packet
+static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
+{
+ unsigned int previous_safe, end;
+
+ // now we want to seek back 64K from the limit
+ if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset)
+ previous_safe = limit_offset - 65536;
+ else
+ previous_safe = f->first_audio_page_offset;
+
+ set_file_offset(f, previous_safe);
+
+ while (vorbis_find_page(f, &end, NULL)) {
+ if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
+ return 1;
+ set_file_offset(f, end);
+ }
+
+ return 0;
+}
+
+// implements the search logic for finding a page and starting decoding. if
+// the function succeeds, current_loc_valid will be true and current_loc will
+// be less than or equal to the provided sample number (the closer the
+// better).
+static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
+{
+ ProbedPage left, right, mid;
+ int i, start_seg_with_known_loc, end_pos, page_start;
+ uint32 delta, stream_length, padding;
+ double offset, bytes_per_sample;
+ int probe = 0;
+
+ // find the last page and validate the target sample
+ stream_length = stb_vorbis_stream_length_in_samples(f);
+ if (stream_length == 0) return error(f, VORBIS_seek_without_length);
+ if (sample_number > stream_length) return error(f, VORBIS_seek_invalid);
+
+ // this is the maximum difference between the window-center (which is the
+ // actual granule position value), and the right-start (which the spec
+ // indicates should be the granule position (give or take one)).
+ padding = ((f->blocksize_1 - f->blocksize_0) >> 2);
+ if (sample_number < padding)
+ sample_number = 0;
+ else
+ sample_number -= padding;
+
+ left = f->p_first;
+ while (left.last_decoded_sample == ~0U) {
+ // (untested) the first page does not have a 'last_decoded_sample'
+ set_file_offset(f, left.page_end);
+ if (!get_seek_page_info(f, &left)) goto error;
+ }
+
+ right = f->p_last;
+ assert(right.last_decoded_sample != ~0U);
+
+ // starting from the start is handled differently
+ if (sample_number <= left.last_decoded_sample) {
+ stb_vorbis_seek_start(f);
+ return 1;
+ }
+
+ while (left.page_end != right.page_start) {
+ assert(left.page_end < right.page_start);
+ // search range in bytes
+ delta = right.page_start - left.page_end;
+ if (delta <= 65536) {
+ // there's only 64K left to search - handle it linearly
+ set_file_offset(f, left.page_end);
+ } else {
+ if (probe < 2) {
+ if (probe == 0) {
+ // first probe (interpolate)
+ double data_bytes = right.page_end - left.page_start;
+ bytes_per_sample = data_bytes / right.last_decoded_sample;
+ offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample);
+ } else {
+ // second probe (try to bound the other side)
+ double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample;
+ if (error >= 0 && error < 8000) error = 8000;
+ if (error < 0 && error > -8000) error = -8000;
+ offset += error * 2;
+ }
+
+ // ensure the offset is valid
+ if (offset < left.page_end)
+ offset = left.page_end;
+ if (offset > right.page_start - 65536)
+ offset = right.page_start - 65536;
+
+ set_file_offset(f, (unsigned int) offset);
+ } else {
+ // binary search for large ranges (offset by 32K to ensure
+ // we don't hit the right page)
+ set_file_offset(f, left.page_end + (delta / 2) - 32768);
+ }
+
+ if (!vorbis_find_page(f, NULL, NULL)) goto error;
+ }
+
+ for (;;) {
+ if (!get_seek_page_info(f, &mid)) goto error;
+ if (mid.last_decoded_sample != ~0U) break;
+ // (untested) no frames end on this page
+ set_file_offset(f, mid.page_end);
+ assert(mid.page_start < right.page_start);
+ }
+
+ // if we've just found the last page again then we're in a tricky file,
+ // and we're close enough.
+ if (mid.page_start == right.page_start)
+ break;
+
+ if (sample_number < mid.last_decoded_sample)
+ right = mid;
+ else
+ left = mid;
+
+ ++probe;
+ }
+
+ // seek back to start of the last packet
+ page_start = left.page_start;
+ set_file_offset(f, page_start);
+ if (!start_page(f)) return error(f, VORBIS_seek_failed);
+ end_pos = f->end_seg_with_known_loc;
+ assert(end_pos >= 0);
+
+ for (;;) {
+ for (i = end_pos; i > 0; --i)
+ if (f->segments[i-1] != 255)
+ break;
+
+ start_seg_with_known_loc = i;
+
+ if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet))
+ break;
+
+ // (untested) the final packet begins on an earlier page
+ if (!go_to_page_before(f, page_start))
+ goto error;
+
+ page_start = stb_vorbis_get_file_offset(f);
+ if (!start_page(f)) goto error;
+ end_pos = f->segment_count - 1;
+ }
+
+ // prepare to start decoding
+ f->current_loc_valid = FALSE;
+ f->last_seg = FALSE;
+ f->valid_bits = 0;
+ f->packet_bytes = 0;
+ f->bytes_in_seg = 0;
+ f->previous_length = 0;
+ f->next_seg = start_seg_with_known_loc;
+
+ for (i = 0; i < start_seg_with_known_loc; i++)
+ skip(f, f->segments[i]);
+
+ // start decoding (optimizable - this frame is generally discarded)
+ vorbis_pump_first_frame(f);
+ return 1;
+
+error:
+ // try to restore the file to a valid state
+ stb_vorbis_seek_start(f);
+ return error(f, VORBIS_seek_failed);
+}
+
+// the same as vorbis_decode_initial, but without advancing
+static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
+{
+ int bits_read, bytes_read;
+
+ if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
+ return 0;
+
+ // either 1 or 2 bytes were read, figure out which so we can rewind
+ bits_read = 1 + ilog(f->mode_count-1);
+ if (f->mode_config[*mode].blockflag)
+ bits_read += 2;
+ bytes_read = (bits_read + 7) / 8;
+
+ f->bytes_in_seg += bytes_read;
+ f->packet_bytes -= bytes_read;
+ skip(f, -bytes_read);
+ if (f->next_seg == -1)
+ f->next_seg = f->segment_count - 1;
+ else
+ f->next_seg--;
+ f->valid_bits = 0;
+
+ return 1;
+}
+
+int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
+{
+ uint32 max_frame_samples;
+
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
+
+ // fast page-level search
+ if (!seek_to_sample_coarse(f, sample_number))
+ return 0;
+
+ assert(f->current_loc_valid);
+ assert(f->current_loc <= sample_number);
+
+ // linear search for the relevant packet
+ max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
+ while (f->current_loc < sample_number) {
+ int left_start, left_end, right_start, right_end, mode, frame_samples;
+ if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
+ return error(f, VORBIS_seek_failed);
+ // calculate the number of samples returned by the next frame
+ frame_samples = right_start - left_start;
+ if (f->current_loc + frame_samples > sample_number) {
+ return 1; // the next frame will contain the sample
+ } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
+ // there's a chance the frame after this could contain the sample
+ vorbis_pump_first_frame(f);
+ } else {
+ // this frame is too early to be relevant
+ f->current_loc += frame_samples;
+ f->previous_length = 0;
+ maybe_start_packet(f);
+ flush_packet(f);
+ }
+ }
+ // the next frame will start with the sample
+ assert(f->current_loc == sample_number);
+ return 1;
+}
+
+int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
+{
+ if (!stb_vorbis_seek_frame(f, sample_number))
+ return 0;
+
+ if (sample_number != f->current_loc) {
+ int n;
+ uint32 frame_start = f->current_loc;
+ stb_vorbis_get_frame_float(f, &n, NULL);
+ assert(sample_number > frame_start);
+ assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end);
+ f->channel_buffer_start += (sample_number - frame_start);
+ }
+
+ return 1;
+}
+
+void stb_vorbis_seek_start(stb_vorbis *f)
+{
+ if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; }
+ set_file_offset(f, f->first_audio_page_offset);
+ f->previous_length = 0;
+ f->first_decode = TRUE;
+ f->next_seg = -1;
+ vorbis_pump_first_frame(f);
+}
+
+unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
+{
+ unsigned int restore_offset, previous_safe;
+ unsigned int end, last_page_loc;
+
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
+ if (!f->total_samples) {
+ unsigned int last;
+ uint32 lo,hi;
+ char header[6];
+
+ // first, store the current decode position so we can restore it
+ restore_offset = stb_vorbis_get_file_offset(f);
+
+ // now we want to seek back 64K from the end (the last page must
+ // be at most a little less than 64K, but let's allow a little slop)
+ if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset)
+ previous_safe = f->stream_len - 65536;
+ else
+ previous_safe = f->first_audio_page_offset;
+
+ set_file_offset(f, previous_safe);
+ // previous_safe is now our candidate 'earliest known place that seeking
+ // to will lead to the final page'
+
+ if (!vorbis_find_page(f, &end, &last)) {
+ // if we can't find a page, we're hosed!
+ f->error = VORBIS_cant_find_last_page;
+ f->total_samples = 0xffffffff;
+ goto done;
+ }
+
+ // check if there are more pages
+ last_page_loc = stb_vorbis_get_file_offset(f);
+
+ // stop when the last_page flag is set, not when we reach eof;
+ // this allows us to stop short of a 'file_section' end without
+ // explicitly checking the length of the section
+ while (!last) {
+ set_file_offset(f, end);
+ if (!vorbis_find_page(f, &end, &last)) {
+ // the last page we found didn't have the 'last page' flag
+ // set. whoops!
+ break;
+ }
+ previous_safe = last_page_loc+1;
+ last_page_loc = stb_vorbis_get_file_offset(f);
+ }
+
+ set_file_offset(f, last_page_loc);
+
+ // parse the header
+ getn(f, (unsigned char *)header, 6);
+ // extract the absolute granule position
+ lo = get32(f);
+ hi = get32(f);
+ if (lo == 0xffffffff && hi == 0xffffffff) {
+ f->error = VORBIS_cant_find_last_page;
+ f->total_samples = SAMPLE_unknown;
+ goto done;
+ }
+ if (hi)
+ lo = 0xfffffffe; // saturate
+ f->total_samples = lo;
+
+ f->p_last.page_start = last_page_loc;
+ f->p_last.page_end = end;
+ f->p_last.last_decoded_sample = lo;
+
+ done:
+ set_file_offset(f, restore_offset);
+ }
+ return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples;
+}
+
+float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
+{
+ return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
+}
+
+
+
+int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
+{
+ int len, right,left,i;
+ if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
+
+ if (!vorbis_decode_packet(f, &len, &left, &right)) {
+ f->channel_buffer_start = f->channel_buffer_end = 0;
+ return 0;
+ }
+
+ len = vorbis_finish_frame(f, len, left, right);
+ for (i=0; i < f->channels; ++i)
+ f->outputs[i] = f->channel_buffers[i] + left;
+
+ f->channel_buffer_start = left;
+ f->channel_buffer_end = left+len;
+
+ if (channels) *channels = f->channels;
+ if (output) *output = f->outputs;
+ return len;
+}
+
+#ifndef STB_VORBIS_NO_STDIO
+
+stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length)
+{
+ stb_vorbis *f, p;
+ vorbis_init(&p, alloc);
+ p.f = file;
+ p.f_start = (uint32) ftell(file);
+ p.stream_len = length;
+ p.close_on_free = close_on_free;
+ if (start_decoder(&p)) {
+ f = vorbis_alloc(&p);
+ if (f) {
+ *f = p;
+ vorbis_pump_first_frame(f);
+ return f;
+ }
+ }
+ if (error) *error = p.error;
+ vorbis_deinit(&p);
+ return NULL;
+}
+
+stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
+{
+ unsigned int len, start;
+ start = (unsigned int) ftell(file);
+ fseek(file, 0, SEEK_END);
+ len = (unsigned int) (ftell(file) - start);
+ fseek(file, start, SEEK_SET);
+ return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
+}
+
+stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
+{
+ FILE *f = fopen(filename, "rb");
+ if (f)
+ return stb_vorbis_open_file(f, TRUE, error, alloc);
+ if (error) *error = VORBIS_file_open_failure;
+ return NULL;
+}
+#endif // STB_VORBIS_NO_STDIO
+
+stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
+{
+ stb_vorbis *f, p;
+ if (data == NULL) return NULL;
+ vorbis_init(&p, alloc);
+ p.stream = (uint8 *) data;
+ p.stream_end = (uint8 *) data + len;
+ p.stream_start = (uint8 *) p.stream;
+ p.stream_len = len;
+ p.push_mode = FALSE;
+ if (start_decoder(&p)) {
+ f = vorbis_alloc(&p);
+ if (f) {
+ *f = p;
+ vorbis_pump_first_frame(f);
+ return f;
+ }
+ }
+ if (error) *error = p.error;
+ vorbis_deinit(&p);
+ return NULL;
+}
+
+#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
+#define PLAYBACK_MONO 1
+#define PLAYBACK_LEFT 2
+#define PLAYBACK_RIGHT 4
+
+#define L (PLAYBACK_LEFT | PLAYBACK_MONO)
+#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO)
+#define R (PLAYBACK_RIGHT | PLAYBACK_MONO)
+
+static int8 channel_position[7][6] =
+{
+ { 0 },
+ { C },
+ { L, R },
+ { L, C, R },
+ { L, R, L, R },
+ { L, C, R, L, R },
+ { L, C, R, L, R, C },
+};
+
+
+#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
+ typedef union {
+ float f;
+ int i;
+ } float_conv;
+ typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
+ #define FASTDEF(x) float_conv x
+ // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round
+ #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
+ #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
+ #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s))
+ #define check_endianness()
+#else
+ #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
+ #define check_endianness()
+ #define FASTDEF(x)
+#endif
+
+static void copy_samples(short *dest, float *src, int len)
+{
+ int i;
+ check_endianness();
+ for (i=0; i < len; ++i) {
+ FASTDEF(temp);
+ int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
+ if ((unsigned int) (v + 32768) > 65535)
+ v = v < 0 ? -32768 : 32767;
+ dest[i] = v;
+ }
+}
+
+static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
+{
+ #define BUFFER_SIZE 32
+ float buffer[BUFFER_SIZE];
+ int i,j,o,n = BUFFER_SIZE;
+ check_endianness();
+ for (o = 0; o < len; o += BUFFER_SIZE) {
+ memset(buffer, 0, sizeof(buffer));
+ if (o + n > len) n = len - o;
+ for (j=0; j < num_c; ++j) {
+ if (channel_position[num_c][j] & mask) {
+ for (i=0; i < n; ++i)
+ buffer[i] += data[j][d_offset+o+i];
+ }
+ }
+ for (i=0; i < n; ++i) {
+ FASTDEF(temp);
+ int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
+ if ((unsigned int) (v + 32768) > 65535)
+ v = v < 0 ? -32768 : 32767;
+ output[o+i] = v;
+ }
+ }
+}
+
+static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
+{
+ #define BUFFER_SIZE 32
+ float buffer[BUFFER_SIZE];
+ int i,j,o,n = BUFFER_SIZE >> 1;
+ // o is the offset in the source data
+ check_endianness();
+ for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
+ // o2 is the offset in the output data
+ int o2 = o << 1;
+ memset(buffer, 0, sizeof(buffer));
+ if (o + n > len) n = len - o;
+ for (j=0; j < num_c; ++j) {
+ int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT);
+ if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) {
+ for (i=0; i < n; ++i) {
+ buffer[i*2+0] += data[j][d_offset+o+i];
+ buffer[i*2+1] += data[j][d_offset+o+i];
+ }
+ } else if (m == PLAYBACK_LEFT) {
+ for (i=0; i < n; ++i) {
+ buffer[i*2+0] += data[j][d_offset+o+i];
+ }
+ } else if (m == PLAYBACK_RIGHT) {
+ for (i=0; i < n; ++i) {
+ buffer[i*2+1] += data[j][d_offset+o+i];
+ }
+ }
+ }
+ for (i=0; i < (n<<1); ++i) {
+ FASTDEF(temp);
+ int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
+ if ((unsigned int) (v + 32768) > 65535)
+ v = v < 0 ? -32768 : 32767;
+ output[o2+i] = v;
+ }
+ }
+}
+
+static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
+{
+ int i;
+ if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
+ static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} };
+ for (i=0; i < buf_c; ++i)
+ compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
+ } else {
+ int limit = buf_c < data_c ? buf_c : data_c;
+ for (i=0; i < limit; ++i)
+ copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
+ for ( ; i < buf_c; ++i)
+ memset(buffer[i]+b_offset, 0, sizeof(short) * samples);
+ }
+}
+
+int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
+{
+ float **output;
+ int len = stb_vorbis_get_frame_float(f, NULL, &output);
+ if (len > num_samples) len = num_samples;
+ if (len)
+ convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
+ return len;
+}
+
+static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
+{
+ int i;
+ check_endianness();
+ if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
+ assert(buf_c == 2);
+ for (i=0; i < buf_c; ++i)
+ compute_stereo_samples(buffer, data_c, data, d_offset, len);
+ } else {
+ int limit = buf_c < data_c ? buf_c : data_c;
+ int j;
+ for (j=0; j < len; ++j) {
+ for (i=0; i < limit; ++i) {
+ FASTDEF(temp);
+ float f = data[i][d_offset+j];
+ int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
+ if ((unsigned int) (v + 32768) > 65535)
+ v = v < 0 ? -32768 : 32767;
+ *buffer++ = v;
+ }
+ for ( ; i < buf_c; ++i)
+ *buffer++ = 0;
+ }
+ }
+}
+
+int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
+{
+ float **output;
+ int len;
+ if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts);
+ len = stb_vorbis_get_frame_float(f, NULL, &output);
+ if (len) {
+ if (len*num_c > num_shorts) len = num_shorts / num_c;
+ convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
+ }
+ return len;
+}
+
+int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
+{
+ float **outputs;
+ int len = num_shorts / channels;
+ int n=0;
+ int z = f->channels;
+ if (z > channels) z = channels;
+ while (n < len) {
+ int k = f->channel_buffer_end - f->channel_buffer_start;
+ if (n+k >= len) k = len - n;
+ if (k)
+ convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);
+ buffer += k*channels;
+ n += k;
+ f->channel_buffer_start += k;
+ if (n == len) break;
+ if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
+ }
+ return n;
+}
+
+int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
+{
+ float **outputs;
+ int n=0;
+ int z = f->channels;
+ if (z > channels) z = channels;
+ while (n < len) {
+ int k = f->channel_buffer_end - f->channel_buffer_start;
+ if (n+k >= len) k = len - n;
+ if (k)
+ convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k);
+ n += k;
+ f->channel_buffer_start += k;
+ if (n == len) break;
+ if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
+ }
+ return n;
+}
+
+#ifndef STB_VORBIS_NO_STDIO
+int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
+{
+ int data_len, offset, total, limit, error;
+ short *data;
+ stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL);
+ if (v == NULL) return -1;
+ limit = v->channels * 4096;
+ *channels = v->channels;
+ if (sample_rate)
+ *sample_rate = v->sample_rate;
+ offset = data_len = 0;
+ total = limit;
+ data = (short *) malloc(total * sizeof(*data));
+ if (data == NULL) {
+ stb_vorbis_close(v);
+ return -2;
+ }
+ for (;;) {
+ int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
+ if (n == 0) break;
+ data_len += n;
+ offset += n * v->channels;
+ if (offset + limit > total) {
+ short *data2;
+ total *= 2;
+ data2 = (short *) realloc(data, total * sizeof(*data));
+ if (data2 == NULL) {
+ free(data);
+ stb_vorbis_close(v);
+ return -2;
+ }
+ data = data2;
+ }
+ }
+ *output = data;
+ stb_vorbis_close(v);
+ return data_len;
+}
+#endif // NO_STDIO
+
+int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output)
+{
+ int data_len, offset, total, limit, error;
+ short *data;
+ stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL);
+ if (v == NULL) return -1;
+ limit = v->channels * 4096;
+ *channels = v->channels;
+ if (sample_rate)
+ *sample_rate = v->sample_rate;
+ offset = data_len = 0;
+ total = limit;
+ data = (short *) malloc(total * sizeof(*data));
+ if (data == NULL) {
+ stb_vorbis_close(v);
+ return -2;
+ }
+ for (;;) {
+ int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
+ if (n == 0) break;
+ data_len += n;
+ offset += n * v->channels;
+ if (offset + limit > total) {
+ short *data2;
+ total *= 2;
+ data2 = (short *) realloc(data, total * sizeof(*data));
+ if (data2 == NULL) {
+ free(data);
+ stb_vorbis_close(v);
+ return -2;
+ }
+ data = data2;
+ }
+ }
+ *output = data;
+ stb_vorbis_close(v);
+ return data_len;
+}
+#endif // STB_VORBIS_NO_INTEGER_CONVERSION
+
+int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
+{
+ float **outputs;
+ int len = num_floats / channels;
+ int n=0;
+ int z = f->channels;
+ if (z > channels) z = channels;
+ while (n < len) {
+ int i,j;
+ int k = f->channel_buffer_end - f->channel_buffer_start;
+ if (n+k >= len) k = len - n;
+ for (j=0; j < k; ++j) {
+ for (i=0; i < z; ++i)
+ *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j];
+ for ( ; i < channels; ++i)
+ *buffer++ = 0;
+ }
+ n += k;
+ f->channel_buffer_start += k;
+ if (n == len)
+ break;
+ if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
+ break;
+ }
+ return n;
+}
+
+int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
+{
+ float **outputs;
+ int n=0;
+ int z = f->channels;
+ if (z > channels) z = channels;
+ while (n < num_samples) {
+ int i;
+ int k = f->channel_buffer_end - f->channel_buffer_start;
+ if (n+k >= num_samples) k = num_samples - n;
+ if (k) {
+ for (i=0; i < z; ++i)
+ memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k);
+ for ( ; i < channels; ++i)
+ memset(buffer[i]+n, 0, sizeof(float) * k);
+ }
+ n += k;
+ f->channel_buffer_start += k;
+ if (n == num_samples)
+ break;
+ if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
+ break;
+ }
+ return n;
+}
+#endif // STB_VORBIS_NO_PULLDATA_API
+
+/* Version history
+ 1.09 - 2016/04/04 - back out 'avoid discarding last frame' fix from previous version
+ 1.08 - 2016/04/02 - fixed multiple warnings; fix setup memory leaks;
+ avoid discarding last frame of audio data
+ 1.07 - 2015/01/16 - fixed some warnings, fix mingw, const-correct API
+ some more crash fixes when out of memory or with corrupt files
+ 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson)
+ some crash fixes when out of memory or with corrupt files
+ 1.05 - 2015/04/19 - don't define __forceinline if it's redundant
+ 1.04 - 2014/08/27 - fix missing const-correct case in API
+ 1.03 - 2014/08/07 - Warning fixes
+ 1.02 - 2014/07/09 - Declare qsort compare function _cdecl on windows
+ 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float
+ 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in multichannel
+ (API change) report sample rate for decode-full-file funcs
+ 0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila
+ 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem
+ 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence
+ 0.99993 - remove assert that fired on legal files with empty tables
+ 0.99992 - rewind-to-start
+ 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo
+ 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++
+ 0.9998 - add a full-decode function with a memory source
+ 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition
+ 0.9996 - query length of vorbis stream in samples/seconds
+ 0.9995 - bugfix to another optimization that only happened in certain files
+ 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors
+ 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation
+ 0.9992 - performance improvement of IMDCT; now performs close to reference implementation
+ 0.9991 - performance improvement of IMDCT
+ 0.999 - (should have been 0.9990) performance improvement of IMDCT
+ 0.998 - no-CRT support from Casey Muratori
+ 0.997 - bugfixes for bugs found by Terje Mathisen
+ 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen
+ 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen
+ 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen
+ 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen
+ 0.992 - fixes for MinGW warning
+ 0.991 - turn fast-float-conversion on by default
+ 0.990 - fix push-mode seek recovery if you seek into the headers
+ 0.98b - fix to bad release of 0.98
+ 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode
+ 0.97 - builds under c++ (typecasting, don't use 'class' keyword)
+ 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code
+ 0.95 - clamping code for 16-bit functions
+ 0.94 - not publically released
+ 0.93 - fixed all-zero-floor case (was decoding garbage)
+ 0.92 - fixed a memory leak
+ 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION
+ 0.90 - first public release
+*/
+
+#endif // STB_VORBIS_HEADER_ONLY
diff --git a/thirdparty/zlib/deflate.c b/thirdparty/zlib/deflate.c
index 2ad890e354..1ec761448d 100644
--- a/thirdparty/zlib/deflate.c
+++ b/thirdparty/zlib/deflate.c
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.10 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
}
func = configuration_table[s->level].func;
- if ((strategy != s->strategy || func != configuration_table[level].func)) {
+ if ((strategy != s->strategy || func != configuration_table[level].func) &&
+ s->high_water) {
/* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR)
@@ -1671,8 +1672,6 @@ local block_state deflate_stored(s, flush)
len = left + s->strm->avail_in; /* limit len to the input */
if (len > have)
len = have; /* limit len to the output */
- if (left > len)
- left = len; /* limit window pull to len */
/* If the stored block would be less than min_block in length, or if
* unable to copy all of the available input when flushing, then try
@@ -1681,13 +1680,13 @@ local block_state deflate_stored(s, flush)
*/
if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
flush == Z_NO_FLUSH ||
- len - left != s->strm->avail_in))
+ len != left + s->strm->avail_in))
break;
/* Make a dummy stored block in pending to get the header bytes,
* including any pending bits. This also updates the debugging counts.
*/
- last = flush == Z_FINISH && len - left == s->strm->avail_in ? 1 : 0;
+ last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
_tr_stored_block(s, (char *)0, 0L, last);
/* Replace the lengths in the dummy stored block with len. */
@@ -1699,14 +1698,16 @@ local block_state deflate_stored(s, flush)
/* Write the stored block header bytes. */
flush_pending(s->strm);
- /* Update debugging counts for the data about to be copied. */
#ifdef ZLIB_DEBUG
+ /* Update debugging counts for the data about to be copied. */
s->compressed_len += len << 3;
s->bits_sent += len << 3;
#endif
/* Copy uncompressed bytes from the window to next_out. */
if (left) {
+ if (left > len)
+ left = len;
zmemcpy(s->strm->next_out, s->window + s->block_start, left);
s->strm->next_out += left;
s->strm->avail_out -= left;
@@ -1756,6 +1757,8 @@ local block_state deflate_stored(s, flush)
s->block_start = s->strstart;
s->insert += MIN(used, s->w_size - s->insert);
}
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */
if (last)
@@ -1783,6 +1786,8 @@ local block_state deflate_stored(s, flush)
read_buf(s->strm, s->window + s->strstart, have);
s->strstart += have;
}
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
/* There was not enough avail_out to write a complete worthy or flushed
* stored block to next_out. Write a stored block to pending instead, if we
diff --git a/thirdparty/zlib/gzlib.c b/thirdparty/zlib/gzlib.c
index e142ffb3d7..4105e6aff9 100644
--- a/thirdparty/zlib/gzlib.c
+++ b/thirdparty/zlib/gzlib.c
@@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012, 2013, 2016 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
diff --git a/thirdparty/zlib/gzwrite.c b/thirdparty/zlib/gzwrite.c
index 1ec1da4095..c7b5651d70 100644
--- a/thirdparty/zlib/gzwrite.c
+++ b/thirdparty/zlib/gzwrite.c
@@ -1,5 +1,5 @@
/* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
diff --git a/thirdparty/zlib/inffast.c b/thirdparty/zlib/inffast.c
index 29eb7d8244..0dbd1dbc09 100644
--- a/thirdparty/zlib/inffast.c
+++ b/thirdparty/zlib/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010, 2013, 2016 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
diff --git a/thirdparty/zlib/inftrees.c b/thirdparty/zlib/inftrees.c
index 8a904ddbce..2ea08fc13e 100644
--- a/thirdparty/zlib/inftrees.c
+++ b/thirdparty/zlib/inftrees.c
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.10 Copyright 1995-2017 Mark Adler ";
+ " inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 192, 202};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
diff --git a/thirdparty/zlib/trees.c b/thirdparty/zlib/trees.c
index 357f313925..50cf4b4571 100644
--- a/thirdparty/zlib/trees.c
+++ b/thirdparty/zlib/trees.c
@@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2016 Jean-loup Gailly
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -906,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s)
/* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
+ * trees or store, and write out the encoded block.
*/
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
deflate_state *s;
diff --git a/thirdparty/zlib/zlib.h b/thirdparty/zlib/zlib.h
index dc90dc8d22..f09cdaf1e0 100644
--- a/thirdparty/zlib/zlib.h
+++ b/thirdparty/zlib/zlib.h
@@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.10, January 2nd, 2017
+ version 1.2.11, January 15th, 2017
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
@@ -37,11 +37,11 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.10"
-#define ZLIB_VERNUM 0x12a0
+#define ZLIB_VERSION "1.2.11"
+#define ZLIB_VERNUM 0x12b0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 10
+#define ZLIB_VER_REVISION 11
#define ZLIB_VER_SUBREVISION 0
/*
@@ -712,10 +712,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
- strategy is changed, then the input available so far is compressed with the
- old level and strategy using deflate(strm, Z_BLOCK). There are three
- approaches for the compression levels 0, 1..3, and 4..9 respectively. The
- new level and strategy will take effect at the next call of deflate().
+ strategy is changed, and if any input has been consumed in a previous
+ deflate() call, then the input available so far is compressed with the old
+ level and strategy using deflate(strm, Z_BLOCK). There are three approaches
+ for the compression levels 0, 1..3, and 4..9 respectively. The new level
+ and strategy will take effect at the next call of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not
diff --git a/thirdparty/zlib/zutil.c b/thirdparty/zlib/zutil.c
index 56534fba0f..a76c6b0c7e 100644
--- a/thirdparty/zlib/zutil.c
+++ b/thirdparty/zlib/zutil.c
@@ -1,5 +1,5 @@
/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010, 2011, 2012, 2016 Jean-loup Gailly
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
diff --git a/tools/SCsub b/tools/SCsub
deleted file mode 100644
index 43cad794d4..0000000000
--- a/tools/SCsub
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-
-env.tool_sources = []
-env.add_source_files(env.tool_sources, "*.cpp")
-
-Export('env')
-
-
-def make_translations_header(target, source, env):
-
- dst = target[0].srcnode().abspath
-
- g = open(dst, "wb")
-
- """"
- """
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
- g.write("#define _EDITOR_TRANSLATIONS_H\n")
-
- import zlib
- import os.path
-
- paths = [node.srcnode().abspath for node in source]
- sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0])
-
- xl_names = []
- for i in range(len(sorted_paths)):
- print("Appending translation: " + sorted_paths[i])
- f = open(sorted_paths[i], "rb")
- buf = f.read()
- decomp_size = len(buf)
- buf = zlib.compress(buf)
- name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
-
- #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n")
- #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n")
- g.write("static const unsigned char _translation_" + name + "_compressed[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i])) + ",\n")
-
- g.write("};\n")
-
- xl_names.append([name, len(buf), str(decomp_size)])
-
- g.write("struct EditorTranslationList {\n")
- g.write("\tconst char* lang;\n")
- g.write("\tint comp_size;\n")
- g.write("\tint uncomp_size;\n")
- g.write("\tconst unsigned char* data;\n")
- g.write("};\n\n")
- g.write("static EditorTranslationList _editor_translations[]={\n")
- for x in xl_names:
- g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n")
- g.write("\t{NULL,0,0,NULL}\n")
- g.write("};\n")
-
- g.write("#endif")
-
-
-def make_fonts_header(target, source, env):
-
- dst = target[0].srcnode().abspath
-
- g = open(dst, "wb")
-
- """"
- """
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_FONTS_H\n")
- g.write("#define _EDITOR_FONTS_H\n")
-
- # saving uncompressed, since freetype will reference from memory pointer
- xl_names = []
- for i in range(len(source)):
- print("Appending font: " + source[i].srcnode().abspath)
- f = open(source[i].srcnode().abspath, "rb")
- buf = f.read()
- import os.path
-
- name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0]
-
- g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n")
- g.write("static const unsigned char _font_" + name + "[]={\n")
- for i in range(len(buf)):
- g.write(str(ord(buf[i])) + ",\n")
-
- g.write("};\n")
-
- g.write("#endif")
-
-
-if (env["tools"] != "no"):
-
- import glob
-
- dir = env.Dir('.').abspath
- tlist = glob.glob(dir + "/translations/*.po")
-
- print("translations: ", tlist)
- env.Depends('#tools/editor/translations.h', tlist)
- env.Command('#tools/editor/translations.h', tlist, make_translations_header)
-
- flist = glob.glob(dir + "/editor_fonts/*.ttf")
- flist.append(glob.glob(dir + "/editor_fonts/*.otf"))
-
- print("fonts: ", flist)
- env.Depends('#tools/editor/builtin_fonts.h', flist)
- env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header)
-
- SConscript('editor/SCsub')
- SConscript('collada/SCsub')
- SConscript('doc/SCsub')
-
- lib = env.Library("tool", env.tool_sources)
-
- env.Prepend(LIBS=[lib])
diff --git a/tools/editor/SCsub b/tools/editor/SCsub
index caf45d25be..76eb65748a 100644
--- a/tools/editor/SCsub
+++ b/tools/editor/SCsub
@@ -1,9 +1,10 @@
#!/usr/bin/env python
Import('env')
+env.editor_sources = []
-def make_doc_header(target, source, env):
+def make_certs_header(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
@@ -15,18 +16,18 @@ def make_doc_header(target, source, env):
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _DOC_DATA_RAW_H\n")
- g.write("#define _DOC_DATA_RAW_H\n")
- g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n")
- g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n")
- g.write("static const unsigned char _doc_data_compressed[]={\n")
+ g.write("#ifndef _CERTS_RAW_H\n")
+ g.write("#define _CERTS_RAW_H\n")
+ g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n")
+ g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n")
+ g.write("static const unsigned char _certs_compressed[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
-def make_certs_header(target, source, env):
+def make_doc_header(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
@@ -38,24 +39,105 @@ def make_certs_header(target, source, env):
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _CERTS_RAW_H\n")
- g.write("#define _CERTS_RAW_H\n")
- g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n")
- g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n")
- g.write("static const unsigned char _certs_compressed[]={\n")
+ g.write("#ifndef _DOC_DATA_RAW_H\n")
+ g.write("#define _DOC_DATA_RAW_H\n")
+ g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n")
+ g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n")
+ g.write("static const unsigned char _doc_data_compressed[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
+def make_fonts_header(target, source, env):
+
+ dst = target[0].srcnode().abspath
+
+ g = open(dst, "wb")
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_FONTS_H\n")
+ g.write("#define _EDITOR_FONTS_H\n")
+
+ # saving uncompressed, since freetype will reference from memory pointer
+ xl_names = []
+ for i in range(len(source)):
+ print("Appending font: " + source[i].srcnode().abspath)
+ f = open(source[i].srcnode().abspath, "rb")
+ buf = f.read()
+ import os.path
+
+ name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0]
+
+ g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n")
+ g.write("static const unsigned char _font_" + name + "[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
+
+ g.write("};\n")
+
+ g.write("#endif")
+
+
+def make_translations_header(target, source, env):
+
+ dst = target[0].srcnode().abspath
+
+ g = open(dst, "wb")
+
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
+ g.write("#define _EDITOR_TRANSLATIONS_H\n")
+
+ import zlib
+ import os.path
+
+ paths = [node.srcnode().abspath for node in source]
+ sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0])
+
+ xl_names = []
+ for i in range(len(sorted_paths)):
+ print("Appending translation: " + sorted_paths[i])
+ f = open(sorted_paths[i], "rb")
+ buf = f.read()
+ decomp_size = len(buf)
+ buf = zlib.compress(buf)
+ name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
+
+ #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n")
+ #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n")
+ g.write("static const unsigned char _translation_" + name + "_compressed[]={\n")
+ for i in range(len(buf)):
+ g.write(str(ord(buf[i])) + ",\n")
+
+ g.write("};\n")
+
+ xl_names.append([name, len(buf), str(decomp_size)])
+
+ g.write("struct EditorTranslationList {\n")
+ g.write("\tconst char* lang;\n")
+ g.write("\tint comp_size;\n")
+ g.write("\tint uncomp_size;\n")
+ g.write("\tconst unsigned char* data;\n")
+ g.write("};\n\n")
+ g.write("static EditorTranslationList _editor_translations[]={\n")
+ for x in xl_names:
+ g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n")
+ g.write("\t{NULL,0,0,NULL}\n")
+ g.write("};\n")
+
+ g.write("#endif")
+
+
if (env["tools"] == "yes"):
+ # Register exporters
reg_exporters_inc = '#include "register_exporters.h"\n'
reg_exporters = 'void register_exporters() {\n'
for e in env.platform_exporters:
- env.tool_sources.append("#platform/" + e + "/export/export.cpp")
- reg_exporters += '\tregister_' + e + '_exporter();\n'
+ env.editor_sources.append("#platform/" + e + "/export/export.cpp")
+ reg_exporters += '\tregister_' + e + '_exporter();\n'
reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
reg_exporters += '}\n'
f = open("register_exporters.cpp", "wb")
@@ -63,18 +145,42 @@ if (env["tools"] == "yes"):
f.write(reg_exporters)
f.close()
+ # API documentation
env.Depends("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml")
env.Command("#tools/editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header)
- env.Depends("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt")
- env.Command("#tools/editor/certs_compressed.h", "#tools/certs/ca-certificates.crt", make_certs_header)
+ # Certificates
+ env.Depends("#tools/editor/certs_compressed.h", "#thirdparty/certs/ca-certificates.crt")
+ env.Command("#tools/editor/certs_compressed.h", "#thirdparty/certs/ca-certificates.crt", make_certs_header)
- # make_doc_header(env.File("#tools/editor/doc_data_raw.h").srcnode().abspath,env.File("#doc/base/classes.xml").srcnode().abspath,env)
+ import glob
+ path = env.Dir('.').abspath
- env.add_source_files(env.tool_sources, "*.cpp")
+ # Translations
+ tlist = glob.glob(path + "/translations/*.po")
+ print("translations: ", tlist)
+ env.Depends('#tools/editor/translations.h', tlist)
+ env.Command('#tools/editor/translations.h', tlist, make_translations_header)
- Export('env')
- SConscript('icons/SCsub')
- SConscript('plugins/SCsub')
+ # Fonts
+ flist = glob.glob(path + "/../../thirdparty/fonts/*.ttf")
+ flist.append(glob.glob(path + "/../../thirdparty/fonts/*.otf"))
+ print("fonts: ", flist)
+ env.Depends('#tools/editor/builtin_fonts.h', flist)
+ env.Command('#tools/editor/builtin_fonts.h', flist, make_fonts_header)
+
+
+ env.add_source_files(env.editor_sources, "*.cpp")
+
+ SConscript('collada/SCsub')
+ SConscript('doc/SCsub')
SConscript('fileserver/SCsub')
+ SConscript('icons/SCsub')
+ SConscript('import/SCsub')
SConscript('io_plugins/SCsub')
+ SConscript('plugins/SCsub')
+
+ lib = env.Library("editor", env.editor_sources)
+ env.Prepend(LIBS=[lib])
+
+ Export('env')
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp
index be4d5f48e2..d675c6a6bb 100644
--- a/tools/editor/animation_editor.cpp
+++ b/tools/editor/animation_editor.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "animation_editor.h"
+
#include "editor_settings.h"
#include "os/keyboard.h"
#include "os/os.h"
@@ -178,12 +179,12 @@ private:
bool sg = val < 0;
val = Math::absf(val);
- val = Math::log(val)/Math::log(2);
+ val = Math::log(val)/Math::log((float)2.0);
//logspace
val+=rel*0.05;
//
- val = Math::pow(2,val);
+ val = Math::pow((float)2.0,val);
if (sg)
val=-val;
@@ -198,7 +199,7 @@ public:
static void _bind_methods() {
- // ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
+ //ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
ClassDB::bind_method("_gui_input",&AnimationCurveEdit::_gui_input);
ADD_SIGNAL(MethodInfo("transition_changed"));
}
@@ -518,7 +519,7 @@ public:
case Animation::TYPE_VALUE: {
if (name=="value") {
- r_ret = animation->track_get_key_value(track,key);;
+ r_ret = animation->track_get_key_value(track,key);
return true;
}
@@ -647,8 +648,10 @@ public:
} break;
}
- //if (animation->track_get_type(track)!=Animation::TYPE_METHOD)
- // p_list->push_back( PropertyInfo( Variant::REAL, "easing", PROPERTY_HINT_EXP_EASING));
+ /*
+ if (animation->track_get_type(track)!=Animation::TYPE_METHOD)
+ p_list->push_back( PropertyInfo( Variant::REAL, "easing", PROPERTY_HINT_EXP_EASING));
+ */
}
UndoRedo *undo_redo;
@@ -1052,9 +1055,9 @@ float AnimationKeyEditor::_get_zoom_scale() const {
float zv = zoom->get_value();
if (zv<1) {
zv = 1.0-zv;
- return Math::pow(1.0+zv,8.0)*100;
+ return Math::pow(1.0f+zv,8.0f)*100;
} else {
- return 1.0/Math::pow(zv,8.0)*100;
+ return 1.0/Math::pow(zv,8.0f)*100;
}
}
@@ -1484,8 +1487,8 @@ void AnimationKeyEditor::_track_editor_draw() {
//draw the keys;
int tt = animation->track_get_type(idx);
- float key_vofs = Math::floor((h - type_icon[tt]->get_height())/2);
- float key_hofs = -Math::floor(type_icon[tt]->get_height()/2);
+ float key_vofs = Math::floor((float)(h - type_icon[tt]->get_height())/2);
+ float key_hofs = -Math::floor((float)type_icon[tt]->get_height()/2);
int kc=animation->track_get_key_count(idx);
bool first=true;
@@ -1589,8 +1592,8 @@ void AnimationKeyEditor::_track_editor_draw() {
continue;
int y = h+i*h+sep;
- float key_vofs = Math::floor((h - type_selected->get_height())/2);
- float key_hofs = -Math::floor(type_selected->get_height()/2);
+ float key_vofs = Math::floor((float)(h - type_selected->get_height())/2);
+ float key_hofs = -Math::floor((float)type_selected->get_height()/2);
float time = animation->track_get_key_time(idx,E->key().key);
float diff = time-from_t;
@@ -1914,7 +1917,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
else
_menu_track(TRACK_MENU_DUPLICATE);
- accept_event();;
+ accept_event();
} else if (p_input.key.scancode==KEY_DELETE && p_input.key.pressed && click.click==ClickOver::CLICK_NONE) {
@@ -1925,14 +1928,14 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (p_input.is_action("ui_up"))
selected_track--;
- if (v_scroll->is_visible() && p_input.is_action("ui_page_up"))
+ if (v_scroll->is_visible_in_tree() && p_input.is_action("ui_page_up"))
selected_track--;
if (selected_track<0)
selected_track=0;
- if (v_scroll->is_visible()) {
+ if (v_scroll->is_visible_in_tree()) {
if (v_scroll->get_value() > selected_track)
v_scroll->set_value(selected_track);
@@ -1947,13 +1950,13 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
if (p_input.is_action("ui_down"))
selected_track++;
- else if (v_scroll->is_visible() && p_input.is_action("ui_page_down"))
+ else if (v_scroll->is_visible_in_tree() && p_input.is_action("ui_page_down"))
selected_track+=v_scroll->get_page();
if (selected_track >= animation->get_track_count())
selected_track=animation->get_track_count()-1;
- if (v_scroll->is_visible() && v_scroll->get_page()+v_scroll->get_value() < selected_track+1) {
+ if (v_scroll->is_visible_in_tree() && v_scroll->get_page()+v_scroll->get_value() < selected_track+1) {
v_scroll->set_value(selected_track-v_scroll->get_page()+1);
}
@@ -2641,8 +2644,10 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
float newpos=E->get().pos-from_t+motion;
- //if (newpos<0)
- // continue; //no add at the begining
+ /*
+ if (newpos<0)
+ continue; //no add at the begining
+ */
undo_redo->add_do_method(animation.ptr(),"track_insert_key",E->key().track,newpos,animation->track_get_key_value(E->key().track,E->key().key),animation->track_get_key_transition(E->key().track,E->key().key));
}
@@ -2651,8 +2656,10 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
for(Map<SelectedKey,KeyInfo>::Element *E=selection.back();E;E=E->prev()) {
float newpos=E->get().pos+-from_t+motion;
- //if (newpos<0)
- // continue; //no remove what no inserted
+ /*
+ if (newpos<0)
+ continue; //no remove what no inserted
+ */
undo_redo->add_undo_method(animation.ptr(),"track_remove_key_at_pos",E->key().track,newpos);
}
@@ -2690,7 +2697,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
float oldpos=E->get().pos;
float newpos=oldpos-from_t+motion;
//if (newpos>=0)
- undo_redo->add_do_method(this,"_select_at_anim",animation,E->key().track,newpos);
+ undo_redo->add_do_method(this,"_select_at_anim",animation,E->key().track,newpos);
undo_redo->add_undo_method(this,"_select_at_anim",animation,E->key().track,oldpos);
}
@@ -2911,7 +2918,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent& p_input) {
} break;
case Animation::TYPE_VALUE: {
- Variant v = animation->track_get_key_value(idx,mouse_over.over_key);;
+ Variant v = animation->track_get_key_value(idx,mouse_over.over_key);
//text+="value: "+String(v)+"\n";
bool prop_exists=false;
@@ -3148,7 +3155,7 @@ void AnimationKeyEditor::_notification(int p_what) {
}
call_select->connect("selected",this,"_add_call_track");
-// rename_anim->set_icon( get_icon("Rename","EditorIcons") );
+ //rename_anim->set_icon( get_icon("Rename","EditorIcons") );
/*
edit_anim->set_icon( get_icon("Edit","EditorIcons") );
blend_anim->set_icon( get_icon("Blend","EditorIcons") );
@@ -3156,8 +3163,8 @@ void AnimationKeyEditor::_notification(int p_what) {
stop->set_icon( get_icon("Stop","EditorIcons") );
pause->set_icon( get_icon("Pause","EditorIcons") );
*/
-// menu->set_icon(get_icon("Animation","EditorIcons"));
-// play->set_icon(get_icon("AnimationPlay","EditorIcons"));
+ //menu->set_icon(get_icon("Animation","EditorIcons"));
+ //play->set_icon(get_icon("AnimationPlay","EditorIcons"));
//menu->set_icon(get_icon("Animation","EditorIcons"));
_update_menu();
@@ -3270,7 +3277,7 @@ Node *AnimationKeyEditor::get_root() const {
void AnimationKeyEditor::update_keying() {
- bool keying_enabled=is_visible() && animation.is_valid();
+ bool keying_enabled=is_visible_in_tree() && animation.is_valid();
if (keying_enabled==keying)
return;
@@ -3289,14 +3296,14 @@ bool AnimationKeyEditor::has_keying() const {
void AnimationKeyEditor::_query_insert(const InsertData& p_id) {
- if (insert_frame!=OS::get_singleton()->get_frames_drawn()) {
+ if (insert_frame!=Engine::get_singleton()->get_frames_drawn()) {
//clear insert list for the frame if frame changed
- if (insert_confirm->is_visible())
+ if (insert_confirm->is_visible_in_tree())
return; //do nothing
insert_data.clear();
insert_query=false;
}
- insert_frame=OS::get_singleton()->get_frames_drawn();
+ insert_frame=Engine::get_singleton()->get_frames_drawn();
for (List<InsertData>::Element *E=insert_data.front();E;E=E->next()) {
//prevent insertion of multiple tracks
@@ -3700,7 +3707,7 @@ void AnimationKeyEditor::_pane_drag(const Point2& p_delta) {
ecs.y-=p_delta.y;
if (ecs.y<100)
ecs.y=100;
- ec->set_custom_minimum_size(ecs);;
+ ec->set_custom_minimum_size(ecs);
}
@@ -3915,48 +3922,48 @@ void AnimationKeyEditor::cleanup() {
void AnimationKeyEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_root_removed"),&AnimationKeyEditor::_root_removed);
- ClassDB::bind_method(_MD("_scale"),&AnimationKeyEditor::_scale);
- ClassDB::bind_method(_MD("set_root"),&AnimationKeyEditor::set_root);
+ ClassDB::bind_method(D_METHOD("_root_removed"),&AnimationKeyEditor::_root_removed);
+ ClassDB::bind_method(D_METHOD("_scale"),&AnimationKeyEditor::_scale);
+ ClassDB::bind_method(D_METHOD("set_root"),&AnimationKeyEditor::set_root);
-// ClassDB::bind_method(_MD("_confirm_insert"),&AnimationKeyEditor::_confirm_insert);
- ClassDB::bind_method(_MD("_confirm_insert_list"),&AnimationKeyEditor::_confirm_insert_list);
+ //ClassDB::bind_method(D_METHOD("_confirm_insert"),&AnimationKeyEditor::_confirm_insert);
+ ClassDB::bind_method(D_METHOD("_confirm_insert_list"),&AnimationKeyEditor::_confirm_insert_list);
- ClassDB::bind_method(_MD("_update_paths"),&AnimationKeyEditor::_update_paths);
- ClassDB::bind_method(_MD("_track_editor_draw"),&AnimationKeyEditor::_track_editor_draw);
+ ClassDB::bind_method(D_METHOD("_update_paths"),&AnimationKeyEditor::_update_paths);
+ ClassDB::bind_method(D_METHOD("_track_editor_draw"),&AnimationKeyEditor::_track_editor_draw);
- ClassDB::bind_method(_MD("_animation_changed"),&AnimationKeyEditor::_animation_changed);
- ClassDB::bind_method(_MD("_scroll_changed"),&AnimationKeyEditor::_scroll_changed);
- ClassDB::bind_method(_MD("_track_editor_gui_input"),&AnimationKeyEditor::_track_editor_gui_input);
- ClassDB::bind_method(_MD("_track_name_changed"),&AnimationKeyEditor::_track_name_changed);
- ClassDB::bind_method(_MD("_track_menu_selected"),&AnimationKeyEditor::_track_menu_selected);
- ClassDB::bind_method(_MD("_menu_add_track"),&AnimationKeyEditor::_menu_add_track);
- ClassDB::bind_method(_MD("_menu_track"),&AnimationKeyEditor::_menu_track);
- ClassDB::bind_method(_MD("_clear_selection_for_anim"),&AnimationKeyEditor::_clear_selection_for_anim);
- ClassDB::bind_method(_MD("_select_at_anim"),&AnimationKeyEditor::_select_at_anim);
- ClassDB::bind_method(_MD("_track_pos_draw"),&AnimationKeyEditor::_track_pos_draw);
- ClassDB::bind_method(_MD("_insert_delay"),&AnimationKeyEditor::_insert_delay);
- ClassDB::bind_method(_MD("_step_changed"),&AnimationKeyEditor::_step_changed);
+ ClassDB::bind_method(D_METHOD("_animation_changed"),&AnimationKeyEditor::_animation_changed);
+ ClassDB::bind_method(D_METHOD("_scroll_changed"),&AnimationKeyEditor::_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_track_editor_gui_input"),&AnimationKeyEditor::_track_editor_gui_input);
+ ClassDB::bind_method(D_METHOD("_track_name_changed"),&AnimationKeyEditor::_track_name_changed);
+ ClassDB::bind_method(D_METHOD("_track_menu_selected"),&AnimationKeyEditor::_track_menu_selected);
+ ClassDB::bind_method(D_METHOD("_menu_add_track"),&AnimationKeyEditor::_menu_add_track);
+ ClassDB::bind_method(D_METHOD("_menu_track"),&AnimationKeyEditor::_menu_track);
+ ClassDB::bind_method(D_METHOD("_clear_selection_for_anim"),&AnimationKeyEditor::_clear_selection_for_anim);
+ ClassDB::bind_method(D_METHOD("_select_at_anim"),&AnimationKeyEditor::_select_at_anim);
+ ClassDB::bind_method(D_METHOD("_track_pos_draw"),&AnimationKeyEditor::_track_pos_draw);
+ ClassDB::bind_method(D_METHOD("_insert_delay"),&AnimationKeyEditor::_insert_delay);
+ ClassDB::bind_method(D_METHOD("_step_changed"),&AnimationKeyEditor::_step_changed);
- ClassDB::bind_method(_MD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed);
- ClassDB::bind_method(_MD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed);
- ClassDB::bind_method(_MD("_create_value_item"),&AnimationKeyEditor::_create_value_item);
- ClassDB::bind_method(_MD("_pane_drag"),&AnimationKeyEditor::_pane_drag);
+ ClassDB::bind_method(D_METHOD("_animation_loop_changed"),&AnimationKeyEditor::_animation_loop_changed);
+ ClassDB::bind_method(D_METHOD("_animation_len_changed"),&AnimationKeyEditor::_animation_len_changed);
+ ClassDB::bind_method(D_METHOD("_create_value_item"),&AnimationKeyEditor::_create_value_item);
+ ClassDB::bind_method(D_METHOD("_pane_drag"),&AnimationKeyEditor::_pane_drag);
- ClassDB::bind_method(_MD("_animation_len_update"),&AnimationKeyEditor::_animation_len_update);
+ ClassDB::bind_method(D_METHOD("_animation_len_update"),&AnimationKeyEditor::_animation_len_update);
- ClassDB::bind_method(_MD("set_animation"),&AnimationKeyEditor::set_animation);
- ClassDB::bind_method(_MD("_animation_optimize"),&AnimationKeyEditor::_animation_optimize);
- ClassDB::bind_method(_MD("_curve_transition_changed"),&AnimationKeyEditor::_curve_transition_changed);
- ClassDB::bind_method(_MD("_toggle_edit_curves"),&AnimationKeyEditor::_toggle_edit_curves);
- ClassDB::bind_method(_MD("_add_call_track"),&AnimationKeyEditor::_add_call_track);
+ ClassDB::bind_method(D_METHOD("set_animation"),&AnimationKeyEditor::set_animation);
+ ClassDB::bind_method(D_METHOD("_animation_optimize"),&AnimationKeyEditor::_animation_optimize);
+ ClassDB::bind_method(D_METHOD("_curve_transition_changed"),&AnimationKeyEditor::_curve_transition_changed);
+ ClassDB::bind_method(D_METHOD("_toggle_edit_curves"),&AnimationKeyEditor::_toggle_edit_curves);
+ ClassDB::bind_method(D_METHOD("_add_call_track"),&AnimationKeyEditor::_add_call_track);
ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@@ -4001,7 +4008,7 @@ AnimationKeyEditor::AnimationKeyEditor() {
//menu->set_pos(Point2());
//add_child(menu);
- zoomicon = memnew( TextureFrame );
+ zoomicon = memnew( TextureRect );
hb->add_child(zoomicon);
zoomicon->set_tooltip(TTR("Animation zoom."));
@@ -4143,9 +4150,9 @@ AnimationKeyEditor::AnimationKeyEditor() {
/* l = memnew( Label );
l->set_text("Base: ");
l->set_pos(Point2(0,3));
-// dr_panel->add_child(l);*/
+ //dr_panel->add_child(l);*/
-// menu->get_popup()->connect("id_pressed",this,"_menu_callback");
+ //menu->get_popup()->connect("id_pressed",this,"_menu_callback");
hb = memnew( HBoxContainer);
diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h
index 0c9b0b5ac6..c4539cd763 100644
--- a/tools/editor/animation_editor.h
+++ b/tools/editor/animation_editor.h
@@ -33,7 +33,7 @@
#include "scene/gui/slider.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/spin_box.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/file_dialog.h"
@@ -177,7 +177,7 @@ class AnimationKeyEditor : public VBoxContainer {
PopupMenu *type_menu;
Control *ec;
- TextureFrame *zoomicon;
+ TextureRect *zoomicon;
HSlider *zoom;
//MenuButton *menu;
SpinBox *length;
@@ -347,7 +347,7 @@ public:
void insert_value_key(const String& p_property, const Variant& p_value, bool p_advance);
void insert_transform_key(Spatial *p_node,const String& p_sub,const Transform& p_xform);
- void show_select_node_warning(bool p_show) { select_anim_warning->set_hidden(!p_show); }
+ void show_select_node_warning(bool p_show) { select_anim_warning->set_visible(p_show); }
AnimationKeyEditor();
~AnimationKeyEditor();
};
diff --git a/tools/editor/array_property_edit.cpp b/tools/editor/array_property_edit.cpp
index b587c4f830..7304d8dddf 100644
--- a/tools/editor/array_property_edit.cpp
+++ b/tools/editor/array_property_edit.cpp
@@ -288,10 +288,10 @@ Node *ArrayPropertyEdit::get_node() {
void ArrayPropertyEdit::_bind_methods() {
- ClassDB::bind_method(_MD("_set_size"),&ArrayPropertyEdit::_set_size);
- ClassDB::bind_method(_MD("_set_value"),&ArrayPropertyEdit::_set_value);
- ClassDB::bind_method(_MD("_notif_change"),&ArrayPropertyEdit::_notif_change);
- ClassDB::bind_method(_MD("_notif_changev"),&ArrayPropertyEdit::_notif_changev);
+ ClassDB::bind_method(D_METHOD("_set_size"),&ArrayPropertyEdit::_set_size);
+ ClassDB::bind_method(D_METHOD("_set_value"),&ArrayPropertyEdit::_set_value);
+ ClassDB::bind_method(D_METHOD("_notif_change"),&ArrayPropertyEdit::_notif_change);
+ ClassDB::bind_method(D_METHOD("_notif_changev"),&ArrayPropertyEdit::_notif_changev);
}
ArrayPropertyEdit::ArrayPropertyEdit()
diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp
index 11d7a2b58b..1c1b6c91e3 100644
--- a/tools/editor/asset_library_editor_plugin.cpp
+++ b/tools/editor/asset_library_editor_plugin.cpp
@@ -27,12 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "asset_library_editor_plugin.h"
+
#include "editor_node.h"
#include "editor_settings.h"
#include "io/json.h"
-
void EditorAssetLibraryItem::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost) {
title->set_text(p_title);
@@ -147,7 +147,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
vb->add_child(rating_hb);
for(int i=0;i<5;i++) {
- stars[i]=memnew(TextureFrame);
+ stars[i]=memnew(TextureRect);
rating_hb->add_child(stars[i]);
}
price = memnew( Label );
@@ -199,9 +199,9 @@ void EditorAssetLibraryItemDescription::set_image(int p_type,int p_index,const R
}
void EditorAssetLibraryItemDescription::_bind_methods() {
- ClassDB::bind_method(_MD("set_image"),&EditorAssetLibraryItemDescription::set_image);
- ClassDB::bind_method(_MD("_link_click"),&EditorAssetLibraryItemDescription::_link_click);
- ClassDB::bind_method(_MD("_preview_click"),&EditorAssetLibraryItemDescription::_preview_click);
+ ClassDB::bind_method(D_METHOD("set_image"),&EditorAssetLibraryItemDescription::set_image);
+ ClassDB::bind_method(D_METHOD("_link_click"),&EditorAssetLibraryItemDescription::_link_click);
+ ClassDB::bind_method(D_METHOD("_preview_click"),&EditorAssetLibraryItemDescription::_preview_click);
}
@@ -296,7 +296,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
desc_bg->add_child(description);
desc_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));
- preview = memnew( TextureFrame );
+ preview = memnew( TextureRect );
preview->set_custom_minimum_size(Size2(640,345));
hbox->add_child(preview);
@@ -485,7 +485,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
HBoxContainer *hb = memnew( HBoxContainer);
add_child(hb);
- icon = memnew( TextureFrame );
+ icon = memnew( TextureRect );
hb->add_child(icon);
VBoxContainer *vb = memnew( VBoxContainer );
@@ -555,7 +555,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
void EditorAssetLibrary::_notification(int p_what) {
if (p_what==NOTIFICATION_READY) {
- TextureFrame *tf = memnew(TextureFrame);
+ TextureRect *tf = memnew(TextureRect);
tf->set_texture(get_icon("Error","EditorIcons"));
reverse->set_icon(get_icon("Updown","EditorIcons"));
@@ -564,7 +564,7 @@ void EditorAssetLibrary::_notification(int p_what) {
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if(!is_hidden()) {
+ if(is_visible()) {
_repository_changed(0); // Update when shown for the first time
}
}
@@ -574,8 +574,8 @@ void EditorAssetLibrary::_notification(int p_what) {
HTTPClient::Status s = request->get_http_client_status();
bool visible = s!=HTTPClient::STATUS_DISCONNECTED;
- if (visible != !load_status->is_hidden()) {
- load_status->set_hidden(!visible);
+ if (visible != load_status->is_visible()) {
+ load_status->set_visible(visible);
}
if (visible) {
@@ -599,8 +599,8 @@ void EditorAssetLibrary::_notification(int p_what) {
}
bool no_downloads = downloads_hb->get_child_count()==0;
- if (no_downloads != downloads_scroll->is_hidden()) {
- downloads_scroll->set_hidden(no_downloads);
+ if (no_downloads == downloads_scroll->is_visible()) {
+ downloads_scroll->set_visible(!no_downloads);
}
}
@@ -789,7 +789,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
}
}
- image_queue[p_queue_id].request->queue_delete();;
+ image_queue[p_queue_id].request->queue_delete();
image_queue.erase(p_queue_id);
_update_image_queue();
@@ -1462,7 +1462,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_vb->set_h_size_flags(SIZE_EXPAND_FILL);
library_vb_border->add_child(library_vb);
-// margin_panel->set_stop_mouse(false);
+ //margin_panel->set_stop_mouse(false);
asset_top_page = memnew( HBoxContainer );
library_vb->add_child(asset_top_page);
diff --git a/tools/editor/asset_library_editor_plugin.h b/tools/editor/asset_library_editor_plugin.h
index 4ae229cefe..0598ea90ea 100644
--- a/tools/editor/asset_library_editor_plugin.h
+++ b/tools/editor/asset_library_editor_plugin.h
@@ -58,7 +58,7 @@ class EditorAssetLibraryItem : public PanelContainer {
LinkButton* title;
LinkButton* category;
LinkButton* author;
- TextureFrame *stars[5];
+ TextureRect *stars[5];
Label* price;
int asset_id;
@@ -104,7 +104,7 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
};
Vector<Preview> preview_images;
- TextureFrame *preview;
+ TextureRect *preview;
void set_image(int p_type,int p_index,const Ref<Texture>& p_image);
@@ -138,7 +138,7 @@ class EditorAssetLibraryItemDownload : public PanelContainer {
GDCLASS(EditorAssetLibraryItemDownload, PanelContainer);
- TextureFrame *icon;
+ TextureRect *icon;
Label* title;
ProgressBar *progress;
Button *install;
diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp
index 054a5098f0..6dfeb87dfd 100644
--- a/tools/editor/call_dialog.cpp
+++ b/tools/editor/call_dialog.cpp
@@ -30,7 +30,7 @@
#if 0
#include "scene/gui/label.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "print_string.h"
@@ -283,7 +283,7 @@ CallDialog::CallDialog() {
property_editor->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 15 );
property_editor->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 50 );
-// property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
+ //property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 );
property_editor->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, 90 );
property_editor->get_scene_tree()->set_hide_root( true );
property_editor->hide_top_label();
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index 0d7dc558ac..0a25b43716 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "code_editor.h"
+
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/separator.h"
@@ -91,7 +92,7 @@ void FindReplaceBar::_notification(int p_what) {
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- set_process_unhandled_input(is_visible());
+ set_process_unhandled_input(is_visible_in_tree());
}
}
@@ -377,7 +378,7 @@ void FindReplaceBar::popup_search() {
void FindReplaceBar::popup_replace() {
- if (!replace_hbc->is_visible() || !replace_options_hbc->is_visible()) {
+ if (!replace_hbc->is_visible_in_tree() || !replace_options_hbc->is_visible_in_tree()) {
replace_text->clear();
replace_hbc->show();
replace_options_hbc->show();
@@ -396,7 +397,7 @@ void FindReplaceBar::_search_options_changed(bool p_pressed) {
void FindReplaceBar::_editor_text_changed() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
preserve_cursor=true;
search_current();
preserve_cursor=false;
@@ -714,7 +715,7 @@ void FindReplaceDialog::_replace() {
}
text_edit->set_v_scroll(vsval);
-// text_edit->set_h_scroll(hsval);
+ //text_edit->set_h_scroll(hsval);
error_label->set_text(vformat(TTR("Replaced %d ocurrence(s)."),rc));
@@ -801,7 +802,7 @@ void FindReplaceDialog::_skip_pressed() {
bool FindReplaceDialog::is_replace_mode() const {
- return replace_text->is_visible();
+ return replace_text->is_visible_in_tree();
}
bool FindReplaceDialog::is_replace_all_mode() const {
@@ -826,7 +827,7 @@ void FindReplaceDialog::ok_pressed() {
void FindReplaceDialog::_search_text_entered(const String& p_text) {
- if (replace_text->is_visible())
+ if (replace_text->is_visible_in_tree())
return;
emit_signal("search");
_search();
@@ -835,7 +836,7 @@ void FindReplaceDialog::_search_text_entered(const String& p_text) {
void FindReplaceDialog::_replace_text_entered(const String& p_text) {
- if (!replace_text->is_visible())
+ if (!replace_text->is_visible_in_tree())
return;
emit_signal("search");
@@ -951,7 +952,7 @@ FindReplaceDialog::FindReplaceDialog() {
VBoxContainer *rvb = memnew( VBoxContainer);
opt_mg->add_child(rvb);
replace_vb=rvb;
-// rvb ->add_child(memnew(HSeparator));
+ //rvb ->add_child(memnew(HSeparator));
rvb ->add_child(memnew(Label));
prompt = memnew( CheckButton );
@@ -1061,7 +1062,7 @@ void CodeTextEditor::_text_changed() {
}
void CodeTextEditor::_code_complete_timer_timeout() {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if (enable_complete_timer)
text_editor->query_code_comple();
diff --git a/tools/collada/SCsub b/tools/editor/collada/SCsub
index 4bc64ffdc2..04c9a827ef 100644
--- a/tools/collada/SCsub
+++ b/tools/editor/collada/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.tool_sources, "*.cpp")
+env.add_source_files(env.editor_sources, "*.cpp")
Export('env')
diff --git a/tools/collada/collada.cpp b/tools/editor/collada/collada.cpp
index 9f2416223e..2ba4f648a3 100644
--- a/tools/collada/collada.cpp
+++ b/tools/editor/collada/collada.cpp
@@ -29,6 +29,7 @@
#ifdef TOOLS_ENABLED
#include "collada.h"
+
#include "stdio.h"
//#define DEBUG_DEFAULT_ANIMATION
@@ -103,7 +104,7 @@ Transform Collada::fix_transform(const Transform& p_transform) {
}
#endif
-// tr.scale(Vector3(state.unit_scale.unit_scale.unit_scale));
+ //tr.scale(Vector3(state.unit_scale.unit_scale.unit_scale));
return tr;
//return state.matrix_fix * p_transform;
}
@@ -351,7 +352,7 @@ void Collada::_parse_image(XMLParser& parser) {
image.path=path;
- } if (name=="data") {
+ } else if (name=="data") {
ERR_PRINT("COLLADA Embedded image data not supported!");
@@ -444,9 +445,11 @@ Vector<String> Collada::_read_string_array(XMLParser& parser) {
// parse String data
String str = parser.get_node_data();
array=str.split_spaces();
- //for(int i=0;i<array.size();i++) {
- // print_line(itos(i)+": "+array[i]);
- //}
+ /*
+ for(int i=0;i<array.size();i++) {
+ print_line(itos(i)+": "+array[i]);
+ }
+ */
}
else
if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END)
@@ -725,7 +728,7 @@ void Collada::_parse_effect_material(XMLParser& parser,Effect &effect,String &id
#endif
}
- } if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (
+ } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (
parser.get_node_name()=="constant" ||
parser.get_node_name()=="lambert" ||
parser.get_node_name()=="phong" ||
@@ -1097,7 +1100,7 @@ void Collada::_parse_mesh_geometry(XMLParser& parser,String p_id,String p_name)
current_source=id;
COLLADA_PRINT("source data: "+id);
- } else if (section=="float_array" || section=="array" || section=="float_array") {
+ } else if (section=="float_array" || section=="array") {
// create a new array and read it.
if (meshdata.sources.has(current_source)) {
@@ -1293,7 +1296,7 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
int stride=1;
if (parser.has_attribute("stride"))
- stride=parser.get_attribute_value("stride").to_int();;
+ stride=parser.get_attribute_value("stride").to_int();
skindata.sources[current_source].stride=stride;
COLLADA_PRINT("section: "+current_source+" stride "+itos(skindata.sources[current_source].stride));
@@ -1367,8 +1370,11 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
skindata.weights=weights;
- }// else if (!parser.is_empty())
- // parser.skip_section();
+ }
+ /*
+ else if (!parser.is_empty())
+ parser.skip_section();
+ */
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="skin")
break;
@@ -1396,7 +1402,7 @@ void Collada::_parse_skin_controller(XMLParser& parser,String p_id) {
for(int i=0;i<joint_source.sarray.size();i++) {
String name = joint_source.sarray[i];
- Transform xform = _read_transform_from_array(ibm_source.array,i*16);// <- this is a mistake, it must be applied to vertices
+ Transform xform = _read_transform_from_array(ibm_source.array,i*16); //<- this is a mistake, it must be applied to vertices
xform.affine_invert(); // inverse for rest, because it's an inverse
#ifdef COLLADA_IMPORT_SCALE_SCENE
xform.origin*=state.unit_scale;
@@ -1442,8 +1448,10 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
} else if (section=="Name_array" || section=="IDREF_array") {
// create a new array and read it.
- //if (section=="IDREF_array")
- // morphdata.use_idrefs=true;
+ /*
+ if (section=="IDREF_array")
+ morphdata.use_idrefs=true;
+ */
if (morphdata.sources.has(current_source)) {
morphdata.sources[current_source].sarray = _read_string_array(parser);
@@ -1463,7 +1471,7 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
int stride=1;
if (parser.has_attribute("stride"))
- stride=parser.get_attribute_value("stride").to_int();;
+ stride=parser.get_attribute_value("stride").to_int();
morphdata.sources[current_source].stride=stride;
COLLADA_PRINT("section: "+current_source+" stride "+itos(morphdata.sources[current_source].stride));
@@ -1491,8 +1499,10 @@ void Collada::_parse_morph_controller(XMLParser& parser, String p_id) {
}
- // else if (!parser.is_empty())
- // parser.skip_section();
+ /*
+ else if (!parser.is_empty())
+ parser.skip_section();
+ */
} else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name()=="morph")
break;
@@ -1705,7 +1715,7 @@ Collada::Node* Collada::_parse_visual_scene_node(XMLParser& parser) {
if ( parser.has_attribute("sid") ) { //bones may not have sid
joint->sid=parser.get_attribute_value("sid");
-// state.bone_map[joint->sid]=joint;
+ //state.bone_map[joint->sid]=joint;
} else if (state.idref_joints.has(name)) {
joint->sid=name; //kind of a cheat but..
} else if (parser.has_attribute("name")) {
@@ -2182,7 +2192,7 @@ void Collada::_parse_scene(XMLParser& parser) {
state.root_visual_scene=_uri_to_id(parser.get_attribute_value("url"));
print_line("***ROOT VISUAL SCENE: "+state.root_visual_scene);
- } if (name=="instance_physics_scene") {
+ } else if (name=="instance_physics_scene") {
state.root_physics_scene=_uri_to_id(parser.get_attribute_value("url"));
diff --git a/tools/collada/collada.h b/tools/editor/collada/collada.h
index fd7ad4920d..2de2d22935 100644
--- a/tools/collada/collada.h
+++ b/tools/editor/collada/collada.h
@@ -33,7 +33,7 @@
#include "scene/resources/material.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/xml_parser.h"
#include "map.h"
diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp
index 6e53c32080..91ba419c97 100644
--- a/tools/editor/connections_dialog.cpp
+++ b/tools/editor/connections_dialog.cpp
@@ -28,10 +28,7 @@
/*************************************************************************/
#include "connections_dialog.h"
-
#include "scene/gui/label.h"
-
-
#include "print_string.h"
#include "editor_settings.h"
#include "editor_node.h"
@@ -421,7 +418,7 @@ ConnectDialog::ConnectDialog() {
-// dst_method_list->get_popup()->connect("id_pressed", this,"_dst_method_list_selected");
+ //dst_method_list->get_popup()->connect("id_pressed", this,"_dst_method_list_selected");
tree->connect("node_selected", this,"_tree_node_selected");
set_as_toplevel(true);
@@ -432,7 +429,7 @@ ConnectDialog::ConnectDialog() {
add_child(error);
error->get_ok()->set_text(TTR("Close"));
get_ok()->set_text(TTR("Connect"));
-// error->get_cancel()->set_text("Close");
+ //error->get_cancel()->set_text("Close");
@@ -857,7 +854,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {
hb->add_spacer();
hb->add_child(connect_button);
connect_button->connect("pressed",this,"_connect_pressed");
-// add_child(tree);
+ //add_child(tree);
connect_dialog = memnew( ConnectDialog );
connect_dialog->set_as_toplevel(true);
diff --git a/tools/editor/connections_dialog.h b/tools/editor/connections_dialog.h
index bfc75266e9..64b292bc34 100644
--- a/tools/editor/connections_dialog.h
+++ b/tools/editor/connections_dialog.h
@@ -77,7 +77,7 @@ protected:
public:
- bool get_make_callback() { return !make_callback->is_hidden() && make_callback->is_pressed(); }
+ bool get_make_callback() { return make_callback->is_visible() && make_callback->is_pressed(); }
NodePath get_dst_path() const;
StringName get_dst_method() const;
bool get_deferred() const;
@@ -86,8 +86,8 @@ public:
void set_dst_method(const StringName& p_method);
void set_dst_node(Node* p_node);
-// Button *get_ok() { return ok; }
-// Button *get_cancel() { return cancel; }
+ //Button *get_ok() { return ok; }
+ //Button *get_cancel() { return cancel; }
void edit(Node *p_node);
ConnectDialog();
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 3e057ecf90..58bb148ce1 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "create_dialog.h"
-#include "object_type_db.h"
+#include "class_db.h"
#include "print_string.h"
#include "scene/gui/box_container.h"
#include "editor_node.h"
@@ -369,7 +369,7 @@ void CreateDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
search_box->call_deferred("grab_focus"); // still not visible
search_box->select_all();
@@ -624,15 +624,15 @@ void CreateDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Cont
void CreateDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_text_changed"),&CreateDialog::_text_changed);
- ClassDB::bind_method(_MD("_confirmed"),&CreateDialog::_confirmed);
- ClassDB::bind_method(_MD("_sbox_input"),&CreateDialog::_sbox_input);
- ClassDB::bind_method(_MD("_item_selected"),&CreateDialog::_item_selected);
- ClassDB::bind_method(_MD("_favorite_toggled"),&CreateDialog::_favorite_toggled);
- ClassDB::bind_method(_MD("_history_selected"),&CreateDialog::_history_selected);
- ClassDB::bind_method(_MD("_favorite_selected"),&CreateDialog::_favorite_selected);
- ClassDB::bind_method(_MD("_history_activated"),&CreateDialog::_history_activated);
- ClassDB::bind_method(_MD("_favorite_activated"),&CreateDialog::_favorite_activated);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&CreateDialog::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"),&CreateDialog::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&CreateDialog::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_item_selected"),&CreateDialog::_item_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_toggled"),&CreateDialog::_favorite_toggled);
+ ClassDB::bind_method(D_METHOD("_history_selected"),&CreateDialog::_history_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_selected"),&CreateDialog::_favorite_selected);
+ ClassDB::bind_method(D_METHOD("_history_activated"),&CreateDialog::_history_activated);
+ ClassDB::bind_method(D_METHOD("_favorite_activated"),&CreateDialog::_favorite_activated);
ClassDB::bind_method("get_drag_data_fw",&CreateDialog::get_drag_data_fw);
@@ -694,7 +694,7 @@ CreateDialog::CreateDialog() {
set_hide_on_ok(false);
search_options->connect("item_activated",this,"_confirmed");
search_options->connect("cell_selected",this,"_item_selected");
-// search_options->set_hide_root(true);
+ //search_options->set_hide_root(true);
base_type="Object";
help_bit = memnew( EditorHelpBit );
diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp
index 20e185104b..d7e04db86e 100644
--- a/tools/editor/dependency_editor.cpp
+++ b/tools/editor/dependency_editor.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dependency_editor.h"
+
#include "os/file_access.h"
#include "scene/gui/margin_container.h"
#include "io/resource_loader.h"
@@ -250,9 +251,9 @@ void DependencyEditor::edit(const String& p_path) {
void DependencyEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_searched"),&DependencyEditor::_searched);
- ClassDB::bind_method(_MD("_load_pressed"),&DependencyEditor::_load_pressed);
- ClassDB::bind_method(_MD("_fix_all"),&DependencyEditor::_fix_all);
+ ClassDB::bind_method(D_METHOD("_searched"),&DependencyEditor::_searched);
+ ClassDB::bind_method(D_METHOD("_load_pressed"),&DependencyEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_fix_all"),&DependencyEditor::_fix_all);
}
@@ -690,8 +691,8 @@ void OrphanResourcesDialog::_button_pressed(Object *p_item,int p_column, int p_i
void OrphanResourcesDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_delete_confirm"),&OrphanResourcesDialog::_delete_confirm);
- ClassDB::bind_method(_MD("_button_pressed"),&OrphanResourcesDialog::_button_pressed);
+ ClassDB::bind_method(D_METHOD("_delete_confirm"),&OrphanResourcesDialog::_delete_confirm);
+ ClassDB::bind_method(D_METHOD("_button_pressed"),&OrphanResourcesDialog::_button_pressed);
}
diff --git a/servers/spatial_sound_2d/SCsub b/tools/editor/doc/SCsub
index ccc76e823f..04c9a827ef 100644
--- a/servers/spatial_sound_2d/SCsub
+++ b/tools/editor/doc/SCsub
@@ -2,6 +2,6 @@
Import('env')
-env.add_source_files(env.servers_sources, "*.cpp")
+env.add_source_files(env.editor_sources, "*.cpp")
Export('env')
diff --git a/tools/doc/doc_data.cpp b/tools/editor/doc/doc_data.cpp
index 6b6a864ecc..e0a4750862 100644
--- a/tools/doc/doc_data.cpp
+++ b/tools/editor/doc/doc_data.cpp
@@ -26,11 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "doc_data.h"
+#include "version.h"
#include "global_constants.h"
-#include "globals.h"
+#include "global_config.h"
#include "script_language.h"
#include "io/marshalls.h"
#include "io/compression.h"
@@ -250,7 +250,7 @@ void DocData::generate(bool p_basic_types) {
} else if (arginfo.type!=Variant::NIL) // {
#endif
method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type);
-// }
+ //}
} else {
@@ -804,7 +804,7 @@ Error DocData::_load(Ref<XMLParser> parser) {
class_list[name]=ClassDoc();
ClassDoc& c = class_list[name];
-// print_line("class: "+name);
+ //print_line("class: "+name);
c.name=name;
if (parser->has_attribute("inherits"))
c.inherits = parser->get_attribute_value("inherits");
diff --git a/tools/doc/doc_data.h b/tools/editor/doc/doc_data.h
index fead1da510..fead1da510 100644
--- a/tools/doc/doc_data.h
+++ b/tools/editor/doc/doc_data.h
diff --git a/tools/doc/doc_dump.cpp b/tools/editor/doc/doc_dump.cpp
index e1ffcfbbb2..5ebba596e9 100644
--- a/tools/doc/doc_dump.cpp
+++ b/tools/editor/doc/doc_dump.cpp
@@ -26,8 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "doc_dump.h"
+
+#include "version.h"
#include "os/file_access.h"
#include "scene/main/node.h"
diff --git a/tools/doc/doc_dump.h b/tools/editor/doc/doc_dump.h
index 4577af078e..84629b89c8 100644
--- a/tools/doc/doc_dump.h
+++ b/tools/editor/doc/doc_dump.h
@@ -29,7 +29,7 @@
#ifndef DOC_DUMP_H
#define DOC_DUMP_H
-#include "object_type_db.h"
+#include "class_db.h"
class DocDump {
public:
diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp
index 54099ddce5..8af01012a4 100644
--- a/tools/editor/editor_asset_installer.cpp
+++ b/tools/editor/editor_asset_installer.cpp
@@ -27,10 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_asset_installer.h"
+
#include "io/zip_io.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "editor_node.h"
+
void EditorAssetInstaller::_update_subitems(TreeItem* p_item,bool p_check,bool p_first) {
@@ -196,7 +198,7 @@ void EditorAssetInstaller::open(const String& p_path,int p_depth) {
ti->set_icon(0,get_icon("folder","FileDialog"));
} else {
String file = path.get_file();
- String extension = file.extension().to_lower();
+ String extension = file.get_extension().to_lower();
if (extension_guess.has(extension)) {
ti->set_icon(0,extension_guess[extension]);
} else {
diff --git a/tools/editor/editor_audio_buses.cpp b/tools/editor/editor_audio_buses.cpp
new file mode 100644
index 0000000000..6ee18f08d8
--- /dev/null
+++ b/tools/editor/editor_audio_buses.cpp
@@ -0,0 +1,1192 @@
+#include "editor_audio_buses.h"
+#include "editor_node.h"
+#include "servers/audio_server.h"
+#include "os/keyboard.h"
+#include "io/resource_saver.h"
+#include "filesystem_dock.h"
+
+void EditorAudioBus::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_READY) {
+
+ vu_l->set_under_texture(get_icon("BusVuEmpty","EditorIcons"));
+ vu_l->set_progress_texture(get_icon("BusVuFull","EditorIcons"));
+ vu_r->set_under_texture(get_icon("BusVuEmpty","EditorIcons"));
+ vu_r->set_progress_texture(get_icon("BusVuFull","EditorIcons"));
+ scale->set_texture( get_icon("BusVuDb","EditorIcons"));
+
+ disabled_vu = get_icon("BusVuFrozen","EditorIcons");
+
+ prev_active=true;
+ update_bus();
+ set_process(true);
+ }
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ if (has_focus()) {
+ draw_style_box(get_stylebox("focus","Button"),Rect2(Vector2(),get_size()));
+ }
+ }
+
+ if (p_what==NOTIFICATION_PROCESS) {
+
+ float real_peak[2]={-100,-100};
+ bool activity_found=false;
+
+ int cc;
+ switch(AudioServer::get_singleton()->get_speaker_mode()) {
+ case AudioServer::SPEAKER_MODE_STEREO: cc = 1; break;
+ case AudioServer::SPEAKER_SURROUND_51: cc = 4; break;
+ case AudioServer::SPEAKER_SURROUND_71: cc = 5; break;
+ }
+
+ for(int i=0;i<cc;i++) {
+ if (AudioServer::get_singleton()->is_bus_channel_active(get_index(),i)) {
+ activity_found=true;
+ real_peak[0]=MAX(real_peak[0],AudioServer::get_singleton()->get_bus_peak_volume_left_db(get_index(),i));
+ real_peak[1]=MAX(real_peak[1],AudioServer::get_singleton()->get_bus_peak_volume_right_db(get_index(),i));
+ }
+ }
+
+
+ if (real_peak[0]>peak_l) {
+ peak_l = real_peak[0];
+ } else {
+ peak_l-=get_process_delta_time()*60.0;
+ }
+
+ if (real_peak[1]>peak_r) {
+ peak_r = real_peak[1];
+ } else {
+ peak_r-=get_process_delta_time()*60.0;
+
+ }
+
+ vu_l->set_value(peak_l);
+ vu_r->set_value(peak_r);
+
+ if (activity_found!=prev_active) {
+ if (activity_found) {
+ vu_l->set_over_texture(Ref<Texture>());
+ vu_r->set_over_texture(Ref<Texture>());
+ } else {
+ vu_l->set_over_texture(disabled_vu);
+ vu_r->set_over_texture(disabled_vu);
+
+ }
+
+ prev_active=activity_found;
+ }
+
+ }
+
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ peak_l=-100;
+ peak_r=-100;
+ prev_active=true;
+
+ set_process(is_visible_in_tree());
+ }
+
+}
+
+void EditorAudioBus::update_send() {
+
+ send->clear();
+ if (get_index()==0) {
+ send->set_disabled(true);
+ send->set_text("Speakers");
+ } else {
+ send->set_disabled(false);
+ StringName current_send = AudioServer::get_singleton()->get_bus_send(get_index());
+ int current_send_index=0; //by default to master
+
+ for(int i=0;i<get_index();i++) {
+ StringName send_name = AudioServer::get_singleton()->get_bus_name(i);
+ send->add_item(send_name);
+ if (send_name==current_send) {
+ current_send_index=i;
+ }
+ }
+
+ send->select(current_send_index);
+ }
+}
+
+void EditorAudioBus::update_bus() {
+
+ if (updating_bus)
+ return;
+
+ updating_bus=true;
+
+ int index = get_index();
+
+ slider->set_value(AudioServer::get_singleton()->get_bus_volume_db(index));
+ track_name->set_text(AudioServer::get_singleton()->get_bus_name(index));
+ if (get_index()==0)
+ track_name->set_editable(false);
+
+ solo->set_pressed( AudioServer::get_singleton()->is_bus_solo(index));
+ mute->set_pressed( AudioServer::get_singleton()->is_bus_mute(index));
+ bypass->set_pressed( AudioServer::get_singleton()->is_bus_bypassing_effects(index));
+ // effects..
+ effects->clear();
+
+ TreeItem *root = effects->create_item();
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(index);i++) {
+
+ Ref<AudioEffect> afx = AudioServer::get_singleton()->get_bus_effect(index,i);
+
+ TreeItem *fx = effects->create_item(root);
+ fx->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ fx->set_editable(0,true);
+ fx->set_checked(0,AudioServer::get_singleton()->is_bus_effect_enabled(index,i));
+ fx->set_text(0,afx->get_name());
+ fx->set_metadata(0,i);
+
+ }
+
+ TreeItem *add = effects->create_item(root);
+ add->set_cell_mode(0,TreeItem::CELL_MODE_CUSTOM);
+ add->set_editable(0,true);
+ add->set_selectable(0,false);
+ add->set_text(0,"Add Effect");
+
+ update_send();
+
+ updating_bus=false;
+
+}
+
+
+void EditorAudioBus::_name_changed(const String& p_new_name) {
+
+ if (p_new_name==AudioServer::get_singleton()->get_bus_name(get_index()))
+ return;
+
+ String attempt=p_new_name;
+ int attempts=1;
+
+ while(true) {
+
+ bool name_free=true;
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+
+ if (AudioServer::get_singleton()->get_bus_name(i)==attempt) {
+ name_free=false;
+ break;
+ }
+ }
+
+ if (name_free) {
+ break;
+ }
+
+ attempts++;
+ attempt=p_new_name+" "+itos(attempts);
+ }
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ StringName current = AudioServer::get_singleton()->get_bus_name(get_index());
+ ur->create_action("Rename Audio Bus");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_name",get_index(),attempt);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_name",get_index(),current);
+
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+ if (AudioServer::get_singleton()->get_bus_send(i)==current) {
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",i,attempt);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",i,current);
+ }
+ }
+
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+
+
+ ur->add_do_method(buses,"_update_sends");
+ ur->add_undo_method(buses,"_update_sends");
+ ur->commit_action();
+
+ updating_bus=false;
+
+}
+
+void EditorAudioBus::_volume_db_changed(float p_db){
+
+ if (updating_bus)
+ return;
+
+ updating_bus=true;
+
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Change Audio Bus Volume",UndoRedo::MERGE_ENDS);
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_volume_db",get_index(),p_db);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_volume_db",get_index(),AudioServer::get_singleton()->get_bus_volume_db(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+
+}
+void EditorAudioBus::_solo_toggled(){
+
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Toggle Audio Bus Solo");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_solo",get_index(),solo->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_solo",get_index(),AudioServer::get_singleton()->is_bus_solo(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+
+}
+void EditorAudioBus::_mute_toggled(){
+
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Toggle Audio Bus Mute");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_mute",get_index(),mute->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_mute",get_index(),AudioServer::get_singleton()->is_bus_mute(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+
+}
+void EditorAudioBus::_bypass_toggled(){
+
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Toggle Audio Bus Bypass Effects");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_bypass_effects",get_index(),bypass->is_pressed());
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_bypass_effects",get_index(),AudioServer::get_singleton()->is_bus_bypassing_effects(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+
+
+}
+
+void EditorAudioBus::_send_selected(int p_which) {
+
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Select Audio Bus Send");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",get_index(),send->get_item_text(p_which));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",get_index(),AudioServer::get_singleton()->get_bus_send(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+}
+
+void EditorAudioBus::_effect_selected() {
+
+ TreeItem *effect = effects->get_selected();
+ if (!effect)
+ return;
+ updating_bus=true;
+
+ if (effect->get_metadata(0)!=Variant()) {
+
+ int index = effect->get_metadata(0);
+ Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(get_index(),index);
+ if (effect.is_valid()) {
+ EditorNode::get_singleton()->push_item(effect.ptr());
+ }
+ }
+
+ updating_bus=false;
+
+}
+
+void EditorAudioBus::_effect_edited() {
+
+ if (updating_bus)
+ return;
+
+ TreeItem *effect = effects->get_edited();
+ if (!effect)
+ return;
+
+ if (effect->get_metadata(0)==Variant()) {
+ Rect2 area = effects->get_item_rect(effect);
+
+ effect_options->set_pos(effects->get_global_pos()+area.pos+Vector2(0,area.size.y));
+ effect_options->popup();
+ //add effect
+ } else {
+ int index = effect->get_metadata(0);
+ updating_bus=true;
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Select Audio Bus Send");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,effect->is_checked(0));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,AudioServer::get_singleton()->is_bus_effect_enabled(get_index(),index));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+ updating_bus=false;
+
+ }
+
+}
+
+void EditorAudioBus::_effect_add(int p_which) {
+
+ if (updating_bus)
+ return;
+
+ StringName name = effect_options->get_item_metadata(p_which);
+
+ Object *fx = ClassDB::instance(name);
+ ERR_FAIL_COND(!fx);
+ AudioEffect *afx = fx->cast_to<AudioEffect>();
+ ERR_FAIL_COND(!afx);
+ Ref<AudioEffect> afxr = Ref<AudioEffect>(afx);
+
+ afxr->set_name(effect_options->get_item_text(p_which));
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Add Audio Bus Effect");
+ ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),afxr,-1);
+ ur->add_undo_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect_count(get_index()));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+}
+
+void EditorAudioBus::_gui_input(const InputEvent& p_event) {
+
+ if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode==KEY_DELETE && !p_event.key.echo) {
+ accept_event();
+ emit_signal("delete_request");
+ }
+ if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==2 && p_event.mouse_button.pressed) {
+
+ Vector2 pos = Vector2(p_event.mouse_button.x,p_event.mouse_button.y);
+ delete_popup->set_pos(get_global_pos()+pos);
+ delete_popup->popup();
+ }
+}
+
+void EditorAudioBus::_delete_pressed(int p_option) {
+
+ if (p_option==1) {
+ emit_signal("delete_request");
+ } else if (p_option==0) {
+ //duplicate
+ emit_signal("duplicate_request",get_index());
+ }
+
+}
+
+
+Variant EditorAudioBus::get_drag_data(const Point2& p_point) {
+
+ if (get_index()==0) {
+ return Variant();
+ }
+
+ Control *c = memnew(Control);
+ Panel *p = memnew( Panel );
+ c->add_child(p);
+ p->add_style_override("panel",get_stylebox("focus","Button"));
+ p->set_size(get_size());
+ p->set_pos(-p_point);
+ set_drag_preview(c);
+ Dictionary d;
+ d["type"]="move_audio_bus";
+ d["index"]=get_index();
+ emit_signal("drop_end_request");
+ return d;
+}
+
+bool EditorAudioBus::can_drop_data(const Point2& p_point,const Variant& p_data) const {
+
+ if (get_index()==0)
+ return false;
+ Dictionary d=p_data;
+ if (d.has("type") && String(d["type"])=="move_audio_bus") {
+ return true;
+ }
+
+ return false;
+}
+void EditorAudioBus::drop_data(const Point2& p_point,const Variant& p_data) {
+
+ Dictionary d=p_data;
+ emit_signal("dropped",d["index"],get_index());
+
+}
+
+Variant EditorAudioBus::get_drag_data_fw(const Point2& p_point,Control* p_from) {
+
+ print_line("drag fw");
+ TreeItem *item = effects->get_item_at_pos(p_point);
+ if (!item) {
+ print_line("no item");
+ return Variant();
+ }
+
+ Variant md = item->get_metadata(0);
+
+ if (md.get_type()==Variant::INT) {
+ Dictionary fxd;
+ fxd["type"]="audio_bus_effect";
+ fxd["bus"]=get_index();
+ fxd["effect"]=md;
+
+ Label *l = memnew( Label );
+ l->set_text(item->get_text(0));
+ effects->set_drag_preview(l);
+
+ return fxd;
+ }
+
+ return Variant();
+
+}
+
+bool EditorAudioBus::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
+
+ Dictionary d = p_data;
+ if (!d.has("type") || String(d["type"])!="audio_bus_effect")
+ return false;
+
+ TreeItem *item = effects->get_item_at_pos(p_point);
+ if (!item)
+ return false;
+
+ effects->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
+
+ return true;
+}
+
+void EditorAudioBus::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
+
+ Dictionary d = p_data;
+
+ TreeItem *item = effects->get_item_at_pos(p_point);
+ if (!item)
+ return;
+ int pos=effects->get_drop_section_at_pos(p_point);
+ Variant md = item->get_metadata(0);
+
+ int paste_at;
+ int bus = d["bus"];
+ int effect = d["effect"];
+
+ if (md.get_type()==Variant::INT) {
+ paste_at=md;
+ if (pos>0)
+ paste_at++;
+
+ if (bus==get_index() && paste_at >effect) {
+ paste_at--;
+ }
+ } else {
+ paste_at=-1;
+ }
+
+
+ bool enabled = AudioServer::get_singleton()->is_bus_effect_enabled(bus,effect);
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Move Bus Effect");
+ ur->add_do_method(AudioServer::get_singleton(),"remove_bus_effect",bus,effect);
+ ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect(bus,effect),paste_at);
+
+ if (paste_at==-1) {
+ paste_at = AudioServer::get_singleton()->get_bus_effect_count(get_index());
+ if (bus==get_index()) {
+ paste_at--;
+ }
+ }
+ if (!enabled) {
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),paste_at,false);
+ }
+
+ ur->add_undo_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),paste_at);
+ ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",bus,AudioServer::get_singleton()->get_bus_effect(bus,effect),effect);
+ if (!enabled) {
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",bus,effect,false);
+ }
+
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ if (get_index()!=bus) {
+ ur->add_do_method(buses,"_update_bus",bus);
+ ur->add_undo_method(buses,"_update_bus",bus);
+ }
+ ur->commit_action();
+
+
+
+}
+
+void EditorAudioBus::_delete_effect_pressed(int p_option) {
+
+ TreeItem * item = effects->get_selected();
+ if (!item)
+ return;
+
+ if (item->get_metadata(0).get_type()!=Variant::INT)
+ return;
+
+ int index = item->get_metadata(0);
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Delete Bus Effect");
+ ur->add_do_method(AudioServer::get_singleton(),"remove_bus_effect",get_index(),index);
+ ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",get_index(),AudioServer::get_singleton()->get_bus_effect(get_index(),index),index);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",get_index(),index,AudioServer::get_singleton()->is_bus_effect_enabled(get_index(),index));
+ ur->add_do_method(buses,"_update_bus",get_index());
+ ur->add_undo_method(buses,"_update_bus",get_index());
+ ur->commit_action();
+
+
+}
+
+void EditorAudioBus::_effect_rmb(const Vector2& p_pos) {
+
+ TreeItem * item = effects->get_selected();
+ if (!item)
+ return;
+
+ if (item->get_metadata(0).get_type()!=Variant::INT)
+ return;
+
+ delete_effect_popup->set_pos(get_global_mouse_pos());
+ delete_effect_popup->popup();
+}
+
+void EditorAudioBus::_bind_methods() {
+
+ ClassDB::bind_method("update_bus",&EditorAudioBus::update_bus);
+ ClassDB::bind_method("update_send",&EditorAudioBus::update_send);
+ ClassDB::bind_method("_name_changed",&EditorAudioBus::_name_changed);
+ ClassDB::bind_method("_volume_db_changed",&EditorAudioBus::_volume_db_changed);
+ ClassDB::bind_method("_solo_toggled",&EditorAudioBus::_solo_toggled);
+ ClassDB::bind_method("_mute_toggled",&EditorAudioBus::_mute_toggled);
+ ClassDB::bind_method("_bypass_toggled",&EditorAudioBus::_bypass_toggled);
+ ClassDB::bind_method("_name_focus_exit",&EditorAudioBus::_name_focus_exit);
+ ClassDB::bind_method("_send_selected",&EditorAudioBus::_send_selected);
+ ClassDB::bind_method("_effect_edited",&EditorAudioBus::_effect_edited);
+ ClassDB::bind_method("_effect_selected",&EditorAudioBus::_effect_selected);
+ ClassDB::bind_method("_effect_add",&EditorAudioBus::_effect_add);
+ ClassDB::bind_method("_gui_input",&EditorAudioBus::_gui_input);
+ ClassDB::bind_method("_delete_pressed",&EditorAudioBus::_delete_pressed);
+ ClassDB::bind_method("get_drag_data_fw",&EditorAudioBus::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw",&EditorAudioBus::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw",&EditorAudioBus::drop_data_fw);
+ ClassDB::bind_method("_delete_effect_pressed",&EditorAudioBus::_delete_effect_pressed);
+ ClassDB::bind_method("_effect_rmb",&EditorAudioBus::_effect_rmb);
+
+
+
+ ADD_SIGNAL(MethodInfo("duplicate_request"));
+ ADD_SIGNAL(MethodInfo("delete_request"));
+ ADD_SIGNAL(MethodInfo("drop_end_request"));
+ ADD_SIGNAL(MethodInfo("dropped"));
+
+}
+
+EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
+
+ buses=p_buses;
+ updating_bus=false;
+
+ VBoxContainer *vb = memnew( VBoxContainer );
+ add_child(vb);
+
+ set_v_size_flags(SIZE_EXPAND_FILL);
+
+ track_name = memnew( LineEdit );
+ vb->add_child(track_name);
+ track_name->connect("text_entered",this,"_name_changed");
+ track_name->connect("focus_exited",this,"_name_focus_exit");
+
+ HBoxContainer *hbc = memnew( HBoxContainer);
+ vb->add_child(hbc);
+ hbc->add_spacer();
+ solo = memnew( ToolButton );
+ solo->set_text("S");
+ solo->set_toggle_mode(true);
+ solo->set_modulate(Color(0.8,1.2,0.8));
+ 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_modulate(Color(1.2,0.8,0.8));
+ 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_modulate(Color(1.1,1.1,0.8));
+ bypass->set_focus_mode(FOCUS_NONE);
+ bypass->connect("pressed",this,"_bypass_toggled");
+ hbc->add_child(bypass);
+ hbc->add_spacer();
+
+ HBoxContainer *hb = memnew( HBoxContainer );
+ vb->add_child(hb);
+ slider = memnew( VSlider );
+ slider->set_min(-80);
+ slider->set_max(24);
+ slider->set_step(0.1);
+
+ slider->connect("value_changed",this,"_volume_db_changed");
+ hb->add_child(slider);
+ vu_l = memnew( TextureProgress );
+ vu_l->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
+ hb->add_child(vu_l);
+ vu_l->set_min(-80);
+ vu_l->set_max(24);
+ vu_l->set_step(0.1);
+
+ vu_r = memnew( TextureProgress );
+ vu_r->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
+ hb->add_child(vu_r);
+ vu_r->set_min(-80);
+ vu_r->set_max(24);
+ vu_r->set_step(0.1);
+
+ scale = memnew( TextureRect );
+ hb->add_child(scale);
+
+ //add_child(hb);
+
+ effects = memnew( Tree );
+ effects->set_hide_root(true);
+ effects->set_custom_minimum_size(Size2(0,90)*EDSCALE);
+ effects->set_hide_folding(true);
+ vb->add_child(effects);
+ effects->connect("item_edited",this,"_effect_edited");
+ effects->connect("cell_selected",this,"_effect_selected");
+ effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
+ effects->set_drag_forwarding(this);
+ effects->connect("item_rmb_selected",this,"_effect_rmb");
+ effects->set_allow_rmb_select(true);
+
+ send = memnew( OptionButton );
+ send->set_clip_text(true);
+ send->connect("item_selected",this,"_send_selected");
+ vb->add_child(send);
+
+ set_focus_mode(FOCUS_CLICK);
+
+ effect_options = memnew( PopupMenu );
+ effect_options->connect("index_pressed",this,"_effect_add");
+ add_child(effect_options);
+ List<StringName> effects;
+ ClassDB::get_inheriters_from_class("AudioEffect",&effects);
+ effects.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E=effects.front();E;E=E->next()) {
+ if (!ClassDB::can_instance(E->get()))
+ continue;
+
+ Ref<Texture> icon;
+ if (has_icon(E->get(),"EditorIcons")) {
+ icon = get_icon(E->get(),"EditorIcons");
+ }
+ String name = E->get().operator String().replace("AudioEffect","");
+ effect_options->add_item(name);
+ effect_options->set_item_metadata(effect_options->get_item_count()-1,E->get());
+ effect_options->set_item_icon(effect_options->get_item_count()-1,icon);
+ }
+
+ delete_popup = memnew( PopupMenu );
+ delete_popup->add_item("Duplicate");
+ delete_popup->add_item("Delete");
+ add_child(delete_popup);
+ delete_popup->connect("index_pressed",this,"_delete_pressed");
+
+ delete_effect_popup = memnew( PopupMenu );
+ delete_effect_popup->add_item("Delete Effect");
+ add_child(delete_effect_popup);
+ delete_effect_popup->connect("index_pressed",this,"_delete_effect_pressed");
+
+}
+
+
+
+bool EditorAudioBusDrop::can_drop_data(const Point2& p_point,const Variant& p_data) const {
+
+ Dictionary d=p_data;
+ if (d.has("type") && String(d["type"])=="move_audio_bus") {
+ return true;
+ }
+
+ return false;
+}
+void EditorAudioBusDrop::drop_data(const Point2& p_point,const Variant& p_data){
+
+ Dictionary d=p_data;
+ emit_signal("dropped",d["index"],-1);
+
+}
+
+void EditorAudioBusDrop::_bind_methods() {
+
+ ADD_SIGNAL(MethodInfo("dropped"));
+}
+
+EditorAudioBusDrop::EditorAudioBusDrop() {
+
+
+}
+
+
+void EditorAudioBuses::_update_buses() {
+
+ while(bus_hb->get_child_count()>0) {
+ memdelete(bus_hb->get_child(0));
+ }
+
+ drop_end=NULL;
+
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+
+ EditorAudioBus *audio_bus = memnew( EditorAudioBus(this) );
+ if (i==0) {
+ audio_bus->set_self_modulate(Color(1,0.9,0.9));
+ }
+ bus_hb->add_child(audio_bus);
+ audio_bus->connect("delete_request",this,"_delete_bus",varray(audio_bus),CONNECT_DEFERRED);
+ audio_bus->connect("duplicate_request",this,"_duplicate_bus",varray(),CONNECT_DEFERRED);
+ audio_bus->connect("drop_end_request",this,"_request_drop_end");
+ audio_bus->connect("dropped",this,"_drop_at_index",varray(),CONNECT_DEFERRED);
+
+
+
+ }
+}
+
+EditorAudioBuses *EditorAudioBuses::register_editor() {
+
+ EditorAudioBuses * audio_buses = memnew( EditorAudioBuses );
+ EditorNode::get_singleton()->add_bottom_panel_item("Audio",audio_buses);
+ return audio_buses;
+}
+
+void EditorAudioBuses::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_READY) {
+ _update_buses();
+ }
+
+ if (p_what==NOTIFICATION_DRAG_END) {
+ if (drop_end) {
+ drop_end->queue_delete();
+ drop_end=NULL;
+ }
+ }
+
+ if (p_what==NOTIFICATION_PROCESS) {
+
+ //check if anything was edited
+ bool edited = AudioServer::get_singleton()->is_edited();
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_count();i++) {
+ for(int j=0;j<AudioServer::get_singleton()->get_bus_effect_count(i);j++) {
+ Ref<AudioEffect> effect = AudioServer::get_singleton()->get_bus_effect(i,j);
+ if (effect->is_edited()) {
+ edited=true;
+ effect->set_edited(false);
+ }
+ }
+ }
+
+ AudioServer::get_singleton()->set_edited(false);
+
+ if (edited) {
+
+ save_timer->start();
+ }
+ }
+
+}
+
+
+void EditorAudioBuses::_add_bus() {
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ //need to simulate new name, so we can undi :(
+ ur->create_action("Add Audio Bus");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_count",AudioServer::get_singleton()->get_bus_count()+1);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_count",AudioServer::get_singleton()->get_bus_count());
+ ur->add_do_method(this,"_update_buses");
+ ur->add_undo_method(this,"_update_buses");
+ ur->commit_action();
+
+}
+
+void EditorAudioBuses::_update_bus(int p_index) {
+
+ if (p_index>=bus_hb->get_child_count())
+ return;
+
+ bus_hb->get_child(p_index)->call("update_bus");
+}
+
+void EditorAudioBuses::_update_sends() {
+
+ for(int i=0;i<bus_hb->get_child_count();i++) {
+ bus_hb->get_child(i)->call("update_send");
+ }
+}
+
+void EditorAudioBuses::_delete_bus(Object* p_which) {
+
+ EditorAudioBus *bus = p_which->cast_to<EditorAudioBus>();
+ int index = bus->get_index();
+ if (index==0) {
+ EditorNode::get_singleton()->show_warning("Master bus can't be deleted!");
+ return;
+ }
+
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ ur->create_action("Delete Audio Bus");
+ ur->add_do_method(AudioServer::get_singleton(),"remove_bus",index);
+ ur->add_undo_method(AudioServer::get_singleton(),"add_bus",index);
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_name",index,AudioServer::get_singleton()->get_bus_name(index));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_volume_db",index,AudioServer::get_singleton()->get_bus_volume_db(index));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_send",index,AudioServer::get_singleton()->get_bus_send(index));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_solo",index,AudioServer::get_singleton()->is_bus_solo(index));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_mute",index,AudioServer::get_singleton()->is_bus_mute(index));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_bypass_effects",index,AudioServer::get_singleton()->is_bus_bypassing_effects(index));
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(index);i++) {
+
+ ur->add_undo_method(AudioServer::get_singleton(),"add_bus_effect",index,AudioServer::get_singleton()->get_bus_effect(index,i));
+ ur->add_undo_method(AudioServer::get_singleton(),"set_bus_effect_enabled",index,i,AudioServer::get_singleton()->is_bus_effect_enabled(index,i));
+ }
+ ur->add_do_method(this,"_update_buses");
+ ur->add_undo_method(this,"_update_buses");
+ ur->commit_action();
+
+}
+
+
+void EditorAudioBuses::_duplicate_bus(int p_which) {
+
+ int add_at_pos = p_which+1;
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action("Duplicate Audio Bus");
+ ur->add_do_method(AudioServer::get_singleton(),"add_bus",add_at_pos);
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_name",add_at_pos,AudioServer::get_singleton()->get_bus_name(p_which)+" Copy");
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_volume_db",add_at_pos,AudioServer::get_singleton()->get_bus_volume_db(p_which));
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_send",add_at_pos,AudioServer::get_singleton()->get_bus_send(p_which));
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_solo",add_at_pos,AudioServer::get_singleton()->is_bus_solo(p_which));
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_mute",add_at_pos,AudioServer::get_singleton()->is_bus_mute(p_which));
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_bypass_effects",add_at_pos,AudioServer::get_singleton()->is_bus_bypassing_effects(p_which));
+ for(int i=0;i<AudioServer::get_singleton()->get_bus_effect_count(p_which);i++) {
+
+ ur->add_do_method(AudioServer::get_singleton(),"add_bus_effect",add_at_pos,AudioServer::get_singleton()->get_bus_effect(p_which,i));
+ ur->add_do_method(AudioServer::get_singleton(),"set_bus_effect_enabled",add_at_pos,i,AudioServer::get_singleton()->is_bus_effect_enabled(p_which,i));
+ }
+ ur->add_undo_method(AudioServer::get_singleton(),"remove_bus",add_at_pos);
+ ur->add_do_method(this,"_update_buses");
+ ur->add_undo_method(this,"_update_buses");
+ ur->commit_action();
+
+}
+
+void EditorAudioBuses::_request_drop_end() {
+
+ if (!drop_end && bus_hb->get_child_count()) {
+ drop_end = memnew( EditorAudioBusDrop );
+
+ bus_hb->add_child(drop_end);
+ drop_end->set_custom_minimum_size(bus_hb->get_child(0)->cast_to<Control>()->get_size());
+ drop_end->connect("dropped",this,"_drop_at_index",varray(),CONNECT_DEFERRED);
+ }
+}
+
+void EditorAudioBuses::_drop_at_index(int p_bus,int p_index) {
+
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+
+ //need to simulate new name, so we can undi :(
+ ur->create_action("Move Audio Bus");
+ ur->add_do_method(AudioServer::get_singleton(),"move_bus",p_bus,p_index);
+ int final_pos;
+ if (p_index==p_bus) {
+ final_pos=p_bus;
+ } else if (p_index==-1) {
+ final_pos = AudioServer::get_singleton()->get_bus_count()-1;
+ } else if (p_index<p_bus) {
+ final_pos = p_index;
+ } else {
+ final_pos = p_index -1;
+ }
+ ur->add_undo_method(AudioServer::get_singleton(),"move_bus",final_pos,p_bus);
+
+ ur->add_do_method(this,"_update_buses");
+ ur->add_undo_method(this,"_update_buses");
+ ur->commit_action();
+}
+
+void EditorAudioBuses::_server_save() {
+
+ Ref<AudioBusLayout> state = AudioServer::get_singleton()->generate_bus_layout();
+ ResourceSaver::save(edited_path,state);
+
+}
+
+void EditorAudioBuses::_select_layout() {
+
+ EditorNode::get_singleton()->get_filesystem_dock()->select_file(edited_path);
+}
+
+void EditorAudioBuses::_save_as_layout() {
+
+ file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_title(TTR("Save Audio Bus Layout As.."));
+ file_dialog->set_current_path(edited_path);
+ file_dialog->popup_centered_ratio();
+ new_layout=false;
+}
+
+
+void EditorAudioBuses::_new_layout() {
+
+ file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_title(TTR("Location for New Layout.."));
+ file_dialog->set_current_path(edited_path);
+ file_dialog->popup_centered_ratio();
+ new_layout=true;
+}
+
+void EditorAudioBuses::_load_layout() {
+
+ file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_title(TTR("Open Audio Bus Layout"));
+ file_dialog->set_current_path(edited_path);
+ file_dialog->popup_centered_ratio();
+ new_layout=false;
+}
+
+
+void EditorAudioBuses::_load_default_layout() {
+
+
+ Ref<AudioBusLayout> state = ResourceLoader::load("res://default_bus_layout.tres");
+ if (state.is_null()) {
+ EditorNode::get_singleton()->show_warning("There is no 'res://default_bus_layout.tres' file.");
+ return;
+ }
+
+ edited_path="res://default_bus_layout.tres";
+ file->set_text(edited_path.get_file());
+ AudioServer::get_singleton()->set_bus_layout(state);
+ _update_buses();
+ EditorNode::get_singleton()->get_undo_redo()->clear_history();
+ call_deferred("_select_layout");
+}
+
+void EditorAudioBuses::_file_dialog_callback(const String& p_string) {
+
+ if (file_dialog->get_mode()==EditorFileDialog::MODE_OPEN_FILE) {
+ Ref<AudioBusLayout> state = ResourceLoader::load(p_string);
+ if (state.is_null()) {
+ EditorNode::get_singleton()->show_warning("Invalid file, not an audio bus layout.");
+ return;
+ }
+
+ edited_path=p_string;
+ file->set_text(p_string.get_file());
+ AudioServer::get_singleton()->set_bus_layout(state);
+ _update_buses();
+ EditorNode::get_singleton()->get_undo_redo()->clear_history();
+ call_deferred("_select_layout");
+
+ } else if (file_dialog->get_mode()==EditorFileDialog::MODE_SAVE_FILE) {
+
+ if (new_layout) {
+ Ref<AudioBusLayout> empty_state;
+ empty_state.instance();
+ AudioServer::get_singleton()->set_bus_layout(empty_state);
+ }
+
+ Error err = ResourceSaver::save(p_string,AudioServer::get_singleton()->generate_bus_layout());
+
+ if (err!=OK) {
+ EditorNode::get_singleton()->show_warning("Error saving file: "+p_string);
+ return;
+ }
+
+ edited_path=p_string;
+ file->set_text(p_string.get_file());
+ _update_buses();
+ EditorNode::get_singleton()->get_undo_redo()->clear_history();
+ call_deferred("_select_layout");
+ }
+
+}
+
+void EditorAudioBuses::_bind_methods() {
+
+ ClassDB::bind_method("_add_bus",&EditorAudioBuses::_add_bus);
+ ClassDB::bind_method("_update_buses",&EditorAudioBuses::_update_buses);
+ ClassDB::bind_method("_update_bus",&EditorAudioBuses::_update_bus);
+ ClassDB::bind_method("_update_sends",&EditorAudioBuses::_update_sends);
+ ClassDB::bind_method("_delete_bus",&EditorAudioBuses::_delete_bus);
+ ClassDB::bind_method("_request_drop_end",&EditorAudioBuses::_request_drop_end);
+ ClassDB::bind_method("_drop_at_index",&EditorAudioBuses::_drop_at_index);
+ ClassDB::bind_method("_server_save",&EditorAudioBuses::_server_save);
+ ClassDB::bind_method("_select_layout",&EditorAudioBuses::_select_layout);
+ ClassDB::bind_method("_save_as_layout",&EditorAudioBuses::_save_as_layout);
+ ClassDB::bind_method("_load_layout",&EditorAudioBuses::_load_layout);
+ ClassDB::bind_method("_load_default_layout",&EditorAudioBuses::_load_default_layout);
+ ClassDB::bind_method("_new_layout",&EditorAudioBuses::_new_layout);
+ ClassDB::bind_method("_duplicate_bus",&EditorAudioBuses::_duplicate_bus);
+
+ ClassDB::bind_method("_file_dialog_callback",&EditorAudioBuses::_file_dialog_callback);
+}
+
+EditorAudioBuses::EditorAudioBuses()
+{
+
+ drop_end = NULL;
+ top_hb = memnew( HBoxContainer );
+ add_child(top_hb);
+
+ add = memnew( Button );
+ top_hb->add_child(add);;
+ add->set_text(TTR("Add Bus"));
+
+ add->connect("pressed",this,"_add_bus");
+
+
+
+ top_hb->add_spacer();
+
+ file = memnew( ToolButton );
+ file->set_text("default_bus_layout.tres");
+ top_hb->add_child(file);
+ file->connect("pressed",this,"_select_layout");
+
+ load = memnew( Button );
+ load->set_text(TTR("Load"));
+ top_hb->add_child(load);
+ load->connect("pressed",this,"_load_layout");
+
+ save_as = memnew( Button );
+ save_as->set_text(TTR("Save As"));
+ top_hb->add_child(save_as);
+ save_as->connect("pressed",this,"_save_as_layout");
+
+ _default = memnew( Button );
+ _default->set_text(TTR("Default"));
+ top_hb->add_child(_default);
+ _default->connect("pressed",this,"_load_default_layout");
+
+ _new = memnew( Button );
+ _new->set_text(TTR("Create"));
+ top_hb->add_child(_new);
+ _new->connect("pressed",this,"_new_layout");
+
+ bus_scroll = memnew( ScrollContainer );
+ bus_scroll->set_v_size_flags(SIZE_EXPAND_FILL);
+ bus_scroll->set_enable_h_scroll(true);
+ bus_scroll->set_enable_v_scroll(false);
+ add_child(bus_scroll);
+ bus_hb = memnew( HBoxContainer );
+ bus_scroll->add_child(bus_hb);
+
+ save_timer=memnew(Timer);
+ save_timer->set_wait_time(0.8);
+ save_timer->set_one_shot(true);
+ add_child(save_timer);
+ save_timer->connect("timeout",this,"_server_save");
+
+ set_v_size_flags(SIZE_EXPAND_FILL);
+
+
+ edited_path = "res://default_bus_layout.tres";
+
+ file_dialog = memnew( EditorFileDialog );
+ List<String> ext;
+ ResourceLoader::get_recognized_extensions_for_type("AudioServerState",&ext);
+ for (List<String>::Element *E=ext.front();E;E=E->next()) {
+ file_dialog->add_filter("*."+E->get()+"; Audio Bus State");
+ }
+ add_child(file_dialog);
+ file_dialog->connect("file_selected",this,"_file_dialog_callback");
+
+ set_process(true);
+
+}
+void EditorAudioBuses::open_layout(const String& p_path) {
+
+ EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
+
+ Ref<AudioBusLayout> state = ResourceLoader::load(p_path);
+ if (state.is_null()) {
+ EditorNode::get_singleton()->show_warning("Invalid file, not an audio bus layout.");
+ return;
+ }
+
+ edited_path=p_path;
+ file->set_text(p_path.get_file());
+ AudioServer::get_singleton()->set_bus_layout(state);
+ _update_buses();
+ EditorNode::get_singleton()->get_undo_redo()->clear_history();
+ call_deferred("_select_layout");
+}
+
+void AudioBusesEditorPlugin::edit(Object *p_node) {
+
+ if (p_node->cast_to<AudioBusLayout>()) {
+
+ String path = p_node->cast_to<AudioBusLayout>()->get_path();
+ if (path.is_resource_file()) {
+ audio_bus_editor->open_layout(path);
+ }
+ }
+}
+
+bool AudioBusesEditorPlugin::handles(Object *p_node) const {
+
+ return (p_node->cast_to<AudioBusLayout>()!=NULL);
+}
+
+void AudioBusesEditorPlugin::make_visible(bool p_visible){
+
+
+}
+
+AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) {
+
+ audio_bus_editor=p_node;
+}
+
+AudioBusesEditorPlugin::~AudioBusesEditorPlugin() {
+
+}
diff --git a/tools/editor/editor_audio_buses.h b/tools/editor/editor_audio_buses.h
new file mode 100644
index 0000000000..e44f8cd579
--- /dev/null
+++ b/tools/editor/editor_audio_buses.h
@@ -0,0 +1,186 @@
+#ifndef EDITORAUDIOBUSES_H
+#define EDITORAUDIOBUSES_H
+
+
+#include "scene/gui/box_container.h"
+#include "scene/gui/button.h"
+#include "scene/gui/tool_button.h"
+#include "scene/gui/scroll_container.h"
+#include "scene/gui/panel_container.h"
+#include "scene/gui/slider.h"
+#include "scene/gui/texture_progress.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/line_edit.h"
+#include "scene/gui/tree.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/panel.h"
+#include "tools/editor/editor_file_dialog.h"
+#include "editor_plugin.h"
+
+class EditorAudioBuses;
+
+class EditorAudioBus : public PanelContainer {
+
+ GDCLASS( EditorAudioBus, PanelContainer )
+
+ bool prev_active;
+ float peak_l;
+ float peak_r;
+
+ Ref<Texture> disabled_vu;
+ LineEdit *track_name;
+ VSlider *slider;
+ TextureProgress *vu_l;
+ TextureProgress *vu_r;
+ TextureRect *scale;
+ OptionButton *send;
+
+ PopupMenu *effect_options;
+ PopupMenu *delete_popup;
+ PopupMenu *delete_effect_popup;
+
+ Button *solo;
+ Button *mute;
+ Button *bypass;
+
+ Tree *effects;
+
+ bool updating_bus;
+
+ void _gui_input(const InputEvent& p_event);
+ void _delete_pressed(int p_option);
+
+ void _name_changed(const String& p_new_name);
+ void _name_focus_exit() { _name_changed(track_name->get_text()); }
+ void _volume_db_changed(float p_db);
+ void _solo_toggled();
+ void _mute_toggled();
+ void _bypass_toggled();
+ void _send_selected(int p_which);
+ void _effect_edited();
+ void _effect_add(int p_which);
+ void _effect_selected();
+ void _delete_effect_pressed(int p_option);
+ void _effect_rmb(const Vector2& p_pos);
+
+
+ virtual Variant get_drag_data(const Point2& p_point);
+ virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const;
+ virtual void drop_data(const Point2& p_point,const Variant& p_data);
+
+
+ Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
+ bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
+ void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
+
+friend class EditorAudioBuses;
+
+ EditorAudioBuses *buses;
+
+protected:
+
+ static void _bind_methods();
+ void _notification(int p_what);
+public:
+
+ void update_bus();
+ void update_send();
+
+ EditorAudioBus(EditorAudioBuses *p_buses=NULL);
+};
+
+
+class EditorAudioBusDrop : public Panel {
+
+ GDCLASS(EditorAudioBusDrop,Panel);
+
+ virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const;
+ virtual void drop_data(const Point2& p_point,const Variant& p_data);
+protected:
+
+ static void _bind_methods();
+public:
+
+ EditorAudioBusDrop();
+};
+
+class EditorAudioBuses : public VBoxContainer {
+
+ GDCLASS(EditorAudioBuses,VBoxContainer)
+
+ HBoxContainer *top_hb;
+
+ Button *add;
+ ScrollContainer *bus_scroll;
+ HBoxContainer *bus_hb;
+
+ EditorAudioBusDrop *drop_end;
+
+ Button *file;
+ Button *load;
+ Button *save_as;
+ Button *_default;
+ Button *_new;
+
+ Timer *save_timer;
+ String edited_path;
+
+ void _add_bus();
+ void _update_buses();
+ void _update_bus(int p_index);
+ void _update_sends();
+
+ void _delete_bus(Object* p_which);
+ void _duplicate_bus(int p_which);
+
+
+ void _request_drop_end();
+ void _drop_at_index(int p_bus,int p_index);
+
+ void _server_save();
+
+ void _select_layout();
+ void _load_layout();
+ void _save_as_layout();
+ void _load_default_layout();
+ void _new_layout();
+
+ EditorFileDialog *file_dialog;
+ bool new_layout;
+
+ void _file_dialog_callback(const String& p_string);
+
+protected:
+
+ static void _bind_methods();
+ void _notification(int p_what);
+public:
+
+ void open_layout(const String& p_path);
+
+ static EditorAudioBuses* register_editor();
+
+ EditorAudioBuses();
+};
+
+
+
+class AudioBusesEditorPlugin : public EditorPlugin {
+
+ GDCLASS( AudioBusesEditorPlugin, EditorPlugin );
+
+ EditorAudioBuses *audio_bus_editor;
+public:
+
+ virtual String get_name() const { return "SampleLibrary"; }
+ bool has_main_screen() const { return false; }
+ virtual void edit(Object *p_node);
+ virtual bool handles(Object *p_node) const;
+ virtual void make_visible(bool p_visible);
+
+ AudioBusesEditorPlugin(EditorAudioBuses *p_node);
+ ~AudioBusesEditorPlugin();
+
+};
+
+#endif // EDITORAUDIOBUSES_H
diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp
index 071a237ea8..3e3362f515 100644
--- a/tools/editor/editor_autoload_settings.cpp
+++ b/tools/editor/editor_autoload_settings.cpp
@@ -26,12 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "editor_autoload_settings.h"
-#include "globals.h"
+#include "global_config.h"
#include "global_constants.h"
-
#include "editor_node.h"
#define PREVIEW_LIST_MAX_SIZE 10
@@ -307,7 +305,7 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
void EditorAutoloadSettings::_autoload_file_callback(const String& p_path) {
- autoload_add_name->set_text(p_path.get_file().basename());
+ autoload_add_name->set_text(p_path.get_file().get_basename());
}
void EditorAutoloadSettings::update_autoload() {
diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp
index 710d955326..d2fa40e08c 100644
--- a/tools/editor/editor_data.cpp
+++ b/tools/editor/editor_data.cpp
@@ -27,7 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_data.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "editor_settings.h"
#include "os/dir_access.h"
#include "io/resource_loader.h"
@@ -524,8 +525,10 @@ void EditorData::remove_scene(int p_idx){
bool EditorData::_find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths) {
-// if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
-// return false;
+ /*
+ if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner()))
+ return false;
+ */
Ref<SceneState> ss;
@@ -766,26 +769,6 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection,
}
-void EditorData::set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_mdata) {
-
- ERR_FAIL_INDEX(current_edited_scene,edited_scene.size());
- edited_scene[current_edited_scene].medatata=p_mdata;
-
-}
-
-Ref<ResourceImportMetadata> EditorData::get_edited_scene_import_metadata(int idx) const{
-
- ERR_FAIL_INDEX_V(current_edited_scene,edited_scene.size(),Ref<ResourceImportMetadata>());
- if(idx<0) {
- return edited_scene[current_edited_scene].medatata;
- } else {
- ERR_FAIL_INDEX_V(idx,edited_scene.size(),Ref<ResourceImportMetadata>());
- return edited_scene[idx].medatata;
- }
-}
-
-
-
void EditorData::clear_edited_scenes() {
for(int i=0;i<edited_scene.size();i++) {
@@ -814,7 +797,7 @@ EditorData::EditorData() {
current_edited_scene=-1;
-// load_imported_scenes_from_globals();
+ //load_imported_scenes_from_globals();
}
///////////
@@ -903,12 +886,12 @@ Array EditorSelection::_get_selected_nodes() {
void EditorSelection::_bind_methods() {
- ClassDB::bind_method(_MD("_node_removed"),&EditorSelection::_node_removed);
- ClassDB::bind_method(_MD("clear"),&EditorSelection::clear);
- ClassDB::bind_method(_MD("add_node","node:Node"),&EditorSelection::add_node);
- ClassDB::bind_method(_MD("remove_node","node:Node"),&EditorSelection::remove_node);
- ClassDB::bind_method(_MD("get_selected_nodes"),&EditorSelection::_get_selected_nodes);
- ClassDB::bind_method(_MD("get_transformable_selected_nodes"),&EditorSelection::_get_transformable_selected_nodes);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&EditorSelection::_node_removed);
+ ClassDB::bind_method(D_METHOD("clear"),&EditorSelection::clear);
+ ClassDB::bind_method(D_METHOD("add_node","node:Node"),&EditorSelection::add_node);
+ ClassDB::bind_method(D_METHOD("remove_node","node:Node"),&EditorSelection::remove_node);
+ ClassDB::bind_method(D_METHOD("get_selected_nodes"),&EditorSelection::_get_selected_nodes);
+ ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"),&EditorSelection::_get_transformable_selected_nodes);
ADD_SIGNAL( MethodInfo("selection_changed") );
}
diff --git a/tools/editor/editor_data.h b/tools/editor/editor_data.h
index f0bc5983a2..fce606f722 100644
--- a/tools/editor/editor_data.h
+++ b/tools/editor/editor_data.h
@@ -129,7 +129,6 @@ private:
struct EditedScene {
Node* root;
Dictionary editor_states;
- Ref<ResourceImportMetadata> medatata;
List<Node*> selection;
Vector<EditorHistory::History> history_stored;
int history_current;
@@ -184,8 +183,6 @@ public:
void remove_scene(int p_idx);
void set_edited_scene(int p_idx);
void set_edited_scene_root(Node* p_root);
- void set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_mdata);
- Ref<ResourceImportMetadata> get_edited_scene_import_metadata(int p_idx = -1) const;
int get_edited_scene() const;
Node* get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp
index 56f9a0fb0b..c353e43070 100644
--- a/tools/editor/editor_dir_dialog.cpp
+++ b/tools/editor/editor_dir_dialog.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_dir_dialog.h"
+
#include "os/os.h"
#include "os/keyboard.h"
#include "tools/editor/editor_settings.h"
@@ -78,7 +79,7 @@ void EditorDirDialog::_update_dir(TreeItem* p_item) {
void EditorDirDialog::reload() {
- if (!is_visible()) {
+ if (!is_visible_in_tree()) {
must_reload=true;
return;
}
@@ -111,7 +112,7 @@ void EditorDirDialog::_notification(int p_what) {
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (must_reload && is_visible()) {
+ if (must_reload && is_visible_in_tree()) {
reload();
}
}
@@ -224,10 +225,10 @@ void EditorDirDialog::_make_dir_confirm() {
void EditorDirDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_item_collapsed"),&EditorDirDialog::_item_collapsed);
- ClassDB::bind_method(_MD("_make_dir"),&EditorDirDialog::_make_dir);
- ClassDB::bind_method(_MD("_make_dir_confirm"),&EditorDirDialog::_make_dir_confirm);
- ClassDB::bind_method(_MD("reload"),&EditorDirDialog::reload);
+ ClassDB::bind_method(D_METHOD("_item_collapsed"),&EditorDirDialog::_item_collapsed);
+ ClassDB::bind_method(D_METHOD("_make_dir"),&EditorDirDialog::_make_dir);
+ ClassDB::bind_method(D_METHOD("_make_dir_confirm"),&EditorDirDialog::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("reload"),&EditorDirDialog::reload);
ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo(Variant::STRING,"dir")));
}
@@ -255,7 +256,7 @@ EditorDirDialog::EditorDirDialog() {
VBoxContainer *makevb= memnew( VBoxContainer );
makedialog->add_child(makevb);
-// makedialog->set_child_rect(makevb);
+ //makedialog->set_child_rect(makevb);
makedirname = memnew( LineEdit );
makevb->add_margin_child(TTR("Name:"),makedirname);
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_export.cpp
index 0003e232c8..a67b583868 100644
--- a/tools/editor/editor_import_export.cpp
+++ b/tools/editor/editor_export.cpp
@@ -26,10 +26,937 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "editor_export.h"
#include "version.h"
-#include "editor_import_export.h"
#include "script_language.h"
-#include "globals.h"
+#include "global_config.h"
+#include "os/file_access.h"
+#include "os/dir_access.h"
+#include "tools/editor/editor_file_system.h"
+#include "io/resource_loader.h"
+#include "editor_node.h"
+#include "editor_settings.h"
+#include "io/config_file.h"
+#include "io/resource_saver.h"
+#include "io/md5.h"
+#include "tools/editor/plugins/script_editor_plugin.h"
+#include "io/zip_io.h"
+
+static int _get_pad(int p_alignment, int p_n) {
+
+ int rest = p_n % p_alignment;
+ int pad = 0;
+ if (rest > 0) {
+ pad = p_alignment - rest;
+ };
+
+ return pad;
+};
+
+#define PCK_PADDING 16
+
+bool EditorExportPreset::_set(const StringName& p_name, const Variant& p_value) {
+
+ if (values.has(p_name)) {
+ values[p_name]=p_value;
+ EditorExport::singleton->save_presets();
+ return true;
+ }
+
+ return false;
+}
+
+bool EditorExportPreset::_get(const StringName& p_name,Variant &r_ret) const{
+
+ if (values.has(p_name)) {
+ r_ret=values[p_name];
+ return true;
+ }
+
+ return false;
+}
+void EditorExportPreset::_get_property_list( List<PropertyInfo> *p_list) const{
+
+ for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
+
+ p_list->push_back(E->get());
+ }
+}
+
+Ref<EditorExportPlatform> EditorExportPreset::get_platform() const {
+
+ return platform;
+}
+
+Vector<String> EditorExportPreset::get_files_to_export() const {
+
+ Vector<String> files;
+ for(Set<String>::Element *E=selected_files.front();E;E=E->next()) {
+ files.push_back(E->get());
+ }
+ return files;
+}
+
+void EditorExportPreset::set_name(const String& p_name) {
+ name=p_name;
+ EditorExport::singleton->save_presets();
+
+}
+
+String EditorExportPreset::get_name() const {
+ return name;
+
+}
+
+void EditorExportPreset::set_runnable(bool p_enable) {
+
+ runnable=p_enable;
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::is_runnable() const {
+
+ return runnable;
+}
+
+void EditorExportPreset::set_export_filter(ExportFilter p_filter) {
+
+ export_filter=p_filter;
+ EditorExport::singleton->save_presets();
+
+}
+
+EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const {
+ return export_filter;
+}
+
+void EditorExportPreset::set_include_filter(const String& p_include) {
+
+ include_filter=p_include;
+ EditorExport::singleton->save_presets();
+
+}
+
+String EditorExportPreset::get_include_filter() const {
+
+ return include_filter;
+}
+
+void EditorExportPreset::set_exclude_filter(const String& p_exclude) {
+
+ exclude_filter=p_exclude;
+ EditorExport::singleton->save_presets();
+}
+
+String EditorExportPreset::get_exclude_filter() const {
+
+ return exclude_filter;
+}
+
+void EditorExportPreset::add_export_file(const String& p_path) {
+
+ selected_files.insert(p_path);
+ EditorExport::singleton->save_presets();
+}
+
+void EditorExportPreset::remove_export_file(const String& p_path) {
+ selected_files.erase(p_path);
+ EditorExport::singleton->save_presets();
+}
+
+bool EditorExportPreset::has_export_file(const String& p_path) {
+
+ return selected_files.has(p_path);
+}
+
+void EditorExportPreset::add_patch(const String& p_path,int p_at_pos) {
+
+ if (p_at_pos<0)
+ patches.push_back(p_path);
+ else
+ patches.insert(p_at_pos,p_path);
+ EditorExport::singleton->save_presets();
+}
+
+void EditorExportPreset::remove_patch(int p_idx) {
+ patches.remove(p_idx);
+ EditorExport::singleton->save_presets();
+}
+
+void EditorExportPreset::set_patch(int p_index,const String& p_path) {
+ ERR_FAIL_INDEX(p_index,patches.size());
+ patches[p_index]=p_path;
+ EditorExport::singleton->save_presets();
+}
+String EditorExportPreset::get_patch(int p_index) {
+
+ ERR_FAIL_INDEX_V(p_index,patches.size(),String());
+ return patches[p_index];
+}
+
+Vector<String> EditorExportPreset::get_patches() const {
+ return patches;
+}
+
+EditorExportPreset::EditorExportPreset() {
+
+ export_filter=EXPORT_ALL_RESOURCES;
+ runnable=false;
+}
+
+
+///////////////////////////////////
+
+void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) {
+
+ String host = EditorSettings::get_singleton()->get("network/debug_host");
+
+ if (p_flags&DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
+ host="localhost";
+
+ if (p_flags&DEBUG_FLAG_DUMB_CLIENT) {
+ int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
+ String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
+ r_flags.push_back("-rfs");
+ r_flags.push_back(host+":"+itos(port));
+ if (passwd!="") {
+ r_flags.push_back("-rfs_pass");
+ r_flags.push_back(passwd);
+ }
+ }
+
+ if (p_flags&DEBUG_FLAG_REMOTE_DEBUG) {
+
+ r_flags.push_back("-rdebug");
+
+ r_flags.push_back(host+":"+String::num(GLOBAL_DEF("network/debug/remote_port", 6007)));
+
+ List<String> breakpoints;
+ ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
+
+
+ if (breakpoints.size()) {
+
+ r_flags.push_back("-bp");
+ String bpoints;
+ for(const List<String>::Element *E=breakpoints.front();E;E=E->next()) {
+
+ bpoints+=E->get().replace(" ","%20");
+ if (E->next())
+ bpoints+=",";
+ }
+
+ r_flags.push_back(bpoints);
+ }
+
+ }
+
+ if (p_flags&DEBUG_FLAG_VIEW_COLLISONS) {
+
+ r_flags.push_back("-debugcol");
+ }
+
+ if (p_flags&DEBUG_FLAG_VIEW_NAVIGATION) {
+
+ r_flags.push_back("-debugnav");
+ }
+}
+
+Error EditorExportPlatform::_save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
+
+ PackData *pd = (PackData*)p_userdata;
+
+ SavedData sd;
+ sd.path_utf8=p_path.utf8();
+ sd.ofs = pd->f->get_pos();
+ sd.size = p_data.size();
+
+ pd->f->store_buffer(p_data.ptr(),p_data.size());
+ int pad = _get_pad(PCK_PADDING,sd.size);
+ for(int i=0;i<pad;i++) {
+ pd->f->store_8(0);
+ }
+
+ {
+ MD5_CTX ctx;
+ MD5Init(&ctx);
+ MD5Update(&ctx,(unsigned char*)p_data.ptr(),p_data.size());
+ MD5Final(&ctx);
+ sd.md5.resize(16);
+ for(int i=0;i<16;i++) {
+ sd.md5[i]=ctx.digest[i];
+ }
+ }
+
+ pd->file_ofs.push_back(sd);
+
+ pd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
+
+ return OK;
+}
+
+Error EditorExportPlatform::_save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
+
+
+ String path=p_path.replace_first("res://","");
+
+ ZipData *zd = (ZipData*)p_userdata;
+
+ zipFile zip=(zipFile)zd->zip;
+
+ zipOpenNewFileInZip(zip,
+ path.utf8().get_data(),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(zip,p_data.ptr(),p_data.size());
+ zipCloseFileInZip(zip);
+
+ zd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false);
+
+ return OK;
+}
+
+String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
+
+ String user_file = EditorSettings::get_singleton()->get_settings_path()
+ +"/templates/"+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"."+_MKSTR(VERSION_STATUS)+"/"+template_file_name;
+ String system_file=OS::get_singleton()->get_installed_templates_path();
+ bool has_system_path=(system_file!="");
+ system_file+=template_file_name;
+
+ // Prefer user file
+ if (FileAccess::exists(user_file)) {
+ return user_file;
+ }
+
+ // Now check system file
+ if (has_system_path) {
+ if (FileAccess::exists(system_file)) {
+ return system_file;
+ }
+ }
+
+ // Not found
+ if (err) {
+ *err+="No export template found at \""+user_file+"\"";
+ if (has_system_path)
+ *err+="\n or \""+system_file+"\".";
+ else
+ *err+=".";
+ }
+ return "";
+}
+
+Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
+
+ Ref<EditorExportPreset> preset;
+ preset.instance();
+ preset->platform=Ref<EditorExportPlatform>(this);
+
+ List<ExportOption> options;
+ get_export_options(&options);
+
+ for (List<ExportOption>::Element *E=options.front();E;E=E->next()) {
+
+ preset->properties.push_back(E->get().option);
+ preset->values[E->get().option.name]=E->get().default_value;
+ }
+
+ return preset;
+
+}
+
+void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths) {
+
+ for(int i=0;i<p_dir->get_subdir_count();i++) {
+ _export_find_resources(p_dir->get_subdir(i),p_paths);
+ }
+
+ for(int i=0;i<p_dir->get_file_count();i++) {
+ p_paths.insert(p_dir->get_file_path(i));
+ }
+}
+
+
+void EditorExportPlatform::_export_find_dependencies(const String& p_path,Set<String>& p_paths) {
+
+ if (p_paths.has(p_path))
+ return;
+
+ p_paths.insert(p_path);
+
+ EditorFileSystemDirectory *dir;
+ int file_idx;
+ dir = EditorFileSystem::get_singleton()->find_file(p_path,&file_idx);
+ if (!dir)
+ return;
+
+ Vector<String> deps = dir->get_file_deps(file_idx);
+
+ for(int i=0;i<deps.size();i++) {
+
+ _export_find_dependencies(deps[i],p_paths);
+ }
+}
+
+
+Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata) {
+
+ Ref<EditorExportPlatform> platform = p_preset->get_platform();
+ List<String> feature_list;
+ platform->get_preset_features(p_preset,&feature_list);
+ //figure out features
+ Set<String> features;
+ for (List<String>::Element *E=feature_list.front();E;E=E->next()) {
+ features.insert(E->get());
+ }
+
+ //figure out paths of files that will be exported
+ Set<String> paths;
+
+ if (p_preset->get_export_filter()==EditorExportPreset::EXPORT_ALL_RESOURCES) {
+ //find stuff
+ _export_find_resources(EditorFileSystem::get_singleton()->get_filesystem(),paths);
+ } else {
+ bool scenes_only = p_preset->get_export_filter()==EditorExportPreset::EXPORT_SELECTED_SCENES;
+
+ Vector<String> files = p_preset->get_files_to_export();
+ for(int i=0;i<files.size();i++) {
+ if (scenes_only && ResourceLoader::get_resource_type(files[i])!="PackedScene")
+ continue;
+
+ _export_find_dependencies(files[i],paths);
+ }
+ }
+
+ //store everything in the export medium
+ int idx = 0;
+ int total=paths.size();
+
+ for(Set<String>::Element *E=paths.front();E;E=E->next()) {
+
+ String path = E->get();
+
+ if (FileAccess::exists(path+".import")) {
+ //file is imported, replace by what it imports
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(path+".import");
+ if (err!=OK) {
+ ERR_PRINTS("Could not parse: '"+path+"', not exported.");
+ continue;
+ }
+
+ List<String> remaps;
+ config->get_section_keys("remap",&remaps);
+
+ for(List<String>::Element *F=remaps.front();F;F=F->next()) {
+
+ String remap=F->get();
+ if (remap=="path") {
+ String remapped_path=config->get_value("remap",remap);
+ Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
+ p_func(p_udata,remapped_path,array,idx,total);
+ } else if (remap.begins_with("path.")) {
+ String feature = remap.get_slice(".",1);
+ if (features.has(feature)) {
+ String remapped_path=config->get_value("remap",remap);
+ Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path);
+ p_func(p_udata,remapped_path,array,idx,total);
+ }
+ }
+ }
+
+ //also save the .import file
+ Vector<uint8_t> array = FileAccess::get_file_as_array(path+".import");
+ p_func(p_udata,path+".import",array,idx,total);
+
+ } else {
+ //just store it as it comes
+ Vector<uint8_t> array = FileAccess::get_file_as_array(path);
+ p_func(p_udata,path,array,idx,total);
+ }
+
+ idx++;
+ }
+
+ //save config!
+
+ String config_file="godot.cfb";
+ String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+config_file;
+ GlobalConfig::get_singleton()->save_custom(engine_cfb);
+ Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
+
+ p_func(p_udata,"res://"+config_file,data,idx,total);
+
+ return OK;
+}
+
+Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
+
+ EditorProgress ep("savepack",TTR("Packing"),102);
+
+ String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp";
+ FileAccess *ftmp = FileAccess::open(tmppath,FileAccess::WRITE);
+ ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
+
+ PackData pd;
+ pd.ep=&ep;
+ pd.f=ftmp;
+
+ Error err = export_project_files(p_preset,_save_pack_file,&pd);
+
+ memdelete(ftmp); //close tmp file
+
+ if (err)
+ return err;
+
+ pd.file_ofs.sort(); //do sort, so we can do binary search later
+
+
+ FileAccess *f = FileAccess::open(p_path,FileAccess::WRITE);
+ ERR_FAIL_COND_V(!f,ERR_CANT_CREATE)
+ f->store_32(0x43504447); //GDPK
+ f->store_32(1); //pack version
+ f->store_32(VERSION_MAJOR);
+ f->store_32(VERSION_MINOR);
+ f->store_32(0); //hmph
+ for(int i=0;i<16;i++) {
+ //reserved
+ f->store_32(0);
+ }
+
+ f->store_32(pd.file_ofs.size()); //amount of files
+
+ size_t header_size = f->get_pos();
+
+ //precalculate header size
+
+ for(int i=0;i<pd.file_ofs.size();i++) {
+ header_size += 4; // size of path string (32 bits is enough)
+ uint32_t string_len = pd.file_ofs[i].path_utf8.length();
+ header_size += string_len + _get_pad(4,string_len); ///size of path string
+ header_size += 8; // offset to file _with_ header size included
+ header_size += 8; // size of file
+ header_size +=16; // md5
+
+ }
+
+ size_t header_padding = _get_pad(PCK_PADDING,header_size);
+
+
+ for(int i=0;i<pd.file_ofs.size();i++) {
+
+ uint32_t string_len = pd.file_ofs[i].path_utf8.length();
+ uint32_t pad = _get_pad(4,string_len);;
+ f->store_32(string_len+pad);
+ f->store_buffer((const uint8_t*)pd.file_ofs[i].path_utf8.get_data(),string_len);
+ for(uint32_t j=0;j<pad;j++) {
+ f->store_8(0);
+ }
+
+ f->store_64(pd.file_ofs[i].ofs + header_padding + header_size);
+ f->store_64(pd.file_ofs[i].size); // pay attention here, this is where file is
+ f->store_buffer(pd.file_ofs[i].md5.ptr(),16); //also save md5 for file
+ }
+
+ for(uint32_t j=0;j<header_padding;j++) {
+ f->store_8(0);
+ }
+
+ //save the rest of the data
+
+ ftmp = FileAccess::open(tmppath,FileAccess::READ);
+ if (!ftmp) {
+ memdelete(f);
+ ERR_FAIL_COND_V(!ftmp,ERR_CANT_CREATE)
+ }
+
+ const int bufsize=16384;
+ uint8_t buf[bufsize];
+
+ while(true) {
+
+ int got = ftmp->get_buffer(buf,bufsize);
+ if (got<=0)
+ break;
+ f->store_buffer(buf,got);
+ }
+
+ memdelete(ftmp);
+
+ f->store_32(0x43504447); //GDPK
+ memdelete(f);
+
+ return OK;
+}
+
+Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path) {
+
+ EditorProgress ep("savezip",TTR("Packing"),102);
+
+ //FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE);
+
+ FileAccess *src_f;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zipFile zip=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io);
+
+ ZipData zd;
+ zd.ep=&ep;
+ zd.zip=zip;
+
+
+ Error err = export_project_files(p_preset,_save_zip_file,&zd);
+
+ zipClose(zip,NULL);
+
+ return OK;
+}
+
+EditorExportPlatform::EditorExportPlatform() {
+
+
+}
+
+
+////
+
+EditorExport *EditorExport::singleton=NULL;
+
+
+void EditorExport::_save() {
+
+
+ Ref<ConfigFile> config;
+ config.instance();
+ for(int i=0;i<export_presets.size();i++) {
+
+ Ref<EditorExportPreset> preset = export_presets[i];
+ String section="preset."+itos(i);
+
+ 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());
+ bool save_files=false;
+ switch(preset->get_export_filter()) {
+ case EditorExportPreset::EXPORT_ALL_RESOURCES: {
+ config->set_value(section,"export_filter","all_resources");
+ } break;
+ case EditorExportPreset::EXPORT_SELECTED_SCENES: {
+ config->set_value(section,"export_filter","scenes");
+ save_files=true;
+ } break;
+ case EditorExportPreset::EXPORT_SELECTED_RESOURCES: {
+ config->set_value(section,"export_filter","resources");
+ save_files=true;
+ } break;
+
+
+ }
+
+ if (save_files) {
+ Vector<String> export_files = preset->get_files_to_export();
+ config->set_value(section,"export_files",export_files);
+ }
+ config->set_value(section,"include_filter",preset->get_include_filter());
+ config->set_value(section,"exclude_filter",preset->get_exclude_filter());
+ config->set_value(section,"patch_list",preset->get_patches());
+
+ String option_section="preset."+itos(i)+".options";
+
+ for (const List<PropertyInfo>::Element *E=preset->get_properties().front();E;E=E->next()) {
+ config->set_value(option_section,E->get().name,preset->get(E->get().name));
+ }
+ }
+
+ config->save("res://export_presets.cfg");
+
+ print_line("saved ok");
+
+}
+
+
+void EditorExport::save_presets() {
+
+ print_line("save presets");
+ if (block_save)
+ return;
+ save_timer->start();
+}
+
+void EditorExport::_bind_methods() {
+
+ ClassDB::bind_method("_save",&EditorExport::_save);
+}
+
+void EditorExport::add_export_platform(const Ref<EditorExportPlatform>& p_platform) {
+
+ export_platforms.push_back(p_platform);
+}
+
+int EditorExport::get_export_platform_count() {
+
+ return export_platforms.size();
+}
+
+Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
+
+ ERR_FAIL_INDEX_V(p_idx,export_platforms.size(),Ref<EditorExportPlatform>());
+
+ return export_platforms[p_idx];
+}
+
+
+void EditorExport::add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos) {
+
+ if (p_at_pos<0)
+ export_presets.push_back(p_preset);
+ else
+ export_presets.insert(p_at_pos,p_preset);
+
+
+}
+
+int EditorExport::get_export_preset_count() const {
+
+ return export_presets.size();
+}
+
+Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) {
+
+ ERR_FAIL_INDEX_V( p_idx, export_presets.size(),Ref<EditorExportPreset>() );
+ return export_presets[p_idx];
+}
+
+void EditorExport::remove_export_preset(int p_idx) {
+
+ export_presets.remove(p_idx);
+}
+
+void EditorExport::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_TREE) {
+ load_config();
+ }
+}
+
+void EditorExport::load_config() {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load("res://export_presets.cfg");
+ if (err!=OK)
+ return;
+
+ block_save=true;
+
+ int index=0;
+ while(true) {
+
+ String section = "preset."+itos(index);
+ if (!config->has_section(section))
+ break;
+
+ String platform=config->get_value(section,"platform");
+
+ Ref<EditorExportPreset> preset;
+
+ for(int i=0;i<export_platforms.size();i++) {
+ if (export_platforms[i]->get_name()==platform) {
+ preset = export_platforms[i]->create_preset();
+ break;
+ }
+ }
+
+ if (!preset.is_valid()) {
+ index++;
+ ERR_CONTINUE(!preset.is_valid());
+ }
+
+ preset->set_name( config->get_value(section,"name") );
+ preset->set_runnable( config->get_value(section,"runnable") );
+
+ String export_filter = config->get_value(section,"export_filter");
+
+ bool get_files=false;
+
+ if (export_filter=="all_resources") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES);
+ } else if (export_filter=="scenes") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES);
+ get_files=true;
+ } else if (export_filter=="resources") {
+ preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES);
+ get_files=true;
+ }
+
+ if (get_files) {
+
+ Vector<String> files = config->get_value(section,"export_files");
+
+ for(int i=0;i<files.size();i++) {
+ preset->add_export_file(files[i]);
+ }
+ }
+
+ preset->set_include_filter( config->get_value(section,"include_filter") );
+ preset->set_exclude_filter( config->get_value(section,"exclude_filter") );
+
+
+ Vector<String> patch_list = config->get_value(section,"patch_list");
+
+ for(int i=0;i<patch_list.size();i++) {
+ preset->add_patch(patch_list[i]);
+ }
+
+ String option_section="preset."+itos(index)+".options";
+
+ List<String> options;
+
+ config->get_section_keys(option_section,&options);
+
+ for (List<String>::Element *E=options.front();E;E=E->next()) {
+
+ Variant value = config->get_value(option_section,E->get());
+
+ preset->set(E->get(),value);
+ }
+
+ add_export_preset(preset);
+ index++;
+ }
+
+ block_save=false;
+
+}
+
+
+
+EditorExport::EditorExport() {
+
+ save_timer = memnew( Timer );
+ add_child(save_timer);
+ save_timer->set_wait_time(0.8);
+ save_timer->set_one_shot(true);
+ save_timer->connect("timeout",this,"_save");
+ block_save=false;
+
+ singleton=this;
+}
+
+EditorExport::~EditorExport() {
+
+
+}
+
+
+//////////
+
+void EditorExportPlatformPC::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 EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) {
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/s3tc"),true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc"),false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"texture_format/etc2"),false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL,"binary_format/64_bits"),true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/release",PROPERTY_HINT_GLOBAL_FILE),""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING,"custom_template/debug",PROPERTY_HINT_GLOBAL_FILE),""));
+}
+
+String EditorExportPlatformPC::get_name() const {
+
+ return name;
+}
+Ref<Texture> EditorExportPlatformPC::get_logo() const {
+
+ return logo;
+}
+
+bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset>& p_preset,String &r_error, bool &r_missing_templates) const {
+
+ r_missing_templates=false;
+
+ if (find_export_template(release_file_32)==String()) {
+ r_missing_templates=true;
+ } else if (find_export_template(debug_file_32)==String()) {
+ r_missing_templates=true;
+ } else if (find_export_template(release_file_64)==String()) {
+ r_missing_templates=true;
+ } else if (find_export_template(debug_file_64)==String()) {
+ r_missing_templates=true;
+ }
+ return !r_missing_templates;
+}
+
+String EditorExportPlatformPC::get_binary_extension() const {
+ return extension;
+}
+
+Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset>& p_preset, bool p_debug, const String& p_path, int p_flags) {
+
+ return OK;
+}
+
+void EditorExportPlatformPC::set_extension(const String& p_extension) {
+ extension=p_extension;
+}
+
+void EditorExportPlatformPC::set_name(const String& p_name) {
+ name=p_name;
+}
+
+void EditorExportPlatformPC::set_logo(const Ref<Texture>& p_logo) {
+ logo=p_logo;
+}
+
+void EditorExportPlatformPC::set_release_64(const String& p_file) {
+
+ release_file_64=p_file;
+}
+
+void EditorExportPlatformPC::set_release_32(const String& p_file){
+
+ release_file_32=p_file;
+}
+void EditorExportPlatformPC::set_debug_64(const String& p_file){
+
+ debug_file_64=p_file;
+}
+void EditorExportPlatformPC::set_debug_32(const String& p_file){
+
+ debug_file_32=p_file;
+
+}
+
+EditorExportPlatformPC::EditorExportPlatformPC() {
+
+}
+
+////////
+
+#if 0
+#include "version.h"
+#include "script_language.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/dir_access.h"
#include "tools/editor/editor_file_system.h"
@@ -77,8 +1004,8 @@ String EditorImportPlugin::_expand_source_path(const String& p_path) {
void EditorImportPlugin::_bind_methods() {
- ClassDB::bind_method(_MD("validate_source_path","path"),&EditorImportPlugin::_validate_source_path);
- ClassDB::bind_method(_MD("expand_source_path","path"),&EditorImportPlugin::_expand_source_path);
+ ClassDB::bind_method(D_METHOD("validate_source_path","path"),&EditorImportPlugin::_validate_source_path);
+ ClassDB::bind_method(D_METHOD("expand_source_path","path"),&EditorImportPlugin::_expand_source_path);
ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_name"));
ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_visible_name"));
@@ -89,7 +1016,7 @@ void EditorImportPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(),MethodInfo("reimport_multiple_files",PropertyInfo(Variant::POOL_STRING_ARRAY,"files")));
ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"can_reimport_multiple_files"));
-// BIND_VMETHOD( mi );
+ //BIND_VMETHOD( mi );
}
String EditorImportPlugin::get_name() const {
@@ -388,8 +1315,8 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const
Set<StringName> exported;
- if (FileAccess::exists("res://engine.cfg"))
- exported.insert("res://engine.cfg");
+ if (FileAccess::exists("res://godot.cfg"))
+ exported.insert("res://godot.cfg");
if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) {
@@ -420,11 +1347,12 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const
{
List<String> l;
- // SceneLoader::get_recognized_extensions(&l);
- // for(List<String>::Element *E=l.front();E;E=E->next()) {
- //
- // scene_extensions.insert(E->get());
- // }
+ /*
+ SceneLoader::get_recognized_extensions(&l);
+ for(List<String>::Element *E=l.front();E;E=E->next()) {
+ scene_extensions.insert(E->get());
+ }
+ */
ResourceLoader::get_recognized_extensions_for_type("",&l);
for(List<String>::Element *E=l.front();E;E=E->next()) {
@@ -742,7 +1670,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
} break; //use default
}
- String image_list_md5;
+ String image_listD_METHOD5;
{
MD5_CTX ctx;
@@ -755,7 +1683,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
}
MD5Final(&ctx);
- image_list_md5=String::md5(ctx.digest);
+ image_listD_METHOD5=String::md5(ctx.digest);
}
//ok see if cached
String md5;
@@ -800,7 +1728,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
if (atlas_valid) {
//check md5 of list of image /names/
- if (f->get_line().strip_edges()!=image_list_md5) {
+ if (f->get_line().strip_edges()!=image_listD_METHOD5) {
atlas_valid=false;
print_line("IMAGE MD5 INVALID!");
}
@@ -826,10 +1754,10 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
uint64_t file_mod_time = FileAccess::get_modified_time(F->get());
if (mod_time!=file_mod_time) {
- String image_md5 = slices[1];
- String file_md5 = FileAccess::get_md5(F->get());
+ String imageD_METHOD5 = slices[1];
+ String fileD_METHOD5 = FileAccess::getD_METHOD5(F->get());
- if (image_md5!=file_md5) {
+ if (imageD_METHOD5!=fileD_METHOD5) {
atlas_valid=false;
print_line("IMAGE INVALID "+slices[0]);
break;
@@ -864,7 +1792,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) {
- imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::get_md5(F->get()));
+ imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::getD_METHOD5(F->get()));
}
@@ -921,8 +1849,8 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
options["lossy_quality"]=group_lossy_quality;
options["shrink"]=EditorImportExport::get_singleton()->image_export_group_get_shrink(E->get());
options["image_format"]=group_format;
-// f->store_line(options.to_json());
- f->store_line(image_list_md5);
+ //f->store_line(options.to_json());
+ f->store_line(image_listD_METHOD5);
}
//go through all ATEX files
@@ -949,7 +1877,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
return ERR_CANT_CREATE;
}
Vector<uint8_t> data = FileAccess::get_file_as_array(path);
- String dst_path = F->get().operator String().basename()+".atex";
+ String dst_path = F->get().operator String().get_basename()+".atex";
err = p_func(p_udata,dst_path,data,counter++,files.size());
saved.insert(dst_path);
if (err)
@@ -958,8 +1886,8 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
if (f) {
//recreating deps..
String depline;
-// depline=String(F->get())+"::"+itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::get_md5(F->get()); name unneccesary by top md5
- depline=itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::get_md5(F->get());
+ //depline=String(F->get())+"::"+itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::getD_METHOD5(F->get()); name unneccesary by top md5
+ depline=itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::getD_METHOD5(F->get());
depline+="::"+itos(region.pos.x)+"::"+itos(region.pos.y)+"::"+itos(region.size.x)+"::"+itos(region.size.y);
depline+="::"+itos(margin.pos.x)+"::"+itos(margin.pos.y)+"::"+itos(margin.size.x)+"::"+itos(margin.size.y);
f->store_line(depline);
@@ -984,7 +1912,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
}
- StringName engine_cfg="res://engine.cfg";
+ StringName engine_cfg="res://godot.cfg";
StringName boot_splash;
{
String splash=GlobalConfig::get_singleton()->get("application/boot_splash"); //avoid splash from being converted
@@ -1038,7 +1966,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
{
- //make binary engine.cfg config
+ //make binary godot.cfg config
Map<String,Variant> custom;
@@ -1082,7 +2010,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func
}
- String remap_file="engine.cfb";
+ String remap_file="godot.cfb";
String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+remap_file;
GlobalConfig::get_singleton()->save_custom(engine_cfb,custom);
Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb);
@@ -1173,7 +2101,7 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path
pd->f->store_32(cs.length());
pd->f->store_buffer((uint8_t*)cs.get_data(),cs.length());
TempData td;
- td.pos=pd->f->get_pos();;
+ td.pos=pd->f->get_pos();
td.ofs=pd->ftmp->get_pos();
td.size=p_data.size();
pd->file_ofs.push_back(td);
@@ -2092,13 +3020,21 @@ void EditorImportExport::save_config() {
if (image_groups.size() && image_group_files.size()){
- Vector<String> igfsave;
- igfsave.resize(image_group_files.size()*2);
+ Vector<String> igfkeys;
+ igfkeys.resize(image_group_files.size());
int idx=0;
for (Map<StringName,StringName>::Element *E=image_group_files.front();E;E=E->next()) {
+ igfkeys[idx++]=E->key();
+ }
+ igfkeys.sort();
+
+ Vector<String> igfsave;
+ igfsave.resize(image_group_files.size()*2);
+ idx=0;
+ for (int i=0;i<igfkeys.size();++i) {
- igfsave[idx++]=E->key();
- igfsave[idx++]=E->get();
+ igfsave[idx++]=igfkeys[i];
+ igfsave[idx++]=image_group_files[igfkeys[i]];
}
cf->set_value("image_group_files","files",igfsave);
}
@@ -2199,49 +3135,49 @@ PoolVector<String> EditorImportExport::_get_export_platforms() {
void EditorImportExport::_bind_methods() {
- ClassDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::add_import_plugin);
- ClassDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::remove_import_plugin);
- ClassDB::bind_method(_MD("get_import_plugin_count"),&EditorImportExport::get_import_plugin_count);
- ClassDB::bind_method(_MD("get_import_plugin:EditorImportPlugin","idx"),&EditorImportExport::get_import_plugin);
- ClassDB::bind_method(_MD("get_import_plugin_by_name:EditorImportPlugin","name"),&EditorImportExport::get_import_plugin_by_name);
+ ClassDB::bind_method(D_METHOD("add_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::add_import_plugin);
+ ClassDB::bind_method(D_METHOD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorImportExport::remove_import_plugin);
+ ClassDB::bind_method(D_METHOD("get_import_plugin_count"),&EditorImportExport::get_import_plugin_count);
+ ClassDB::bind_method(D_METHOD("get_import_plugin:EditorImportPlugin","idx"),&EditorImportExport::get_import_plugin);
+ ClassDB::bind_method(D_METHOD("get_import_plugin_by_name:EditorImportPlugin","name"),&EditorImportExport::get_import_plugin_by_name);
- ClassDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::add_export_plugin);
- ClassDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::remove_export_plugin);
- ClassDB::bind_method(_MD("get_export_plugin_count"),&EditorImportExport::get_export_plugin_count);
- ClassDB::bind_method(_MD("get_export_plugin:EditorExportPlugin","idx"),&EditorImportExport::get_export_plugin);
+ ClassDB::bind_method(D_METHOD("add_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::add_export_plugin);
+ ClassDB::bind_method(D_METHOD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorImportExport::remove_export_plugin);
+ ClassDB::bind_method(D_METHOD("get_export_plugin_count"),&EditorImportExport::get_export_plugin_count);
+ ClassDB::bind_method(D_METHOD("get_export_plugin:EditorExportPlugin","idx"),&EditorImportExport::get_export_plugin);
- ClassDB::bind_method(_MD("set_export_file_action","file","action"),&EditorImportExport::set_export_file_action);
- ClassDB::bind_method(_MD("get_export_file_action","file"),&EditorImportExport::get_export_file_action);
- ClassDB::bind_method(_MD("get_export_file_list"),&EditorImportExport::_get_export_file_list);
+ ClassDB::bind_method(D_METHOD("set_export_file_action","file","action"),&EditorImportExport::set_export_file_action);
+ ClassDB::bind_method(D_METHOD("get_export_file_action","file"),&EditorImportExport::get_export_file_action);
+ ClassDB::bind_method(D_METHOD("get_export_file_list"),&EditorImportExport::_get_export_file_list);
- ClassDB::bind_method(_MD("add_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
- //ClassDB::bind_method(_MD("remove_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
- ClassDB::bind_method(_MD("get_export_platform:EditorExportPlatform","name"),&EditorImportExport::get_export_platform);
- ClassDB::bind_method(_MD("get_export_platforms"),&EditorImportExport::_get_export_platforms);
+ ClassDB::bind_method(D_METHOD("add_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
+ //ClassDB::bind_method(D_METHOD("remove_export_platform","platform:EditorExportplatform"),&EditorImportExport::add_export_platform);
+ ClassDB::bind_method(D_METHOD("get_export_platform:EditorExportPlatform","name"),&EditorImportExport::get_export_platform);
+ ClassDB::bind_method(D_METHOD("get_export_platforms"),&EditorImportExport::_get_export_platforms);
- ClassDB::bind_method(_MD("set_export_filter","filter"),&EditorImportExport::set_export_filter);
- ClassDB::bind_method(_MD("get_export_filter"),&EditorImportExport::get_export_filter);
+ ClassDB::bind_method(D_METHOD("set_export_filter","filter"),&EditorImportExport::set_export_filter);
+ ClassDB::bind_method(D_METHOD("get_export_filter"),&EditorImportExport::get_export_filter);
- ClassDB::bind_method(_MD("set_export_custom_filter","filter"),&EditorImportExport::set_export_custom_filter);
- ClassDB::bind_method(_MD("get_export_custom_filter"),&EditorImportExport::get_export_custom_filter);
+ ClassDB::bind_method(D_METHOD("set_export_custom_filter","filter"),&EditorImportExport::set_export_custom_filter);
+ ClassDB::bind_method(D_METHOD("get_export_custom_filter"),&EditorImportExport::get_export_custom_filter);
- ClassDB::bind_method(_MD("set_export_custom_filter_exclude","filter_exclude"),&EditorImportExport::set_export_custom_filter_exclude);
- ClassDB::bind_method(_MD("get_export_custom_filter_exclude"),&EditorImportExport::get_export_custom_filter_exclude);
+ ClassDB::bind_method(D_METHOD("set_export_custom_filter_exclude","filter_exclude"),&EditorImportExport::set_export_custom_filter_exclude);
+ ClassDB::bind_method(D_METHOD("get_export_custom_filter_exclude"),&EditorImportExport::get_export_custom_filter_exclude);
- ClassDB::bind_method(_MD("image_export_group_create"),&EditorImportExport::image_export_group_create);
- ClassDB::bind_method(_MD("image_export_group_remove"),&EditorImportExport::image_export_group_remove);
- ClassDB::bind_method(_MD("image_export_group_set_image_action"),&EditorImportExport::image_export_group_set_image_action);
- ClassDB::bind_method(_MD("image_export_group_set_make_atlas"),&EditorImportExport::image_export_group_set_make_atlas);
- ClassDB::bind_method(_MD("image_export_group_set_shrink"),&EditorImportExport::image_export_group_set_shrink);
- ClassDB::bind_method(_MD("image_export_group_get_image_action"),&EditorImportExport::image_export_group_get_image_action);
- ClassDB::bind_method(_MD("image_export_group_get_make_atlas"),&EditorImportExport::image_export_group_get_make_atlas);
- ClassDB::bind_method(_MD("image_export_group_get_shrink"),&EditorImportExport::image_export_group_get_shrink);
- ClassDB::bind_method(_MD("image_add_to_export_group"),&EditorImportExport::image_add_to_export_group);
- ClassDB::bind_method(_MD("script_set_action"),&EditorImportExport::script_set_action);
- ClassDB::bind_method(_MD("script_set_encryption_key"),&EditorImportExport::script_set_encryption_key);
- ClassDB::bind_method(_MD("script_get_action"),&EditorImportExport::script_get_action);
- ClassDB::bind_method(_MD("script_get_encryption_key"),&EditorImportExport::script_get_encryption_key);
+ ClassDB::bind_method(D_METHOD("image_export_group_create"),&EditorImportExport::image_export_group_create);
+ ClassDB::bind_method(D_METHOD("image_export_group_remove"),&EditorImportExport::image_export_group_remove);
+ ClassDB::bind_method(D_METHOD("image_export_group_set_image_action"),&EditorImportExport::image_export_group_set_image_action);
+ ClassDB::bind_method(D_METHOD("image_export_group_set_make_atlas"),&EditorImportExport::image_export_group_set_make_atlas);
+ ClassDB::bind_method(D_METHOD("image_export_group_set_shrink"),&EditorImportExport::image_export_group_set_shrink);
+ ClassDB::bind_method(D_METHOD("image_export_group_get_image_action"),&EditorImportExport::image_export_group_get_image_action);
+ ClassDB::bind_method(D_METHOD("image_export_group_get_make_atlas"),&EditorImportExport::image_export_group_get_make_atlas);
+ ClassDB::bind_method(D_METHOD("image_export_group_get_shrink"),&EditorImportExport::image_export_group_get_shrink);
+ ClassDB::bind_method(D_METHOD("image_add_to_export_group"),&EditorImportExport::image_add_to_export_group);
+ ClassDB::bind_method(D_METHOD("script_set_action"),&EditorImportExport::script_set_action);
+ ClassDB::bind_method(D_METHOD("script_set_encryption_key"),&EditorImportExport::script_set_encryption_key);
+ ClassDB::bind_method(D_METHOD("script_get_action"),&EditorImportExport::script_get_action);
+ ClassDB::bind_method(D_METHOD("script_get_encryption_key"),&EditorImportExport::script_get_encryption_key);
@@ -2292,3 +3228,4 @@ EditorImportExport::~EditorImportExport() {
}
+#endif
diff --git a/tools/editor/editor_export.h b/tools/editor/editor_export.h
new file mode 100644
index 0000000000..8a9dc965e5
--- /dev/null
+++ b/tools/editor/editor_export.h
@@ -0,0 +1,297 @@
+/*************************************************************************/
+/* editor_import_export.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_EXPORT_H
+#define EDITOR_EXPORT_H
+
+
+
+#include "resource.h"
+#include "scene/main/node.h"
+#include "scene/resources/texture.h"
+#include "scene/main/timer.h"
+
+class EditorProgress;
+class FileAccess;
+class EditorExportPlatform;
+class EditorFileSystemDirectory;
+
+class EditorExportPreset : public Reference {
+
+ GDCLASS( EditorExportPreset,Reference )
+public:
+ enum ExportFilter {
+ EXPORT_ALL_RESOURCES,
+ EXPORT_SELECTED_SCENES,
+ EXPORT_SELECTED_RESOURCES,
+ };
+
+private:
+
+ Ref<EditorExportPlatform> platform;
+ ExportFilter export_filter;
+ String include_filter;
+ String exclude_filter;
+
+ String exporter;
+ Set<String> selected_files;
+ bool runnable;
+
+ Vector<String> patches;
+
+
+friend class EditorExport;
+friend class EditorExportPlatform;
+
+ List<PropertyInfo> properties;
+ Map<StringName,Variant> values;
+
+ String name;
+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:
+
+ Ref<EditorExportPlatform> get_platform() const;
+ bool has(const StringName& p_property) const { return values.has(p_property); }
+
+ Vector<String> get_files_to_export() const;
+
+ void add_export_file(const String& p_path);
+ void remove_export_file(const String& p_path);
+ bool has_export_file(const String& p_path);
+
+ void set_name(const String& p_name);
+ String get_name() const;
+
+ void set_runnable(bool p_enable);
+ bool is_runnable() const;
+
+ void set_export_filter(ExportFilter p_filter);
+ ExportFilter get_export_filter() const;
+
+ void set_include_filter(const String& p_include);
+ String get_include_filter() const;
+
+ void set_exclude_filter(const String& p_exclude);
+ String get_exclude_filter() const;
+
+ void add_patch(const String& p_path,int p_at_pos=-1);
+ void set_patch(int p_index,const String& p_path);
+ String get_patch(int p_index);
+ void remove_patch(int p_idx);
+ Vector<String> get_patches() const;
+
+ const List<PropertyInfo>& get_properties() const { return properties; }
+
+ EditorExportPreset();
+};
+
+
+class EditorExportPlatform : public Reference {
+
+ GDCLASS( EditorExportPlatform,Reference )
+
+public:
+
+ typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
+
+private:
+
+ struct SavedData {
+
+ uint64_t ofs;
+ uint64_t size;
+ Vector<uint8_t> md5;
+ CharString path_utf8;
+
+ bool operator<(const SavedData& p_data) const {
+ return path_utf8 < p_data.path_utf8;
+ }
+ };
+
+ struct PackData {
+
+ FileAccess *f;
+ Vector<SavedData> file_ofs;
+ EditorProgress *ep;
+ };
+
+ struct ZipData {
+
+ void* zip;
+ EditorProgress *ep;
+
+ };
+
+ void _export_find_resources(EditorFileSystemDirectory *p_dir,Set<String>& p_paths);
+ void _export_find_dependencies(const String& p_path,Set<String>& p_paths);
+
+ void gen_debug_flags(Vector<String> &r_flags, int p_flags);
+ static Error _save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
+ 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;
+ String find_export_template(String template_file_name, String *err=NULL) const;
+
+public:
+
+
+ struct ExportOption {
+ PropertyInfo option;
+ Variant default_value;
+
+ ExportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; }
+ ExportOption() {}
+ };
+
+ virtual Ref<EditorExportPreset> create_preset();
+
+ virtual void get_export_options(List<ExportOption> *r_options)=0;
+ virtual String get_name() const =0;
+ virtual Ref<Texture> get_logo() const =0;
+
+
+ Error export_project_files(const Ref<EditorExportPreset>& p_preset,EditorExportSaveFunction p_func, void* p_udata);
+
+ Error save_pack(const Ref<EditorExportPreset>& p_preset,const String& p_path);
+ Error save_zip(const Ref<EditorExportPreset>& p_preset,const String& p_path);
+
+
+ virtual bool poll_devices() { return false; }
+ virtual int get_device_count() const { return 0; }
+ virtual String get_device_name(int p_device) const { return ""; }
+ virtual String get_device_info(int p_device) const { return ""; }
+
+ enum DebugFlags {
+ DEBUG_FLAG_DUMB_CLIENT=1,
+ DEBUG_FLAG_REMOTE_DEBUG=2,
+ DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST=4,
+ DEBUG_FLAG_VIEW_COLLISONS=8,
+ DEBUG_FLAG_VIEW_NAVIGATION=16,
+ };
+
+ virtual Error run(int p_device,int p_debug_flags) { return OK; }
+
+ virtual bool can_export(const Ref<EditorExportPreset>& p_preset,String &r_error,bool &r_missing_templates) const=0;
+
+ 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;
+
+ EditorExportPlatform();
+};
+
+
+class EditorExport : public Node {
+ GDCLASS(EditorExport,Node);
+
+ Vector<Ref<EditorExportPlatform> > export_platforms;
+ Vector<Ref<EditorExportPreset> > export_presets;
+
+ Timer *save_timer;
+ bool block_save;
+
+ static EditorExport *singleton;
+
+ void _save();
+protected:
+
+friend class EditorExportPreset;
+ void save_presets();
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ static EditorExport * get_singleton() { return singleton; }
+
+ void add_export_platform(const Ref<EditorExportPlatform>& p_platform);
+ int get_export_platform_count();
+ Ref<EditorExportPlatform> get_export_platform(int p_idx);
+
+
+ void add_export_preset(const Ref<EditorExportPreset>& p_preset,int p_at_pos=-1);
+ int get_export_preset_count() const;
+ Ref<EditorExportPreset> get_export_preset(int p_idx);
+ void remove_export_preset(int p_idx);
+
+ void load_config();
+
+ EditorExport();
+ ~EditorExport();
+};
+
+
+
+
+class EditorExportPlatformPC : public EditorExportPlatform {
+
+ GDCLASS( EditorExportPlatformPC,EditorExportPlatform )
+
+ Ref<ImageTexture> logo;
+ String name;
+ String extension;
+
+ String release_file_32;
+ String release_file_64;
+ String debug_file_32;
+ String debug_file_64;
+
+public:
+
+ virtual void get_preset_features(const Ref<EditorExportPreset>& p_preset,List<String>* r_features);
+
+ virtual void get_export_options(List<ExportOption> *r_options);
+
+ virtual String get_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;
+ virtual String get_binary_extension() const;
+ virtual Error export_project(const Ref<EditorExportPreset>& p_preset,bool p_debug,const String& p_path,int p_flags=0);
+
+ void set_extension(const String& p_extension);
+ void set_name(const String& p_name);
+
+ void set_logo(const Ref<Texture>& p_loco);
+
+ void set_release_64(const String& p_file);
+ void set_release_32(const String& p_file);
+ void set_debug_64(const String& p_file);
+ void set_debug_32(const String& p_file);
+
+ EditorExportPlatformPC();
+};
+
+
+#endif // EDITOR_IMPORT_EXPORT_H
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index 408818f729..bfaf1906d8 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_file_dialog.h"
+
#include "scene/gui/label.h"
#include "scene/gui/center_container.h"
#include "print_string.h"
@@ -36,6 +37,7 @@
#include "scene/gui/margin_container.h"
#include "os/file_access.h"
#include "editor_scale.h"
+
EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL;
EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL;
@@ -218,10 +220,10 @@ void EditorFileDialog::_post_popup() {
else
item_list->grab_focus();
- if (is_visible() && get_current_file()!="")
+ if (is_visible_in_tree() && get_current_file()!="")
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
- if (is_visible()) {
+ if (is_visible_in_tree()) {
Ref<Texture> folder = get_icon("folder","FileDialog");
recent->clear();
@@ -713,8 +715,10 @@ void EditorFileDialog::update_file_list() {
}
// ??
- //if (tree->get_root() && tree->get_root()->get_children())
- // tree->get_root()->get_children()->select(0);
+ /*
+ if (tree->get_root() && tree->get_root()->get_children())
+ tree->get_root()->get_children()->select(0);
+ */
files.clear();
@@ -806,7 +810,7 @@ void EditorFileDialog::set_current_file(const String& p_file) {
file->grab_focus();
}
- if (is_visible())
+ if (is_visible_in_tree())
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
@@ -882,7 +886,7 @@ void EditorFileDialog::set_access(Access p_access) {
void EditorFileDialog::invalidate() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
update_file_list();
invalidated=false;
} else {
@@ -1148,7 +1152,7 @@ void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
mode_list->set_pressed(true);
}
display_mode=p_mode;
- invalidate();;
+ invalidate();
}
EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{
@@ -1160,55 +1164,55 @@ EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const{
void EditorFileDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_unhandled_input"),&EditorFileDialog::_unhandled_input);
-
- ClassDB::bind_method(_MD("_item_selected"),&EditorFileDialog::_item_selected);
- ClassDB::bind_method(_MD("_item_db_selected"),&EditorFileDialog::_item_dc_selected);
- ClassDB::bind_method(_MD("_dir_entered"),&EditorFileDialog::_dir_entered);
- ClassDB::bind_method(_MD("_file_entered"),&EditorFileDialog::_file_entered);
- ClassDB::bind_method(_MD("_action_pressed"),&EditorFileDialog::_action_pressed);
- ClassDB::bind_method(_MD("_cancel_pressed"),&EditorFileDialog::_cancel_pressed);
- ClassDB::bind_method(_MD("_filter_selected"),&EditorFileDialog::_filter_selected);
- ClassDB::bind_method(_MD("_save_confirm_pressed"),&EditorFileDialog::_save_confirm_pressed);
-
- ClassDB::bind_method(_MD("clear_filters"),&EditorFileDialog::clear_filters);
- ClassDB::bind_method(_MD("add_filter","filter"),&EditorFileDialog::add_filter);
- ClassDB::bind_method(_MD("get_current_dir"),&EditorFileDialog::get_current_dir);
- ClassDB::bind_method(_MD("get_current_file"),&EditorFileDialog::get_current_file);
- ClassDB::bind_method(_MD("get_current_path"),&EditorFileDialog::get_current_path);
- ClassDB::bind_method(_MD("set_current_dir","dir"),&EditorFileDialog::set_current_dir);
- ClassDB::bind_method(_MD("set_current_file","file"),&EditorFileDialog::set_current_file);
- ClassDB::bind_method(_MD("set_current_path","path"),&EditorFileDialog::set_current_path);
- ClassDB::bind_method(_MD("set_mode","mode"),&EditorFileDialog::set_mode);
- ClassDB::bind_method(_MD("get_mode"),&EditorFileDialog::get_mode);
- ClassDB::bind_method(_MD("get_vbox:VBoxContainer"),&EditorFileDialog::get_vbox);
- ClassDB::bind_method(_MD("set_access","access"),&EditorFileDialog::set_access);
- ClassDB::bind_method(_MD("get_access"),&EditorFileDialog::get_access);
- ClassDB::bind_method(_MD("set_show_hidden_files","show"),&EditorFileDialog::set_show_hidden_files);
- ClassDB::bind_method(_MD("is_showing_hidden_files"),&EditorFileDialog::is_showing_hidden_files);
- ClassDB::bind_method(_MD("_select_drive"),&EditorFileDialog::_select_drive);
- ClassDB::bind_method(_MD("_make_dir"),&EditorFileDialog::_make_dir);
- ClassDB::bind_method(_MD("_make_dir_confirm"),&EditorFileDialog::_make_dir_confirm);
- ClassDB::bind_method(_MD("_update_file_list"),&EditorFileDialog::update_file_list);
- ClassDB::bind_method(_MD("_update_dir"),&EditorFileDialog::update_dir);
- ClassDB::bind_method(_MD("_thumbnail_done"),&EditorFileDialog::_thumbnail_done);
- ClassDB::bind_method(_MD("set_display_mode","mode"),&EditorFileDialog::set_display_mode);
- ClassDB::bind_method(_MD("get_display_mode"),&EditorFileDialog::get_display_mode);
- ClassDB::bind_method(_MD("_thumbnail_result"),&EditorFileDialog::_thumbnail_result);
- ClassDB::bind_method(_MD("set_disable_overwrite_warning","disable"),&EditorFileDialog::set_disable_overwrite_warning);
- ClassDB::bind_method(_MD("is_overwrite_warning_disabled"),&EditorFileDialog::is_overwrite_warning_disabled);
-
- ClassDB::bind_method(_MD("_recent_selected"),&EditorFileDialog::_recent_selected);
- ClassDB::bind_method(_MD("_go_back"),&EditorFileDialog::_go_back);
- ClassDB::bind_method(_MD("_go_forward"),&EditorFileDialog::_go_forward);
- ClassDB::bind_method(_MD("_go_up"),&EditorFileDialog::_go_up);
-
- ClassDB::bind_method(_MD("_favorite_toggled"),&EditorFileDialog::_favorite_toggled);
- ClassDB::bind_method(_MD("_favorite_selected"),&EditorFileDialog::_favorite_selected);
- ClassDB::bind_method(_MD("_favorite_move_up"),&EditorFileDialog::_favorite_move_up);
- ClassDB::bind_method(_MD("_favorite_move_down"),&EditorFileDialog::_favorite_move_down);
-
- ClassDB::bind_method(_MD("invalidate"),&EditorFileDialog::invalidate);
+ ClassDB::bind_method(D_METHOD("_unhandled_input"),&EditorFileDialog::_unhandled_input);
+
+ ClassDB::bind_method(D_METHOD("_item_selected"),&EditorFileDialog::_item_selected);
+ ClassDB::bind_method(D_METHOD("_item_db_selected"),&EditorFileDialog::_item_dc_selected);
+ ClassDB::bind_method(D_METHOD("_dir_entered"),&EditorFileDialog::_dir_entered);
+ ClassDB::bind_method(D_METHOD("_file_entered"),&EditorFileDialog::_file_entered);
+ ClassDB::bind_method(D_METHOD("_action_pressed"),&EditorFileDialog::_action_pressed);
+ ClassDB::bind_method(D_METHOD("_cancel_pressed"),&EditorFileDialog::_cancel_pressed);
+ ClassDB::bind_method(D_METHOD("_filter_selected"),&EditorFileDialog::_filter_selected);
+ ClassDB::bind_method(D_METHOD("_save_confirm_pressed"),&EditorFileDialog::_save_confirm_pressed);
+
+ ClassDB::bind_method(D_METHOD("clear_filters"),&EditorFileDialog::clear_filters);
+ ClassDB::bind_method(D_METHOD("add_filter","filter"),&EditorFileDialog::add_filter);
+ ClassDB::bind_method(D_METHOD("get_current_dir"),&EditorFileDialog::get_current_dir);
+ ClassDB::bind_method(D_METHOD("get_current_file"),&EditorFileDialog::get_current_file);
+ ClassDB::bind_method(D_METHOD("get_current_path"),&EditorFileDialog::get_current_path);
+ ClassDB::bind_method(D_METHOD("set_current_dir","dir"),&EditorFileDialog::set_current_dir);
+ ClassDB::bind_method(D_METHOD("set_current_file","file"),&EditorFileDialog::set_current_file);
+ ClassDB::bind_method(D_METHOD("set_current_path","path"),&EditorFileDialog::set_current_path);
+ ClassDB::bind_method(D_METHOD("set_mode","mode"),&EditorFileDialog::set_mode);
+ ClassDB::bind_method(D_METHOD("get_mode"),&EditorFileDialog::get_mode);
+ ClassDB::bind_method(D_METHOD("get_vbox:VBoxContainer"),&EditorFileDialog::get_vbox);
+ ClassDB::bind_method(D_METHOD("set_access","access"),&EditorFileDialog::set_access);
+ ClassDB::bind_method(D_METHOD("get_access"),&EditorFileDialog::get_access);
+ ClassDB::bind_method(D_METHOD("set_show_hidden_files","show"),&EditorFileDialog::set_show_hidden_files);
+ ClassDB::bind_method(D_METHOD("is_showing_hidden_files"),&EditorFileDialog::is_showing_hidden_files);
+ ClassDB::bind_method(D_METHOD("_select_drive"),&EditorFileDialog::_select_drive);
+ ClassDB::bind_method(D_METHOD("_make_dir"),&EditorFileDialog::_make_dir);
+ ClassDB::bind_method(D_METHOD("_make_dir_confirm"),&EditorFileDialog::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("_update_file_list"),&EditorFileDialog::update_file_list);
+ ClassDB::bind_method(D_METHOD("_update_dir"),&EditorFileDialog::update_dir);
+ ClassDB::bind_method(D_METHOD("_thumbnail_done"),&EditorFileDialog::_thumbnail_done);
+ ClassDB::bind_method(D_METHOD("set_display_mode","mode"),&EditorFileDialog::set_display_mode);
+ ClassDB::bind_method(D_METHOD("get_display_mode"),&EditorFileDialog::get_display_mode);
+ ClassDB::bind_method(D_METHOD("_thumbnail_result"),&EditorFileDialog::_thumbnail_result);
+ ClassDB::bind_method(D_METHOD("set_disable_overwrite_warning","disable"),&EditorFileDialog::set_disable_overwrite_warning);
+ ClassDB::bind_method(D_METHOD("is_overwrite_warning_disabled"),&EditorFileDialog::is_overwrite_warning_disabled);
+
+ ClassDB::bind_method(D_METHOD("_recent_selected"),&EditorFileDialog::_recent_selected);
+ ClassDB::bind_method(D_METHOD("_go_back"),&EditorFileDialog::_go_back);
+ ClassDB::bind_method(D_METHOD("_go_forward"),&EditorFileDialog::_go_forward);
+ ClassDB::bind_method(D_METHOD("_go_up"),&EditorFileDialog::_go_up);
+
+ ClassDB::bind_method(D_METHOD("_favorite_toggled"),&EditorFileDialog::_favorite_toggled);
+ ClassDB::bind_method(D_METHOD("_favorite_selected"),&EditorFileDialog::_favorite_selected);
+ ClassDB::bind_method(D_METHOD("_favorite_move_up"),&EditorFileDialog::_favorite_move_up);
+ ClassDB::bind_method(D_METHOD("_favorite_move_down"),&EditorFileDialog::_favorite_move_down);
+
+ ClassDB::bind_method(D_METHOD("invalidate"),&EditorFileDialog::invalidate);
ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::POOL_STRING_ARRAY,"paths")));
@@ -1405,7 +1409,7 @@ EditorFileDialog::EditorFileDialog() {
filter_hb->add_child(preview_vb);
CenterContainer *prev_cc = memnew( CenterContainer );
preview_vb->add_margin_child(TTR("Preview:"),prev_cc);
- preview = memnew( TextureFrame );
+ preview = memnew( TextureRect );
prev_cc->add_child(preview);
preview_vb->hide();
@@ -1489,11 +1493,11 @@ EditorFileDialog::~EditorFileDialog() {
void EditorLineEditFileChooser::_bind_methods() {
- ClassDB::bind_method(_MD("_browse"),&EditorLineEditFileChooser::_browse);
- ClassDB::bind_method(_MD("_chosen"),&EditorLineEditFileChooser::_chosen);
- ClassDB::bind_method(_MD("get_button:Button"),&EditorLineEditFileChooser::get_button);
- ClassDB::bind_method(_MD("get_line_edit:LineEdit"),&EditorLineEditFileChooser::get_line_edit);
- ClassDB::bind_method(_MD("get_file_dialog:EditorFileDialog"),&EditorLineEditFileChooser::get_file_dialog);
+ ClassDB::bind_method(D_METHOD("_browse"),&EditorLineEditFileChooser::_browse);
+ ClassDB::bind_method(D_METHOD("_chosen"),&EditorLineEditFileChooser::_chosen);
+ ClassDB::bind_method(D_METHOD("get_button:Button"),&EditorLineEditFileChooser::get_button);
+ ClassDB::bind_method(D_METHOD("get_line_edit:LineEdit"),&EditorLineEditFileChooser::get_line_edit);
+ ClassDB::bind_method(D_METHOD("get_file_dialog:EditorFileDialog"),&EditorLineEditFileChooser::get_file_dialog);
}
diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h
index e2a40cd5df..193cbc513c 100644
--- a/tools/editor/editor_file_dialog.h
+++ b/tools/editor/editor_file_dialog.h
@@ -35,7 +35,7 @@
#include "scene/gui/option_button.h"
#include "os/dir_access.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -93,7 +93,7 @@ private:
OptionButton *drives;
ItemList *item_list;
- TextureFrame *preview;
+ TextureRect *preview;
VBoxContainer *preview_vb;
HBoxContainer *list_hb;
LineEdit *file;
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp
index 5fb274f38f..cd151cd90b 100644
--- a/tools/editor/editor_file_system.cpp
+++ b/tools/editor/editor_file_system.cpp
@@ -27,14 +27,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_file_system.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
#include "os/file_access.h"
#include "editor_node.h"
#include "io/resource_saver.h"
+#include "io/resource_import.h"
#include "editor_settings.h"
#include "editor_resource_preview.h"
+#include "variant_parser.h"
EditorFileSystem *EditorFileSystem::singleton=NULL;
@@ -114,74 +117,12 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const {
return "res://"+file;
}
-bool EditorFileSystemDirectory::get_file_meta(int p_idx) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),"");
- return files[p_idx]->meta.enabled;
-}
Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>());
- return files[p_idx]->meta.deps;
-
-}
-Vector<String> EditorFileSystemDirectory::get_missing_sources(int p_idx) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),Vector<String>());
- Vector<String> missing;
- for(int i=0;i<files[p_idx]->meta.sources.size();i++) {
- if (files[p_idx]->meta.sources[i].missing)
- missing.push_back(files[p_idx]->meta.sources[i].path);
- }
-
- return missing;
-
-
-}
-bool EditorFileSystemDirectory::is_missing_sources(int p_idx) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),false);
- for(int i=0;i<files[p_idx]->meta.sources.size();i++) {
- if (files[p_idx]->meta.sources[i].missing)
- return true;
- }
-
- return false;
-}
-
-bool EditorFileSystemDirectory::have_sources_changed(int p_idx) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),false);
- return files[p_idx]->meta.sources_changed;
-
-}
-
-int EditorFileSystemDirectory::get_source_count(int p_idx) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),0);
- if (!files[p_idx]->meta.enabled)
- return 0;
- return files[p_idx]->meta.sources.size();
-}
-String EditorFileSystemDirectory::get_source_file(int p_idx,int p_source) const {
+ return files[p_idx]->deps;
- ERR_FAIL_INDEX_V(p_idx,files.size(),String());
- ERR_FAIL_INDEX_V(p_source,files[p_idx]->meta.sources.size(),String());
- if (!files[p_idx]->meta.enabled)
- return String();
-
- return files[p_idx]->meta.sources[p_source].path;
-
-}
-bool EditorFileSystemDirectory::is_source_file_missing(int p_idx,int p_source) const {
-
- ERR_FAIL_INDEX_V(p_idx,files.size(),false);
- ERR_FAIL_INDEX_V(p_source,files[p_idx]->meta.sources.size(),false);
- if (!files[p_idx]->meta.enabled)
- return false;
-
- return files[p_idx]->meta.sources[p_source].missing;
}
@@ -203,18 +144,17 @@ EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() {
void EditorFileSystemDirectory::_bind_methods() {
- ClassDB::bind_method(_MD("get_subdir_count"),&EditorFileSystemDirectory::get_subdir_count);
- ClassDB::bind_method(_MD("get_subdir","idx"),&EditorFileSystemDirectory::get_subdir);
- ClassDB::bind_method(_MD("get_file_count"),&EditorFileSystemDirectory::get_file_count);
- ClassDB::bind_method(_MD("get_file","idx"),&EditorFileSystemDirectory::get_file);
- ClassDB::bind_method(_MD("get_file_path","idx"),&EditorFileSystemDirectory::get_file_path);
- ClassDB::bind_method(_MD("get_file_type","idx"),&EditorFileSystemDirectory::get_file_type);
- ClassDB::bind_method(_MD("is_missing_sources","idx"),&EditorFileSystemDirectory::is_missing_sources);
- ClassDB::bind_method(_MD("get_name"),&EditorFileSystemDirectory::get_name);
- ClassDB::bind_method(_MD("get_path"),&EditorFileSystemDirectory::get_path);
- ClassDB::bind_method(_MD("get_parent:EditorFileSystemDirectory"),&EditorFileSystemDirectory::get_parent);
- ClassDB::bind_method(_MD("find_file_index","name"),&EditorFileSystemDirectory::find_file_index);
- ClassDB::bind_method(_MD("find_dir_index","name"),&EditorFileSystemDirectory::find_dir_index);
+ 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_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);
+ ClassDB::bind_method(D_METHOD("get_file_type","idx"),&EditorFileSystemDirectory::get_file_type);
+ ClassDB::bind_method(D_METHOD("get_name"),&EditorFileSystemDirectory::get_name);
+ ClassDB::bind_method(D_METHOD("get_path"),&EditorFileSystemDirectory::get_path);
+ ClassDB::bind_method(D_METHOD("get_parent:EditorFileSystemDirectory"),&EditorFileSystemDirectory::get_parent);
+ ClassDB::bind_method(D_METHOD("find_file_index","name"),&EditorFileSystemDirectory::find_file_index);
+ ClassDB::bind_method(D_METHOD("find_dir_index","name"),&EditorFileSystemDirectory::find_dir_index);
}
@@ -243,39 +183,6 @@ EditorFileSystemDirectory::~EditorFileSystemDirectory() {
-
-EditorFileSystemDirectory::ImportMeta EditorFileSystem::_get_meta(const String& p_path) {
-
- Ref<ResourceImportMetadata> imd = ResourceLoader::load_import_metadata(p_path);
- EditorFileSystemDirectory::ImportMeta m;
- if (imd.is_null()) {
- m.enabled=false;
- m.sources_changed=false;
- } else {
- m.enabled=true;
- m.sources_changed=false;
-
- for(int i=0;i<imd->get_source_count();i++) {
- EditorFileSystemDirectory::ImportMeta::Source s;
- s.path=imd->get_source_path(i);
- s.md5=imd->get_source_md5(i);
- s.modified_time=0;
- s.missing=false;
- m.sources.push_back(s);
- }
- m.import_editor=imd->get_editor();
- }
-
- List<String> deps;
- ResourceLoader::get_dependencies(p_path,&deps);
- for(List<String>::Element *E=deps.front();E;E=E->next()) {
- m.deps.push_back(E->get());
- }
-
- return m;
-}
-
-
void EditorFileSystem::_scan_filesystem() {
ERR_FAIL_COND(!scanning || new_filesystem);
@@ -288,7 +195,7 @@ void EditorFileSystem::_scan_filesystem() {
String project=GlobalConfig::get_singleton()->get_resource_path();
- String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache");
+ String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2");
FileAccess *f =FileAccess::open(fscache,FileAccess::READ);
if (f) {
@@ -318,30 +225,14 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type=split[1];
fc.modification_time=split[2].to_int64();
- String meta = split[3].strip_edges();
- fc.meta.enabled=false;
- if (meta.find("<>")!=-1){
- Vector<String> spl = meta.split("<>");
- int sc = spl.size()-1;
- if (sc%3==0){
- fc.meta.enabled=true;
- fc.meta.import_editor=spl[0];
- fc.meta.sources.resize(sc/3);
- for(int i=0;i<fc.meta.sources.size();i++) {
- fc.meta.sources[i].path=spl[1+i*3+0];
- fc.meta.sources[i].md5=spl[1+i*3+1];
- fc.meta.sources[i].modified_time=spl[1+i*3+2].to_int64();
- }
-
- }
+ fc.import_modification_time = split[3].to_int64();
- }
String deps = split[4].strip_edges();
if (deps.length()) {
Vector<String> dp = deps.split("<>");
for(int i=0;i<dp.size();i++) {
String path=dp[i];
- fc.meta.deps.push_back(path);
+ fc.deps.push_back(path);
}
}
@@ -378,7 +269,7 @@ void EditorFileSystem::_scan_filesystem() {
//save back the findings
-// String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache");
+ //String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("file_cache");
f=FileAccess::open(fscache,FileAccess::WRITE);
_save_filesystem_cache(new_filesystem,f);
@@ -389,7 +280,14 @@ void EditorFileSystem::_scan_filesystem() {
}
+void EditorFileSystem::_save_filesystem_cache() {
+ String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2");
+ FileAccess *f=FileAccess::open(fscache,FileAccess::WRITE);
+ _save_filesystem_cache(filesystem,f);
+ f->close();
+ memdelete(f);
+}
void EditorFileSystem::_thread_func(void *_userdata) {
@@ -404,6 +302,8 @@ bool EditorFileSystem::_update_scan_actions() {
bool fs_changed=false;
+ Vector<String> reimports;
+
for (List<ItemAction>::Element *E=scan_actions.front();E;E=E->next()) {
ItemAction&ia = E->get();
@@ -468,18 +368,25 @@ bool EditorFileSystem::_update_scan_actions() {
//print_line("*ACTION REMOVE FILE: "+ia.file);
} break;
- case ItemAction::ACTION_FILE_SOURCES_CHANGED: {
+ case ItemAction::ACTION_FILE_REIMPORT: {
+
int idx = ia.dir->find_file_index(ia.file);
ERR_CONTINUE(idx==-1);
String full_path = ia.dir->get_file_path(idx);
- sources_changed.push_back(full_path);
+ reimports.push_back(full_path);
+ fs_changed=true;
} break;
}
}
+
+ if (reimports.size()) {
+ reimport_files(reimports);
+
+ }
scan_actions.clear();
return fs_changed;
@@ -491,9 +398,10 @@ void EditorFileSystem::scan() {
if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/)
return;
- if (scanning || scanning_sources|| thread)
+ if (scanning || scanning_changes|| thread)
return;
+ _update_extensions();
abort_scan=false;
if (!use_threads) {
@@ -502,7 +410,7 @@ void EditorFileSystem::scan() {
_scan_filesystem();
if (filesystem)
memdelete(filesystem);
-// file_type_cache.clear();
+ //file_type_cache.clear();
filesystem=new_filesystem;
new_filesystem=NULL;
_update_scan_actions();
@@ -528,42 +436,6 @@ void EditorFileSystem::scan() {
}
-bool EditorFileSystem::_check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta) {
-
- if (p_meta.enabled) {
-
- for(int j=0;j<p_meta.sources.size();j++) {
-
-
- String src = EditorImportPlugin::expand_source_path(p_meta.sources[j].path);
-
- if (!FileAccess::exists(src)) {
- p_meta.sources[j].missing=true;
- continue;
- }
-
- p_meta.sources[j].missing=false;
-
- uint64_t mt = FileAccess::get_modified_time(src);
-
- if (mt!=p_meta.sources[j].modified_time) {
- //scan
- String md5 = FileAccess::get_md5(src);
- //print_line("checking: "+src);
- //print_line("md5: "+md5);
- //print_line("vs: "+p_meta.sources[j].md5);
- if (md5!=p_meta.sources[j].md5) {
- //really changed
- return true;
- }
- p_meta.sources[j].modified_time=mt;
- }
- }
- }
-
- return false;
-}
-
void EditorFileSystem::ScanProgress::update(int p_current,int p_total) const {
float ratio = low + ((hi-low)/p_total)*p_current;
@@ -579,9 +451,75 @@ EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_cur
sp.hi=slice;
return sp;
-
}
+bool EditorFileSystem::_check_missing_imported_files(const String& p_path) {
+
+ if (!reimport_on_missing_imported_files)
+ return true;
+
+ Error err;
+ FileAccess *f= FileAccess::open(p_path+".import",FileAccess::READ,&err);
+
+ if (!f) {
+ print_line("could not open import for "+p_path);
+ return false;
+ }
+
+ VariantParser::StreamFile stream;
+ stream.f=f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines=0;
+ String error_text;
+
+ List<String> to_check;
+
+ while(true) {
+
+ assign=Variant();
+ next_tag.fields.clear();
+ next_tag.name=String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true);
+ if (err==ERR_FILE_EOF) {
+ memdelete(f);
+ return OK;
+ }
+ else if (err!=OK) {
+ ERR_PRINTS("ResourceFormatImporter::load - "+p_path+".import:"+itos(lines)+" error: "+error_text);
+ memdelete(f);
+ return false;
+ }
+
+ if (assign!=String()) {
+ if (assign.begins_with("path")) {
+ to_check.push_back(value);
+ } else if (assign=="files") {
+ Array fa = value;
+ for(int i=0;i<fa.size();i++) {
+ to_check.push_back(fa[i]);
+ }
+ }
+
+ } else if (next_tag.name!="remap" && next_tag.name!="deps") {
+ break;
+ }
+ }
+
+ memdelete(f);
+
+ for (List<String>::Element *E=to_check.front();E;E=E->next()) {
+ if (!FileAccess::exists(E->get())) {
+ print_line("missing "+E->get()+", reimport" );
+ return false;
+ }
+ }
+ return true;
+}
void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress) {
@@ -606,7 +544,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
if (f.begins_with(".")) //ignore hidden and . / ..
continue;
- if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
+ if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
continue;
dirs.push_back(f);
@@ -670,9 +608,11 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
for (List<String>::Element*E=files.front();E;E=E->next(),idx++) {
- String ext = E->get().extension().to_lower();
- if (!valid_extensions.has(ext))
+
+ String ext = E->get().get_extension().to_lower();
+ if (!valid_extensions.has(ext)) {
continue; //invalid
+ }
EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
fi->file=E->get();
@@ -682,32 +622,59 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
FileCache *fc = file_cache.getptr(path);
uint64_t mt = FileAccess::get_modified_time(path);
- if (fc && fc->modification_time == mt) {
+ if (import_extensions.has(ext)) {
- fi->meta=fc->meta;
- fi->type=fc->type;
- fi->modified_time=fc->modification_time;
- } else {
- fi->meta=_get_meta(path);
- fi->type=ResourceLoader::get_resource_type(path);
- fi->modified_time=mt;
+ //is imported
+ uint64_t import_mt=0;
+ if (FileAccess::exists(path+".import")) {
+ import_mt=FileAccess::get_modified_time(path+".import");
+ }
+
+
+ if (fc && fc->modification_time==mt && fc->import_modification_time==import_mt && _check_missing_imported_files(path)) {
+
+ fi->type=fc->type;
+ fi->modified_time=fc->modification_time;
+ fi->import_modified_time=fc->import_modification_time;
+
+ } else {
+
+ if (!fc) {
+ print_line("REIMPORT BECAUSE: not previously found");
+ } else if (fc->modification_time!=mt) {
+ print_line("REIMPORT BECAUSE: modified resource time "+itos(fc->modification_time)+" vs "+itos(mt));
+
+ } else if (fc->import_modification_time!=import_mt) {
+ print_line("REIMPORT BECAUSE: modified .import time"+itos(fc->import_modification_time)+" vs "+itos(import_mt));
+
+ } else {
+
+ print_line("REIMPORT BECAUSE: missing imported files");
+ }
- }
- if (fi->meta.enabled) {
- if (_check_meta_sources(fi->meta)) {
+ fi->type=ResourceFormatImporter::get_singleton()->get_resource_type(path);
+ fi->modified_time=0;
+ fi->import_modified_time=0;
+
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
+ ia.action=ItemAction::ACTION_FILE_REIMPORT;
ia.dir=p_dir;
ia.file=E->get();
scan_actions.push_back(ia);
- fi->meta.sources_changed=true;
- } else {
- fi->meta.sources_changed=false;
}
-
} else {
- fi->meta.sources_changed=true;
+ //not imported, so just update type if changed
+ if (fc && fc->modification_time == mt) {
+
+ fi->type=fc->type;
+ fi->modified_time=fc->modification_time;
+ fi->import_modified_time=0;
+ } else {
+ fi->type=ResourceLoader::get_resource_type(path);
+ fi->modified_time=mt;
+ fi->import_modified_time=0;
+ }
}
p_dir->files.push_back(fi);
@@ -717,11 +684,13 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
}
+
void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const ScanProgress& p_progress) {
uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path());
bool updated_dir=false;
+ String cd = p_dir->get_path();
//print_line("dir: "+p_dir->get_path()+" MODTIME: "+itos(p_dir->modified_time)+" CTIME: "+itos(current_mtime));
@@ -746,7 +715,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
//then scan files and directories and check what's different
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- String cd = p_dir->get_path();
+
da->change_dir(cd);
da->list_dir_begin();
while (true) {
@@ -764,7 +733,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
int idx = p_dir->find_dir_index(f);
if (idx==-1) {
- if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
+ if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
continue;
EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
@@ -789,7 +758,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
} else {
- String ext = f.extension().to_lower();
+ String ext = f.get_extension().to_lower();
if (!valid_extensions.has(ext))
continue; //invalid
@@ -802,7 +771,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
String path = cd.plus_file(fi->file);
fi->modified_time=FileAccess::get_modified_time(path);
- fi->meta=_get_meta(path);
+ fi->import_modified_time=0;
fi->type=ResourceLoader::get_resource_type(path);
{
@@ -812,19 +781,22 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
ia.file=f;
ia.new_file=fi;
scan_actions.push_back(ia);
- }
- //take the chance and scan sources
- if (_check_meta_sources(fi->meta)) {
+ }
+
+ if (import_extensions.has(ext)) {
+ //if it can be imported, and it was added, it needs to be reimported
+ print_line("REIMPORT: file was not found before, reimport");
+ print_line("at dir: "+p_dir->get_path()+" file: "+f);
+ for(int i=0;i<p_dir->files.size();i++) {
+ print_line(itos(i)+": "+p_dir->files[i]->file);
+ }
ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
+ ia.action=ItemAction::ACTION_FILE_REIMPORT;
ia.dir=p_dir;
ia.file=f;
scan_actions.push_back(ia);
- fi->meta.sources_changed=true;
- } else {
- fi->meta.sources_changed=false;
}
} else {
@@ -854,15 +826,43 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
}
- if (_check_meta_sources(p_dir->files[i]->meta)) {
- ItemAction ia;
- ia.action=ItemAction::ACTION_FILE_SOURCES_CHANGED;
- ia.dir=p_dir;
- ia.file=p_dir->files[i]->file;
- scan_actions.push_back(ia);
- p_dir->files[i]->meta.sources_changed=true;
- } else {
- p_dir->files[i]->meta.sources_changed=false;
+ if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) {
+ //check here if file must be imported or not
+
+ String path = cd.plus_file(p_dir->files[i]->file);
+
+ uint64_t mt = FileAccess::get_modified_time(path);
+
+ bool reimport=false;
+
+ if (mt!=p_dir->files[i]->modified_time) {
+ print_line("REIMPORT: modified time changed, reimport");
+ reimport=true; //it was modified, must be reimported.
+ } else if (!FileAccess::exists(path+".import")) {
+ print_line("REIMPORT: no .import exists, reimport");
+ reimport=true; //no .import file, obviously reimport
+ } else {
+
+ uint64_t import_mt=FileAccess::get_modified_time(path+".import");
+ print_line(itos(import_mt)+" vs "+itos(p_dir->files[i]->import_modified_time));
+ if (import_mt!=p_dir->files[i]->import_modified_time) {
+ print_line("REIMPORT: import modified changed, reimport");
+ reimport=true;
+ } else if (!_check_missing_imported_files(path)) {
+ print_line("REIMPORT: imported files removed");
+ reimport=true;
+ }
+ }
+
+ if (reimport) {
+
+ ItemAction ia;
+ ia.action=ItemAction::ACTION_FILE_REIMPORT;
+ ia.dir=p_dir;
+ ia.file=p_dir->files[i]->file;
+ scan_actions.push_back(ia);
+ }
+
}
EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i));
@@ -895,7 +895,7 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
sp.low=0;
efs->_scan_fs_changes(efs->filesystem,sp);
}
- efs->scanning_sources_done=true;
+ efs->scanning_changes_done=true;
}
void EditorFileSystem::get_changed_sources(List<String> *r_changed) {
@@ -903,14 +903,15 @@ void EditorFileSystem::get_changed_sources(List<String> *r_changed) {
*r_changed=sources_changed;
}
-void EditorFileSystem::scan_sources() {
+void EditorFileSystem::scan_changes() {
- if (scanning || scanning_sources|| thread)
+ if (scanning || scanning_changes|| thread)
return;
+ _update_extensions();
sources_changed.clear();
- scanning_sources=true;
- scanning_sources_done=false;
+ scanning_changes=true;
+ scanning_changes_done=false;
abort_scan=false;
@@ -926,8 +927,8 @@ void EditorFileSystem::scan_sources() {
if (_update_scan_actions())
emit_signal("filesystem_changed");
}
- scanning_sources=false;
- scanning_sources_done=true;
+ scanning_changes=false;
+ scanning_changes_done=true;
emit_signal("sources_changed",sources_changed.size()>0);
} else {
@@ -982,11 +983,11 @@ void EditorFileSystem::_notification(int p_what) {
if (use_threads) {
- if (scanning_sources) {
+ if (scanning_changes) {
- if (scanning_sources_done) {
+ if (scanning_changes_done) {
- scanning_sources=false;
+ scanning_changes=false;
set_process(false);
@@ -1027,7 +1028,7 @@ void EditorFileSystem::_notification(int p_what) {
bool EditorFileSystem::is_scanning() const {
- return scanning;
+ return scanning || scanning_changes;
}
float EditorFileSystem::get_scanning_progress() const {
@@ -1048,22 +1049,13 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory*p_dir,Fi
for(int i=0;i<p_dir->files.size();i++) {
- String s=p_dir->files[i]->file+"::"+p_dir->files[i]->type+"::"+String::num(p_dir->files[i]->modified_time)+"::";
- if (p_dir->files[i]->meta.enabled) {
- s+=p_dir->files[i]->meta.import_editor;
- for(int j=0;j<p_dir->files[i]->meta.sources.size();j++){
- s+="<>"+p_dir->files[i]->meta.sources[j].path;
- s+="<>"+p_dir->files[i]->meta.sources[j].md5;
- s+="<>"+String::num(p_dir->files[i]->meta.sources[j].modified_time);
-
- }
- }
+ String s=p_dir->files[i]->file+"::"+p_dir->files[i]->type+"::"+itos(p_dir->files[i]->modified_time)+"::"+itos(p_dir->files[i]->import_modified_time);
s+="::";
- for(int j=0;j<p_dir->files[i]->meta.deps.size();j++) {
+ for(int j=0;j<p_dir->files[i]->deps.size();j++) {
if (j>0)
s+="<>";
- s+=p_dir->files[i]->meta.deps[j];
+ s+=p_dir->files[i]->deps[j];
}
p_file->store_line(s);
@@ -1106,6 +1098,8 @@ bool EditorFileSystem::_find_file(const String& p_file,EditorFileSystemDirectory
for(int i=0;i<path.size();i++) {
+ if (path[i].begins_with("."))
+ return false;
int idx=-1;
for(int j=0;j<fs->get_subdir_count();j++) {
@@ -1198,7 +1192,7 @@ EditorFileSystemDirectory* EditorFileSystem::find_file(const String& p_file,int*
}
-EditorFileSystemDirectory *EditorFileSystem::get_path(const String& p_path) {
+EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String& p_path) {
if (!filesystem || scanning)
return NULL;
@@ -1256,34 +1250,8 @@ void EditorFileSystem::_resource_saved(const String& p_path){
}
-String EditorFileSystem::_find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const {
-
- for(int i=0;i<p_dir->files.size();i++) {
- for(int j=0;j<p_dir->files[i]->meta.sources.size();j++) {
-
- if (p_dir->files[i]->meta.sources[j].path==p_src)
- return p_dir->get_file_path(i);
- }
- }
-
- for(int i=0;i<p_dir->subdirs.size();i++) {
-
- String ret = _find_first_from_source(p_dir->subdirs[i],p_src);
- if (ret.length()>0)
- return ret;
- }
-
- return String();
-}
-
-
-String EditorFileSystem::find_resource_from_source(const String& p_path) const {
- if (filesystem)
- return _find_first_from_source(filesystem,p_path);
- return String();
-}
void EditorFileSystem::update_file(const String& p_file) {
@@ -1319,6 +1287,7 @@ void EditorFileSystem::update_file(const String& p_file) {
EditorFileSystemDirectory::FileInfo *fi = memnew( EditorFileSystemDirectory::FileInfo );
fi->file=p_file.get_file();
+ fi->import_modified_time=0;
if (idx==fs->files.size()) {
fs->files.push_back(fi);
@@ -1334,7 +1303,9 @@ void EditorFileSystem::update_file(const String& p_file) {
//print_line("UPDATING: "+p_file);
fs->files[cpos]->type=type;
fs->files[cpos]->modified_time=FileAccess::get_modified_time(p_file);
- fs->files[cpos]->meta=_get_meta(p_file);
+ //if (FileAccess::exists(p_file+".import")) {
+ // fs->files[cpos]->import_modified_time=FileAccess::get_modified_time(p_file+".import");
+ //}
EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation",p_file);
call_deferred("emit_signal","filesystem_changed"); //update later
@@ -1342,48 +1313,233 @@ void EditorFileSystem::update_file(const String& p_file) {
}
+void EditorFileSystem::_reimport_file(const String& p_file) {
+
+ print_line("REIMPORTING: "+p_file);
+
+ EditorFileSystemDirectory *fs=NULL;
+ int cpos=-1;
+ bool found = _find_file(p_file,&fs,cpos);
+ ERR_FAIL_COND(!found);
+
+ //try to obtain existing params
+
+ Map<StringName,Variant> params;
+ String importer_name;
+
+ if (FileAccess::exists(p_file+".import")) {
+
+ Ref<ConfigFile> cf;
+ cf.instance();
+ Error err = cf->load(p_file+".import");
+ if (err==OK) {
+ List<String> sk;
+ cf->get_section_keys("params",&sk);
+ for(List<String>::Element *E=sk.front();E;E=E->next()) {
+ params[E->get()]=cf->get_value("params",E->get());
+ }
+ importer_name = cf->get_value("remap","importer");
+ }
+ }
+
+ Ref<ResourceImporter> importer;
+ //find the importer
+ if (importer_name!="") {
+ importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
+ }
+
+ if (importer.is_null()) {
+ //not found by name, find by extension
+ importer = ResourceFormatImporter::get_singleton()->get_importer_by_extension(p_file.get_extension());
+ if (importer.is_null()) {
+ ERR_PRINT("BUG: File queued for import, but can't be imported!");
+ ERR_FAIL();
+
+ }
+ }
+
+ //mix with default params, in case a parameter is missing
+
+ List<ResourceImporter::ImportOption> opts;
+ importer->get_import_options(&opts);
+ for (List<ResourceImporter::ImportOption>::Element *E=opts.front();E;E=E->next()) {
+ if (!params.has(E->get().option.name)) { //this one is not present
+ params[E->get().option.name]=E->get().default_value;
+ }
+ }
+
+ //finally, perform import!!
+ String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_file);
+
+ List<String> import_variants;
+ List<String> gen_files;
+
+ Error err = importer->import(p_file,base_path,params,&import_variants,&gen_files);
+
+ if (err!=OK) {
+ ERR_PRINTS("Error importing: "+p_file);
+ }
+
+ //as import is complete, save the .import file
+
+ FileAccess *f = FileAccess::open(p_file+".import",FileAccess::WRITE);
+ ERR_FAIL_COND(!f);
+
+ //write manually, as order matters ([remap] has to go first for performance).
+ f->store_line("[remap]");
+ f->store_line("");
+ f->store_line("importer=\""+importer->get_importer_name()+"\"");
+ if (importer->get_resource_type()!="") {
+ f->store_line("type=\""+importer->get_resource_type()+"\"");
+ }
+
+
+ if (importer->get_save_extension()=="") {
+ //no path
+ } else if (import_variants.size()) {
+ //import with variants
+ for(List<String>::Element *E=import_variants.front();E;E=E->next()) {
+
+
+ String path = base_path.c_escape()+"."+E->get()+"."+importer->get_save_extension();
+
+ f->store_line("path."+E->get()+"=\""+path+"\"");
+
+ }
+ } else {
+
+ f->store_line("path=\""+base_path+"."+importer->get_save_extension()+"\"");
+ }
+
+ f->store_line("");
+ if (gen_files.size()) {
+ f->store_line("[gen]");
+ Array genf;
+ for (List<String>::Element *E=gen_files.front();E;E=E->next()) {
+ genf.push_back(E->get());
+ }
+
+ String value;
+ VariantWriter::write_to_string(genf,value);
+ f->store_line("files="+value);
+ f->store_line("");
+ }
+
+
+ f->store_line("[params]");
+ f->store_line("");
+
+ //store options in provided order, to avoid file changing
+
+
+ for (List<ResourceImporter::ImportOption>::Element *E=opts.front();E;E=E->next()) {
+
+ String base = E->get().option.name;
+ String value;
+ VariantWriter::write_to_string(params[base],value);
+ f->store_line(base+"="+value);
+
+
+ }
+
+ f->close();
+ memdelete(f);
+
+ //update modified times, to avoid reimport
+ fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
+ fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file+".import");
+
+ //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it
+ //to reload properly
+ if (ResourceCache::has(p_file)) {
+
+ Resource *r = ResourceCache::get(p_file);
+
+ if (r->get_import_path()!=String()) {
+
+ String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_file);
+ r->set_import_path(dst_path);
+ r->set_import_last_modified_time(0);
+ }
+ }
+}
+
+void EditorFileSystem::reimport_files(const Vector<String>& p_files) {
+
+ importing=true;
+ EditorProgress pr("reimport",TTR("(Re)Importing Assets"),p_files.size());
+ for(int i=0;i<p_files.size();i++) {
+ pr.step(p_files[i].get_file(),i);
+
+ _reimport_file(p_files[i]);
+ }
+
+ _save_filesystem_cache();
+ importing=false;
+ if (!is_scanning()) {
+ emit_signal("filesystem_changed");
+ }
+}
void EditorFileSystem::_bind_methods() {
- ClassDB::bind_method(_MD("get_filesystem:EditorFileSystemDirectory"),&EditorFileSystem::get_filesystem);
- ClassDB::bind_method(_MD("is_scanning"),&EditorFileSystem::is_scanning);
- ClassDB::bind_method(_MD("get_scanning_progress"),&EditorFileSystem::get_scanning_progress);
- ClassDB::bind_method(_MD("scan"),&EditorFileSystem::scan);
- ClassDB::bind_method(_MD("scan_sources"),&EditorFileSystem::scan_sources);
- ClassDB::bind_method(_MD("update_file","path"),&EditorFileSystem::update_file);
- ClassDB::bind_method(_MD("get_path:EditorFileSystemDirectory","path"),&EditorFileSystem::get_path);
- ClassDB::bind_method(_MD("get_file_type","path"),&EditorFileSystem::get_file_type);
+ ClassDB::bind_method(D_METHOD("get_filesystem:EditorFileSystemDirectory"),&EditorFileSystem::get_filesystem);
+ ClassDB::bind_method(D_METHOD("is_scanning"),&EditorFileSystem::is_scanning);
+ ClassDB::bind_method(D_METHOD("get_scanning_progress"),&EditorFileSystem::get_scanning_progress);
+ ClassDB::bind_method(D_METHOD("scan"),&EditorFileSystem::scan);
+ ClassDB::bind_method(D_METHOD("scan_sources"),&EditorFileSystem::scan_changes);
+ ClassDB::bind_method(D_METHOD("update_file","path"),&EditorFileSystem::update_file);
+ ClassDB::bind_method(D_METHOD("get_filesystem_path:EditorFileSystemDirectory","path"),&EditorFileSystem::get_filesystem_path);
+ ClassDB::bind_method(D_METHOD("get_file_type","path"),&EditorFileSystem::get_file_type);
ADD_SIGNAL( MethodInfo("filesystem_changed") );
ADD_SIGNAL( MethodInfo("sources_changed",PropertyInfo(Variant::BOOL,"exist")) );
}
+void EditorFileSystem::_update_extensions() {
+ valid_extensions.clear();
+ import_extensions.clear();
+
+ List<String> extensionsl;
+ ResourceLoader::get_recognized_extensions_for_type("",&extensionsl);
+ for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+
+ valid_extensions.insert(E->get());
+ }
+
+ extensionsl.clear();
+ ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl);
+ for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
+
+ import_extensions.insert(E->get());
+ }
+}
EditorFileSystem::EditorFileSystem() {
+ reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files",true);
singleton=this;
filesystem=memnew( EditorFileSystemDirectory ); //like, empty
thread = NULL;
scanning=false;
+ importing=false;
use_threads=true;
thread_sources=NULL;
new_filesystem=NULL;
- scanning_sources=false;
+ scanning_changes=false;
ResourceSaver::set_save_callback(_resource_saved);
- List<String> extensionsl;
- ResourceLoader::get_recognized_extensions_for_type("",&extensionsl);
- for(List<String>::Element *E = extensionsl.front();E;E=E->next()) {
-
- valid_extensions.insert(E->get());
+ DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ if (da->change_dir("res://.import")!=OK) {
+ da->make_dir("res://.import");
}
-
+ memdelete(da);
scan_total=0;
}
diff --git a/tools/editor/editor_file_system.h b/tools/editor/editor_file_system.h
index 97c253c70b..10d9b919fc 100644
--- a/tools/editor/editor_file_system.h
+++ b/tools/editor/editor_file_system.h
@@ -48,30 +48,13 @@ class EditorFileSystemDirectory : public Object {
EditorFileSystemDirectory *parent;
Vector<EditorFileSystemDirectory*> subdirs;
- struct ImportMeta {
-
- struct Source {
-
- String path;
- String md5;
- uint64_t modified_time;
- bool missing;
-
- };
-
- Vector<Source> sources;
- String import_editor;
- Vector<String> deps;
- bool enabled;
- bool sources_changed;
-
- };
struct FileInfo {
String file;
StringName type;
uint64_t modified_time;
- ImportMeta meta;
+ uint64_t import_modified_time;
+ Vector<String> deps;
bool verified; //used for checking changes
};
@@ -101,14 +84,7 @@ public:
String get_file(int p_idx) const;
String get_file_path(int p_idx) const;
StringName get_file_type(int p_idx) const;
- bool get_file_meta(int p_idx) const;
- bool is_missing_sources(int p_idx) const;
- bool have_sources_changed(int p_idx) const;
- Vector<String> get_missing_sources(int p_idx) const;
Vector<String> get_file_deps(int p_idx) const;
- int get_source_count(int p_idx) const;
- String get_source_file(int p_idx,int p_source) const;
- bool is_source_file_missing(int p_idx,int p_source) const;
EditorFileSystemDirectory *get_parent();
@@ -136,7 +112,7 @@ class EditorFileSystem : public Node {
ACTION_DIR_REMOVE,
ACTION_FILE_ADD,
ACTION_FILE_REMOVE,
- ACTION_FILE_SOURCES_CHANGED
+ ACTION_FILE_REIMPORT
};
Action action;
@@ -157,6 +133,7 @@ class EditorFileSystem : public Node {
bool abort_scan;
bool scanning;
+ bool importing;
float scan_total;
@@ -171,7 +148,7 @@ class EditorFileSystem : public Node {
String type;
uint64_t modification_time;
- EditorFileSystemDirectory::ImportMeta meta;
+ uint64_t import_modification_time;
Vector<String> deps;
};
@@ -186,25 +163,25 @@ class EditorFileSystem : public Node {
ScanProgress get_sub(int p_current,int p_total) const;
};
- static EditorFileSystemDirectory::ImportMeta _get_meta(const String& p_path);
-
- bool _check_meta_sources(EditorFileSystemDirectory::ImportMeta & p_meta);
+ void _save_filesystem_cache();
void _save_filesystem_cache(EditorFileSystemDirectory *p_dir,FileAccess *p_file);
bool _find_file(const String& p_file,EditorFileSystemDirectory ** r_d, int &r_file_pos) const;
void _scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress);
+
int md_count;
Set<String> valid_extensions;
+ Set<String> import_extensions;
void _scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess *da,const ScanProgress& p_progress);
Thread *thread_sources;
- bool scanning_sources;
- bool scanning_sources_done;
+ bool scanning_changes;
+ bool scanning_changes_done;
static void _thread_func_sources(void *_userdata);
@@ -214,7 +191,14 @@ class EditorFileSystem : public Node {
bool _update_scan_actions();
static void _resource_saved(const String& p_path);
- String _find_first_from_source(EditorFileSystemDirectory* p_dir,const String &p_src) const;
+
+ void _update_extensions();
+
+ void _reimport_file(const String &p_file);
+
+ bool _check_missing_imported_files(const String& p_path);
+
+ bool reimport_on_missing_imported_files;
protected:
@@ -227,16 +211,19 @@ public:
EditorFileSystemDirectory *get_filesystem();
bool is_scanning() const;
+ bool is_importing() const { return importing; }
float get_scanning_progress() const;
void scan();
- void scan_sources();
+ void scan_changes();
void get_changed_sources(List<String> *r_changed);
void update_file(const String& p_file);
- String find_resource_from_source(const String& p_path) const;
- EditorFileSystemDirectory *get_path(const String& p_path);
+
+ EditorFileSystemDirectory *get_filesystem_path(const String& p_path);
String get_file_type(const String& p_file) const;
EditorFileSystemDirectory* find_file(const String& p_file,int* r_index) const;
+ void reimport_files(const Vector<String>& p_files);
+
EditorFileSystem();
~EditorFileSystem();
};
diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp
index 3e128e7759..3652a59978 100644
--- a/tools/editor/editor_fonts.cpp
+++ b/tools/editor/editor_fonts.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_fonts.h"
+
#include "doc_font.h"
#include "doc_title_font.h"
#include "doc_code_font.h"
@@ -127,9 +128,9 @@ void editor_register_fonts(Ref<Theme> p_theme) {
p_theme->set_default_theme_font(df);
-// Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons"));
-// Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
-// Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
+ //Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons"));
+ //Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons"));
+ //Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons"));
MAKE_DROID_SANS(df_title,int(EDITOR_DEF("text_editor/help/help_title_font_size",18))*EDSCALE);
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index 11eeaffdb6..5b629b2590 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -27,15 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_help.h"
+
#include "editor_node.h"
#include "editor_settings.h"
#include "os/keyboard.h"
#include "doc_data_compressed.h"
#include "tools/editor/plugins/script_editor_plugin.h"
-
-#include "os/keyboard.h"
-
void EditorHelpSearch::popup() {
popup_centered_ratio(0.6);
if (search_box->get_text()!="") {
@@ -287,7 +285,7 @@ void EditorHelpSearch::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
search_box->call_deferred("grab_focus"); // still not visible
search_box->select_all();
@@ -299,10 +297,10 @@ void EditorHelpSearch::_notification(int p_what) {
void EditorHelpSearch::_bind_methods() {
- ClassDB::bind_method(_MD("_text_changed"),&EditorHelpSearch::_text_changed);
- ClassDB::bind_method(_MD("_confirmed"),&EditorHelpSearch::_confirmed);
- ClassDB::bind_method(_MD("_sbox_input"),&EditorHelpSearch::_sbox_input);
- ClassDB::bind_method(_MD("_update_search"),&EditorHelpSearch::_update_search);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&EditorHelpSearch::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"),&EditorHelpSearch::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&EditorHelpSearch::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_update_search"),&EditorHelpSearch::_update_search);
ADD_SIGNAL(MethodInfo("go_to_help"));
@@ -334,7 +332,7 @@ EditorHelpSearch::EditorHelpSearch() {
search_options->connect("item_activated",this,"_confirmed");
set_title(TTR("Search Help"));
-// search_options->set_hide_root(true);
+ //search_options->set_hide_root(true);
}
@@ -349,8 +347,10 @@ void EditorHelpIndex::add_type(const String& p_type,HashMap<String,TreeItem*>& p
if (p_types.has(p_type))
return;
-// if (!ClassDB::is_type(p_type,base) || p_type==base)
-// return;
+ /*
+ if (!ClassDB::is_type(p_type,base) || p_type==base)
+ return;
+ */
String inherits=EditorHelp::get_doc_data()->class_list[p_type].inherits;
@@ -538,7 +538,7 @@ DocData *EditorHelp::doc=NULL;
void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if ( p_ev.key.mod.control && p_ev.key.scancode==KEY_F) {
@@ -571,15 +571,15 @@ void EditorHelp::_button_pressed(int p_idx) {
if (p_idx==PAGE_CLASS_LIST) {
- // edited_class->set_pressed(false);
- // class_list_button->set_pressed(true);
- // tabs->set_current_tab(PAGE_CLASS_LIST);
+ //edited_class->set_pressed(false);
+ //class_list_button->set_pressed(true);
+ //tabs->set_current_tab(PAGE_CLASS_LIST);
} else if (p_idx==PAGE_CLASS_DESC) {
- // edited_class->set_pressed(true);
- // class_list_button->set_pressed(false);
- // tabs->set_current_tab(PAGE_CLASS_DESC);
+ //edited_class->set_pressed(true);
+ //class_list_button->set_pressed(false);
+ //tabs->set_current_tab(PAGE_CLASS_DESC);
} else if (p_idx==PAGE_CLASS_PREV) {
@@ -619,7 +619,7 @@ void EditorHelp::_class_desc_select(const String& p_select) {
-// print_line("LINK: "+p_select);
+ //print_line("LINK: "+p_select);
if (p_select.begins_with("#")) {
//_goto_desc(p_select.substr(1,p_select.length()));
emit_signal("go_to_help","class_name:"+p_select.substr(1,p_select.length()));
@@ -674,7 +674,7 @@ void EditorHelp::_scroll_changed(double p_scroll) {
if (scroll_locked)
return;
- if (class_desc->get_v_scroll()->is_hidden())
+ if (!class_desc->get_v_scroll()->is_visible())
p_scroll=0;
//history[p].scroll=p_scroll;
@@ -824,7 +824,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->add_text(TTR("Members:"));
class_desc->pop();
class_desc->pop();
-// class_desc->add_newline();
+ //class_desc->add_newline();
class_desc->push_indent(1);
class_desc->push_table(2);
@@ -924,7 +924,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
class_desc->pop();
//class_desc->add_newline();
-// class_desc->add_newline();
+ //class_desc->add_newline();
class_desc->push_indent(1);
class_desc->push_table(2);
@@ -997,7 +997,7 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) {
}
class_desc->pop();//monofont
-// class_desc->add_newline();
+ //class_desc->add_newline();
class_desc->pop(); //cell
}
@@ -1734,8 +1734,8 @@ void EditorHelp::_notification(int p_what) {
case NOTIFICATION_READY: {
-// forward->set_icon(get_icon("Forward","EditorIcons"));
-// back->set_icon(get_icon("Back","EditorIcons"));
+ //forward->set_icon(get_icon("Forward","EditorIcons"));
+ //back->set_icon(get_icon("Back","EditorIcons"));
_update_doc();
} break;
@@ -1789,7 +1789,7 @@ void EditorHelp::_bind_methods() {
ClassDB::bind_method("_class_list_select",&EditorHelp::_class_list_select);
ClassDB::bind_method("_class_desc_select",&EditorHelp::_class_desc_select);
ClassDB::bind_method("_class_desc_input",&EditorHelp::_class_desc_input);
-// ClassDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
+ //ClassDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
ClassDB::bind_method("_scroll_changed",&EditorHelp::_scroll_changed);
ClassDB::bind_method("_request_help",&EditorHelp::_request_help);
ClassDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input);
@@ -1852,7 +1852,7 @@ EditorHelp::EditorHelp() {
editor->get_gui_base()->add_child(class_search);
class_search->connect("go_to_help",this,"_help_callback");*/
-// prev_search_page=-1;
+ //prev_search_page=-1;
}
EditorHelp::~EditorHelp() {
@@ -1872,8 +1872,7 @@ void EditorHelpBit::_go_to_help(String p_what) {
void EditorHelpBit::_meta_clicked(String p_select) {
-
- // print_line("LINK: "+p_select);
+ //print_line("LINK: "+p_select);
if (p_select.begins_with("#")) {
//_goto_desc(p_select.substr(1,p_select.length()));
_go_to_help("class_name:"+p_select.substr(1,p_select.length()));
@@ -1887,10 +1886,11 @@ void EditorHelpBit::_meta_clicked(String p_select) {
_go_to_help("class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0));
} else {
-//
- // if (!method_line.has(m))
- // return;
- //class_desc->scroll_to_line(method_line[m]);
+ /*
+ if (!method_line.has(m))
+ return;
+ class_desc->scroll_to_line(method_line[m]);
+ */
}
}
diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h
index 85bac27705..3c4ba1f43e 100644
--- a/tools/editor/editor_help.h
+++ b/tools/editor/editor_help.h
@@ -40,7 +40,7 @@
#include "scene/main/timer.h"
#include "tools/editor/code_editor.h"
-#include "tools/doc/doc_data.h"
+#include "tools/editor/doc/doc_data.h"
class EditorNode;
diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h
deleted file mode 100644
index fb75373f17..0000000000
--- a/tools/editor/editor_import_export.h
+++ /dev/null
@@ -1,422 +0,0 @@
-/*************************************************************************/
-/* editor_import_export.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* */
-/* 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_IMPORT_EXPORT_H
-#define EDITOR_IMPORT_EXPORT_H
-
-#include "resource.h"
-#include "scene/main/node.h"
-#include "scene/resources/texture.h"
-
-
-class EditorExportPlatform;
-class FileAccess;
-struct EditorProgress;
-
-class EditorImportPlugin : public Reference {
-
- GDCLASS( EditorImportPlugin, Reference);
-
-protected:
-
- static void _bind_methods();
-
- String _validate_source_path(const String& p_path);
- String _expand_source_path(const String& p_path);
-
-
-public:
-
-
- static String validate_source_path(const String& p_path);
- static String expand_source_path(const String& p_path);
-
- virtual String get_name() const;
- virtual String get_visible_name() const;
- virtual void import_dialog(const String& p_from="");
- virtual Error import(const String& p_path, const Ref<ResourceImportMetadata>& p_from);
- virtual void import_from_drop(const Vector<String>& p_drop,const String& p_dest_path);
- virtual void reimport_multiple_files(const Vector<String>& p_list);
- virtual bool can_reimport_multiple_files() const;
- virtual Vector<uint8_t> custom_export(const String& p_path,const Ref<EditorExportPlatform> &p_platform);
-
- EditorImportPlugin();
-};
-
-class EditorExportPlugin : public Reference {
-
- GDCLASS( EditorExportPlugin, Reference);
-
-protected:
- static void _bind_methods();
-
-public:
-
- virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform);
-
- EditorExportPlugin();
-};
-
-class EditorExportPlatform : public Reference {
-
- GDCLASS( EditorExportPlatform,Reference );
-
-public:
-
- typedef Error (*EditorExportSaveFunction)(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
-
-private:
-
- bool debugging_enabled;
-
-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;
-
- Vector<uint8_t> get_exported_file_default(String& p_fname) const;
- virtual Vector<uint8_t> get_exported_file(String& p_fname) const;
- virtual Vector<StringName> get_dependencies(bool p_bundles) const;
- virtual String find_export_template(String template_file_name, String *err=NULL) const;
- virtual bool exists_export_template(String template_file_name, String *err=NULL) const;
-
- struct TempData {
-
- uint64_t pos;
- uint64_t ofs;
- uint64_t size;
- };
-
- struct PackData {
-
- FileAccess *ftmp;
- FileAccess *f;
- Vector<TempData> file_ofs;
- EditorProgress *ep;
- int count;
- int alignment;
-
- };
-
- struct ZipData {
-
- void* zip;
- EditorProgress *ep;
- int count;
-
- };
-
- void gen_export_flags(Vector<String> &r_flags, int p_flags);
- static Error save_pack_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
- static Error save_zip_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
-
-public:
-
- enum ImageCompression {
-
- IMAGE_COMPRESSION_NONE,
- IMAGE_COMPRESSION_INDEXED, // used for older hardware
- IMAGE_COMPRESSION_BC, // directx compression format
- IMAGE_COMPRESSION_PVRTC, // powervr compression format
- IMAGE_COMPRESSION_PVRTC_SQUARE, // powervr compression format, square (ios)
- IMAGE_COMPRESSION_ETC1, // ericsson compression format (alpha is uncompressed)
- IMAGE_COMPRESSION_ETC2, // ericsson new compression format (can handle alpha)
- };
-
- enum ExportFlags {
- EXPORT_DUMB_CLIENT=1,
- EXPORT_REMOTE_DEBUG=2,
- EXPORT_REMOTE_DEBUG_LOCALHOST=4,
- EXPORT_VIEW_COLLISONS=8,
- EXPORT_VIEW_NAVIGATION=16,
- };
-
- bool is_debugging_enabled() const;
- void set_debugging_enabled( bool p_enabled );
-
- Error export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles);
-
- Error save_pack(FileAccess *p_where, bool p_make_bundles=false, int p_alignment = 1);
- Error save_zip(const String& p_path, bool p_make_bundles=false);
-
- virtual String get_name() const =0;
- virtual ImageCompression get_image_compression() const=0;
- virtual Ref<Texture> get_logo() const =0;
-
- virtual bool poll_devices() { return false; }
- virtual int get_device_count() const { return 0; }
- virtual String get_device_name(int p_device) const { return ""; }
- virtual String get_device_info(int p_device) const { return ""; }
- virtual Error run(int p_device,int p_flags) { return OK; }
-
- virtual bool can_export(String *r_error=NULL) const=0;
-
-
- virtual bool requires_password(bool p_debug) const { return false; }
- virtual String get_binary_extension() const=0;
- virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0)=0;
-
- EditorExportPlatform();
-};
-
-class EditorExportPlatformPC : public EditorExportPlatform {
-
- GDCLASS( EditorExportPlatformPC,EditorExportPlatform );
-
-public:
-
- enum ExportMode {
- EXPORT_EXE,
- EXPORT_PACK,
- EXPORT_ZIP
- };
-
-
-private:
-
-
- String binary_extension;
- String platform;
-
- String custom_release_binary;
- String custom_debug_binary;
- String release_binary32;
- String debug_binary32;
- String release_binary64;
- String debug_binary64;
- String name;
- bool use64;
-
- Ref<Texture> logo;
-
- ExportMode export_mode;
- bool bundle;
-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 name; }
- virtual Ref<Texture> get_logo() const { return logo; }
- virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_BC; }
-
- virtual String get_binary_extension() const { return binary_extension; }
- virtual Error export_project(const String& p_path, bool p_debug, int p_flags=0);
- virtual void set_release_binary32(const String& p_binary) { release_binary32=p_binary; }
- virtual void set_debug_binary32(const String& p_binary) { debug_binary32=p_binary; }
- virtual void set_release_binary64(const String& p_binary) { release_binary64=p_binary; }
- virtual void set_debug_binary64(const String& p_binary) { debug_binary64=p_binary; }
- virtual void set_name(const String& p_name) { name=p_name; }
- virtual void set_logo(const Ref<Texture>& p_logo) { logo=p_logo; }
-
- virtual bool can_export(String *r_error=NULL) const;
-
- void set_binary_extension(const String& p_extension);
-
- EditorExportPlatformPC();
-};
-
-
-class EditorImportExport : public Node {
- GDCLASS(EditorImportExport,Node);
-public:
-
- enum FileAction {
-
- ACTION_NONE,
- ACTION_COPY,
- ACTION_BUNDLE
- };
-
- enum ExportFilter {
- EXPORT_SELECTED,
- EXPORT_RESOURCES,
- EXPORT_ALL,
-
- };
-
- enum ImageAction {
- IMAGE_ACTION_NONE,
- IMAGE_ACTION_COMPRESS_DISK,
- IMAGE_ACTION_COMPRESS_RAM,
- IMAGE_ACTION_KEEP //for group
-
- };
-
- enum ScriptAction {
- SCRIPT_ACTION_NONE,
- SCRIPT_ACTION_COMPILE,
- SCRIPT_ACTION_ENCRYPT
- };
-
- enum SampleAction {
-
- SAMPLE_ACTION_NONE,
- SAMPLE_ACTION_COMPRESS_RAM,
- };
-
-protected:
-
- struct ImageGroup {
-
- ImageAction action;
- bool make_atlas;
- float lossy_quality;
- float shrink;
- };
-
- Vector<Ref<EditorExportPlugin> > export_plugins;
- Vector<Ref<EditorImportPlugin> > plugins;
- Map<String,int> by_idx;
- ImageAction image_action;
- float image_action_compress_quality;
- float image_shrink;
- Set<String> image_formats;
-
- ExportFilter export_filter;
- String export_custom_filter, export_custom_filter_exclude;
- Map<StringName,FileAction> files;
- Map<StringName,Ref<EditorExportPlatform> > exporters;
- Map<StringName,ImageGroup> image_groups;
- Map<StringName,StringName> image_group_files;
- Vector<String> diff_packs;
-
- ScriptAction script_action;
- String script_key;
-
- SampleAction sample_action;
- int sample_action_max_hz;
- bool sample_action_trim;
-
- bool convert_text_scenes;
-
- static EditorImportExport* singleton;
-
- PoolVector<String> _get_export_file_list();
- PoolVector<String> _get_export_platforms();
-
- static void _bind_methods();
-public:
-
- static EditorImportExport* get_singleton() { return singleton; }
-
- void add_import_plugin(const Ref<EditorImportPlugin>& p_plugin);
- void remove_import_plugin(const Ref<EditorImportPlugin>& p_plugin);
- int get_import_plugin_count() const;
- Ref<EditorImportPlugin> get_import_plugin(int p_idx) const;
- Ref<EditorImportPlugin> get_import_plugin_by_name(const String& p_string) const;
-
- void add_export_plugin(const Ref<EditorExportPlugin>& p_plugin);
- void remove_export_plugin(const Ref<EditorExportPlugin>& p_plugin);
- int get_export_plugin_count() const;
- Ref<EditorExportPlugin> get_export_plugin(int p_idx) const;
-
- bool poll_export_platforms();
-
- void set_export_file_action(const StringName& p_export_file, FileAction p_action);
- FileAction get_export_file_action(const StringName& p_export_file) const;
- void get_export_file_list(List<StringName> *p_export_files);
-
- void add_export_platform(const Ref<EditorExportPlatform>& p_export);
- Ref<EditorExportPlatform> get_export_platform(const StringName& p_platform);
- void get_export_platforms(List<StringName> *r_platforms);
-
- void set_export_filter(ExportFilter p_enable);
- ExportFilter get_export_filter() const;
-
- void set_export_custom_filter(const String& p_custom_filter);
- void set_export_custom_filter_exclude(const String& p_custom_filter);
- String get_export_custom_filter() const;
- String get_export_custom_filter_exclude() const;
-
- void set_export_image_action(ImageAction p_action);
- ImageAction get_export_image_action() const;
-
- void set_export_image_shrink(float p_shrink);
- float get_export_image_shrink() const;
-
- void set_export_image_quality(float p_quality);
- float get_export_image_quality() const;
-
- Vector<String>& get_diff_packs() { return diff_packs; }
-
- void image_export_group_create(const StringName& p_name);
- void image_export_group_remove(const StringName& p_name);
- bool image_export_has_group(const StringName& p_name) const;
- void image_export_get_groups(List<StringName> *r_name) const;
- void image_export_group_set_image_action(const StringName& p_export_group,ImageAction p_action);
- ImageAction image_export_group_get_image_action(const StringName& p_export_group) const;
- void image_export_group_set_make_atlas(const StringName& p_export_group,bool p_make);
- bool image_export_group_get_make_atlas(const StringName& p_export_group) const;
- void image_export_group_set_shrink(const StringName& p_export_group,float p_amount);
- float image_export_group_get_shrink(const StringName& p_export_group) const;
- void image_export_group_set_lossy_quality(const StringName& p_export_group,float p_quality);
- float image_export_group_get_lossy_quality(const StringName& p_export_group) const;
-
- void image_add_to_export_group(const StringName& p_image,const StringName& p_export_group);
- StringName image_get_export_group(const StringName& p_image) const;
- void image_export_get_images_in_group(const StringName& p_group, List<StringName> *r_images) const;
-
- Set<String>& get_image_formats() { return image_formats; }
-
- void script_set_action(ScriptAction p_action);
- ScriptAction script_get_action() const;
-
- void script_set_encryption_key(const String& p_key);
- String script_get_encryption_key() const;
-
- void sample_set_action(SampleAction p_action);
- SampleAction sample_get_action() const;
-
- void sample_set_max_hz(int p_hz);
- int sample_get_max_hz() const;
-
- void sample_set_trim(bool p_trim);
- bool sample_get_trim() const;
-
- void set_convert_text_scenes(bool p_convert);
- bool get_convert_text_scenes() const;
-
- void load_config();
- void save_config();
-
- EditorImportExport();
- ~EditorImportExport();
-};
-
-VARIANT_ENUM_CAST(EditorImportExport::FileAction);
-VARIANT_ENUM_CAST(EditorImportExport::ExportFilter);
-VARIANT_ENUM_CAST(EditorImportExport::ImageAction);
-VARIANT_ENUM_CAST(EditorImportExport::ScriptAction);
-VARIANT_ENUM_CAST(EditorImportExport::SampleAction);
-
-#endif // EDITOR_IMPORT_EXPORT_H
diff --git a/tools/editor/editor_initialize_ssl.cpp b/tools/editor/editor_initialize_ssl.cpp
index 9ac4f90e9f..c08dcc6656 100644
--- a/tools/editor/editor_initialize_ssl.cpp
+++ b/tools/editor/editor_initialize_ssl.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_initialize_ssl.h"
+
#include "certs_compressed.h"
#include "io/stream_peer_ssl.h"
#include "io/compression.h"
diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp
index 16dfb7afb2..850d9273f8 100644
--- a/tools/editor/editor_log.cpp
+++ b/tools/editor/editor_log.cpp
@@ -26,8 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "editor_log.h"
+
+#include "version.h"
#include "scene/gui/center_container.h"
#include "editor_node.h"
@@ -44,8 +45,10 @@ void EditorLog::_error_handler(void *p_self, const char*p_func, const char*p_fil
err_str=String(p_file)+":"+itos(p_line)+" - "+String(p_error);
}
-// if (!self->is_visible())
-// self->emit_signal("show_request");
+ /*
+ if (!self->is_visible_in_tree())
+ self->emit_signal("show_request");
+ */
err_str=" "+err_str;
self->log->add_newline();
@@ -129,7 +132,7 @@ void EditorLog::add_message(const String& p_msg,bool p_error) {
log->add_newline();
log->add_text(p_msg);
-// button->set_text(p_msg);
+ //button->set_text(p_msg);
if (p_error)
log->pop();
@@ -164,9 +167,9 @@ void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) {
void EditorLog::_bind_methods() {
- ClassDB::bind_method(_MD("_clear_request"),&EditorLog::_clear_request );
+ ClassDB::bind_method(D_METHOD("_clear_request"),&EditorLog::_clear_request );
ClassDB::bind_method("_override_logger_styles",&EditorLog::_override_logger_styles );
- //ClassDB::bind_method(_MD("_dragged"),&EditorLog::_dragged );
+ //ClassDB::bind_method(D_METHOD("_dragged"),&EditorLog::_dragged );
ADD_SIGNAL( MethodInfo("clear_request"));
}
diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h
index e59b877ea0..965d8d6420 100644
--- a/tools/editor/editor_log.h
+++ b/tools/editor/editor_log.h
@@ -36,7 +36,7 @@
//#include "scene/gui/empty_control.h"
#include "scene/gui/box_container.h"
#include "scene/gui/panel_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#include "pane_drag.h"
#include "os/thread.h"
@@ -48,7 +48,7 @@ class EditorLog : public VBoxContainer {
Label *title;
RichTextLabel *log;
HBoxContainer *title_hb;
-// PaneDrag *pd;
+ //PaneDrag *pd;
Control *ec;
PanelContainer *pc;
@@ -58,7 +58,7 @@ class EditorLog : public VBoxContainer {
Thread::ID current;
-// void _dragged(const Point2& p_ofs);
+ //void _dragged(const Point2& p_ofs);
void _clear_request();
static void _undo_redo_cbk(void *p_self,const String& p_name);
protected:
diff --git a/tools/editor/editor_name_dialog.cpp b/tools/editor/editor_name_dialog.cpp
index e7dcea4d40..da9f25f1e3 100644
--- a/tools/editor/editor_name_dialog.cpp
+++ b/tools/editor/editor_name_dialog.cpp
@@ -26,9 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "editor_name_dialog.h"
-#include "object_type_db.h"
+
+#include "class_db.h"
#include "os/keyboard.h"
void EditorNameDialog::_line_gui_input(const InputEvent& p_event) {
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 98c59208d2..7a85941b0d 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -26,22 +26,20 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "editor_node.h"
+
+#include "version.h"
#include "print_string.h"
#include "editor_themes.h"
-
#include "editor_help.h"
#include "core/io/resource_saver.h"
#include "core/io/resource_loader.h"
#include "servers/physics_2d_server.h"
#include "scene/resources/packed_scene.h"
#include "editor_settings.h"
-#include "io_plugins/editor_import_collada.h"
-#include "io_plugins/editor_scene_importer_fbxconv.h"
-#include "globals.h"
+#include "global_config.h"
#include <stdio.h>
-#include "object_type_db.h"
+#include "class_db.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "os/file_access.h"
@@ -56,6 +54,8 @@
#include "io/config_file.h"
#include "animation_editor.h"
#include "io/stream_peer_ssl.h"
+#include "main/input_default.h"
+#include "os/input.h"
// plugins
#include "plugins/sprite_frames_editor_plugin.h"
#include "plugins/texture_region_editor_plugin.h"
@@ -76,7 +76,6 @@
#include "plugins/mesh_instance_editor_plugin.h"
#include "plugins/mesh_editor_plugin.h"
#include "plugins/theme_editor_plugin.h"
-
#include "plugins/tile_map_editor_plugin.h"
#include "plugins/cube_grid_theme_editor_plugin.h"
#include "plugins/shader_editor_plugin.h"
@@ -88,6 +87,7 @@
#include "plugins/script_editor_plugin.h"
#include "plugins/script_text_editor.h"
#include "plugins/path_2d_editor_plugin.h"
+#include "plugins/line_2d_editor_plugin.h"
#include "plugins/particles_editor_plugin.h"
#include "plugins/particles_2d_editor_plugin.h"
#include "plugins/animation_tree_editor_plugin.h"
@@ -100,20 +100,27 @@
#include "plugins/color_ramp_editor_plugin.h"
#include "plugins/collision_shape_2d_editor_plugin.h"
#include "plugins/gi_probe_editor_plugin.h"
-#include "main/input_default.h"
+#include "import/resource_importer_texture.h"
+#include "import/resource_importer_csv_translation.h"
+#include "import/resource_importer_wav.h"
+#include "import/resource_importer_obj.h"
+#include "import/resource_importer_scene.h"
// end
-#include "tools/editor/editor_settings.h"
-#include "tools/editor/io_plugins/editor_texture_import_plugin.h"
-#include "tools/editor/io_plugins/editor_scene_import_plugin.h"
-#include "tools/editor/io_plugins/editor_font_import_plugin.h"
-#include "tools/editor/io_plugins/editor_sample_import_plugin.h"
-#include "tools/editor/io_plugins/editor_translation_import_plugin.h"
-#include "tools/editor/io_plugins/editor_bitmask_import_plugin.h"
-#include "tools/editor/io_plugins/editor_mesh_import_plugin.h"
-#include "tools/editor/io_plugins/editor_export_scene.h"
+#include "editor_settings.h"
+#include "io_plugins/editor_texture_import_plugin.h"
+#include "io_plugins/editor_scene_import_plugin.h"
+#include "io_plugins/editor_font_import_plugin.h"
+#include "io_plugins/editor_sample_import_plugin.h"
+#include "io_plugins/editor_translation_import_plugin.h"
+#include "io_plugins/editor_bitmask_import_plugin.h"
+#include "io_plugins/editor_mesh_import_plugin.h"
+#include "io_plugins/editor_export_scene.h"
+#include "import/editor_import_collada.h"
+#include "io_plugins/editor_scene_importer_fbxconv.h"
#include "plugins/editor_preview_plugins.h"
#include "editor_initialize_ssl.h"
+#include "editor_audio_buses.h"
#include "script_editor_debugger.h"
EditorNode *EditorNode::singleton=NULL;
@@ -188,6 +195,9 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) {
next_tab = next_tab >= 0 ? next_tab : editor_data.get_edited_scene_count() - 1;
_scene_tab_changed(next_tab);
}
+ if (ED_IS_SHORTCUT("editor/filter_files", p_event)) {
+ filesystem_dock->focus_on_filter();
+ }
switch(p_event.key.scancode) {
@@ -241,7 +251,7 @@ void EditorNode::_notification(int p_what) {
}
#endif
- if (opening_prev && confirmation->is_hidden())
+ if (opening_prev && !confirmation->is_visible())
opening_prev=false;
if (unsaved_cache != (saved_version!=editor_data.get_undo_redo().get_version())) {
@@ -258,7 +268,7 @@ void EditorNode::_notification(int p_what) {
//get_root_node()->set_rect(viewport->get_global_rect());
//update the circle
- uint64_t frame = OS::get_singleton()->get_frames_drawn();
+ uint64_t frame = Engine::get_singleton()->get_frames_drawn();
uint32_t tick = OS::get_singleton()->get_ticks_msec();
if (frame!=circle_step_frame && (tick-circle_step_msec)>(1000/8)) {
@@ -279,7 +289,7 @@ void EditorNode::_notification(int p_what) {
editor_selection->update();
{
- uint32_t p32 = AudioServer::get_singleton()->read_output_peak()>>8;
+ uint32_t p32 = 0;//AudioServer::get_singleton()->read_output_peak()>>8;
float peak = p32==0? -80 : Math::linear2db(p32 / 65535.0);
@@ -299,6 +309,8 @@ void EditorNode::_notification(int p_what) {
}
+ ResourceImporterTexture::get_singleton()->update_imports();
+
}
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -322,26 +334,12 @@ void EditorNode::_notification(int p_what) {
}
if (p_what==NOTIFICATION_READY) {
- VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport(),true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport(),true);
+ VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(),true);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(),true);
VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(),true);
_editor_select(EDITOR_3D);
-
- if (defer_load_scene!="") {
-
- load_scene(defer_load_scene);
- defer_load_scene="";
- }
-
- if (defer_translatable!="") {
-
- Error ok = save_translatable_strings(defer_translatable);
- if (ok!=OK)
- OS::get_singleton()->set_exit_code(255);
- defer_translatable="";
- get_tree()->quit();
- }
+ _update_debug_options();
/*
if (defer_optimize!="") {
@@ -365,40 +363,7 @@ void EditorNode::_notification(int p_what) {
if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) {
- /*
- List<Ref<Resource> > cached;
- ResourceCache::get_cached_resources(&cached);
-
- bool changes=false;
- for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
-
- if (!E->get()->can_reload_from_file())
- continue;
- if (E->get()->get_path().find("::")!=-1)
- continue;
- uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
- if (mt!=E->get()->get_last_modified_time()) {
- changes=true;
- break;
- }
- }
-
-
-
- sources_button->get_popup()->set_item_disabled(sources_button->get_popup()->get_item_index(DEPENDENCY_UPDATE_LOCAL),!changes);
- if (changes && sources_button->get_popup()->is_item_disabled(sources_button->get_popup()->get_item_index(DEPENDENCY_UPDATE_IMPORTED))) {
- sources_button->set_icon(gui_base->get_icon("DependencyLocalChanged","EditorIcons"));
- }
-*/
-
- if (bool(EDITOR_DEF("filesystem/resources/auto_reload_modified_images",true))) {
-
- _menu_option_confirm(DEPENDENCY_LOAD_CHANGED_IMAGES,true);
- }
-
- waiting_for_sources_changed=true;
- EditorFileSystem::get_singleton()->scan_sources();
-
+ EditorFileSystem::get_singleton()->scan_changes();
}
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) {
@@ -426,63 +391,75 @@ void EditorNode::_fs_changed() {
if (export_defer.platform!="") {
- project_export_settings->export_platform(export_defer.platform,export_defer.path,export_defer.debug,export_defer.password,true);
+ //project_export_settings->export_platform(export_defer.platform,export_defer.path,export_defer.debug,export_defer.password,true);
export_defer.platform="";
}
-}
-
-void EditorNode::_sources_changed(bool p_exist) {
+ {
- if (p_exist && bool(EditorSettings::get_singleton()->get("filesystem/import/automatic_reimport_on_sources_changed"))) {
- p_exist=false;
+ //reload changed resources
+ List<Ref<Resource> > changed;
- List<String> changed_sources;
- EditorFileSystem::get_singleton()->get_changed_sources(&changed_sources);
+ List<Ref<Resource> > cached;
+ ResourceCache::get_cached_resources(&cached);
+ //this should probably be done in a thread..
+ for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
+ if (!E->get()->editor_can_reload_from_file())
+ continue;
+ if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path())
+ continue;
+ if (!FileAccess::exists(E->get()->get_path()))
+ continue;
- EditorProgress ep("reimport",TTR("Re-Importing"),changed_sources.size());
- int step_idx=0;
+ if (E->get()->get_import_path()!=String()) {
+ //imported resource
+ uint64_t mt = FileAccess::get_modified_time(E->get()->get_import_path());
+ print_line("testing modified: "+E->get()->get_import_path()+" "+itos(mt)+" vs "+itos(E->get()->get_import_last_modified_time()));
- for(List<String>::Element *E=changed_sources.front();E;E=E->next()) {
+ if (mt!=E->get()->get_import_last_modified_time()) {
+ print_line("success");
+ changed.push_back(E->get());
+ }
- ep.step(TTR("Importing:")+" "+E->get(),step_idx++);
+ } else {
+ uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
- Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(E->get());
- ERR_CONTINUE(rimd.is_null());
- String editor = rimd->get_editor();
- if (editor.begins_with("texture_")) {
- editor="texture"; //compatibility fix for old versions
- }
- Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor);
- ERR_CONTINUE(eip.is_null());
- Error err = eip->import(E->get(),rimd);
- if (err!=OK) {
- EditorNode::add_io_error("Error Re Importing:\n "+E->get());
+ if (mt!=E->get()->get_last_modified_time()) {
+ changed.push_back(E->get());
+ }
}
+ }
+ if (changed.size()) {
+ //EditorProgress ep("reload_res","Reload Modified Resources",changed.size());
+ int idx=0;
+ for(List<Ref<Resource> >::Element *E=changed.front();E;E=E->next()) {
+
+ //ep.step(E->get()->get_path(),idx++);
+ E->get()->reload_from_file();
+ }
}
- EditorFileSystem::get_singleton()->scan_sources();
- waiting_for_sources_changed=false;
- return;
}
+}
- if (p_exist) {
+void EditorNode::_sources_changed(bool p_exist) {
- sources_button->set_icon(gui_base->get_icon("DependencyChanged","EditorIcons"));
- sources_button->set_disabled(false);
+ if (waiting_for_first_scan) {
- } else {
+ if (defer_load_scene!="") {
- sources_button->set_icon(gui_base->get_icon("DependencyOk","EditorIcons"));
- sources_button->set_disabled(true);
+ print_line("loading scene DEFERED");
+ load_scene(defer_load_scene);
+ defer_load_scene="";
+ }
+ waiting_for_first_scan=false;
}
- waiting_for_sources_changed=false;
}
@@ -497,9 +474,11 @@ void EditorNode::_rebuild_import_menu()
p->clear();
//p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE);
//p->add_separator();
+#if 0
for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) {
p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i);
}
+#endif
}
void EditorNode::_node_renamed() {
@@ -557,8 +536,10 @@ void EditorNode::save_resource_in_path(const Ref<Resource>& p_resource,const Str
int flg=0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
- //if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- // flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ /*
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
+ flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ */
String path = GlobalConfig::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -568,7 +549,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource>& p_resource,const Str
accept->popup_centered_minsize();
return;
}
-// EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
+ //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource*)p_resource.ptr())->set_path(path);
emit_signal("resource_saved",p_resource);
@@ -623,7 +604,7 @@ void EditorNode::save_resource_as(const Ref<Resource>& p_resource,const String&
file->set_current_path(p_resource->get_path());
if (extensions.size()) {
- String ext=p_resource->get_path().extension().to_lower();
+ String ext=p_resource->get_path().get_extension().to_lower();
if (extensions.find(ext)==NULL) {
file->set_current_path(p_resource->get_path().replacen("."+ext,"."+extensions.front()->get()));
}
@@ -666,11 +647,11 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) {
case ERR_FILE_CANT_WRITE: {
- accept->set_text(TTR("Can't open file for writing:")+" "+p_file.extension());
+ accept->set_text(TTR("Can't open file for writing:")+" "+p_file.get_extension());
} break;
case ERR_FILE_UNRECOGNIZED: {
- accept->set_text(TTR("Requested file format unknown:")+" "+p_file.extension());
+ accept->set_text(TTR("Requested file format unknown:")+" "+p_file.get_extension());
} break;
default: {
@@ -770,7 +751,7 @@ bool EditorNode::_find_and_save_resource(RES res,Map<RES,bool>& processed,int32_
bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags);
-// print_line("checking if edited: "+res->get_type()+" :: "+res->get_name()+" :: "+res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged));
+ //print_line("checking if edited: "+res->get_type()+" :: "+res->get_name()+" :: "+res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged));
if (res->get_path().is_resource_file()) {
if (changed || subchanged) {
@@ -828,7 +809,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map<RES,bool>& p
case Variant::DICTIONARY: {
- Dictionary d=obj->get(E->get().name);;
+ Dictionary d=obj->get(E->get().name);
List<Variant> keys;
d.get_key_list(&keys);
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
@@ -890,10 +871,10 @@ void EditorNode::_save_scene_with_preview(String p_file) {
RID viewport;
bool is2d;
if (c3d<c2d) {
- viewport=scene_root->get_viewport();
+ viewport=scene_root->get_viewport_rid();
is2d=true;
} else {
- viewport=SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_viewport();
+ viewport=SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_viewport_rid();
is2d=false;
}
@@ -914,7 +895,7 @@ void EditorNode::_save_scene_with_preview(String p_file) {
save.step(TTR("Creating Thumbnail"),3);
#if 0
Image img = VS::get_singleton()->viewport_texture(scree_capture(viewport);
- int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");;
+ int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
preview_size*=EDSCALE;
int width,height;
if (img.get_width() > preview_size && img.get_width() >= img.get_height()) {
@@ -1001,12 +982,13 @@ void EditorNode::_save_scene(String p_file, int idx) {
return;
}
- sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata(idx));
int flg=0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
- //if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- // flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ /*
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
+ flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ */
flg|=ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
@@ -1051,7 +1033,7 @@ void EditorNode::_import_action(const String& p_action) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error importing scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
return;
}
@@ -1067,7 +1049,7 @@ void EditorNode::_import_action(const String& p_action) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error load scene to update.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
return;
}
@@ -1108,7 +1090,7 @@ void EditorNode::_import(const String &p_file) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error importing scene.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
return;
}
@@ -1196,12 +1178,6 @@ void EditorNode::_dialog_action(String p_file) {
get_undo_redo()->clear_history();
} break;
- case FILE_DUMP_STRINGS: {
-
- save_translatable_strings(p_file);
-
- } break;
-
case FILE_SAVE_SCENE:
case FILE_SAVE_AS_SCENE: {
@@ -1245,7 +1221,7 @@ void EditorNode::_dialog_action(String p_file) {
ml = Ref<MeshLibrary>( memnew( MeshLibrary ));
}
-// MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
+ //MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(),ml,true);
Error err = ResourceSaver::save(p_file,ml);
if (err) {
@@ -1344,9 +1320,11 @@ void EditorNode::_dialog_action(String p_file) {
unzCloseCurrentFile(pkg);
print_line(fname);
- //for(int i=0;i<512;i++) {
- // print_line(itos(data[i]));
- //}
+ /*
+ for(int i=0;i<512;i++) {
+ print_line(itos(data[i]));
+ }
+ */
file=file.get_file();
@@ -1671,7 +1649,7 @@ void EditorNode::_edit_current() {
main_plugin->edit(current_obj);
}
- else if (main_plugin!=editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible() || ScriptEditor::get_singleton()->can_take_away_focus())) {
+ else if (main_plugin!=editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin
if (!changing_scene) {
@@ -1814,7 +1792,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
- String current_filename;
+ String main_scene;
String run_filename;
String args;
@@ -1841,25 +1819,16 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
}
-
-
- if (run_settings_dialog->get_run_mode()==RunSettingsDialog::RUN_LOCAL_SCENE) {
-
- run_filename=scene->get_filename();
- } else {
- current_filename=scene->get_filename();
- }
-
+ run_filename=scene->get_filename();
} else if (p_custom!="") {
-
- run_filename=p_custom;
+ run_filename = p_custom;
}
if (run_filename=="") {
//evidently, run the scene
- run_filename=GLOBAL_DEF("application/main_scene","");
- if (run_filename=="") {
+ main_scene=GLOBAL_DEF("application/main_scene","");
+ if (main_scene=="") {
current_option=-1;
//accept->get_cancel()->hide();
@@ -1868,21 +1837,21 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
return;
}
- if (!FileAccess::exists(run_filename)) {
+ if (!FileAccess::exists(main_scene)) {
current_option=-1;
//accept->get_cancel()->hide();
- pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), run_filename));
+ pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
}
- if (ResourceLoader::get_resource_type(run_filename)!="PackedScene") {
+ if (ResourceLoader::get_resource_type(main_scene)!="PackedScene") {
current_option=-1;
//accept->get_cancel()->hide();
- pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), run_filename));
+ pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene));
pick_main_scene->popup_centered_minsize();
return;
@@ -1917,20 +1886,20 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
editor_data.save_editor_external_data();
}
- if (bool(EDITOR_DEF("run/always_clear_output_on_play", true))) {
+ if (bool(EDITOR_DEF("run/output/always_clear_output_on_play", true))) {
log->clear();
}
- if (bool(EDITOR_DEF("run/always_open_output_on_play", true))) {
+ if (bool(EDITOR_DEF("run/output/always_open_output_on_play", true))) {
make_bottom_panel_item_visible(log);
}
List<String> breakpoints;
editor_data.get_editor_breakpoints(&breakpoints);
-
+
args = GlobalConfig::get_singleton()->get("editor/main_run_args");
- Error error = editor_run.run(run_filename,args,breakpoints,current_filename);
+ Error error = editor_run.run(run_filename,args,breakpoints);
if (error!=OK) {
@@ -1948,7 +1917,7 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
play_scene_button->set_pressed(true);
play_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons"));
} else if (p_custom!="") {
- run_custom_filename=run_filename;
+ run_custom_filename=p_custom;
play_custom_scene_button->set_pressed(true);
play_custom_scene_button->set_icon(gui_base->get_icon("Reload","EditorIcons"));
} else {
@@ -2068,14 +2037,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
quick_open->set_title(TTR("Quick Open Script.."));
} break;
- case FILE_QUICK_OPEN_FILE: {
-
-
- //quick_open->popup("Resource", false, true);
- //quick_open->set_title("Quick Search File..");
- scenes_dock->focus_on_filter();
-
- } break;
case FILE_RUN_SCRIPT: {
file_script->popup_centered_ratio();
@@ -2154,7 +2115,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
if (scene->get_filename()!="") {
file->set_current_path(scene->get_filename());
if (extensions.size()) {
- String ext=scene->get_filename().extension().to_lower();
+ String ext=scene->get_filename().get_extension().to_lower();
if (extensions.find(ext)==NULL) {
file->set_current_path(scene->get_filename().replacen("."+ext,"."+extensions.front()->get()));
}
@@ -2199,46 +2160,6 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
_menu_option_confirm(FILE_SAVE_AND_RUN, true);
} break;
- case FILE_DUMP_STRINGS: {
-
- Node *scene = editor_data.get_edited_scene_root();
-
- if (!scene) {
-
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text(TTR("I see.."));
- accept->set_text("This operation can't be done without a tree root.");
- accept->popup_centered_minsize();
- break;
- }
-
- String cpath;
- if (scene->get_filename()!="") {
- cpath = scene->get_filename();
-
- String fn = cpath.substr(0,cpath.length() - cpath.extension().size());
- String ext=cpath.extension();
- cpath=fn+".pot";
-
-
- } else {
- current_option=-1;
- //confirmation->get_cancel()->hide();
- accept->get_ok()->set_text(TTR("I see.."));
- accept->set_text(TTR("Please save the scene first."));
- accept->popup_centered_minsize();
- break;
-
- }
-
- file->set_mode(EditorFileDialog::MODE_SAVE_FILE);
-
- file->set_current_path(cpath);
- file->set_title(TTR("Save Translatable Strings"));
- file->popup_centered_ratio();
-
- } break;
case FILE_SAVE_OPTIMIZED: {
#if 0
Node *scene = editor_data.get_edited_scene_root();
@@ -2248,7 +2169,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a tree root.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
break;
}
@@ -2270,7 +2191,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Please save the scene first.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
break;
}
@@ -2279,25 +2200,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case FILE_EXPORT_PROJECT: {
- project_export_settings->popup_export();
- /*
- String target = export_db->get_current_platform();
- Ref<EditorExporter> exporter = export_db->get_exporter(target);
- if (exporter.is_null()) {
- accept->set_text("No exporter for platform '"+target+"' yet.");
- accept->popup_centered(Size2(300,70));;
- return;
- }
-
- String extension = exporter->get_binary_extension();
- print_line("for target: "+target+" extension: "+extension);
- file_export_password->set_editable( exporter->requieres_password(file_export_check->is_pressed()));
-
- file_export->clear_filters();
- if (extension!="") {
- file_export->add_filter("*."+extension);
- }
- file_export->popup_centered_ratio();*/
+ project_export->popup_export();
} break;
case FILE_EXPORT_MESH_LIBRARY: {
@@ -2402,8 +2305,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
case EDIT_UNDO: {
- if (OS::get_singleton()->get_mouse_button_state())
+
+
+ if (Input::get_singleton()->get_mouse_button_mask()&0x7) {
+ print_line("no because state");
break; // can't undo while mouse buttons are pressed
+ }
String action = editor_data.get_undo_redo().get_current_action_name();
if (action!="")
@@ -2413,7 +2320,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case EDIT_REDO: {
- if (OS::get_singleton()->get_mouse_button_state())
+ if (Input::get_singleton()->get_mouse_button_mask()&0x7)
break; // can't redo while mouse buttons are pressed
editor_data.get_undo_redo().redo();
@@ -2468,7 +2375,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a selected node.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
break;
}
@@ -2480,7 +2387,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//confirmation->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("This operation can't be done without a selected node.");
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
break;
}
@@ -2492,7 +2399,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("Ugh");
accept->set_text("Error loading scene from "+external_file);
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
return;
}
@@ -2506,8 +2413,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
editor_data.get_undo_redo().add_undo_method(parent,"remove_child",instanced_scene);
editor_data.get_undo_redo().commit_action();
-// parent->add_child(instanced_scene);
-// instanced_scene->set_owner(edited_scene);
+ //parent->add_child(instanced_scene);
+ //instanced_scene->set_owner(edited_scene);
_last_instanced_scene=instanced_scene;
} break;
@@ -2587,20 +2494,20 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case OBJECT_COPY_PARAMS: {
- editor_data.apply_changes_in_editors();;
+ editor_data.apply_changes_in_editors();
if (current)
editor_data.copy_object_params(current);
} break;
case OBJECT_PASTE_PARAMS: {
- editor_data.apply_changes_in_editors();;
+ editor_data.apply_changes_in_editors();
if (current)
editor_data.paste_object_params(current);
editor_data.get_undo_redo().clear_history();
} break;
case OBJECT_UNIQUE_RESOURCES: {
- editor_data.apply_changes_in_editors();;
+ editor_data.apply_changes_in_editors();
if (current) {
List<PropertyInfo> props;
current->get_property_list(&props);
@@ -2671,6 +2578,14 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
play_custom_scene_button->set_pressed(false);
play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom","EditorIcons"));
//pause_button->set_pressed(false);
+ if (bool(EDITOR_DEF("run/output/always_close_output_on_stop", true))) {
+ for(int i=0;i<bottom_panel_items.size();i++) {
+ if (bottom_panel_items[i].control==log) {
+ _bottom_panel_switch(false,i);
+ break;
+ }
+ }
+ }
emit_signal("stop_pressed");
} break;
@@ -2742,7 +2657,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_FILE_SERVER),!ischecked);
-
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked);
} break;
case RUN_LIVE_DEBUG: {
@@ -2750,6 +2665,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_LIVE_DEBUG),!ischecked);
ScriptEditor::get_singleton()->get_debugger()->set_live_debugging(!ischecked);
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked);
+
} break;
/*case RUN_DEPLOY_DUMB_CLIENTS: {
@@ -2764,6 +2681,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
bool ischecked = debug_button->get_popup()->is_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG));
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG),!ischecked);
run_native->set_deploy_debug_remote(!ischecked);
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked);
} break;
case RUN_DEBUG_COLLISONS: {
@@ -2772,6 +2690,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_COLLISONS),!ischecked);
run_native->set_debug_collisions(!ischecked);
editor_run.set_debug_collisions(!ischecked);
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked);
+
} break;
case RUN_DEBUG_NAVIGATION: {
@@ -2779,6 +2699,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION),!ischecked);
run_native->set_debug_navigation(!ischecked);
editor_run.set_debug_navigation(!ischecked);
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked);
+
} break;
case RUN_RELOAD_SCRIPTS: {
@@ -2787,6 +2709,8 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
debug_button->get_popup()->set_item_checked( debug_button->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS),!ischecked);
ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked);
+ EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked);
+
} break;
case SETTINGS_UPDATE_ALWAYS: {
@@ -2800,10 +2724,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
update_menu->get_popup()->set_item_checked(1,true);
OS::get_singleton()->set_low_processor_usage_mode(true);
} break;
- case SETTINGS_UPDATE_SPINNER_HIDE: {
+ case SETTINGS_UPDATE_SPINNER_HIDE: {
update_menu->set_icon(gui_base->get_icon("Collapse","EditorIcons"));
- update_menu->get_popup()->toggle_item_checked(3);
- } break;
+ update_menu->get_popup()->toggle_item_checked(3);
+ } break;
case SETTINGS_PREFERENCES: {
settings_config_dialog->popup_edit_settings();
@@ -2854,29 +2778,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SOURCES_REIMPORT: {
- reimport_dialog->popup_reimport();
+ //reimport_dialog->popup_reimport();
} break;
case DEPENDENCY_LOAD_CHANGED_IMAGES: {
- List<Ref<Resource> > cached;
- ResourceCache::get_cached_resources(&cached);
- //this should probably be done in a thread..
- for(List<Ref<Resource> >::Element *E=cached.front();E;E=E->next()) {
-
- if (!E->get()->editor_can_reload_from_file())
- continue;
- if (!E->get()->get_path().is_resource_file() && !E->get()->get_path().is_abs_path())
- continue;
- if (!FileAccess::exists(E->get()->get_path()))
- continue;
- uint64_t mt = FileAccess::get_modified_time(E->get()->get_path());
- if (mt!=E->get()->get_last_modified_time()) {
- E->get()->reload_from_file();
- }
-
- }
-
} break;
case DEPENDENCY_UPDATE_IMPORTED: {
@@ -2908,7 +2814,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
//accept->get_cancel()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Can't import if edited scene was not saved."); //i dont think this code will ever run
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
break;
}
@@ -2944,16 +2850,29 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
current->call(name);
} else if (p_option>=IMPORT_PLUGIN_BASE) {
- Ref<EditorImportPlugin> p = editor_import_export->get_import_plugin(p_option-IMPORT_PLUGIN_BASE);
- if (p.is_valid()) {
- p->import_dialog();
- }
}
}
}
}
+void EditorNode::_update_debug_options() {
+
+ bool check_deploy_remote = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false);
+ bool check_file_server = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false);
+ bool check_debug_collisons = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisons", false);
+ bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false);
+ bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", false);
+ bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", false);
+
+ if (check_deploy_remote) _menu_option_confirm(RUN_DEPLOY_REMOTE_DEBUG, true);
+ if (check_file_server) _menu_option_confirm(RUN_FILE_SERVER, true);
+ if (check_debug_collisons) _menu_option_confirm(RUN_DEBUG_COLLISONS, true);
+ if (check_debug_navigation) _menu_option_confirm(RUN_DEBUG_NAVIGATION, true);
+ if (check_live_debug) _menu_option_confirm(RUN_LIVE_DEBUG, true);
+ if (check_reload_scripts) _menu_option_confirm(RUN_RELOAD_SCRIPTS, true);
+
+}
Control* EditorNode::get_viewport() {
@@ -3048,20 +2967,6 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) {
}
-void EditorNode::add_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
-
- ERR_FAIL_COND( p_editor_import.is_null() );
- editor_import_export->add_import_plugin(p_editor_import);
- _rebuild_import_menu();
-}
-
-void EditorNode::remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
- ERR_FAIL_COND( p_editor_import.is_null() );
-
- editor_import_export->remove_import_plugin(p_editor_import);
- _rebuild_import_menu();
-}
-
void EditorNode::_update_addon_config() {
@@ -3176,15 +3081,17 @@ void EditorNode::_remove_edited_scene() {
_update_title();
_update_scene_tabs();
-// if (editor_data.get_edited_scene_count()==1) {
-// //make new scene appear saved
-// set_current_version(editor_data.get_undo_redo().get_version());
-// unsaved_cache=false;
-// }
+ /*
+ if (editor_data.get_edited_scene_count()==1) {
+ //make new scene appear saved
+ set_current_version(editor_data.get_undo_redo().get_version());
+ unsaved_cache=false;
+ }
+ */
}
void EditorNode::_remove_scene(int index) {
-// printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene());
+ //printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene());
if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene
@@ -3219,230 +3126,6 @@ void EditorNode::set_edited_scene(Node *p_scene) {
}
-void EditorNode::_fetch_translatable_strings(const Object *p_object,Set<StringName>& strings) {
-
-
- List<String> tstrings;
- p_object->get_translatable_strings(&tstrings);
- for(List<String>::Element *E=tstrings.front();E;E=E->next())
- strings.insert(E->get());
-
-
-
- const Node * node = p_object->cast_to<Node>();
-
- if (!node)
- return;
-
- Ref<Script> script = node->get_script();
- if (script.is_valid())
- _fetch_translatable_strings(script.ptr(),strings);
-
- for(int i=0;i<node->get_child_count();i++) {
-
- Node *c=node->get_child(i);
- if (c->get_owner()!=get_edited_scene())
- continue;
-
- _fetch_translatable_strings(c,strings);
- }
-
-}
-
-
-Error EditorNode::save_translatable_strings(const String& p_to_file) {
-
- if (!is_inside_tree()) {
- defer_translatable=p_to_file;
- return OK;
- }
-
- ERR_FAIL_COND_V(!get_edited_scene(),ERR_INVALID_DATA);
-
- Set<StringName> strings;
- _fetch_translatable_strings(get_edited_scene(),strings);
-
- Error err;
- FileAccess *f = FileAccess::open(p_to_file,FileAccess::WRITE,&err);
- ERR_FAIL_COND_V(err,err);
-
- OS::Date date = OS::get_singleton()->get_date();
- OS::Time time = OS::get_singleton()->get_time();
- f->store_line("# Translation Strings Dump.");
- f->store_line("# Created By.");
- f->store_line("# \t" VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.");
- f->store_line("# From Scene: ");
- f->store_line("# \t"+get_edited_scene()->get_filename());
- f->store_line("");
- f->store_line("msgid \"\"");
- f->store_line("msgstr \"\"");
- f->store_line("\"Report-Msgid-Bugs-To: <define>\\n\"");
- f->store_line("\"POT-Creation-Date: "+itos(date.year)+"-"+itos(date.month)+"-"+itos(date.day)+" "+itos(time.hour)+":"+itos(time.min)+"0000\\n\"");
-// f->store_line("\"PO-Revision-Date: 2006-08-30 13:56-0700\\n\"");
-// f->store_line("\"Last-Translator: Rubén C. Díaz Alonso <outime@gmail.com>\\n\"");
- f->store_line("\"Language-Team: <define>\\n\"");
- f->store_line("\"MIME-Version: 1.0\\n\"");
- f->store_line("\"Content-Type: text/plain; charset=UTF-8\\n\"");
- f->store_line("\"Content-Transfer-Encoding: 8bit\\n\"");
- f->store_line("");
-
- for(Set<StringName>::Element *E=strings.front();E;E=E->next()) {
-
- String s = E->get();
- if (s=="" || s.strip_edges()=="")
- continue;
- Vector<String> substr = s.split("\n");
- ERR_CONTINUE(substr.size()==0);
-
- f->store_line("");
-
- if (substr.size()==1) {
-
- f->store_line("msgid \""+substr[0].c_escape()+"\"");
- } else {
-
- f->store_line("msgid \"\"");
- for(int i=0;i<substr.size();i++) {
-
- String s = substr[i];
- if (i!=substr.size()-1)
- s+="\n";
- f->store_line("\""+s.c_escape()+"\"");
- }
- }
-
- f->store_line("msgstr \"\"");
-
- }
-
-
- f->close();
- memdelete(f);
-
- return OK;
-
-}
-
-Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_preset) {
-
-#if 0
-
- if (!is_inside_scene()) {
- defer_optimize=p_scene;
- defer_optimize_preset=p_preset;
- return OK;
- }
-
-
- if (!get_edited_scene()) {
-
- get_scene()->quit();
- ERR_EXPLAIN("No scene to optimize (loading failed?)");
- ERR_FAIL_V(ERR_FILE_NOT_FOUND);
- }
-
-
- String src_scene=GlobalConfig::get_singleton()->localize_path(get_edited_scene()->get_filename());
-
-
- String path=p_scene;
- print_line("p_path: "+p_scene);
- print_line("src_scene: "+p_scene);
-
- if (path.is_rel_path()) {
- print_line("rel path!?");
- path=src_scene.get_base_dir()+"/"+path;
- }
- path = GlobalConfig::get_singleton()->localize_path(path);
-
- print_line("path: "+path);
-
-
- String preset = "optimizer_presets/"+p_preset;
- if (!GlobalConfig::get_singleton()->has(preset)) {
-
- //accept->"()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Optimizer preset not found: "+p_preset);
- accept->popup_centered(Size2(300,70));;
- ERR_EXPLAIN("Optimizer preset not found: "+p_preset);
- ERR_FAIL_V(ERR_INVALID_PARAMETER);
-
- }
-
- Dictionary d = GlobalConfig::get_singleton()->get(preset);
-
- ERR_FAIL_COND_V(!d.has("__type__"),ERR_INVALID_DATA);
- String type=d["__type__"];
-
- Ref<EditorOptimizedSaver> saver;
-
- for(int i=0;i<editor_data.get_optimized_saver_count();i++) {
-
- print_line(type+" vs "+editor_data.get_optimized_saver(i)->get_target_name());
- if (editor_data.get_optimized_saver(i)->get_target_name()==type) {
- saver=editor_data.get_optimized_saver(i);
- }
- }
-
- ERR_EXPLAIN("Preset '"+p_preset+"' references nonexistent saver: "+type);
- ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA);
-
- List<Variant> keys;
- d.get_key_list(&keys);
-
- saver->clear();
-
- for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
- saver->set(E->get(),d[E->get()]);
- }
-
- uint32_t flags=0;
-
-// if (saver->is_bundle_scenes_enabled())
-// flags|=ResourceSaver::FLAG_BUNDLE_INSTANCED_SCENES;
- if (saver->is_bundle_resources_enabled())
- flags|=ResourceSaver::FLAG_BUNDLE_RESOURCES;
- if (saver->is_remove_editor_data_enabled())
- flags|=ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
- if (saver->is_big_endian_data_enabled())
- flags|=ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
-
- String platform=saver->get_target_platform();
- if (platform=="")
- platform="all";
-
- Ref<PackedScene> sdata = memnew( PackedScene );
- Error err = sdata->pack(get_edited_scene());
-
- if (err) {
-
- current_option=-1;
- //accept->get_cancel()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Couldn't save scene. Likely dependencies (instances) couldn't be satisfied.");
- accept->popup_centered(Size2(300,70));;
- return ERR_INVALID_DATA;
-
- }
- err = ResourceSaver::save(path,sdata,flags); //todo, saverSceneSaver::save(path,get_edited_scene(),flags,saver);
-
- if (err) {
-
- //accept->"()->hide();
- accept->get_ok()->set_text("I see..");
- accept->set_text("Error saving optimized scene: "+path);
- accept->popup_centered(Size2(300,70));;
-
- ERR_FAIL_COND_V(err,err);
-
- }
-
- project_settings->add_remapped_path(src_scene,path,platform);
-#endif
- return OK;
-}
int EditorNode::_get_current_main_editor() {
@@ -3634,7 +3317,10 @@ void EditorNode::fix_dependencies(const String& p_for_file) {
dependency_fixer->edit(p_for_file);
}
-Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited,bool p_clear_errors) {
+
+
+
+Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported) {
if (!is_inside_tree()) {
defer_load_scene = p_scene;
@@ -3643,6 +3329,8 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
if(!p_set_inherited) {
+
+
for(int i=0;i<editor_data.get_edited_scene_count();i++) {
if (editor_data.get_scene_path(i)==p_scene) {
@@ -3650,9 +3338,19 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
return OK;
}
}
+
+ if (!p_force_open_imported && FileAccess::exists(p_scene+".import")) {
+ open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."),p_scene.get_file()));
+ open_imported->popup_centered_minsize();
+ new_inherited_button->grab_focus();
+ open_import_request=p_scene;
+ return OK;
+ }
+
}
+
if (p_clear_errors)
load_errors->clear();
@@ -3784,8 +3482,10 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
state->set_path(lpath);
new_scene->set_scene_inherited_state(state);
new_scene->set_filename(String());
- //if (new_scene->get_scene_instance_state().is_valid())
- // new_scene->get_scene_instance_state()->set_path(String());
+ /*
+ if (new_scene->get_scene_instance_state().is_valid())
+ new_scene->get_scene_instance_state()->set_path(String());
+ */
}
new_scene->set_scene_instance_state(Ref<SceneState>());
@@ -3799,9 +3499,8 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo
property_editor->edit(new_scene);
editor_data.set_edited_scene_root(new_scene);
*/
- editor_data.set_edited_scene_import_metadata( sdata->get_import_metadata() );
-// editor_data.get_undo_redo().clear_history();
+ //editor_data.get_undo_redo().clear_history();
saved_version=editor_data.get_undo_redo().get_version();
_update_title();
_update_scene_tabs();
@@ -3839,9 +3538,13 @@ void EditorNode::request_instance_scenes(const Vector<String>& p_files) {
scene_tree_dock->instance_scenes(p_files);
}
-FileSystemDock *EditorNode::get_scenes_dock() {
+ImportDock *EditorNode::get_import_dock() {
+ return import_dock;
+}
+
+FileSystemDock *EditorNode::get_filesystem_dock() {
- return scenes_dock;
+ return filesystem_dock;
}
SceneTreeDock *EditorNode::get_scene_tree_dock() {
@@ -3893,17 +3596,17 @@ void EditorNode::update_keying() {
void EditorNode::_close_messages() {
-// left_split->set_dragger_visible(false);
+ //left_split->set_dragger_visible(false);
old_split_ofs = center_split->get_split_offset();
center_split->set_split_offset(0);
-// scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,0);
+ //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,0);
}
void EditorNode::_show_messages() {
-// left_split->set_dragger_visible(true);
+ //left_split->set_dragger_visible(true);
center_split->set_split_offset(old_split_ofs);
-// scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP));
+ //scene_root_parent->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,log->get_margin(MARGIN_TOP));
}
@@ -3934,7 +3637,7 @@ void EditorNode::animation_editor_make_visible(bool p_visible) {
} else {
//pd_anim->hide();
animation_editor->hide();
-// scene_root_parent->set_margin(MARGIN_TOP,0);
+ //scene_root_parent->set_margin(MARGIN_TOP,0);
if (!animation_vb->get_parent_control())
return;
animation_vb->get_parent_control()->minimum_size_changed();
@@ -3989,7 +3692,7 @@ void EditorNode::_open_recent_scene(int p_idx) {
void EditorNode::_save_optimized() {
-// save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset());
+ //save_optimized_copy(optimized_save->get_optimized_scene(),optimized_save->get_preset());
#if 0
String path = optimized_save->get_optimized_scene();
@@ -4016,7 +3719,7 @@ void EditorNode::_save_optimized() {
//accept->"()->hide();
accept->get_ok()->set_text("I see..");
accept->set_text("Error saving optimized scene: "+path);
- accept->popup_centered(Size2(300,70));;
+ accept->popup_centered(Size2(300,70));
return;
}
@@ -4142,9 +3845,9 @@ bool EditorNode::is_scene_in_use(const String& p_path) {
void EditorNode::register_editor_types() {
ClassDB::register_class<EditorPlugin>();
- ClassDB::register_class<EditorImportPlugin>();
- ClassDB::register_class<EditorExportPlugin>();
- ClassDB::register_class<EditorScenePostImport>();
+// ClassDB::register_class<EditorImportPlugin>();
+// ClassDB::register_class<EditorExportPlugin>();
+// ClassDB::register_class<EditorScenePostImport>();
ClassDB::register_class<EditorScript>();
ClassDB::register_class<EditorSelection>();
ClassDB::register_class<EditorFileDialog>();
@@ -4159,7 +3862,7 @@ void EditorNode::register_editor_types() {
//ClassDB::register_type<EditorImporter>();
-// ClassDB::register_type<EditorPostImport>();
+ //ClassDB::register_type<EditorPostImport>();
}
void EditorNode::unregister_editor_types() {
@@ -4217,7 +3920,7 @@ void EditorNode::progress_end_task_bg(const String& p_task) {
Ref<Texture> EditorNode::_file_dialog_get_icon(const String& p_path) {
- EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_path(p_path.get_base_dir());
+ EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir());
if (efsd) {
String file = p_path.get_file();
@@ -4501,6 +4204,8 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p
}
}
+ p_layout->set_value(p_section,"dock_filesystem_split",filesystem_dock->get_split_offset());
+
VSplitContainer*splits[DOCK_SLOT_MAX/2]={
left_l_vsplit,
left_r_vsplit,
@@ -4510,7 +4215,7 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String& p
for(int i=0;i<DOCK_SLOT_MAX/2;i++) {
- if (splits[i]->is_visible()) {
+ if (splits[i]->is_visible_in_tree()) {
p_layout->set_value(p_section,"dock_split_"+itos(i+1),splits[i]->get_split_offset());
}
}
@@ -4609,7 +4314,7 @@ void EditorNode::_update_dock_slots_visibility() {
for(int i=0;i<DOCK_SLOT_MAX;i++) {
- if (!dock_slot[i]->is_hidden() && dock_slot[i]->get_tab_count()) {
+ if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
}
}
@@ -4677,6 +4382,12 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String&
}
}
+ int fs_split_ofs = 0;
+ if (p_layout->has_section_key(p_section,"dock_filesystem_split")) {
+ fs_split_ofs = p_layout->get_value(p_section,"dock_filesystem_split");
+ }
+ filesystem_dock->set_split_offset(fs_split_ofs);
+
VSplitContainer*splits[DOCK_SLOT_MAX/2]={
left_l_vsplit,
left_r_vsplit,
@@ -4717,7 +4428,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String&
for(int i=0;i<DOCK_SLOT_MAX;i++) {
- if (!dock_slot[i]->is_hidden() && dock_slot[i]->get_tab_count()) {
+ if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) {
dock_slot[i]->set_current_tab(0);
}
}
@@ -4955,7 +4666,7 @@ void EditorNode::remove_bottom_panel_item(Control *p_item) {
for(int i=0;i<bottom_panel_items.size();i++) {
if (bottom_panel_items[i].control==p_item) {
- if (p_item->is_visible()) {
+ if (p_item->is_visible_in_tree()) {
_bottom_panel_switch(false,0);
}
bottom_panel_vb->remove_child(bottom_panel_items[i].control);
@@ -4982,7 +4693,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
for(int i=0;i<bottom_panel_items.size();i++) {
bottom_panel_items[i].button->set_pressed(i==p_idx);
- bottom_panel_items[i].control->set_hidden(i!=p_idx);
+ bottom_panel_items[i].control->set_visible(i==p_idx);
}
center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE);
center_split->set_collapsed(false);
@@ -4990,7 +4701,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable,int p_idx) {
for(int i=0;i<bottom_panel_items.size();i++) {
bottom_panel_items[i].button->set_pressed(false);
- bottom_panel_items[i].control->set_hidden(true);
+ bottom_panel_items[i].control->set_visible(false);
}
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
center_split->set_collapsed(true);
@@ -5057,10 +4768,9 @@ Variant EditorNode::drag_resource(const Ref<Resource>& p_res,Control* p_from) {
Control *drag_control = memnew( Control );
- TextureFrame *drag_preview = memnew( TextureFrame );
+ TextureRect *drag_preview = memnew( TextureRect );
Label* label=memnew( Label );
- waiting_for_sources_changed=true; //
Ref<Texture> preview;
{
@@ -5165,10 +4875,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String>& p_files, Control *
void EditorNode::_dropped_files(const Vector<String>& p_files,int p_screen) {
- String cur_path = scenes_dock->get_current_path();
- for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
- EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
- }
+ String cur_path = filesystem_dock->get_current_path();
+// for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
+// EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
+// }
}
void EditorNode::_file_access_close_error_notify(const String& p_str) {
@@ -5276,6 +4986,19 @@ void EditorNode::_call_build() {
}
}
+
+void EditorNode::_inherit_imported(const String& p_action) {
+
+ open_imported->hide();
+ load_scene(open_import_request,true,true);
+
+}
+
+void EditorNode::_open_imported() {
+
+ load_scene(open_import_request,true,false,true,true);
+}
+
void EditorNode::_bind_methods() {
@@ -5308,9 +5031,9 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_import_action",&EditorNode::_import_action);
//ClassDB::bind_method("_import",&EditorNode::_import);
-// ClassDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved);
+ //ClassDB::bind_method("_import_conflicts_solved",&EditorNode::_import_conflicts_solved);
ClassDB::bind_method("_open_recent_scene",&EditorNode::_open_recent_scene);
-// ClassDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
+ //ClassDB::bind_method("_open_recent_scene_confirm",&EditorNode::_open_recent_scene_confirm);
ClassDB::bind_method("_save_optimized",&EditorNode::_save_optimized);
@@ -5348,11 +5071,13 @@ void EditorNode::_bind_methods() {
- ClassDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
- ClassDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
- ClassDB::bind_method(_MD("get_gui_base"), &EditorNode::get_gui_base);
- ClassDB::bind_method(_MD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
+// ClassDB::bind_method(D_METHOD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin);
+ //ClassDB::bind_method(D_METHOD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin);
+ ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
+ ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch);
+ ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported);
+ ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported);
ADD_SIGNAL( MethodInfo("play_pressed") );
ADD_SIGNAL( MethodInfo("pause_pressed") );
@@ -5402,7 +5127,6 @@ EditorNode::EditorNode() {
FileAccess::set_backup_save(true);
- PathRemap::get_singleton()->clear_remaps();; //editor uses no remaps
TranslationServer::get_singleton()->set_enabled(false);
// load settings
if (!EditorSettings::get_singleton())
@@ -5438,6 +5162,37 @@ EditorNode::EditorNode() {
ResourceLoader::set_timestamp_on_load(true);
ResourceSaver::set_timestamp_on_save(true);
+
+ { //register importers at the begining, so dialogs are created with the right extensions
+ Ref<ResourceImporterTexture> import_texture;
+ import_texture.instance();
+ ResourceFormatImporter::get_singleton()->add_importer(import_texture);
+
+ Ref<ResourceImporterCSVTranslation> import_csv_translation;
+ import_csv_translation.instance();
+ ResourceFormatImporter::get_singleton()->add_importer(import_csv_translation);
+
+ Ref<ResourceImporterWAV> import_wav;
+ 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);
+
+ {
+ Ref<EditorSceneImporterCollada> import_collada;
+ import_collada.instance();
+ import_scene->add_importer(import_collada);
+ }
+
+ }
+
_pvrtc_register_compressors();
editor_selection = memnew( EditorSelection );
@@ -5454,15 +5209,13 @@ EditorNode::EditorNode() {
EditorFileDialog::register_func=_editor_file_dialog_register;
EditorFileDialog::unregister_func=_editor_file_dialog_unregister;
+ editor_export = memnew( EditorExport );
+ add_child(editor_export);
- editor_import_export = memnew( EditorImportExport );
- add_child(editor_import_export);
register_exporters();
- editor_import_export->load_config();
-
- GLOBAL_DEF("editor/main_run_args","$scene");
+ GLOBAL_DEF("editor/main_run_args","");
ClassDB::set_class_enabled("CollisionShape",true);
ClassDB::set_class_enabled("CollisionShape2D",true);
@@ -5497,7 +5250,7 @@ EditorNode::EditorNode() {
#if 0
PanelContainer *top_dark_panel = memnew( PanelContainer );
Ref<StyleBoxTexture> top_dark_sb;
- top_dark_sb.instance();;
+ 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);
@@ -5517,7 +5270,7 @@ EditorNode::EditorNode() {
menu_hb = memnew( HBoxContainer );
main_vbox->add_child(menu_hb);
-// top_dark_vb->add_child(scene_tabs);
+ //top_dark_vb->add_child(scene_tabs);
//left
left_l_hsplit = memnew( HSplitContainer );
main_vbox->add_child(left_l_hsplit);
@@ -5696,12 +5449,12 @@ EditorNode::EditorNode() {
//scene_root_base->add_child(scene_root);
//scene_root->set_meta("_editor_disable_input",true);
- VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport(),true);
+ VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(),true);
scene_root->set_disable_input(true);
scene_root->set_as_audio_listener_2d(true);
//scene_root->set_size_override(true,Size2(GlobalConfig::get_singleton()->get("display/width"),GlobalConfig::get_singleton()->get("display/height")));
-// scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) );
+ //scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) );
viewport = memnew( VBoxContainer );
@@ -5742,6 +5495,7 @@ EditorNode::EditorNode() {
ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD+KEY_TAB);
ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_TAB);
+ ED_SHORTCUT("editor/filter_files", TTR("Filter Files.."), KEY_MASK_ALT+KEY_MASK_CMD+KEY_P);
file_menu->set_tooltip(TTR("Operations with scene files."));
@@ -5761,14 +5515,12 @@ EditorNode::EditorNode() {
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);
p->add_shortcut(ED_SHORTCUT("editor/quick_open_script",TTR("Quick Open Script.."),KEY_MASK_ALT+KEY_MASK_CMD+KEY_O),FILE_QUICK_OPEN_SCRIPT);
- p->add_shortcut(ED_SHORTCUT("editor/quick_filter_files",TTR("Quick Filter Files.."),KEY_MASK_ALT+KEY_MASK_CMD+KEY_P),FILE_QUICK_OPEN_FILE);
p->add_separator();
PopupMenu *pm_export = memnew(PopupMenu );
pm_export->set_name("Export");
p->add_child(pm_export);
p->add_submenu_item(TTR("Convert To.."),"Export");
- pm_export->add_item(TTR("Translatable Strings.."),FILE_DUMP_STRINGS);
pm_export->add_separator();
pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_MeshLibrary", TTR("MeshLibrary..")), FILE_EXPORT_MESH_LIBRARY);
pm_export->add_shortcut(ED_SHORTCUT("editor/convert_to_TileSet", TTR("TileSet..")), FILE_EXPORT_TILESET);
@@ -5819,7 +5571,7 @@ EditorNode::EditorNode() {
#if 0
node_menu = memnew( MenuButton );
node_menu->set_text("Node");
- node_menu->set_pos( Point2( 50,0) );;
+ node_menu->set_pos( Point2( 50,0) );
menu_panel->add_child( node_menu );
p=node_menu->get_popup();
@@ -5934,8 +5686,8 @@ 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);
+ //VSeparator *s1 = memnew( VSeparator );
+ //play_hb->add_child(s1);
play_scene_button = memnew( ToolButton );
play_hb->add_child(play_scene_button);
@@ -6251,6 +6003,11 @@ EditorNode::EditorNode() {
property_editor->set_undo_redo(&editor_data.get_undo_redo());
+ import_dock = memnew( ImportDock );
+ dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(import_dock);
+ import_dock->set_name(TTR("Import"));
+
+
node_dock = memnew( NodeDock );
//node_dock->set_undoredo(&editor_data.get_undo_redo());
if (use_single_dock_column) {
@@ -6259,21 +6016,21 @@ EditorNode::EditorNode() {
dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock);
}
- scenes_dock = memnew( FileSystemDock(this) );
- scenes_dock->set_name(TTR("FileSystem"));
- scenes_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
+ filesystem_dock = memnew( FileSystemDock(this) );
+ filesystem_dock->set_name(TTR("FileSystem"));
+ filesystem_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
if (use_single_dock_column) {
- dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(scenes_dock);
+ dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(filesystem_dock);
left_r_vsplit->hide();
dock_slot[DOCK_SLOT_LEFT_UR]->hide();
dock_slot[DOCK_SLOT_LEFT_BR]->hide();
} else {
- dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock);
+ dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock);
}
- //prop_pallete->add_child(scenes_dock);
- scenes_dock->connect("open",this,"open_request");
- scenes_dock->connect("instance",this,"_instance_request");
+ //prop_pallete->add_child(filesystem_dock);
+ filesystem_dock->connect("open",this,"open_request");
+ filesystem_dock->connect("instance",this,"_instance_request");
const String docks_section = "docks";
@@ -6322,8 +6079,8 @@ EditorNode::EditorNode() {
bottom_pc->add_child(bottom_hb);*/
-// center_vb->add_child( log->get_button() );
-// log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ //center_vb->add_child( log->get_button() );
+ //log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL);
//progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -6338,7 +6095,7 @@ EditorNode::EditorNode() {
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");;
+ animation_menu->connect("pressed",this,"_animation_visibility_toggle");
*/
@@ -6371,15 +6128,15 @@ EditorNode::EditorNode() {
-// optimized_save = memnew( OptimizedSaveDialog(&editor_data) );
+ //optimized_save = memnew( OptimizedSaveDialog(&editor_data) );
//gui_base->add_child(optimized_save);
//optimized_save->connect("confirmed",this,"_save_optimized");
- project_export = memnew( ProjectExport(&editor_data) );
+ project_export = memnew( ProjectExportDialog );
gui_base->add_child(project_export);
- project_export_settings = memnew( ProjectExportDialog(this) );
- gui_base->add_child(project_export_settings);
+ //project_export_settings = memnew( ProjectExportDialog(this) );
+ //gui_base->add_child(project_export_settings);
//optimized_presets = memnew( OptimizedPresetsDialog(&editor_data) );
//gui_base->add_child(optimized_presets);
@@ -6432,7 +6189,7 @@ EditorNode::EditorNode() {
about_text->set_pos(Point2(gui_base->get_icon("Logo","EditorIcons")->get_size().width+30,20));
gui_base->add_child(about);
about->add_child(about_text);
- TextureFrame *logo = memnew( TextureFrame );
+ TextureRect *logo = memnew( TextureRect );
about->add_child(logo);
logo->set_pos(Point2(20,20));
logo->set_texture(gui_base->get_icon("Logo","EditorIcons") );
@@ -6493,8 +6250,8 @@ EditorNode::EditorNode() {
gui_base->add_child(file_script);
file_script->connect("file_selected",this,"_dialog_action");
- reimport_dialog = memnew( EditorReImportDialog );
- gui_base->add_child(reimport_dialog);
+ //reimport_dialog = memnew( EditorReImportDialog );
+ //gui_base->add_child(reimport_dialog);
@@ -6520,25 +6277,6 @@ EditorNode::EditorNode() {
file_server = memnew( EditorFileServer );
- editor_import_export->add_import_plugin( Ref<EditorTextureImportPlugin>( memnew(EditorTextureImportPlugin(this) )));
- Ref<EditorSceneImportPlugin> _scene_import = memnew(EditorSceneImportPlugin(this) );
- Ref<EditorSceneImporterCollada> _collada_import = memnew( EditorSceneImporterCollada);
- _scene_import->add_importer(_collada_import);
-// Ref<EditorSceneImporterFBXConv> _fbxconv_import = memnew( EditorSceneImporterFBXConv);
-// _scene_import->add_importer(_fbxconv_import);
- editor_import_export->add_import_plugin( _scene_import);
- // TODO: This plugin has no code, it should be either implemented or dropped (GH-3667)
- // editor_import_export->add_import_plugin( Ref<EditorSceneAnimationImportPlugin>( memnew(EditorSceneAnimationImportPlugin(this))));
- editor_import_export->add_import_plugin( Ref<EditorMeshImportPlugin>( memnew(EditorMeshImportPlugin(this))));
- editor_import_export->add_import_plugin( Ref<EditorFontImportPlugin>( memnew(EditorFontImportPlugin(this))));
- editor_import_export->add_import_plugin( Ref<EditorSampleImportPlugin>( memnew(EditorSampleImportPlugin(this))));
- editor_import_export->add_import_plugin( Ref<EditorTranslationImportPlugin>( memnew(EditorTranslationImportPlugin(this))));
- editor_import_export->add_import_plugin( Ref<EditorBitMaskImportPlugin>( memnew(EditorBitMaskImportPlugin(this))));
-
-
- editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin)));
- editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin)));
- editor_import_export->add_export_plugin( Ref<EditorSceneExportPlugin>( memnew(EditorSceneExportPlugin)));
add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) );
@@ -6546,6 +6284,9 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( SpatialEditorPlugin(this) ) );
add_editor_plugin( memnew( ScriptEditorPlugin(this) ) );
+
+ EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();
+
ScriptTextEditor::register_editor(); //register one for text scripts
if (StreamPeerSSL::is_available()) {
@@ -6562,21 +6303,21 @@ 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( 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( 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) ) );
@@ -6585,16 +6326,18 @@ EditorNode::EditorNode() {
add_editor_plugin( memnew( Particles2DEditorPlugin(this) ) );
add_editor_plugin( memnew( GIProbeEditorPlugin(this) ) );
add_editor_plugin( memnew( Path2DEditorPlugin(this) ) );
-// add_editor_plugin( memnew( PathEditorPlugin(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) ) );
add_editor_plugin( memnew( NavigationPolygonEditorPlugin(this) ) );
add_editor_plugin( memnew( ColorRampEditorPlugin(this) ) );
add_editor_plugin( memnew( CollisionShape2DEditorPlugin(this) ) );
add_editor_plugin( memnew( TextureEditorPlugin(this) ) );
-// add_editor_plugin( memnew( MaterialEditorPlugin(this) ) );
-// add_editor_plugin( memnew( MeshEditorPlugin(this) ) );
+ add_editor_plugin( memnew( AudioBusesEditorPlugin(audio_bus_editor) ) );
+ //add_editor_plugin( memnew( MaterialEditorPlugin(this) ) );
+ //add_editor_plugin( memnew( MeshEditorPlugin(this) ) );
for(int i=0;i<EditorPlugins::get_plugin_count();i++)
add_editor_plugin( EditorPlugins::create(i,this) );
@@ -6603,6 +6346,9 @@ EditorNode::EditorNode() {
plugin_init_callbacks[i]();
}
+
+
+
/*resource_preview->add_preview_generator( Ref<EditorTexturePreviewPlugin>( memnew(EditorTexturePreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorPackedScenePreviewPlugin>( memnew(EditorPackedScenePreviewPlugin )));
resource_preview->add_preview_generator( Ref<EditorMaterialPreviewPlugin>( memnew(EditorMaterialPreviewPlugin )));
@@ -6614,7 +6360,7 @@ EditorNode::EditorNode() {
circle_step_msec=OS::get_singleton()->get_ticks_msec();
- circle_step_frame=OS::get_singleton()->get_frames_drawn();
+ circle_step_frame=Engine::get_singleton()->get_frames_drawn();
circle_step=0;
_rebuild_import_menu();
@@ -6622,7 +6368,7 @@ EditorNode::EditorNode() {
editor_plugin_screen=NULL;
editor_plugins_over = memnew(EditorPluginList);
-// force_top_viewport(true);
+ //force_top_viewport(true);
_edit_current();
current=NULL;
@@ -6631,7 +6377,7 @@ EditorNode::EditorNode() {
ScriptServer::set_scripting_enabled(false); // no scripting by default if editor
-// GlobalConfig::get_singleton()->set("render/room_cull_enabled",false);
+ //GlobalConfig::get_singleton()->set("render/room_cull_enabled",false);
reference_resource_mem=true;
save_external_resources_mem=true;
@@ -6659,6 +6405,14 @@ EditorNode::EditorNode() {
}
}
+ open_imported = memnew( ConfirmationDialog );
+ open_imported->get_ok()->set_text(TTR("Open Anyway"));
+ new_inherited_button=open_imported->add_button("New Inherited",!OS::get_singleton()->get_swap_ok_cancel(),"inherit");
+ open_imported->connect("confirmed",this,"_open_imported");
+ open_imported->connect("custom_action",this,"_inherit_imported");
+ gui_base->add_child(open_imported);
+
+
//edited_scene=NULL;
saved_version=1;
@@ -6684,9 +6438,9 @@ EditorNode::EditorNode() {
set_process_unhandled_input(true);
_playing_edited=false;
-// Panel *errors = memnew( Panel );
+ //Panel *errors = memnew( Panel );
load_errors = memnew( RichTextLabel );
-// load_errors->set_readonly(true);
+ //load_errors->set_readonly(true);
load_error_dialog = memnew( AcceptDialog );
load_error_dialog->add_child(load_errors);
load_error_dialog->set_title(TTR("Load Errors"));
@@ -6722,8 +6476,8 @@ EditorNode::EditorNode() {
pick_main_scene->get_ok()->set_text("Select");
pick_main_scene->connect("confirmed",this,"_menu_option",varray(SETTINGS_PICK_MAIN_SCENE));
-// Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
-// OS::get_singleton()->set_icon( it->get_data() );
+ //Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
+ //OS::get_singleton()->set_icon( it->get_data() );
for(int i=0;i<_init_callbacks.size();i++)
_init_callbacks[i]();
@@ -6749,6 +6503,7 @@ EditorNode::EditorNode() {
FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify);
+ waiting_for_first_scan=true;
}
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 2cb1cd00ab..41c1012ff0 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -50,6 +50,7 @@
#include "tools/editor/reparent_dialog.h"
#include "tools/editor/connections_dialog.h"
#include "tools/editor/node_dock.h"
+#include "tools/editor/import_dock.h"
#include "tools/editor/settings_config_dialog.h"
#include "tools/editor/groups_editor.h"
#include "tools/editor/editor_data.h"
@@ -72,7 +73,7 @@
#include "tools/editor/quick_open.h"
#include "tools/editor/project_export.h"
#include "tools/editor/editor_sub_scene.h"
-#include "editor_import_export.h"
+#include "editor_export.h"
#include "editor_reimport_dialog.h"
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_name_dialog.h"
@@ -134,12 +135,10 @@ private:
FILE_EXPORT_MESH_LIBRARY,
FILE_EXPORT_TILESET,
FILE_SAVE_OPTIMIZED,
- FILE_DUMP_STRINGS,
FILE_OPEN_RECENT,
FILE_OPEN_OLD_SCENE,
FILE_QUICK_OPEN_SCENE,
FILE_QUICK_OPEN_SCRIPT,
- FILE_QUICK_OPEN_FILE,
FILE_RUN_SCRIPT,
FILE_OPEN_PREV,
FILE_CLOSE,
@@ -197,7 +196,9 @@ private:
IMPORT_PLUGIN_BASE=100,
- OBJECT_METHOD_BASE=500
+ OBJECT_METHOD_BASE=500,
+
+ TOOL_MENU_BASE=1000
};
@@ -277,8 +278,9 @@ private:
//ResourcesDock *resources_dock;
PropertyEditor *property_editor;
NodeDock *node_dock;
+ ImportDock *import_dock;
VBoxContainer *prop_editor_vb;
- FileSystemDock *scenes_dock;
+ FileSystemDock *filesystem_dock;
EditorRunNative *run_native;
HBoxContainer *search_bar;
@@ -286,7 +288,7 @@ private:
CreateDialog *create_dialog;
-// CallDialog *call_dialog;
+ //CallDialog *call_dialog;
ConfirmationDialog *confirmation;
ConfirmationDialog *import_confirmation;
ConfirmationDialog *open_recent_confirmation;
@@ -317,9 +319,6 @@ private:
//TabContainer *prop_pallete;
//TabContainer *top_pallete;
String defer_load_scene;
- String defer_translatable;
- String defer_optimize;
- String defer_optimize_preset;
String defer_export;
String defer_export_platform;
bool defer_export_debug;
@@ -339,7 +338,7 @@ private:
Vector<ToolButton*> main_editor_buttons;
Vector<EditorPlugin*> editor_table;
- EditorReImportDialog *reimport_dialog;
+// EditorReImportDialog *reimport_dialog;
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
@@ -347,6 +346,10 @@ private:
DependencyErrorDialog *dependency_error;
DependencyEditor *dependency_fixer;
OrphanResourcesDialog *orphan_resources;
+ ConfirmationDialog *open_imported;
+ Button *new_inherited_button;
+ String open_import_request;
+
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
@@ -362,7 +365,7 @@ private:
String _tmp_import_path;
- EditorImportExport *editor_import_export;
+ EditorExport *editor_export;
Object *current;
@@ -375,6 +378,7 @@ private:
bool unsaved_cache;
String open_navigate;
bool changing_scene;
+ bool waiting_for_first_scan;
bool waiting_for_sources_changed;
@@ -390,8 +394,8 @@ private:
EditorData editor_data;
EditorRun editor_run;
EditorSelection *editor_selection;
- ProjectExport *project_export;
- ProjectExportDialog *project_export_settings;
+// ProjectExport *project_export;
+ ProjectExportDialog *project_export;
EditorResourcePreview *resource_preview;
EditorFileServer *file_server;
@@ -428,6 +432,7 @@ private:
void _menu_option(int p_option);
void _menu_confirm_current();
void _menu_option_confirm(int p_option,bool p_confirmed);
+ void _update_debug_options();
void _property_editor_forward();
void _property_editor_back();
@@ -487,7 +492,6 @@ private:
static void _load_error_notify(void* p_ud,const String& p_text);
bool has_main_screen() const { return true; }
- void _fetch_translatable_strings(const Object *p_object,Set<StringName>& strings);
bool _find_editing_changed_scene(Node *p_from);
@@ -585,6 +589,8 @@ private:
MAX_BUILD_CALLBACKS=128
};
+ void _inherit_imported(const String &p_action);
+ void _open_imported();
static int plugin_init_callback_count;
@@ -593,6 +599,22 @@ private:
void _call_build();
static int build_callback_count;
static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
+
+ bool _initializing_tool_menu;
+
+ struct ToolMenuItem {
+ String name;
+ String submenu;
+ Variant ud;
+ ObjectID handler;
+ String callback;
+ };
+
+ Vector<ToolMenuItem> tool_menu_items;
+
+ void _tool_menu_insert_item(const ToolMenuItem& p_item);
+ void _rebuild_tool_menu() const;
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -630,9 +652,6 @@ public:
void add_control_to_dock(DockSlot p_slot,Control* p_control);
void remove_control_from_dock(Control* p_control);
- void add_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
- void remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
-
void set_addon_plugin_enabled(const String& p_addon,bool p_enabled);
bool is_addon_plugin_enabled(const String &p_addon) const;
@@ -669,11 +688,10 @@ public:
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
- Error save_optimized_copy(const String& p_scene,const String& p_preset);
void fix_dependencies(const String& p_for_file);
void clear_scene() { _cleanup_scene(); }
- Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true);
+ Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true,bool p_force_open_imported=false);
Error load_resource(const String& p_scene);
bool is_scene_open(const String& p_path);
@@ -688,14 +706,13 @@ public:
void request_instance_scene(const String &p_path);
void request_instance_scenes(const Vector<String>& p_files);
- FileSystemDock *get_scenes_dock();
+ FileSystemDock *get_filesystem_dock();
+ ImportDock *get_import_dock();
SceneTreeDock *get_scene_tree_dock();
static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
EditorSelection *get_editor_selection() { return editor_selection; }
- Error save_translatable_strings(const String& p_to_file);
-
void set_convert_old_scene(bool p_old) { convert_old=p_old; }
void notify_child_process_exited();
@@ -755,6 +772,9 @@ public:
Variant drag_files(const Vector<String>& p_files,Control* p_from);
Variant drag_files_and_dirs(const Vector<String>& p_files,Control* p_from);
+ 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, PopupMenu *p_submenu);
+ void remove_tool_menu_item(const String& p_name);
EditorNode();
~EditorNode();
@@ -767,7 +787,6 @@ public:
};
-
struct EditorProgress {
String task;
diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp
index b359522e4f..8cd31c4bcc 100644
--- a/tools/editor/editor_path.cpp
+++ b/tools/editor/editor_path.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_path.h"
+
#include "editor_scale.h"
#include "editor_node.h"
diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp
index 8769fe2cd8..2a0efa5be9 100644
--- a/tools/editor/editor_plugin.cpp
+++ b/tools/editor/editor_plugin.cpp
@@ -27,6 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_plugin.h"
+
+#include "scene/gui/popup_menu.h"
#include "scene/3d/camera.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
@@ -132,6 +134,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Co
}
}
+void EditorPlugin::add_tool_menu_item(const String& p_name, Object *p_handler, const String& p_callback, const Variant& p_ud) {
+
+ //EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud);
+}
+
+void EditorPlugin::add_tool_submenu_item(const String& p_name, Object *p_submenu) {
+
+ ERR_FAIL_NULL(p_submenu);
+ PopupMenu *submenu = p_submenu->cast_to<PopupMenu>();
+ ERR_FAIL_NULL(submenu);
+ //EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
+}
+
+void EditorPlugin::remove_tool_menu_item(const String& p_name) {
+
+ //EditorNode::get_singleton()->remove_tool_menu_item(p_name);
+}
+
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
@@ -299,27 +319,6 @@ EditorResourcePreview *EditorPlugin::get_resource_previewer() {
return EditorResourcePreview::get_singleton();
}
-void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
-
- EditorNode::get_singleton()->add_editor_import_plugin(p_editor_import);
-}
-
-void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import){
-
- EditorNode::get_singleton()->remove_editor_import_plugin(p_editor_import);
-
-}
-
-void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
-
- EditorImportExport::get_singleton()->add_export_plugin(p_editor_export);
-}
-void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
-
- EditorImportExport::get_singleton()->remove_export_plugin(p_editor_export);
-
-}
-
Control *EditorPlugin::get_base_control() {
return EditorNode::get_singleton()->get_gui_base();
@@ -346,36 +345,33 @@ EditorFileSystem *EditorPlugin::get_resource_file_system() {
void EditorPlugin::_bind_methods() {
- ClassDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
- ClassDB::bind_method(_MD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
- ClassDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
- ClassDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
- ClassDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
- ClassDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
- ClassDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
- ClassDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
-
- ClassDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
- ClassDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
-
- ClassDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin);
- ClassDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin);
-
- ClassDB::bind_method(_MD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer);
- ClassDB::bind_method(_MD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system);
-
- ClassDB::bind_method(_MD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
- ClassDB::bind_method(_MD("update_canvas"),&EditorPlugin::update_canvas);
-
- ClassDB::bind_method(_MD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
- ClassDB::bind_method(_MD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
-
- ClassDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
- ClassDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
- ClassDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
- ClassDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
- ClassDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout);
- ClassDB::bind_method(_MD("edit_resource"),&EditorPlugin::edit_resource);
+ ClassDB::bind_method(D_METHOD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
+ ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
+ ClassDB::bind_method(D_METHOD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
+ ClassDB::bind_method(D_METHOD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
+ ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
+ //ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"),&EditorPlugin::add_tool_menu_item,DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu:PopupMenu"),&EditorPlugin::add_tool_submenu_item);
+ //ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item);
+ ClassDB::bind_method(D_METHOD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
+ ClassDB::bind_method(D_METHOD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
+ ClassDB::bind_method(D_METHOD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
+
+ ClassDB::bind_method(D_METHOD("get_resource_previewer:EditorResourcePreview"),&EditorPlugin::get_resource_previewer);
+ ClassDB::bind_method(D_METHOD("get_resource_filesystem:EditorFileSystem"),&EditorPlugin::get_resource_file_system);
+
+ ClassDB::bind_method(D_METHOD("inspect_object","object","for_property"),&EditorPlugin::inspect_object,DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("update_canvas"),&EditorPlugin::update_canvas);
+
+ ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible","item:Control"), &EditorPlugin::make_bottom_panel_item_visible);
+ ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
+
+ ClassDB::bind_method(D_METHOD("get_base_control:Control"),&EditorPlugin::get_base_control);
+ 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("queue_save_layout"),&EditorPlugin::queue_save_layout);
+ ClassDB::bind_method(D_METHOD("edit_resource"),&EditorPlugin::edit_resource);
ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"forward_canvas_gui_input",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::INPUT_EVENT,"event")));
ClassDB::add_virtual_method(get_class_static(),MethodInfo("forward_draw_over_canvas",PropertyInfo(Variant::TRANSFORM2D,"canvas_xform"),PropertyInfo(Variant::OBJECT,"canvas:Control")));
diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h
index 9943e94d98..13d8ab0343 100644
--- a/tools/editor/editor_plugin.h
+++ b/tools/editor/editor_plugin.h
@@ -43,7 +43,7 @@ class EditorNode;
class Spatial;
class Camera;
class EditorSelection;
-class EditorImportExport;
+class EditorExport;
class EditorSettings;
class SpatialEditorGizmo;
class EditorImportPlugin;
@@ -103,6 +103,10 @@ public:
Control* get_editor_viewport();
void edit_resource(const Ref<Resource>& p_resource);
+ 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);
+ void remove_tool_menu_item(const String& p_name);
+
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual bool forward_canvas_gui_input(const Transform2D& p_canvas_xform, const InputEvent& p_event);
virtual void forward_draw_over_canvas(const Transform2D& p_canvas_xform,Control *p_canvas);
@@ -135,12 +139,6 @@ public:
void make_bottom_panel_item_visible(Control *p_item);
void hide_bottom_panel();
- void add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
- void remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
-
- void add_export_plugin(const Ref<EditorExportPlugin>& p_editor_export);
- void remove_export_plugin(const Ref<EditorExportPlugin>& p_editor_export);
-
EditorSelection* get_selection();
//EditorImportExport *get_import_export();
EditorSettings *get_editor_settings();
diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp
index 208e576a8a..2d879e38cf 100644
--- a/tools/editor/editor_plugin_settings.cpp
+++ b/tools/editor/editor_plugin_settings.cpp
@@ -27,11 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_plugin_settings.h"
+
#include "scene/gui/margin_container.h"
#include "io/config_file.h"
#include "os/file_access.h"
#include "os/main_loop.h"
-#include "globals.h"
+#include "global_config.h"
#include "editor_node.h"
void EditorPluginSettings::_notification(int p_what) {
diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp
index c527aae385..d9a4174246 100644
--- a/tools/editor/editor_profiler.cpp
+++ b/tools/editor/editor_profiler.cpp
@@ -1,4 +1,33 @@
+/*************************************************************************/
+/* editor_profiler.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_profiler.h"
+
#include "editor_settings.h"
#include "os/os.h"
@@ -349,7 +378,7 @@ void EditorProfiler::_update_plot() {
}
- graph_texture->set_data(img);;
+ graph_texture->set_data(img);
graph->set_texture(graph_texture);
@@ -617,16 +646,16 @@ void EditorProfiler::_combo_changed(int) {
void EditorProfiler::_bind_methods() {
- ClassDB::bind_method(_MD("_update_frame"),&EditorProfiler::_update_frame);
- ClassDB::bind_method(_MD("_update_plot"),&EditorProfiler::_update_plot);
- ClassDB::bind_method(_MD("_activate_pressed"),&EditorProfiler::_activate_pressed);
- ClassDB::bind_method(_MD("_graph_tex_draw"),&EditorProfiler::_graph_tex_draw);
- ClassDB::bind_method(_MD("_graph_tex_input"),&EditorProfiler::_graph_tex_input);
- ClassDB::bind_method(_MD("_graph_tex_mouse_exit"),&EditorProfiler::_graph_tex_mouse_exit);
- ClassDB::bind_method(_MD("_cursor_metric_changed"),&EditorProfiler::_cursor_metric_changed);
- ClassDB::bind_method(_MD("_combo_changed"),&EditorProfiler::_combo_changed);
+ ClassDB::bind_method(D_METHOD("_update_frame"),&EditorProfiler::_update_frame);
+ ClassDB::bind_method(D_METHOD("_update_plot"),&EditorProfiler::_update_plot);
+ ClassDB::bind_method(D_METHOD("_activate_pressed"),&EditorProfiler::_activate_pressed);
+ ClassDB::bind_method(D_METHOD("_graph_tex_draw"),&EditorProfiler::_graph_tex_draw);
+ ClassDB::bind_method(D_METHOD("_graph_tex_input"),&EditorProfiler::_graph_tex_input);
+ ClassDB::bind_method(D_METHOD("_graph_tex_mouse_exit"),&EditorProfiler::_graph_tex_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_cursor_metric_changed"),&EditorProfiler::_cursor_metric_changed);
+ ClassDB::bind_method(D_METHOD("_combo_changed"),&EditorProfiler::_combo_changed);
- ClassDB::bind_method(_MD("_item_edited"),&EditorProfiler::_item_edited);
+ ClassDB::bind_method(D_METHOD("_item_edited"),&EditorProfiler::_item_edited);
ADD_SIGNAL( MethodInfo("enable_profiling",PropertyInfo(Variant::BOOL,"enable")));
ADD_SIGNAL( MethodInfo("break_request"));
@@ -708,7 +737,7 @@ EditorProfiler::EditorProfiler()
variables->connect("item_edited",this,"_item_edited");
- graph = memnew( TextureFrame );
+ graph = memnew( TextureRect );
graph->set_expand(true);
graph->set_mouse_filter(MOUSE_FILTER_STOP);
//graph->set_ignore_mouse(false);
@@ -724,7 +753,7 @@ EditorProfiler::EditorProfiler()
int metric_size=CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size",600)),60,1024);
frame_metrics.resize(metric_size);
last_metric=-1;
-// cursor_metric=-1;
+ //cursor_metric=-1;
hover_metric=-1;
@@ -750,6 +779,6 @@ EditorProfiler::EditorProfiler()
seeking=false;
graph_height=1;
-// activate->set_disabled(true);
+ //activate->set_disabled(true);
}
diff --git a/tools/editor/editor_profiler.h b/tools/editor/editor_profiler.h
index 233bc2e0fd..bf89e3939c 100644
--- a/tools/editor/editor_profiler.h
+++ b/tools/editor/editor_profiler.h
@@ -1,9 +1,37 @@
+/*************************************************************************/
+/* editor_profiler.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 EDITORPROFILER_H
#define EDITORPROFILER_H
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
#include "scene/gui/tree.h"
@@ -71,7 +99,7 @@ public:
private:
Button *activate;
- TextureFrame *graph;
+ TextureRect *graph;
Ref<ImageTexture> graph_texture;
PoolVector<uint8_t> graph_image;
Tree *variables;
diff --git a/tools/editor/editor_reimport_dialog.cpp b/tools/editor/editor_reimport_dialog.cpp
index c6a8f13dc7..5904070230 100644
--- a/tools/editor/editor_reimport_dialog.cpp
+++ b/tools/editor/editor_reimport_dialog.cpp
@@ -27,8 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_reimport_dialog.h"
+
#include "editor_file_system.h"
#include "editor_node.h"
+
+#if 0
void EditorReImportDialog::popup_reimport() {
if (EditorFileSystem::get_singleton()->is_scanning()) {
@@ -142,3 +145,4 @@ EditorReImportDialog::EditorReImportDialog() {
scene_must_save=false;
}
+#endif
diff --git a/tools/editor/editor_reimport_dialog.h b/tools/editor/editor_reimport_dialog.h
index 68e1ca0597..7379c70c5e 100644
--- a/tools/editor/editor_reimport_dialog.h
+++ b/tools/editor/editor_reimport_dialog.h
@@ -29,6 +29,7 @@
#ifndef EDITOR_REIMPORT_DIALOG_H
#define EDITOR_REIMPORT_DIALOG_H
+#if 0
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
@@ -49,3 +50,4 @@ public:
};
#endif // EDITOR_REIMPORT_DIALOG_H
+#endif
diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp
index 76ae53d821..ab2226e79a 100644
--- a/tools/editor/editor_resource_preview.cpp
+++ b/tools/editor/editor_resource_preview.cpp
@@ -27,11 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_resource_preview.h"
+
#include "editor_settings.h"
#include "os/file_access.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
-#include "globals.h"
+#include "global_config.h"
#include "editor_scale.h"
#include "message_queue.h"
@@ -378,11 +379,11 @@ void EditorResourcePreview::_bind_methods() {
ClassDB::bind_method("_preview_ready",&EditorResourcePreview::_preview_ready);
- ClassDB::bind_method(_MD("queue_resource_preview","path","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_resource_preview);
- ClassDB::bind_method(_MD("queue_edited_resource_preview","resource:Resource","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_edited_resource_preview);
- ClassDB::bind_method(_MD("add_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::add_preview_generator);
- ClassDB::bind_method(_MD("remove_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::remove_preview_generator);
- ClassDB::bind_method(_MD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation);
+ ClassDB::bind_method(D_METHOD("queue_resource_preview","path","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_resource_preview);
+ ClassDB::bind_method(D_METHOD("queue_edited_resource_preview","resource:Resource","receiver","receiver_func","userdata:Variant"),&EditorResourcePreview::queue_edited_resource_preview);
+ ClassDB::bind_method(D_METHOD("add_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::add_preview_generator);
+ ClassDB::bind_method(D_METHOD("remove_preview_generator","generator:EditorResourcePreviewGenerator"),&EditorResourcePreview::remove_preview_generator);
+ ClassDB::bind_method(D_METHOD("check_for_invalidation","path"),&EditorResourcePreview::check_for_invalidation);
ADD_SIGNAL(MethodInfo("preview_invalidated",PropertyInfo(Variant::STRING,"path")));
diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp
index 7d79412b3b..46e400ae7f 100644
--- a/tools/editor/editor_run.cpp
+++ b/tools/editor/editor_run.cpp
@@ -27,14 +27,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_run.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "editor_settings.h"
EditorRun::Status EditorRun::get_status() const {
return status;
}
-Error EditorRun::run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints,const String& p_edited_scene) {
+Error EditorRun::run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints) {
List<String> args;
@@ -140,11 +141,15 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List
args.push_back(bpoints);
}
+
+ if (p_scene!="") {
+ args.push_back(p_scene);
+ }
if (p_custom_args!="") {
Vector<String> cargs=p_custom_args.split(" ",false);
for(int i=0;i<cargs.size();i++) {
- args.push_back(cargs[i].replace("$scene",p_scene).replace(" ","%20"));
+ args.push_back(cargs[i].replace(" ","%20"));
}
}
diff --git a/tools/editor/editor_run.h b/tools/editor/editor_run.h
index 78fa892488..46c5dc7521 100644
--- a/tools/editor/editor_run.h
+++ b/tools/editor/editor_run.h
@@ -49,7 +49,7 @@ private:
public:
Status get_status() const;
- Error run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints,const String& p_edited_scene);
+ Error run(const String& p_scene,const String p_custom_args,const List<String>& p_breakpoints);
void run_native_notify() { status=STATUS_PLAY; }
void stop();
diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp
index caa1bf5db7..60a9f53b94 100644
--- a/tools/editor/editor_run_native.cpp
+++ b/tools/editor/editor_run_native.cpp
@@ -27,12 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_run_native.h"
-#include "editor_import_export.h"
+#include "editor_export.h"
void EditorRunNative::_notification(int p_what) {
-
+#if 0
if (p_what==NOTIFICATION_ENTER_TREE) {
List<StringName> ep;
@@ -97,11 +97,12 @@ void EditorRunNative::_notification(int p_what) {
first=false;
}
}
-
+#endif
}
void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
+#if 0
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform);
ERR_FAIL_COND(eep.is_null());
if (p_idx == -1) {
@@ -125,6 +126,8 @@ void EditorRunNative::_run_native(int p_idx,const String& p_platform) {
flags|=EditorExportPlatform::EXPORT_VIEW_NAVIGATION;
eep->run(p_idx,flags);
+
+#endif
}
void EditorRunNative::_bind_methods() {
diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp
index c8f3f9fc5d..77dc7bd4bf 100644
--- a/tools/editor/editor_run_script.cpp
+++ b/tools/editor/editor_run_script.cpp
@@ -27,11 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_run_script.h"
-#include "editor_node.h"
-
-
-
+#include "editor_node.h"
void EditorScript::add_root_node(Node *p_node) {
@@ -46,7 +43,7 @@ void EditorScript::add_root_node(Node *p_node) {
return;
}
-// editor->set_edited_scene(p_node);
+ //editor->set_edited_scene(p_node);
}
Node *EditorScript::get_scene() {
@@ -86,8 +83,8 @@ void EditorScript::set_editor(EditorNode *p_editor) {
void EditorScript::_bind_methods() {
- ClassDB::bind_method(_MD("add_root_node","node"),&EditorScript::add_root_node);
- ClassDB::bind_method(_MD("get_scene"),&EditorScript::get_scene);
+ ClassDB::bind_method(D_METHOD("add_root_node","node"),&EditorScript::add_root_node);
+ ClassDB::bind_method(D_METHOD("get_scene"),&EditorScript::get_scene);
BIND_VMETHOD( MethodInfo("_run") );
diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp
index 8575e1c30a..5687f97b22 100644
--- a/tools/editor/editor_scale.cpp
+++ b/tools/editor/editor_scale.cpp
@@ -1,4 +1,33 @@
+/*************************************************************************/
+/* editor_scale.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_scale.h"
+
#include "os/os.h"
static float scale = 1.0;
diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h
index 90e575f771..035a5056c1 100644
--- a/tools/editor/editor_scale.h
+++ b/tools/editor/editor_scale.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* editor_scale.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_SCALE_H
#define EDITOR_SCALE_H
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index 50bd629b67..f977a40243 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http:/www.godotengine.org */
+/* http:/www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
@@ -27,20 +27,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_settings.h"
+
#include "os/os.h"
#include "os/dir_access.h"
#include "os/file_access.h"
-
#include "version.h"
#include "scene/main/scene_main_loop.h"
-#include "os/os.h"
#include "scene/main/node.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "scene/main/viewport.h"
#include "io/config_file.h"
#include "editor_node.h"
-#include "globals.h"
+#include "global_config.h"
#include "translations.h"
#include "io/file_access_memory.h"
#include "io/translation_loader_po.h"
@@ -127,7 +126,7 @@ bool EditorSettings::_get(const StringName& p_name,Variant &r_ret) const {
const VariantContainer *v=props.getptr(p_name);
if (!v) {
- //print_line("WARNING NOT FOUND: "+String(p_name));
+ print_line("EditorSettings::_get - Warning, not found: "+String(p_name));
return false;
}
r_ret = v->variant;
@@ -243,13 +242,20 @@ void EditorSettings::create() {
String exe_path = OS::get_singleton()->get_executable_path().get_base_dir();
DirAccess* d = DirAccess::create_for_path(exe_path);
+ bool self_contained = false;
if (d->file_exists(exe_path + "/._sc_")) {
+ self_contained = true;
+ extra_config->load(exe_path + "/._sc_");
+ } else if (d->file_exists(exe_path + "/_sc_")) {
+ self_contained = true;
+ extra_config->load(exe_path + "/_sc_");
+ }
+ if (self_contained) {
// editor is self contained
config_path = exe_path;
config_dir = "editor_data";
- extra_config->load(exe_path + "/._sc_");
} else {
if (OS::get_singleton()->has_environment("APPDATA")) {
@@ -654,6 +660,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("run/auto_save/save_before_running",true);
+ set("run/output/always_clear_output_on_play",true);
+ set("run/output/always_open_output_on_play",true);
+ set("run/output/always_close_output_on_stop",false);
set("filesystem/resources/save_compressed_resources",true);
set("filesystem/resources/auto_reload_modified_images",true);
@@ -714,6 +723,7 @@ void EditorSettings::_load_default_text_editor_theme() {
set("text_editor/highlighting/selection_color",Color::html("7b5dbe"));
set("text_editor/highlighting/brace_mismatch_color",Color(1,0.2,0.2));
set("text_editor/highlighting/current_line_color",Color(0.3,0.5,0.8,0.15));
+ set("text_editor/highlighting/line_length_guideline_color",Color(0.3,0.5,0.8,0.1));
set("text_editor/highlighting/mark_color", Color(1.0,0.4,0.4,0.4));
set("text_editor/highlighting/breakpoint_color", Color(0.8,0.8,0.4,0.2));
set("text_editor/highlighting/word_highlighted_color",Color(0.8,0.9,0.9,0.15));
@@ -846,8 +856,8 @@ void EditorSettings::list_text_editor_themes() {
d->list_dir_begin();
String file = d->get_next();
while(file != String()) {
- if (file.extension() == "tet" && file.basename().to_lower() != "default") {
- themes += "," + file.basename();
+ if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default") {
+ themes += "," + file.get_basename();
}
file = d->get_next();
}
@@ -971,6 +981,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
cf->set_value(theme_section, "selection_color", ((Color)get("text_editor/highlighting/selection_color")).to_html());
cf->set_value(theme_section, "brace_mismatch_color", ((Color)get("text_editor/highlighting/brace_mismatch_color")).to_html());
cf->set_value(theme_section, "current_line_color", ((Color)get("text_editor/highlighting/current_line_color")).to_html());
+ cf->set_value(theme_section, "line_length_guideline_color", ((Color)get("text_editor/highlighting/line_length_guideline_color")).to_html());
cf->set_value(theme_section, "mark_color", ((Color)get("text_editor/highlighting/mark_color")).to_html());
cf->set_value(theme_section, "breakpoint_color", ((Color)get("text_editor/highlighting/breakpoint_color")).to_html());
cf->set_value(theme_section, "word_highlighted_color", ((Color)get("text_editor/highlighting/word_highlighted_color")).to_html());
@@ -1026,42 +1037,38 @@ void EditorSettings::set_optimize_save(bool p_optimize) {
optimize_save=p_optimize;
}
-String EditorSettings::get_last_selected_language()
-{
+Variant EditorSettings::get_project_metadata(const String& p_section, const String& p_key, Variant p_default) {
Ref<ConfigFile> cf = memnew( ConfigFile );
String path = get_project_settings_path().plus_file("project_metadata.cfg");
Error err = cf->load(path);
if (err != OK) {
- return "";
+ return p_default;
}
- Variant last_selected_language = cf->get_value("script_setup", "last_selected_language");
- if (last_selected_language.get_type() != Variant::STRING)
- return "";
- return static_cast<String>(last_selected_language);
+ return cf->get_value(p_section, p_key, p_default);
}
-void EditorSettings::set_last_selected_language(String p_language)
+void EditorSettings::set_project_metadata(const String& p_section, const String& p_key, Variant p_data)
{
Ref<ConfigFile> cf = memnew( ConfigFile );
String path = get_project_settings_path().plus_file("project_metadata.cfg");
cf->load(path);
- cf->set_value("script_setup", "last_selected_language", p_language);
+ cf->set_value(p_section, p_key, p_data);
cf->save(path);
}
void EditorSettings::_bind_methods() {
- ClassDB::bind_method(_MD("erase","property"),&EditorSettings::erase);
- ClassDB::bind_method(_MD("get_settings_path"),&EditorSettings::get_settings_path);
- ClassDB::bind_method(_MD("get_project_settings_path"),&EditorSettings::get_project_settings_path);
+ ClassDB::bind_method(D_METHOD("erase","property"),&EditorSettings::erase);
+ ClassDB::bind_method(D_METHOD("get_settings_path"),&EditorSettings::get_settings_path);
+ ClassDB::bind_method(D_METHOD("get_project_settings_path"),&EditorSettings::get_project_settings_path);
- ClassDB::bind_method(_MD("add_property_info", "info"),&EditorSettings::_add_property_info_bind);
+ ClassDB::bind_method(D_METHOD("add_property_info", "info"),&EditorSettings::_add_property_info_bind);
- ClassDB::bind_method(_MD("set_favorite_dirs","dirs"),&EditorSettings::set_favorite_dirs);
- ClassDB::bind_method(_MD("get_favorite_dirs"),&EditorSettings::get_favorite_dirs);
+ ClassDB::bind_method(D_METHOD("set_favorite_dirs","dirs"),&EditorSettings::set_favorite_dirs);
+ ClassDB::bind_method(D_METHOD("get_favorite_dirs"),&EditorSettings::get_favorite_dirs);
- ClassDB::bind_method(_MD("set_recent_dirs","dirs"),&EditorSettings::set_recent_dirs);
- ClassDB::bind_method(_MD("get_recent_dirs"),&EditorSettings::get_recent_dirs);
+ ClassDB::bind_method(D_METHOD("set_recent_dirs","dirs"),&EditorSettings::set_recent_dirs);
+ ClassDB::bind_method(D_METHOD("get_recent_dirs"),&EditorSettings::get_recent_dirs);
ADD_SIGNAL(MethodInfo("settings_changed"));
@@ -1105,7 +1112,7 @@ EditorSettings::EditorSettings() {
EditorSettings::~EditorSettings() {
-// singleton=NULL;
+ //singleton=NULL;
}
Ref<ShortCut> ED_GET_SHORTCUT(const String& p_path) {
diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h
index c11feef667..809389eb40 100644
--- a/tools/editor/editor_settings.h
+++ b/tools/editor/editor_settings.h
@@ -160,8 +160,8 @@ public:
void set_optimize_save(bool p_optimize);
- String get_last_selected_language();
- void set_last_selected_language(String p_language);
+ Variant get_project_metadata(const String& p_section, const String& p_key, Variant p_default);
+ void set_project_metadata(const String& p_section, const String& p_key, Variant p_data);
EditorSettings();
~EditorSettings();
diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp
index 8f1f24f769..917560b540 100644
--- a/tools/editor/editor_sub_scene.cpp
+++ b/tools/editor/editor_sub_scene.cpp
@@ -27,10 +27,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_sub_scene.h"
+
#include "scene/gui/margin_container.h"
#include "scene/resources/packed_scene.h"
-void EditorSubScene::_path_selected(const String& p_path) {
+void EditorSubScene::_path_selected(const String& p_path) {
path->set_text(p_path);
_path_changed(p_path);
@@ -75,7 +76,7 @@ void EditorSubScene::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (!is_visible()) {
+ if (!is_visible_in_tree()) {
}
@@ -186,9 +187,9 @@ void EditorSubScene::clear() {
void EditorSubScene::_bind_methods() {
- ClassDB::bind_method(_MD("_path_selected"),&EditorSubScene::_path_selected);
- ClassDB::bind_method(_MD("_path_changed"),&EditorSubScene::_path_changed);
- ClassDB::bind_method(_MD("_path_browse"),&EditorSubScene::_path_browse);
+ ClassDB::bind_method(D_METHOD("_path_selected"),&EditorSubScene::_path_selected);
+ ClassDB::bind_method(D_METHOD("_path_changed"),&EditorSubScene::_path_changed);
+ ClassDB::bind_method(D_METHOD("_path_browse"),&EditorSubScene::_path_browse);
ADD_SIGNAL( MethodInfo("subscene_selected"));
}
@@ -203,7 +204,7 @@ EditorSubScene::EditorSubScene() {
VBoxContainer *vb = memnew( VBoxContainer );
add_child(vb);
-// set_child_rect(vb);
+ //set_child_rect(vb);
HBoxContainer *hb = memnew( HBoxContainer );
path = memnew( LineEdit );
diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp
index 56654cad7a..7657996b81 100644
--- a/tools/editor/editor_themes.cpp
+++ b/tools/editor/editor_themes.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* editor_themes.cpp */
+/* editor_themes.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "editor_themes.h"
+
#include "editor_icons.h"
#include "editor_fonts.h"
#include "editor_settings.h"
diff --git a/tools/editor/editor_themes.h b/tools/editor/editor_themes.h
index 83e7dde78a..bf15420917 100644
--- a/tools/editor/editor_themes.h
+++ b/tools/editor/editor_themes.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* editor_themes.h */
+/* editor_themes.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp
index 176205a7df..891669db13 100644
--- a/tools/editor/file_type_cache.cpp
+++ b/tools/editor/file_type_cache.cpp
@@ -27,9 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_type_cache.h"
-#include "globals.h"
-#include "os/file_access.h"
+#include "global_config.h"
+#include "os/file_access.h"
FileTypeCache* FileTypeCache::singleton=NULL;
diff --git a/tools/editor/fileserver/SCsub b/tools/editor/fileserver/SCsub
index 4bf55189cc..f1fa50148f 100644
--- a/tools/editor/fileserver/SCsub
+++ b/tools/editor/fileserver/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources, "*.cpp")
+env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/tools/editor/fileserver/editor_file_server.cpp b/tools/editor/fileserver/editor_file_server.cpp
index d640b0ad1d..2e5dbf6248 100644
--- a/tools/editor/fileserver/editor_file_server.cpp
+++ b/tools/editor/fileserver/editor_file_server.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_file_server.h"
+
#include "io/marshalls.h"
#include "io/marshalls.h"
#include "../editor_settings.h"
@@ -38,7 +39,7 @@
void EditorFileServer::_close_client(ClientData *cd) {
- cd->connection->disconnect();
+ cd->connection->disconnect_from_host();
cd->efs->wait_mutex->lock();
cd->efs->to_wait.insert(cd->thread);
cd->efs->wait_mutex->unlock();
diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp
index 1bf91d4ceb..bce0e9148a 100644
--- a/tools/editor/filesystem_dock.cpp
+++ b/tools/editor/filesystem_dock.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* scenes_dock.cpp */
+/* filesystem_dock.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,14 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "filesystem_dock.h"
+
#include "os/dir_access.h"
#include "os/file_access.h"
-#include "globals.h"
-
+#include "global_config.h"
#include "io/resource_loader.h"
#include "os/os.h"
#include "editor_node.h"
-
#include "editor_settings.h"
#include "scene/main/viewport.h"
@@ -171,7 +170,7 @@ void FileSystemDock::_notification(int p_what) {
_update_tree(); //maybe it finished already
if (EditorFileSystem::get_singleton()->is_scanning()) {
- _set_scannig_mode();
+ _set_scanning_mode();
}
} break;
@@ -186,7 +185,7 @@ void FileSystemDock::_notification(int p_what) {
case NOTIFICATION_DRAG_BEGIN: {
Dictionary dd = get_viewport()->gui_get_drag_data();
- if (tree->is_visible() && dd.has("type") ) {
+ if (tree->is_visible_in_tree() && dd.has("type") ) {
if ( (String(dd["type"])=="files") || (String(dd["type"])=="files_and_dirs") || (String(dd["type"])=="resource")) {
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
}
@@ -288,11 +287,44 @@ String FileSystemDock::get_current_path() const {
return path;
}
+void FileSystemDock::navigate_to_path(const String& p_path) {
+ // If the path is a file, do not only go to the directory in the tree, also select the file in the file list.
+ String dir_path="";
+ String file_name="";
+ DirAccess* dirAccess=DirAccess::open("res://");
+ if (dirAccess->file_exists(p_path)) {
+ dir_path=p_path.get_base_dir();
+ file_name=p_path.get_file();
+ } else if (dirAccess->dir_exists(p_path)) {
+ dir_path=p_path;
+ } else {
+ ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!"));
+ ERR_FAIL();
+ }
+
+ path=dir_path;
+ _update_tree();
+ tree->ensure_cursor_is_visible();
+
+ if (!file_name.empty()) {
+ _open_pressed(); // Seems to be the only way to get into the file view. This also pushes to history.
+
+ // Focus the given file.
+ for (int i=0; i<files->get_item_count(); i++) {
+ if (files->get_item_text(i) == file_name) {
+ files->select(i,true);
+ files->ensure_current_is_visible();
+ break;
+ }
+ }
+ }
+}
+
void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_preview, const Variant& p_udata) {
bool valid=false;
- if (!search_box->is_hidden()) {
+ if (search_box->is_visible()) {
valid=true;
} else {
valid=(path==p_path.get_base_dir());
@@ -351,25 +383,9 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path,List<FileInfo>* m
FileInfo fi;
fi.name=file;
fi.type=p_path->get_file_type(i);
- fi.path=p_path->get_file_path(i);
- if (p_path->get_file_meta(i)) {
- if (p_path->is_missing_sources(i)) {
- fi.import_status=3;
- } else if (p_path->have_sources_changed(i)) {
- fi.import_status=2;
- } else {
- fi.import_status=1;
- }
- } else {
- fi.import_status=0;
- }
- for(int j=0;j<p_path->get_source_count(i);j++) {
- String s = EditorImportPlugin::expand_source_path(p_path->get_source_file(i,j));
- if (p_path->is_source_file_missing(i,j)) {
- s+=" (Missing)";
- }
- fi.sources.push_back(s);
- }
+ fi.path=p_path->get_file_path(i);
+ fi.import_status=0;
+
matches->push_back(fi);
if (matches->size()>p_max_items)
@@ -396,7 +412,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
current_path->set_text(path);
- EditorFileSystemDirectory *efd = EditorFileSystem::get_singleton()->get_path(path);
+ EditorFileSystemDirectory *efd = EditorFileSystem::get_singleton()->get_filesystem_path(path);
if (!efd)
return;
@@ -501,25 +517,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
fi.name=efd->get_file(i);
fi.path=path.plus_file(fi.name);
fi.type=efd->get_file_type(i);
- if (efd->get_file_meta(i)) {
- if (efd->is_missing_sources(i)) {
- fi.import_status=3;
- } else if (efd->have_sources_changed(i)) {
- fi.import_status=2;
- } else {
- fi.import_status=1;
- }
-
- for(int j=0;j<efd->get_source_count(i);j++) {
- String s = EditorImportPlugin::expand_source_path(efd->get_source_file(i,j));
- if (efd->is_source_file_missing(i,j)) {
- s+=" (Missing)";
- }
- fi.sources.push_back(s);
- }
- } else {
- fi.import_status=0;
- }
+ fi.import_status=0;
@@ -624,7 +622,7 @@ void FileSystemDock::_go_to_dir(const String& p_dir){
void FileSystemDock::_preview_invalidated(const String& p_path) {
- if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible()) {
+ if (p_path.get_base_dir()==path && search_box->get_text()==String() && file_list_vb->is_visible_in_tree()) {
for(int i=0;i<files->get_item_count();i++) {
@@ -649,13 +647,13 @@ void FileSystemDock::_fs_changed() {
scanning_vb->hide();
split_box->show();
- if (!tree->is_hidden()) {
+ if (tree->is_visible()) {
button_favorite->show();
_update_tree();
}
- if (!file_list_vb->is_hidden()) {
+ if (file_list_vb->is_visible()) {
_update_files(true);
}
@@ -663,7 +661,7 @@ void FileSystemDock::_fs_changed() {
set_process(false);
}
-void FileSystemDock::_set_scannig_mode() {
+void FileSystemDock::_set_scanning_mode() {
split_box->hide();
button_hist_prev->set_disabled(true);
@@ -685,14 +683,14 @@ void FileSystemDock::_fw_history() {
path=history[history_pos];
- if (!tree->is_hidden()) {
+ if (tree->is_visible()) {
_update_tree();
tree->grab_focus();
tree->ensure_cursor_is_visible();
}
- if (!file_list_vb->is_hidden()) {
+ if (file_list_vb->is_visible()) {
_update_files(false);
current_path->set_text(path);
}
@@ -710,13 +708,13 @@ void FileSystemDock::_bw_history() {
path=history[history_pos];
- if (!tree->is_hidden()) {
+ if (tree->is_visible()) {
_update_tree();
tree->grab_focus();
tree->ensure_cursor_is_visible();
}
- if (!file_list_vb->is_hidden()) {
+ if (file_list_vb->is_visible()) {
_update_files(false);
current_path->set_text(path);
}
@@ -832,7 +830,7 @@ void FileSystemDock::_move_operation(const String& p_to_path) {
return;
}
- EditorFileSystemDirectory *efsd=EditorFileSystem::get_singleton()->get_path(move_dirs[i]);
+ EditorFileSystemDirectory *efsd=EditorFileSystem::get_singleton()->get_filesystem_path(move_dirs[i]);
if (!efsd)
continue;
_find_inside_move_files(efsd,inside_files);
@@ -990,7 +988,7 @@ void FileSystemDock::_file_option(int p_option) {
} break;
case FILE_MOVE: {
- move_dirs.clear();;
+ move_dirs.clear();
move_files.clear();
for(int i=0;i<files->get_item_count();i++) {
@@ -1015,7 +1013,7 @@ void FileSystemDock::_file_option(int p_option) {
if (move_dirs.empty() && move_files.size()==1) {
rename_dialog->clear_filters();
- rename_dialog->add_filter("*."+move_files[0].extension());
+ rename_dialog->add_filter("*."+move_files[0].get_extension());
rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
rename_dialog->set_current_path(move_files[0]);
rename_dialog->popup_centered_ratio();
@@ -1069,7 +1067,7 @@ void FileSystemDock::_file_option(int p_option) {
}
ERR_FAIL_COND(reimport.size()==0);
-
+/*
Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]);
ERR_FAIL_COND(!rimd.is_valid());
String editor=rimd->get_editor();
@@ -1087,6 +1085,7 @@ void FileSystemDock::_file_option(int p_option) {
rimp->reimport_multiple_files(reimport);
}
+ */
} break;
case FILE_COPY_PATH:
@@ -1149,7 +1148,7 @@ void FileSystemDock::_open_pressed(){
current_path->set_text(path);
_push_to_history();
-// emit_signal("open",path);
+ //emit_signal("open",path);
}
@@ -1167,7 +1166,7 @@ void FileSystemDock::_dir_rmb_pressed(const Vector2& p_pos) {
void FileSystemDock::_search_changed(const String& p_text) {
- if (!search_box->is_visible())
+ if (!search_box->is_visible_in_tree())
return; //wtf
_update_files(false);
@@ -1175,7 +1174,7 @@ void FileSystemDock::_search_changed(const String& p_text) {
void FileSystemDock::_rescan() {
- _set_scannig_mode();
+ _set_scanning_mode();
EditorFileSystem::get_singleton()->scan();
}
@@ -1187,6 +1186,14 @@ void FileSystemDock::fix_dependencies(const String& p_for_file) {
void FileSystemDock::focus_on_filter() {
+ if (!search_box->is_visible_in_tree()) {
+ // Tree mode, switch to files list with search box
+ tree->hide();
+ file_list_vb->show();
+ button_favorite->hide();
+ }
+
+ search_box->grab_focus();
}
void FileSystemDock::set_display_mode(int p_mode) {
@@ -1242,8 +1249,10 @@ Variant FileSystemDock::get_drag_data_fw(const Point2& p_point,Control* p_from)
if (seldirs.empty() && selfiles.empty())
return Variant();
- //if (seldirs.size() && selfiles.size())
- // return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting
+ /*
+ if (seldirs.size() && selfiles.size())
+ return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting
+ */
/*if (selfiles.size()==1) {
Ref<Resource> resource = ResourceLoader::load(files->get_item_metadata(selfiles.front()->get()));
@@ -1528,25 +1537,6 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
if (efsd) {
- if (!efsd->get_file_meta(pos)) {
- all_can_reimport=false;
-
-
- } else {
- Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(path);
- if (rimd.is_valid()) {
-
- String editor=rimd->get_editor();
- if (editor.begins_with("texture_")) { //compatibility fix for old texture format
- editor="texture";
- }
- types.insert(editor);
-
- } else {
- all_can_reimport=false;
-
- }
- }
} else {
all_can_reimport=false;
@@ -1594,7 +1584,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
if (all_can_reimport && types.size()==1) { //all can reimport and are of the same type
-
+/*
bool valid=true;
Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(types.front()->get());
if (rimp.is_valid()) {
@@ -1610,6 +1600,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
file_options->add_separator();
file_options->add_item(TTR("Re-Import.."),FILE_REIMPORT);
}
+ */
}
file_options->set_pos(files->get_global_pos() + p_pos);
@@ -1617,37 +1608,103 @@ void FileSystemDock::_files_list_rmb_select(int p_item,const Vector2& p_pos) {
}
+void FileSystemDock::select_file(const String& p_file) {
+
+ _go_to_dir(p_file.get_base_dir());
+ for(int i=0;i<files->get_item_count();i++) {
+ if (files->get_item_metadata(i)==p_file) {
+ files->select(i);
+ files->ensure_current_is_visible();
+ break;
+ }
+ }
+
+}
+
+void FileSystemDock::_file_multi_selected(int p_index,bool p_selected) {
+
+
+ _file_selected();
+}
+
+void FileSystemDock::_file_selected() {
+
+ //check import
+ Vector<String> imports;
+ String import_type;
+
+ for(int i=0;i<files->get_item_count();i++) {
+ if (!files->is_selected(i))
+ continue;
+
+ String p = files->get_item_metadata(i);
+ if (!FileAccess::exists(p+".import")) {
+ imports.clear();
+ break;
+ }
+ Ref<ConfigFile> cf;
+ cf.instance();
+ Error err = cf->load(p+".import");
+ if (err!=OK) {
+ imports.clear();
+ break;
+ }
+
+ String type = cf->get_value("remap","type");
+ if (import_type=="") {
+ import_type=type;
+ } else if (import_type!=type) {
+ //all should be the same type
+ imports.clear();
+ break;
+ }
+ imports.push_back(p);
+ }
+
+
+ if (imports.size()==0) {
+ EditorNode::get_singleton()->get_import_dock()->clear();
+ } else if (imports.size()==1) {
+ EditorNode::get_singleton()->get_import_dock()->set_edit_path(imports[0]);
+ } else {
+ EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
+ }
+}
+
+
void FileSystemDock::_bind_methods() {
- ClassDB::bind_method(_MD("_update_tree"),&FileSystemDock::_update_tree);
- ClassDB::bind_method(_MD("_rescan"),&FileSystemDock::_rescan);
- ClassDB::bind_method(_MD("_favorites_pressed"),&FileSystemDock::_favorites_pressed);
-// ClassDB::bind_method(_MD("_instance_pressed"),&ScenesDock::_instance_pressed);
- ClassDB::bind_method(_MD("_open_pressed"),&FileSystemDock::_open_pressed);
- ClassDB::bind_method(_MD("_dir_rmb_pressed"),&FileSystemDock::_dir_rmb_pressed);
-
- ClassDB::bind_method(_MD("_thumbnail_done"),&FileSystemDock::_thumbnail_done);
- ClassDB::bind_method(_MD("_select_file"), &FileSystemDock::_select_file);
- ClassDB::bind_method(_MD("_go_to_tree"), &FileSystemDock::_go_to_tree);
- ClassDB::bind_method(_MD("_go_to_dir"), &FileSystemDock::_go_to_dir);
- ClassDB::bind_method(_MD("_change_file_display"), &FileSystemDock::_change_file_display);
- ClassDB::bind_method(_MD("_fw_history"), &FileSystemDock::_fw_history);
- ClassDB::bind_method(_MD("_bw_history"), &FileSystemDock::_bw_history);
- ClassDB::bind_method(_MD("_fs_changed"), &FileSystemDock::_fs_changed);
- ClassDB::bind_method(_MD("_dir_selected"), &FileSystemDock::_dir_selected);
- ClassDB::bind_method(_MD("_file_option"), &FileSystemDock::_file_option);
- ClassDB::bind_method(_MD("_folder_option"), &FileSystemDock::_folder_option);
- ClassDB::bind_method(_MD("_move_operation"), &FileSystemDock::_move_operation);
- ClassDB::bind_method(_MD("_rename_operation"), &FileSystemDock::_rename_operation);
-
- ClassDB::bind_method(_MD("_search_changed"), &FileSystemDock::_search_changed);
-
- ClassDB::bind_method(_MD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &FileSystemDock::drop_data_fw);
- ClassDB::bind_method(_MD("_files_list_rmb_select"),&FileSystemDock::_files_list_rmb_select);
-
- ClassDB::bind_method(_MD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
+ ClassDB::bind_method(D_METHOD("_update_tree"),&FileSystemDock::_update_tree);
+ ClassDB::bind_method(D_METHOD("_rescan"),&FileSystemDock::_rescan);
+ ClassDB::bind_method(D_METHOD("_favorites_pressed"),&FileSystemDock::_favorites_pressed);
+ //ClassDB::bind_method(D_METHOD("_instance_pressed"),&ScenesDock::_instance_pressed);
+ ClassDB::bind_method(D_METHOD("_open_pressed"),&FileSystemDock::_open_pressed);
+ ClassDB::bind_method(D_METHOD("_dir_rmb_pressed"),&FileSystemDock::_dir_rmb_pressed);
+
+ ClassDB::bind_method(D_METHOD("_thumbnail_done"),&FileSystemDock::_thumbnail_done);
+ ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
+ ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
+ ClassDB::bind_method(D_METHOD("_go_to_dir"), &FileSystemDock::_go_to_dir);
+ ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
+ ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
+ ClassDB::bind_method(D_METHOD("_bw_history"), &FileSystemDock::_bw_history);
+ ClassDB::bind_method(D_METHOD("_fs_changed"), &FileSystemDock::_fs_changed);
+ ClassDB::bind_method(D_METHOD("_dir_selected"), &FileSystemDock::_dir_selected);
+ ClassDB::bind_method(D_METHOD("_file_option"), &FileSystemDock::_file_option);
+ ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option);
+ ClassDB::bind_method(D_METHOD("_move_operation"), &FileSystemDock::_move_operation);
+ ClassDB::bind_method(D_METHOD("_rename_operation"), &FileSystemDock::_rename_operation);
+
+ ClassDB::bind_method(D_METHOD("_search_changed"), &FileSystemDock::_search_changed);
+
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("_files_list_rmb_select"),&FileSystemDock::_files_list_rmb_select);
+
+ ClassDB::bind_method(D_METHOD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
+ ClassDB::bind_method(D_METHOD("_file_selected"),&FileSystemDock::_file_selected);
+ ClassDB::bind_method(D_METHOD("_file_multi_selected"),&FileSystemDock::_file_multi_selected);
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
@@ -1700,7 +1757,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
button_favorite->set_focus_mode(FOCUS_NONE);
-// Control *spacer = memnew( Control);
+ //Control *spacer = memnew( Control);
@@ -1752,6 +1809,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
files->set_select_mode(ItemList::SELECT_MULTI);
files->set_drag_forwarding(this);
files->connect("item_rmb_selected",this,"_files_list_rmb_select");
+ files->connect("item_selected",this,"_file_selected");
+ files->connect("multi_selected",this,"_file_multi_selected");
files->set_allow_rmb_select(true);
file_list_vb = memnew( VBoxContainer );
@@ -1770,8 +1829,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
path_hb->add_child(search_box);
search_box->connect("text_changed",this,"_search_changed");
- search_icon = memnew( TextureFrame );
- search_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
+ search_icon = memnew( TextureRect );
+ search_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
path_hb->add_child(search_icon);
button_display_mode = memnew( ToolButton );
diff --git a/tools/editor/filesystem_dock.h b/tools/editor/filesystem_dock.h
index 804017be73..916321d8fd 100644
--- a/tools/editor/filesystem_dock.h
+++ b/tools/editor/filesystem_dock.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* scenes_dock.h */
+/* filesystem_dock.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -95,7 +95,7 @@ private:
Button *button_hist_prev;
LineEdit *current_path;
LineEdit *search_box;
- TextureFrame *search_icon;
+ TextureRect *search_icon;
HBoxContainer *path_hb;
bool split_mode;
@@ -126,6 +126,11 @@ private:
Tree * tree; //directories
ItemList *files;
+
+ void _file_multi_selected(int p_index, bool p_selected);
+ void _file_selected();
+
+
void _go_to_tree();
void _go_to_dir(const String& p_dir);
void _select_file(int p_idx);
@@ -153,7 +158,7 @@ private:
void _dir_selected();
void _update_tree();
void _rescan();
- void _set_scannig_mode();
+ void _set_scanning_mode();
void _favorites_pressed();
@@ -193,12 +198,17 @@ public:
String get_selected_path() const;
String get_current_path() const;
+ void navigate_to_path(const String& p_path);
void focus_on_filter();
void fix_dependencies(const String& p_for_file);
void set_display_mode(int p_mode);
+ int get_split_offset() { return split_box->get_split_offset(); }
+ void set_split_offset(int p_offset) { split_box->set_split_offset(p_offset); }
+ void select_file(const String& p_file);
+
FileSystemDock(EditorNode *p_editor);
~FileSystemDock();
};
diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp
index 07b2bca385..90f0bab6dd 100644
--- a/tools/editor/groups_editor.cpp
+++ b/tools/editor/groups_editor.cpp
@@ -32,6 +32,7 @@
#include "scene/gui/label.h"
#include "editor_node.h"
#include "scene/resources/packed_scene.h"
+
void GroupsEditor::_add_group(const String& p_group) {
if (!node)
diff --git a/tools/editor/icons/2x/icon_anchor.png b/tools/editor/icons/2x/icon_anchor.png
index db964fd910..7e9e259c13 100644
--- a/tools/editor/icons/2x/icon_anchor.png
+++ b/tools/editor/icons/2x/icon_anchor.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_animation.png b/tools/editor/icons/2x/icon_animation.png
index 5b21e99e43..ef18959a74 100644
--- a/tools/editor/icons/2x/icon_animation.png
+++ b/tools/editor/icons/2x/icon_animation.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_area.png b/tools/editor/icons/2x/icon_area.png
index ff332bf748..d9cefe8fc4 100644
--- a/tools/editor/icons/2x/icon_area.png
+++ b/tools/editor/icons/2x/icon_area.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_auto_play.png b/tools/editor/icons/2x/icon_auto_play.png
index 9a50d1c030..ec31dee958 100644
--- a/tools/editor/icons/2x/icon_auto_play.png
+++ b/tools/editor/icons/2x/icon_auto_play.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_bitmap_font.png b/tools/editor/icons/2x/icon_bitmap_font.png
index df6d2a5081..c533b5f40e 100644
--- a/tools/editor/icons/2x/icon_bitmap_font.png
+++ b/tools/editor/icons/2x/icon_bitmap_font.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_canvas_layer.png b/tools/editor/icons/2x/icon_canvas_layer.png
index 9861d3ef45..8a4b31cd7d 100644
--- a/tools/editor/icons/2x/icon_canvas_layer.png
+++ b/tools/editor/icons/2x/icon_canvas_layer.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_canvas_modulate.png b/tools/editor/icons/2x/icon_canvas_modulate.png
index 07ee8a0570..6cc15e2655 100644
--- a/tools/editor/icons/2x/icon_canvas_modulate.png
+++ b/tools/editor/icons/2x/icon_canvas_modulate.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_color_rect.png b/tools/editor/icons/2x/icon_color_rect.png
new file mode 100644
index 0000000000..153029ac20
--- /dev/null
+++ b/tools/editor/icons/2x/icon_color_rect.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_copy_node_path.png b/tools/editor/icons/2x/icon_copy_node_path.png
new file mode 100644
index 0000000000..056748d20b
--- /dev/null
+++ b/tools/editor/icons/2x/icon_copy_node_path.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_create_new_scene_from.png b/tools/editor/icons/2x/icon_create_new_scene_from.png
index 15b2c89dc5..cc3be48033 100644
--- a/tools/editor/icons/2x/icon_create_new_scene_from.png
+++ b/tools/editor/icons/2x/icon_create_new_scene_from.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_dynamic_font_data.png b/tools/editor/icons/2x/icon_dynamic_font_data.png
index 397a849b4f..6d76303c81 100644
--- a/tools/editor/icons/2x/icon_dynamic_font_data.png
+++ b/tools/editor/icons/2x/icon_dynamic_font_data.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_error.png b/tools/editor/icons/2x/icon_error.png
index b577182044..a6d79ab41b 100644
--- a/tools/editor/icons/2x/icon_error.png
+++ b/tools/editor/icons/2x/icon_error.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_fixed_spatial_material.png b/tools/editor/icons/2x/icon_fixed_spatial_material.png
index b95e78d6cc..65509a590e 100644
--- a/tools/editor/icons/2x/icon_fixed_spatial_material.png
+++ b/tools/editor/icons/2x/icon_fixed_spatial_material.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_key_next.png b/tools/editor/icons/2x/icon_key_next.png
index cb2c4eae4b..d35b52d3c7 100644
--- a/tools/editor/icons/2x/icon_key_next.png
+++ b/tools/editor/icons/2x/icon_key_next.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_line_2d.png b/tools/editor/icons/2x/icon_line_2d.png
new file mode 100644
index 0000000000..27299a2b69
--- /dev/null
+++ b/tools/editor/icons/2x/icon_line_2d.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_material_shader.png b/tools/editor/icons/2x/icon_material_shader.png
index 65509a590e..f8c2e15fcb 100644
--- a/tools/editor/icons/2x/icon_material_shader.png
+++ b/tools/editor/icons/2x/icon_material_shader.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_patch_9_frame.png b/tools/editor/icons/2x/icon_nine_patch_rect.png
index 5762a0392e..5762a0392e 100644
--- a/tools/editor/icons/2x/icon_patch_9_frame.png
+++ b/tools/editor/icons/2x/icon_nine_patch_rect.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_patch_9_rect.png b/tools/editor/icons/2x/icon_patch_9_rect.png
new file mode 100644
index 0000000000..5762a0392e
--- /dev/null
+++ b/tools/editor/icons/2x/icon_patch_9_rect.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_reference_frame.png b/tools/editor/icons/2x/icon_reference_rect.png
index 63fe559fa7..63fe559fa7 100644
--- a/tools/editor/icons/2x/icon_reference_frame.png
+++ b/tools/editor/icons/2x/icon_reference_rect.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_reparent.png b/tools/editor/icons/2x/icon_reparent.png
index 2473a3b362..3063da4b43 100644
--- a/tools/editor/icons/2x/icon_reparent.png
+++ b/tools/editor/icons/2x/icon_reparent.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_script_remove.png b/tools/editor/icons/2x/icon_script_remove.png
new file mode 100644
index 0000000000..f9a1bb19a4
--- /dev/null
+++ b/tools/editor/icons/2x/icon_script_remove.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_shader.png b/tools/editor/icons/2x/icon_shader.png
index 65509a590e..f8c2e15fcb 100644
--- a/tools/editor/icons/2x/icon_shader.png
+++ b/tools/editor/icons/2x/icon_shader.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_shader_material.png b/tools/editor/icons/2x/icon_shader_material.png
index 65509a590e..f8c2e15fcb 100644
--- a/tools/editor/icons/2x/icon_shader_material.png
+++ b/tools/editor/icons/2x/icon_shader_material.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_spot_light.png b/tools/editor/icons/2x/icon_spot_light.png
index e50c7b6135..e7aa35cbbf 100644
--- a/tools/editor/icons/2x/icon_spot_light.png
+++ b/tools/editor/icons/2x/icon_spot_light.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_tab_container.png b/tools/editor/icons/2x/icon_tab_container.png
index 086be0c5ba..93b7161a69 100644
--- a/tools/editor/icons/2x/icon_tab_container.png
+++ b/tools/editor/icons/2x/icon_tab_container.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_tabs.png b/tools/editor/icons/2x/icon_tabs.png
index ade8071b7f..6c317010c8 100644
--- a/tools/editor/icons/2x/icon_tabs.png
+++ b/tools/editor/icons/2x/icon_tabs.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_texture_frame.png b/tools/editor/icons/2x/icon_texture_rect.png
index 50d715dd09..50d715dd09 100644
--- a/tools/editor/icons/2x/icon_texture_frame.png
+++ b/tools/editor/icons/2x/icon_texture_rect.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_track_add_key.png b/tools/editor/icons/2x/icon_track_add_key.png
index 9cf0314270..9b7bd14fb4 100644
--- a/tools/editor/icons/2x/icon_track_add_key.png
+++ b/tools/editor/icons/2x/icon_track_add_key.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_track_add_key_hl.png b/tools/editor/icons/2x/icon_track_add_key_hl.png
index 7d170725f6..0763836c3a 100644
--- a/tools/editor/icons/2x/icon_track_add_key_hl.png
+++ b/tools/editor/icons/2x/icon_track_add_key_hl.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_transparent.png b/tools/editor/icons/2x/icon_transparent.png
new file mode 100644
index 0000000000..627607039b
--- /dev/null
+++ b/tools/editor/icons/2x/icon_transparent.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_viewport_container.png b/tools/editor/icons/2x/icon_viewport_container.png
new file mode 100644
index 0000000000..c43e53c34e
--- /dev/null
+++ b/tools/editor/icons/2x/icon_viewport_container.png
Binary files differ
diff --git a/tools/editor/icons/2x/icon_warning.png b/tools/editor/icons/2x/icon_warning.png
index 7359a798ee..5d807065e7 100644
--- a/tools/editor/icons/2x/icon_warning.png
+++ b/tools/editor/icons/2x/icon_warning.png
Binary files differ
diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub
index f86ae2b10d..4af481d1f6 100644
--- a/tools/editor/icons/SCsub
+++ b/tools/editor/icons/SCsub
@@ -92,5 +92,5 @@ make_editor_icons_builder = Builder(action=make_editor_icons_action,
env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder
env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#tools/editor/editor_icons.cpp', Glob("*.png"))])
-env.tool_sources.append("#tools/editor/editor_icons.cpp")
+env.editor_sources.append("#tools/editor/editor_icons.cpp")
Export('env')
diff --git a/tools/editor/icons/icon_accept_dialog.png b/tools/editor/icons/icon_accept_dialog.png
index 1ba2ce8db3..7530127f82 100644
--- a/tools/editor/icons/icon_accept_dialog.png
+++ b/tools/editor/icons/icon_accept_dialog.png
Binary files differ
diff --git a/tools/editor/icons/icon_anchor.png b/tools/editor/icons/icon_anchor.png
index 9c20808bdc..7b02eb448e 100644
--- a/tools/editor/icons/icon_anchor.png
+++ b/tools/editor/icons/icon_anchor.png
Binary files differ
diff --git a/tools/editor/icons/icon_animation.png b/tools/editor/icons/icon_animation.png
index 2bc13f0b4c..b333f82711 100644
--- a/tools/editor/icons/icon_animation.png
+++ b/tools/editor/icons/icon_animation.png
Binary files differ
diff --git a/tools/editor/icons/icon_area.png b/tools/editor/icons/icon_area.png
index ea7af5f9ac..31b4473d17 100644
--- a/tools/editor/icons/icon_area.png
+++ b/tools/editor/icons/icon_area.png
Binary files differ
diff --git a/tools/editor/icons/icon_audio_effect_amplify.png b/tools/editor/icons/icon_audio_effect_amplify.png
new file mode 100644
index 0000000000..9af3227d40
--- /dev/null
+++ b/tools/editor/icons/icon_audio_effect_amplify.png
Binary files differ
diff --git a/tools/editor/icons/icon_auto_play.png b/tools/editor/icons/icon_auto_play.png
index fcd3bedcda..a6be64a1d1 100644
--- a/tools/editor/icons/icon_auto_play.png
+++ b/tools/editor/icons/icon_auto_play.png
Binary files differ
diff --git a/tools/editor/icons/icon_bitmap_font.png b/tools/editor/icons/icon_bitmap_font.png
index 2739248796..5334c335dc 100644
--- a/tools/editor/icons/icon_bitmap_font.png
+++ b/tools/editor/icons/icon_bitmap_font.png
Binary files differ
diff --git a/tools/editor/icons/icon_bus_vu_db.png b/tools/editor/icons/icon_bus_vu_db.png
new file mode 100644
index 0000000000..52507cae52
--- /dev/null
+++ b/tools/editor/icons/icon_bus_vu_db.png
Binary files differ
diff --git a/tools/editor/icons/icon_bus_vu_empty.png b/tools/editor/icons/icon_bus_vu_empty.png
new file mode 100644
index 0000000000..6fc3143a55
--- /dev/null
+++ b/tools/editor/icons/icon_bus_vu_empty.png
Binary files differ
diff --git a/tools/editor/icons/icon_bus_vu_frozen.png b/tools/editor/icons/icon_bus_vu_frozen.png
new file mode 100644
index 0000000000..cf128afa91
--- /dev/null
+++ b/tools/editor/icons/icon_bus_vu_frozen.png
Binary files differ
diff --git a/tools/editor/icons/icon_bus_vu_full.png b/tools/editor/icons/icon_bus_vu_full.png
new file mode 100644
index 0000000000..9e3d7a93e3
--- /dev/null
+++ b/tools/editor/icons/icon_bus_vu_full.png
Binary files differ
diff --git a/tools/editor/icons/icon_canvas_layer.png b/tools/editor/icons/icon_canvas_layer.png
index cae31fe3bc..bb32d6d3ad 100644
--- a/tools/editor/icons/icon_canvas_layer.png
+++ b/tools/editor/icons/icon_canvas_layer.png
Binary files differ
diff --git a/tools/editor/icons/icon_canvas_modulate.png b/tools/editor/icons/icon_canvas_modulate.png
index 711ebbae5f..b76e532268 100644
--- a/tools/editor/icons/icon_canvas_modulate.png
+++ b/tools/editor/icons/icon_canvas_modulate.png
Binary files differ
diff --git a/tools/editor/icons/icon_color_frame.png b/tools/editor/icons/icon_color_frame.png
deleted file mode 100644
index a82eefc10a..0000000000
--- a/tools/editor/icons/icon_color_frame.png
+++ /dev/null
Binary files differ
diff --git a/tools/editor/icons/icon_color_rect.png b/tools/editor/icons/icon_color_rect.png
new file mode 100644
index 0000000000..40b9dab605
--- /dev/null
+++ b/tools/editor/icons/icon_color_rect.png
Binary files differ
diff --git a/tools/editor/icons/icon_copy_node_path.png b/tools/editor/icons/icon_copy_node_path.png
new file mode 100644
index 0000000000..d777f132d8
--- /dev/null
+++ b/tools/editor/icons/icon_copy_node_path.png
Binary files differ
diff --git a/tools/editor/icons/icon_create_new_scene_from.png b/tools/editor/icons/icon_create_new_scene_from.png
index 908c82626c..45df9b1e25 100644
--- a/tools/editor/icons/icon_create_new_scene_from.png
+++ b/tools/editor/icons/icon_create_new_scene_from.png
Binary files differ
diff --git a/tools/editor/icons/icon_dynamic_font_data.png b/tools/editor/icons/icon_dynamic_font_data.png
index 8f36106b61..5cff86c40c 100644
--- a/tools/editor/icons/icon_dynamic_font_data.png
+++ b/tools/editor/icons/icon_dynamic_font_data.png
Binary files differ
diff --git a/tools/editor/icons/icon_error.png b/tools/editor/icons/icon_error.png
index 0fdf5facbf..7a9bed43aa 100644
--- a/tools/editor/icons/icon_error.png
+++ b/tools/editor/icons/icon_error.png
Binary files differ
diff --git a/tools/editor/icons/icon_fixed_spatial_material.png b/tools/editor/icons/icon_fixed_spatial_material.png
index 2e52c45a46..f26ac3be37 100644
--- a/tools/editor/icons/icon_fixed_spatial_material.png
+++ b/tools/editor/icons/icon_fixed_spatial_material.png
Binary files differ
diff --git a/tools/editor/icons/icon_key_next.png b/tools/editor/icons/icon_key_next.png
index ed7a20637f..288161d245 100644
--- a/tools/editor/icons/icon_key_next.png
+++ b/tools/editor/icons/icon_key_next.png
Binary files differ
diff --git a/tools/editor/icons/icon_line_2d.png b/tools/editor/icons/icon_line_2d.png
new file mode 100644
index 0000000000..4ebf46af04
--- /dev/null
+++ b/tools/editor/icons/icon_line_2d.png
Binary files differ
diff --git a/tools/editor/icons/icon_material_shader.png b/tools/editor/icons/icon_material_shader.png
index f26ac3be37..568a45d938 100644
--- a/tools/editor/icons/icon_material_shader.png
+++ b/tools/editor/icons/icon_material_shader.png
Binary files differ
diff --git a/tools/editor/icons/icon_patch_9_frame.png b/tools/editor/icons/icon_nine_patch_rect.png
index bdd1467144..bdd1467144 100644
--- a/tools/editor/icons/icon_patch_9_frame.png
+++ b/tools/editor/icons/icon_nine_patch_rect.png
Binary files differ
diff --git a/tools/editor/icons/icon_patch_9_rect.png b/tools/editor/icons/icon_patch_9_rect.png
new file mode 100644
index 0000000000..bdd1467144
--- /dev/null
+++ b/tools/editor/icons/icon_patch_9_rect.png
Binary files differ
diff --git a/tools/editor/icons/icon_reference_frame.png b/tools/editor/icons/icon_reference_rect.png
index b253af477f..b253af477f 100644
--- a/tools/editor/icons/icon_reference_frame.png
+++ b/tools/editor/icons/icon_reference_rect.png
Binary files differ
diff --git a/tools/editor/icons/icon_reparent.png b/tools/editor/icons/icon_reparent.png
index b3235e60c5..135ccee4ad 100644
--- a/tools/editor/icons/icon_reparent.png
+++ b/tools/editor/icons/icon_reparent.png
Binary files differ
diff --git a/tools/editor/icons/icon_script_remove.png b/tools/editor/icons/icon_script_remove.png
new file mode 100644
index 0000000000..c200b01690
--- /dev/null
+++ b/tools/editor/icons/icon_script_remove.png
Binary files differ
diff --git a/tools/editor/icons/icon_shader.png b/tools/editor/icons/icon_shader.png
index f26ac3be37..568a45d938 100644
--- a/tools/editor/icons/icon_shader.png
+++ b/tools/editor/icons/icon_shader.png
Binary files differ
diff --git a/tools/editor/icons/icon_shader_material.png b/tools/editor/icons/icon_shader_material.png
index f26ac3be37..568a45d938 100644
--- a/tools/editor/icons/icon_shader_material.png
+++ b/tools/editor/icons/icon_shader_material.png
Binary files differ
diff --git a/tools/editor/icons/icon_spot_light.png b/tools/editor/icons/icon_spot_light.png
index 89b0b28aa3..f52570a5cd 100644
--- a/tools/editor/icons/icon_spot_light.png
+++ b/tools/editor/icons/icon_spot_light.png
Binary files differ
diff --git a/tools/editor/icons/icon_tab_container.png b/tools/editor/icons/icon_tab_container.png
index dd661c5ab6..7ff3081ec1 100644
--- a/tools/editor/icons/icon_tab_container.png
+++ b/tools/editor/icons/icon_tab_container.png
Binary files differ
diff --git a/tools/editor/icons/icon_tabs.png b/tools/editor/icons/icon_tabs.png
index cc7e08a835..bef0f60660 100644
--- a/tools/editor/icons/icon_tabs.png
+++ b/tools/editor/icons/icon_tabs.png
Binary files differ
diff --git a/tools/editor/icons/icon_texture_frame.png b/tools/editor/icons/icon_texture_rect.png
index 84e4a90bfb..84e4a90bfb 100644
--- a/tools/editor/icons/icon_texture_frame.png
+++ b/tools/editor/icons/icon_texture_rect.png
Binary files differ
diff --git a/tools/editor/icons/icon_track_add_key.png b/tools/editor/icons/icon_track_add_key.png
index fb86b37963..02d92439a3 100644
--- a/tools/editor/icons/icon_track_add_key.png
+++ b/tools/editor/icons/icon_track_add_key.png
Binary files differ
diff --git a/tools/editor/icons/icon_track_add_key_hl.png b/tools/editor/icons/icon_track_add_key_hl.png
index c1bfee736a..0e857f5fe2 100644
--- a/tools/editor/icons/icon_track_add_key_hl.png
+++ b/tools/editor/icons/icon_track_add_key_hl.png
Binary files differ
diff --git a/tools/editor/icons/icon_transparent.png b/tools/editor/icons/icon_transparent.png
new file mode 100644
index 0000000000..07e9b52b5c
--- /dev/null
+++ b/tools/editor/icons/icon_transparent.png
Binary files differ
diff --git a/tools/editor/icons/icon_viewport_container.png b/tools/editor/icons/icon_viewport_container.png
new file mode 100644
index 0000000000..c70dee3698
--- /dev/null
+++ b/tools/editor/icons/icon_viewport_container.png
Binary files differ
diff --git a/tools/editor/icons/icon_vu_db.png b/tools/editor/icons/icon_vu_db.png
new file mode 100644
index 0000000000..405a929e2a
--- /dev/null
+++ b/tools/editor/icons/icon_vu_db.png
Binary files differ
diff --git a/tools/editor/icons/icon_warning.png b/tools/editor/icons/icon_warning.png
index 0928062938..451beba820 100644
--- a/tools/editor/icons/icon_warning.png
+++ b/tools/editor/icons/icon_warning.png
Binary files differ
diff --git a/tools/editor/icons/source/icon_accept_dialog.svg b/tools/editor/icons/source/icon_accept_dialog.svg
index 8d2c307691..9f82b30c94 100644
--- a/tools/editor/icons/source/icon_accept_dialog.svg
+++ b/tools/editor/icons/source/icon_accept_dialog.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="6.0807642"
- inkscape:cy="9.1331382"
+ inkscape:zoom="45.254834"
+ inkscape:cx="8.3712909"
+ inkscape:cy="7.2310094"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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 10.474609 6.6367188 L 11.888672 8.0507812 L 8.3535156 11.585938 L 6.9394531 13 L 5.5253906 11.585938 L 4.1113281 10.171875 L 5.5253906 8.7578125 L 6.9394531 10.171875 L 10.474609 6.6367188 z "
+ d="M 3,1 C 1.89543,1 1,1.8954 1,3 L 1,4 15,4 15,3 C 15,1.8954 14.104569,1 13,1 Z m 9,1 1,0 0,1 -1,0 z M 1,5 1,13 c 0,1.1046 0.89543,2 2,2 l 10,0 c 1.104569,0 2,-0.8954 2,-2 L 15,5 Z M 10.474609,6.6367188 11.888672,8.0507812 6.9394531,13 4.1113281,10.171875 5.5253906,8.7578125 6.9394531,10.171875 Z"
transform="translate(0,1036.3622)"
- id="rect4140" />
+ id="rect4140"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ssccsssccccccssssccccccccc" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_add_track.svg b/tools/editor/icons/source/icon_add_track.svg
index 916199d29e..d19448efb0 100644
--- a/tools/editor/icons/source/icon_add_track.svg
+++ b/tools/editor/icons/source/icon_add_track.svg
@@ -18,7 +18,7 @@
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_add_track (copy).svg">
+ sodipodi:docname="icon_add_track.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32.000001"
- inkscape:cx="4.2247291"
- inkscape:cy="8.9595523"
+ inkscape:zoom="45.254835"
+ inkscape:cx="6.9909025"
+ inkscape:cy="7.4569962"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,20 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
+ <path
style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4137"
- width="14"
- height="1.9999478"
- x="1"
- y="1043.3622" />
- <rect
- y="-9"
- x="1037.3622"
- height="2.0000017"
- width="13.999966"
- id="rect4158"
- style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- transform="matrix(0,1,-1,0,0,0)" />
+ d="M 7 1 L 7 7 L 1 7 L 1 9 L 7 9 L 7 15 L 9 15 L 9 9 L 15 9 L 15 7 L 9 7 L 9 1 L 7 1 z "
+ transform="translate(0,1036.3622)"
+ id="rect4137" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_anchor.svg b/tools/editor/icons/source/icon_anchor.svg
index ff43271224..6b10be040b 100644
--- a/tools/editor/icons/source/icon_anchor.svg
+++ b/tools/editor/icons/source/icon_anchor.svg
@@ -18,7 +18,7 @@
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_anchor.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_anchor (copy).svg">
+ sodipodi:docname="icon_anchor.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="5.8188721"
- inkscape:cy="10.181863"
+ inkscape:cx="12.991456"
+ inkscape:cy="8.2347656"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -70,27 +70,8 @@
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 8 1 A 3 3.0000043 0 0 0 5 4 A 3 3.0000043 0 0 0 8 7 A 3 3.0000043 0 0 0 11 4 A 3 3.0000043 0 0 0 8 1 z M 8 3 A 1.000016 1.0000174 0 0 1 9 4 A 1.000016 1.0000174 0 0 1 8 5 A 1.000016 1.0000174 0 0 1 7 4 A 1.000016 1.0000174 0 0 1 8 3 z "
+ d="M 8 1 A 3 3.0000043 0 0 0 5 4 A 3 3.0000043 0 0 0 7 6.8261719 L 7 7 L 5 7 L 5 9 L 7 9 L 7 12.898438 A 5.0000172 5.0000172 0 0 1 3.171875 9.2949219 L 1.2382812 9.8125 A 7 7 0 0 0 8 15 A 7 7 0 0 0 14.761719 9.8125 L 12.824219 9.2929688 A 5.0000172 5.0000172 0 0 1 9 12.896484 L 9 9 L 11 9 L 11 7 L 9 7 L 9 6.8242188 A 3 3.0000043 0 0 0 11 4 A 3 3.0000043 0 0 0 8 1 z M 8 3 A 1.000016 1.0000174 0 0 1 9 4 A 1.000016 1.0000174 0 0 1 8 5 A 1.000016 1.0000174 0 0 1 7 4 A 1.000016 1.0000174 0 0 1 8 3 z "
transform="translate(0,1036.3622)"
id="path4142" />
- <rect
- y="1042.3622"
- x="7"
- height="7.0000172"
- width="2"
- id="rect4148"
- style="fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <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 12.824219 9.2929688 A 5.0000172 5.0000172 0 0 1 8 13 A 5.0000172 5.0000172 0 0 1 3.171875 9.2949219 L 1.2382812 9.8125 A 7 7 0 0 0 8 15 A 7 7 0 0 0 14.761719 9.8125 L 12.824219 9.2929688 z "
- transform="translate(0,1036.3622)"
- id="path4150" />
- <rect
- 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="rect4155"
- width="6"
- height="2"
- x="5"
- y="1043.3622" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_animation.svg b/tools/editor/icons/source/icon_animation.svg
index 38d73cf5bb..371979345f 100644
--- a/tools/editor/icons/source/icon_animation.svg
+++ b/tools/editor/icons/source/icon_animation.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="64"
- inkscape:cx="10.327464"
- inkscape:cy="2.5689331"
+ inkscape:zoom="22.627417"
+ inkscape:cx="9.2543315"
+ inkscape:cy="5.9550306"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -70,49 +70,8 @@
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 8 2 A 6 6 0 0 0 2 8 A 6 6 0 0 0 8 14 A 6 6 0 0 0 14 8 A 6 6 0 0 0 8 2 z M 8 3 A 1 1 0 0 1 9 4 A 1 1 0 0 1 8 5 A 1 1 0 0 1 7 4 A 1 1 0 0 1 8 3 z M 11.441406 5 A 1 1 0 0 1 12.330078 5.5 A 1 1 0 0 1 11.964844 6.8652344 A 1 1 0 0 1 10.597656 6.5 A 1 1 0 0 1 10.964844 5.1347656 A 1 1 0 0 1 11.441406 5 z M 4.4882812 5.0019531 A 1 1 0 0 1 5.0351562 5.1347656 A 1 1 0 0 1 5.4023438 6.5 A 1 1 0 0 1 4.0351562 6.8652344 A 1 1 0 0 1 3.6699219 5.5 A 1 1 0 0 1 4.4882812 5.0019531 z M 4.5117188 9 A 1 1 0 0 1 5.4023438 9.5 A 1 1 0 0 1 5.0351562 10.865234 A 1 1 0 0 1 3.6699219 10.5 A 1 1 0 0 1 4.0351562 9.1347656 A 1 1 0 0 1 4.5117188 9 z M 11.416016 9.0019531 A 1 1 0 0 1 11.964844 9.1347656 A 1 1 0 0 1 12.330078 10.5 A 1 1 0 0 1 10.964844 10.865234 A 1 1 0 0 1 10.597656 9.5 A 1 1 0 0 1 11.416016 9.0019531 z M 8 11 A 1 1 0 0 1 9 12 A 1 1 0 0 1 8 13 A 1 1 0 0 1 7 12 A 1 1 0 0 1 8 11 z "
- transform="translate(0,1036.3622)"
- id="path4140" />
- <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 13 8 L 13 14 A 1 1 0 0 0 14 15 L 15 15 L 15 14 L 14 14 L 14 13 L 14 8 L 13 8 z "
- transform="translate(0,1036.3622)"
- id="rect4202" />
- <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 14 13.5 L 14 14 L 14.5 14 A 0.5 0.4999913 0 0 1 14 13.5 z "
- transform="translate(0,1036.3622)"
- id="rect4215" />
- <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="rect4137"
- width="1"
- height="3.0000174"
- x="12"
- y="1047.3622" />
- <path
- id="path4139"
- transform="translate(0,1036.3622)"
- d="M 13 8 L 13 14 A 1 1 0 0 0 14 15 L 15 15 L 15 14 L 14 14 L 14 13 L 14 8 L 13 8 z "
- 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" />
- <rect
- y="1050.3622"
- x="14"
- height="2"
- width="1"
- id="rect4141"
- 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" />
- <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"
- id="path4145"
- sodipodi:type="arc"
- sodipodi:cx="14"
- sodipodi:cy="1050.3622"
- sodipodi:rx="2"
- sodipodi:ry="2"
- sodipodi:start="1.5707963"
- sodipodi:end="4.712389"
- d="m 14,1052.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:open="true" />
+ d="M 8 2 A 6 6 0 0 0 2 8 A 6 6 0 0 0 8 14 A 6 6 0 0 0 12 12.464844 L 12 14 L 12.001953 14 A 2 2 0 0 0 12.267578 15 A 2 2 0 0 0 14 16 L 15 16 L 15 15 L 15 14 L 14.5 14 A 0.5 0.4999913 0 0 1 14 13.5 L 14 13 L 14 8 A 6 6 0 0 0 8 2 z M 8 3 A 1 1 0 0 1 9 4 A 1 1 0 0 1 8 5 A 1 1 0 0 1 7 4 A 1 1 0 0 1 8 3 z M 11.441406 5 A 1 1 0 0 1 12.330078 5.5 A 1 1 0 0 1 11.964844 6.8652344 A 1 1 0 0 1 10.597656 6.5 A 1 1 0 0 1 10.964844 5.1347656 A 1 1 0 0 1 11.441406 5 z M 4.4882812 5.0019531 A 1 1 0 0 1 5.0351562 5.1347656 A 1 1 0 0 1 5.4023438 6.5 A 1 1 0 0 1 4.0351562 6.8652344 A 1 1 0 0 1 3.6699219 5.5 A 1 1 0 0 1 4.4882812 5.0019531 z M 4.5117188 9 A 1 1 0 0 1 5.4023438 9.5 A 1 1 0 0 1 5.0351562 10.865234 A 1 1 0 0 1 3.6699219 10.5 A 1 1 0 0 1 4.0351562 9.1347656 A 1 1 0 0 1 4.5117188 9 z M 11.416016 9.0019531 A 1 1 0 0 1 11.964844 9.1347656 A 1 1 0 0 1 12.330078 10.5 A 1 1 0 0 1 10.964844 10.865234 A 1 1 0 0 1 10.597656 9.5 A 1 1 0 0 1 11.416016 9.0019531 z M 8 11 A 1 1 0 0 1 9 12 A 1 1 0 0 1 8 13 A 1 1 0 0 1 7 12 A 1 1 0 0 1 8 11 z "
+ id="path4140"
+ transform="translate(0,1036.3622)" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_area.svg b/tools/editor/icons/source/icon_area.svg
index d56043cf3b..d16ad26e23 100644
--- a/tools/editor/icons/source/icon_area.svg
+++ b/tools/editor/icons/source/icon_area.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="5.5000497"
- inkscape:cy="8.7464605"
+ inkscape:cx="-2.7642608"
+ inkscape:cy="8.6580722"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -68,97 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
+ <path
style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4148"
- width="2"
- height="4"
- x="1"
- y="1047.3622" />
- <rect
- y="1049.3622"
- x="1"
- height="1.9999304"
- width="4"
- id="rect4150"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="1040.3622"
- x="4"
- height="8.0000172"
- width="2"
- id="rect4152"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="-1041.3622"
- x="1"
- height="4"
- width="2"
- id="rect4154"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;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)" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4156"
- width="4"
- height="1.9999304"
- x="1"
- y="-1039.3622"
- transform="scale(1,-1)" />
- <rect
- transform="scale(-1,-1)"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4158"
- width="2"
- height="4"
- x="-15"
- y="-1041.3622" />
- <rect
- transform="scale(-1,-1)"
- y="-1039.3622"
- x="-15"
- height="1.9999304"
- width="4"
- id="rect4160"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <rect
- y="1047.3623"
- x="-15"
- height="4"
- width="2"
- id="rect4162"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;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)" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4164"
- width="4"
- height="1.9999304"
- x="-15"
- y="1049.3623"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4168"
- width="8"
- height="1.9999998"
- x="4"
- y="1046.3622" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4170"
- width="2"
- height="8.0000172"
- x="-12"
- y="-1048.3622"
- transform="scale(-1,-1)" />
- <rect
- y="-1042.3622"
- x="-12"
- height="1.9999998"
- width="8"
- id="rect4172"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;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)" />
+ d="M 1 1 L 1 3 L 1 5 L 3 5 L 3 3 L 5 3 L 5 1 L 1 1 z M 11 1 L 11 3 L 13 3 L 13 5 L 15 5 L 15 1 L 11 1 z M 4 4 L 4 6 L 4 10 L 4 12 L 12 12 L 12 10 L 12 4 L 4 4 z M 6 6 L 10 6 L 10 10 L 6 10 L 6 6 z M 1 11 L 1 13 L 1 15 L 3 15 L 5 15 L 5 13 L 3 13 L 3 11 L 1 11 z M 13 11 L 13 13 L 11 13 L 11 15 L 15 15 L 15 13 L 15 11 L 13 11 z "
+ transform="translate(0,1036.3622)"
+ id="rect4148" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_area_2d.svg b/tools/editor/icons/source/icon_area_2d.svg
index 1373d9f0e4..ef7b16dd06 100644
--- a/tools/editor/icons/source/icon_area_2d.svg
+++ b/tools/editor/icons/source/icon_area_2d.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.313709"
- inkscape:cx="14.936968"
- inkscape:cy="11.331549"
+ inkscape:cx="-1.5916523"
+ inkscape:cy="11.154772"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -68,97 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
+ <path
style="opacity:1;fill:#a5b7f1;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="rect4148"
- width="2"
- height="4"
- x="1"
- y="1047.3622" />
- <rect
- y="1049.3622"
- x="1"
- height="1.9999304"
- width="4"
- id="rect4150"
- style="opacity:1;fill:#a5b7f1;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" />
- <rect
- y="1040.3622"
- x="4"
- height="8.0000172"
- width="2"
- id="rect4152"
- style="opacity:1;fill:#a5b7f1;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" />
- <rect
- y="-1041.3622"
- x="1"
- height="4"
- width="2"
- id="rect4154"
- style="opacity:1;fill:#a5b7f1;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"
- transform="scale(1,-1)" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4156"
- width="4"
- height="1.9999304"
- x="1"
- y="-1039.3622"
- transform="scale(1,-1)" />
- <rect
- transform="scale(-1,-1)"
- style="opacity:1;fill:#a5b7f1;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="rect4158"
- width="2"
- height="4"
- x="-15"
- y="-1041.3622" />
- <rect
- transform="scale(-1,-1)"
- y="-1039.3622"
- x="-15"
- height="1.9999304"
- width="4"
- id="rect4160"
- style="opacity:1;fill:#a5b7f1;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" />
- <rect
- y="1047.3623"
- x="-15"
- height="4"
- width="2"
- id="rect4162"
- style="opacity:1;fill:#a5b7f1;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"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4164"
- width="4"
- height="1.9999304"
- x="-15"
- y="1049.3623"
- transform="scale(-1,1)" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4168"
- width="8"
- height="1.9999998"
- x="4"
- y="1046.3622" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4170"
- width="2"
- height="8.0000172"
- x="-12"
- y="-1048.3622"
- transform="scale(-1,-1)" />
- <rect
- y="-1042.3622"
- x="-12"
- height="1.9999998"
- width="8"
- id="rect4172"
- style="opacity:1;fill:#a5b7f1;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"
- transform="scale(-1,-1)" />
+ d="M 1 1 L 1 3 L 1 5 L 3 5 L 3 3 L 5 3 L 5 1 L 1 1 z M 11 1 L 11 3 L 13 3 L 13 5 L 15 5 L 15 1 L 11 1 z M 4 4 L 4 6 L 4 10 L 4 12 L 12 12 L 12 10 L 12 4 L 4 4 z M 6 6 L 10 6 L 10 10 L 6 10 L 6 6 z M 1 11 L 1 13 L 1 15 L 3 15 L 5 15 L 5 13 L 3 13 L 3 11 L 1 11 z M 13 11 L 13 13 L 11 13 L 11 15 L 15 15 L 15 13 L 15 11 L 13 11 z "
+ transform="translate(0,1036.3622)"
+ id="rect4148" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_arrow_left.svg b/tools/editor/icons/source/icon_arrow_left.svg
index 7af9be05d8..75a9ef0d68 100644
--- a/tools/editor/icons/source/icon_arrow_left.svg
+++ b/tools/editor/icons/source/icon_arrow_left.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="5.5903114"
- inkscape:cy="9.1977698"
+ inkscape:cx="-0.2534386"
+ inkscape:cy="9.1352698"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -68,30 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4352"
- width="9"
- height="2.0000174"
- x="6"
- y="1043.3622" />
<path
- transform="matrix(0,1.2810265,0.92450034,0,964.29952,1037.9571)"
- inkscape:transform-center-y="-9.6789057e-05"
- d="m 8.122499,-1036.5594 -3.122499,0 -3.122499,0 1.5612495,-2.7042 L 5,-1041.9677 l 1.5612495,2.7041 z"
- inkscape:randomized="0"
- inkscape:rounded="0"
- inkscape:flatsided="false"
- sodipodi:arg2="1.5707963"
- sodipodi:arg1="0.52359878"
- sodipodi:r2="1.8027756"
- sodipodi:r1="3.6055512"
- sodipodi:cy="-1038.3622"
- sodipodi:cx="5"
- sodipodi:sides="3"
- id="path4435"
- style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-linecap:round;stroke-opacity:1"
- sodipodi:type="star"
- inkscape:transform-center-x="1.1667546" />
+ style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 6 4 L 3.5 6 L 1 8 L 3.5 10 L 6 12 L 6 9 L 15 9 L 15 7 L 6 7 L 6 4 z "
+ transform="translate(0,1036.3622)"
+ id="rect4352" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_arrow_right.svg b/tools/editor/icons/source/icon_arrow_right.svg
index 860a6f1481..a7600699f7 100644
--- a/tools/editor/icons/source/icon_arrow_right.svg
+++ b/tools/editor/icons/source/icon_arrow_right.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="6.7465614"
- inkscape:cy="9.3227698"
+ inkscape:cx="0.9028114"
+ inkscape:cy="9.2602698"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,9 @@
transform="translate(0,-1036.3622)">
<path
style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 10,1048.3622 2.5,-2 2.5,-2 -2.5,-2 -2.5,-2 0,3 -9,0 0,2 9,0 0,3 z"
+ d="m 10,1048.3622 5,-4 -5,-4 0,3 -9,0 0,2 9,0 z"
id="rect4352"
- inkscape:connector-curvature="0" />
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_auto_play.svg b/tools/editor/icons/source/icon_auto_play.svg
index 00bc96aac5..d4e1068ebf 100644
--- a/tools/editor/icons/source/icon_auto_play.svg
+++ b/tools/editor/icons/source/icon_auto_play.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="64"
- inkscape:cx="6.4431479"
- inkscape:cy="7.7277865"
+ inkscape:zoom="32"
+ inkscape:cx="9.592521"
+ inkscape:cy="9.4268437"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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>
@@ -70,40 +70,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="fill:none;fill-rule:evenodd;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
- d="m 2,1049.3622 0,-10 8,0 4,5 -4,5 z"
- id="path4164"
- inkscape:connector-curvature="0" />
- <rect
- y="1043.3622"
- x="4"
- height="3.9999824"
- width="1"
- id="rect4162"
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
- <path
- style="fill:#e0e0e0;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
- d="m 11,1044.3622 -2,-2 0,4 z"
- id="path4166"
- inkscape:connector-curvature="0" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4168"
- width="1"
- height="3.9999824"
- x="7"
- y="1043.3622" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4170"
- width="2"
- height="0.99994755"
- x="5"
- y="1044.3622" />
- <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:1"
- d="M 6 5 C 4.8954305 5 4 5.8954 4 7 L 5 7 A 1 1 0 0 1 6 6 A 1 1 0 0 1 7 7 L 8 7 C 8 5.8954 7.1045695 5 6 5 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;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:#e0e0e0;fill-opacity:1;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 2 2 A 1.0001 1.0001 0 0 0 1 3 L 1 13 A 1.0001 1.0001 0 0 0 2 14 L 10 14 A 1.0001 1.0001 0 0 0 10.78125 13.625 L 14.78125 8.625 A 1.0001 1.0001 0 0 0 14.78125 7.3769531 L 10.78125 2.3769531 A 1.0001 1.0001 0 0 0 10 2 L 2 2 z M 3 4 L 9.5195312 4 L 12.71875 8 L 9.5195312 12 L 3 12 L 3 4 z M 6 5 C 4.8954305 5 4 5.8954 4 7 L 4 11 L 5 11 L 5 9 L 7 9 L 7 11 L 8 11 L 8 7 C 8 5.8954 7.1045695 5 6 5 z M 6 6 A 1 1 0 0 1 7 7 L 7 8 L 5 8 L 5 7 A 1 1 0 0 1 6 6 z M 9 6 L 9 10 L 11 8 L 9 6 z "
transform="translate(0,1036.3622)"
- id="path4172" />
+ id="path4164" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_back_buffer_copy.svg b/tools/editor/icons/source/icon_back_buffer_copy.svg
index 150421d7dd..17d83ed73f 100644
--- a/tools/editor/icons/source/icon_back_buffer_copy.svg
+++ b/tools/editor/icons/source/icon_back_buffer_copy.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="12.102474"
- inkscape:cy="8.4888344"
+ inkscape:cx="3.8381635"
+ inkscape:cy="8.4004461"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,57 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
+ <path
style="opacity:1;fill:#a5b7f1;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="rect4146"
- width="2"
- height="9"
- x="1"
- y="1037.3622" />
- <rect
- y="1037.3622"
- x="1"
- height="2.0000174"
- width="8"
- id="rect4148"
- style="opacity:1;fill:#a5b7f1;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" />
- <rect
- y="-1051.3622"
- x="-15"
- height="9"
- width="2"
- id="rect4150"
- style="opacity:1;fill:#a5b7f1;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"
- transform="scale(-1,-1)" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4152"
- width="7"
- height="2.0000174"
- x="-15"
- y="-1051.3622"
- transform="scale(-1,-1)" />
- <rect
- transform="scale(-1,-1)"
- style="opacity:1;fill:#a5b7f1;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="rect4154"
- width="2"
- height="9"
- x="-9"
- y="-1051.3622" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4156"
- width="8"
- height="2.0000174"
- x="7"
- y="1040.3622" />
- <rect
- style="opacity:1;fill:#a5b7f1;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="rect4158"
- width="5"
- height="2.0000174"
- x="1"
- y="1046.3622" />
+ d="M 1 1 L 1 3 L 1 10 L 1 12 L 6 12 L 6 10 L 3 10 L 3 3 L 9 3 L 9 1 L 3 1 L 1 1 z M 7 4 L 7 6 L 7 15 L 9 15 L 15 15 L 15 13 L 15 6 L 15 4 L 7 4 z M 9 6 L 13 6 L 13 13 L 9 13 L 9 6 z "
+ transform="translate(0,1036.3622)"
+ id="rect4146" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_bake.svg b/tools/editor/icons/source/icon_bake.svg
index 7f1e9b4ae8..ca07bca379 100644
--- a/tools/editor/icons/source/icon_bake.svg
+++ b/tools/editor/icons/source/icon_bake.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="4.5449307"
- inkscape:cy="12.981869"
+ inkscape:cx="-3.7193798"
+ inkscape:cy="12.893481"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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>
@@ -71,22 +71,8 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z "
+ d="M 2 1 L 2 3 L 14 3 L 14 1 L 2 1 z M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z M 6 8 L 6 9 L 10 9 L 10 8 L 6 8 z "
transform="translate(0,1036.3622)"
id="rect4155" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4173"
- width="12"
- height="2.0000174"
- x="2"
- y="1037.3622" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4159"
- width="4"
- height="1.0000174"
- x="6"
- y="1044.3622" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_baked_light.svg b/tools/editor/icons/source/icon_baked_light.svg
index 7f1e9b4ae8..98dc3135f6 100644
--- a/tools/editor/icons/source/icon_baked_light.svg
+++ b/tools/editor/icons/source/icon_baked_light.svg
@@ -18,7 +18,7 @@
inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_bone.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
- sodipodi:docname="icon_bake.svg">
+ sodipodi:docname="icon_baked_light.svg">
<defs
id="defs4" />
<sodipodi:namedview
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="4.5449307"
- inkscape:cy="12.981869"
+ inkscape:cx="6.1801151"
+ inkscape:cy="10.551189"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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>
@@ -71,22 +71,8 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z "
+ d="M 2 1 L 2 3 L 14 3 L 14 1 L 2 1 z M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z M 6 8 L 6 9 L 10 9 L 10 8 L 6 8 z "
transform="translate(0,1036.3622)"
id="rect4155" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4173"
- width="12"
- height="2.0000174"
- x="2"
- y="1037.3622" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4159"
- width="4"
- height="1.0000174"
- x="6"
- y="1044.3622" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_baked_light_instance.svg b/tools/editor/icons/source/icon_baked_light_instance.svg
index 434bf0f6fc..d854378f12 100644
--- a/tools/editor/icons/source/icon_baked_light_instance.svg
+++ b/tools/editor/icons/source/icon_baked_light_instance.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="-3.1006614"
- inkscape:cy="12.893481"
+ inkscape:cx="10.864698"
+ inkscape:cy="11.302491"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -71,22 +71,8 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z "
+ d="M 2 1 L 2 3 L 14 3 L 14 1 L 2 1 z M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 13 15 A 2 2.0000174 0 0 0 15 13 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 3 7 L 13 7 L 13 13 L 3 13 L 3 7 z M 6 8 L 6 9 L 10 9 L 10 8 L 6 8 z "
transform="translate(0,1036.3622)"
id="rect4155" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4173"
- width="12"
- height="2.0000174"
- x="2"
- y="1037.3622" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4159"
- width="4"
- height="1.0000174"
- x="6"
- y="1044.3622" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_baked_light_sampler.svg b/tools/editor/icons/source/icon_baked_light_sampler.svg
index aa6e6e26d0..2dc7c39621 100644
--- a/tools/editor/icons/source/icon_baked_light_sampler.svg
+++ b/tools/editor/icons/source/icon_baked_light_sampler.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="3.5600026"
- inkscape:cy="5.9708001"
+ inkscape:cx="9.2162526"
+ inkscape:cy="7.9395501"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -71,20 +71,8 @@
transform="translate(0,-1036.3622)">
<path
style="opacity:1;fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 7 15 L 7 13 L 3 13 L 3 7 L 7 7 L 13 7 L 15 7 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 6 8 L 6 9 L 7 9 L 7 8 L 6 8 z "
+ d="M 2 1 L 2 3 L 14 3 L 14 1 L 2 1 z M 1 4 L 1 13 A 2 2.0000174 0 0 0 3 15 L 7 15 L 7 13 L 3 13 L 3 7 L 7 7 L 13 7 L 15 7 L 15 4 L 1 4 z M 3 5 L 4 5 L 4 6 L 3 6 L 3 5 z M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 12 5 L 13 5 L 13 6 L 12 6 L 12 5 z M 6 8 L 6 9 L 7 9 L 7 8 L 6 8 z M 10 9 A 1 1 0 0 0 9 10 L 9 14 A 1 1 0 0 0 10 15 L 14 15 A 1 1 0 0 0 15 14 L 15 10 A 1 1 0 0 0 14 9 L 10 9 z M 13 10 A 1 1 0 0 1 14 11 A 1 1 0 0 1 13 12 A 1 1 0 0 1 12 11 A 1 1 0 0 1 13 10 z M 11 12 A 1 1 0 0 1 12 13 A 1 1 0 0 1 11 14 A 1 1 0 0 1 10 13 A 1 1 0 0 1 11 12 z "
transform="translate(0,1036.3622)"
id="rect4155" />
- <rect
- style="opacity:1;fill:#fc9c9c;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4173"
- width="12"
- height="2.0000174"
- x="2"
- y="1037.3622" />
- <path
- style="opacity:1;fill:#fc9c9c;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"
- d="M 10 9 A 1 1 0 0 0 9 10 L 9 14 A 1 1 0 0 0 10 15 L 14 15 A 1 1 0 0 0 15 14 L 15 10 A 1 1 0 0 0 14 9 L 10 9 z M 13 10 A 1 1 0 0 1 14 11 A 1 1 0 0 1 13 12 A 1 1 0 0 1 12 11 A 1 1 0 0 1 13 10 z M 11 12 A 1 1 0 0 1 12 13 A 1 1 0 0 1 11 14 A 1 1 0 0 1 10 13 A 1 1 0 0 1 11 12 z "
- transform="translate(0,1036.3622)"
- id="rect4156" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_bitmap_font.svg b/tools/editor/icons/source/icon_bitmap_font.svg
index fa9fdaf5c5..70749923d5 100644
--- a/tools/editor/icons/source/icon_bitmap_font.svg
+++ b/tools/editor/icons/source/icon_bitmap_font.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="10.302728"
- inkscape:cy="7.9861624"
+ inkscape:cx="5.619442"
+ inkscape:cy="6.940754"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,62 +69,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <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="rect4212"
- width="14"
- height="2"
- x="1"
- y="1037.3622" />
- <rect
- y="1037.3622"
- x="7"
- height="14.000017"
- width="2"
- id="rect4214"
- style="opacity:1;fill:#fcef9c;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:#fcef9c;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="rect4216"
- width="6"
- height="0.99999976"
- x="5"
- y="1050.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:0.99607843"
- d="M 1 1 L 1 3 L 1 5 L 2 5 L 2 4 L 3 4 L 3 3 L 4 3 L 4 1 L 2 1 L 1 1 z "
- transform="translate(0,1036.3622)"
- id="rect4218" />
<path
- style="opacity:1;fill:#be9cfc;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 12 1 L 12 3 L 13 3 L 13 4 L 14 4 L 14 5 L 15 5 L 15 3 L 15 1 L 14 1 L 12 1 z "
- transform="translate(0,1036.3622)"
- id="rect4220" />
- <rect
- style="opacity:1;fill:#fcef9c;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="rect4259"
- width="1"
- height="1"
- x="9"
- y="1049.3622" />
- <rect
- y="1049.3622"
- x="6"
- height="1"
- width="1"
- id="rect4261"
- style="opacity:1;fill:#fcef9c;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" />
- <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:0.99607843"
- d="M 4 1 L 4 3 L 7 3 L 7 6 L 9 6 L 9 3 L 12 3 L 12 1 L 4 1 z "
- transform="translate(0,1036.3622)"
- id="rect4276" />
- <rect
- style="opacity:1;fill:#a5b7f8;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"
- id="rect4307"
- width="2"
- height="5"
- x="7"
- y="1042.3622" />
+ style="opacity:1;fill:#84c2ff;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 1,1037.3622 0,2 0,2 1,0 0,-1 1,0 0,-1 4,0 0,3 0,5 0,2 -1,0 0,1 -1,0 0,1 6,0 0,-1 -1,0 0,-1 -1,0 0,-10 4,0 0,1 1,0 0,1 1,0 0,-2 0,-2 -13,0 -1,0 z"
+ id="rect4212"
+ inkscape:connector-curvature="0" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_canvas_layer.svg b/tools/editor/icons/source/icon_canvas_layer.svg
index a26edd7d6d..794d832eea 100644
--- a/tools/editor/icons/source/icon_canvas_layer.svg
+++ b/tools/editor/icons/source/icon_canvas_layer.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="-3.1074492"
- inkscape:cy="10.973033"
+ inkscape:cx="-2.2677599"
+ inkscape:cy="10.08915"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="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,35 +74,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- sodipodi:nodetypes="cscsccccsssc"
- inkscape:connector-curvature="0"
- id="path4146"
- d="m 2.920797,1046.3957 c -0.2637264,0.3 -0.4203983,0.7296 -0.4203983,1.2383 0,1.6277 -3.13814186,-0.1781 -0.337569,2.6703 0.8838207,0.899 2.6543881,0.6701 3.538224,-0.2288 0.8838352,-0.899 0.8838163,-2.3565 0,-3.2554 -1.1002211,-1.1191 -2.200058,-1.0845 -2.7802567,-0.4244 z m 2.3801743,-1.6103 2.4004918,2.4416 6.8013899,-6.9177 c 0.662863,-0.6742 0.662863,-1.7673 0,-2.4415 -0.662877,-0.6741 -1.737613,-0.6741 -2.400491,0 z"
- style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <path
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="M 3 1 A 2 2 0 0 0 1 3 L 2 3 A 1.0000174 1.0000174 0 0 1 3 2 L 3 1 z "
+ style="fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 3 1 A 2 2 0 0 0 1 3 L 1 9 L 2 9 L 2 3 A 1.0000174 1.0000174 0 0 1 3 2 L 9 2 L 9 1 L 3 1 z M 13.302734 1 C 12.868331 1 12.433001 1.1688094 12.101562 1.5058594 L 5.3007812 8.4238281 L 7.7011719 10.865234 L 14.501953 3.9472656 C 15.164816 3.2730656 15.164816 2.1800594 14.501953 1.5058594 C 14.170515 1.1688094 13.737138 1 13.302734 1 z M 14 7 L 14 13 A 1.0000174 1.0000174 0 0 1 13 14 L 7 14 L 7 15 L 13 15 A 2 2 0 0 0 15 13 L 15 7 L 14 7 z M 4.1152344 9.578125 C 3.6302227 9.5294 3.2100212 9.7031531 2.9199219 10.033203 C 2.6561955 10.333203 2.5 10.762784 2.5 11.271484 C 2.5 12.899184 -0.63846349 11.093006 2.1621094 13.941406 C 3.0459301 14.840406 4.817336 14.611791 5.7011719 13.712891 C 6.5850071 12.813891 6.5849882 11.355931 5.7011719 10.457031 C 5.1510613 9.8974813 4.6002461 9.62685 4.1152344 9.578125 z "
transform="translate(0,1036.3622)"
- id="path4160" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4164"
- width="6"
- height="1"
- x="3"
- y="1037.3622" />
- <rect
- y="-2"
- x="1039.3622"
- height="1"
- width="6"
- id="rect4166"
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;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
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- d="m 13,1051.3622 a 2,2 0 0 0 2,-2 l 0,-6 -1,0 0,6 a 1.0000174,1.0000174 0 0 1 -1,1 l -6,0 0,1 6,0 z"
- id="path4169"
- inkscape:connector-curvature="0" />
+ id="path4146" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_canvas_modulate.svg b/tools/editor/icons/source/icon_canvas_modulate.svg
index 450823e005..8f8bd55f82 100644
--- a/tools/editor/icons/source/icon_canvas_modulate.svg
+++ b/tools/editor/icons/source/icon_canvas_modulate.svg
@@ -20,7 +20,44 @@
inkscape:export-ydpi="90"
sodipodi:docname="icon_canvas_modulate.svg">
<defs
- id="defs4" />
+ 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="clipPath4392">
+ <path
+ 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 8.072266,1041.3622 a 5,5 0 0 0 -3.607422,1.4648 5,5 0 0 0 0,7.0704 5,5 0 0 0 7.070312,0 l -1.416015,-1.4161 A 3,3 0 0 1 8,1049.3622 a 3,3 0 0 1 -3,-3 3,3 0 0 1 3,-3 3,3 0 0 1 2.119141,0.8809 l 1.416015,-1.4161 a 5,5 0 0 0 -3.46289,-1.4648 z"
+ id="path4394"
+ inkscape:connector-curvature="0" />
+ </clipPath>
+ <clipPath
+ id="clipPath4196"
+ clipPathUnits="userSpaceOnUse">
+ <path
+ inkscape:connector-curvature="0"
+ id="path4198"
+ d="m 8.0624999,1025.8622 a 3.375,2.9999997 0 0 0 -3.375,3 3.375,2.9999997 0 0 0 1.6875,2.5957 l 0,9.8115 a 3.375,2.9999997 0 0 0 -1.6875,2.5928 3.375,2.9999997 0 0 0 3.375,3 3.375,2.9999997 0 0 0 3.3750001,-3 3.375,2.9999997 0 0 0 -1.6875001,-2.5957 l 0,-8.7832 11.9311511,10.6054 a 3.375,2.9999997 0 0 0 -0.118651,0.7735 3.375,2.9999997 0 0 0 3.375,3 3.375,2.9999997 0 0 0 3.375,-3 3.375,2.9999997 0 0 0 -3.375,-3 3.375,2.9999997 0 0 0 -0.873413,0.1025 l -11.927857,-10.6025 9.884399,0 a 3.375,2.9999997 0 0 0 2.916871,1.5 3.375,2.9999997 0 0 0 3.375,-3 3.375,2.9999997 0 0 0 -3.375,-3 3.375,2.9999997 0 0 0 -2.920166,1.5 l -11.037964,0 a 3.375,2.9999997 0 0 0 -2.9168701,-1.5 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>
+ </defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
@@ -28,9 +65,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="16"
- inkscape:cx="7.3785882"
- inkscape:cy="11.139886"
+ inkscape:zoom="45.254834"
+ inkscape:cx="10.091501"
+ inkscape:cy="9.4358129"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +83,10 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true">
<inkscape:grid
type="xygrid"
id="grid3336"
@@ -60,7 +100,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,39 +109,29 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="rect4159"
- width="10"
- height="10.000017"
- x="3"
- y="1039.3622" />
<path
style="fill:#a5b7f1;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 1,1037.3622 0,2 0,12 2,0 12,0 0,-2 0,-12 -2,0 -10,0 z m 2,2 10,0 0,10 -10,0 z"
+ d="m 1,1037.3622 0,14 14,0 0,-14 z m 2,2 10,0 0,10 -10,0 z"
id="rect4280"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccccccccccc" />
- <ellipse
- style="fill:#ff0000;fill-opacity:0.78431373;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="path4153"
- cx="6.5"
- cy="1045.8622"
- rx="2.5"
- ry="2.4999871" />
- <ellipse
- style="fill:#0000ff;fill-opacity:0.78431373;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="ellipse4157"
- cx="8"
- cy="1042.8622"
- rx="2.5"
- ry="2.4999938" />
- <ellipse
- ry="2.4999936"
- rx="2.5"
- cy="1045.8622"
- cx="9.5"
- id="ellipse4155"
- style="fill:#00ff00;fill-opacity:0.78431373;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ sodipodi:nodetypes="cccccccccc" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4183"
+ d="m 12,1048.3622 -5,0 5,-5 z"
+ style="fill:#70bfff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="cccc" />
+ <path
+ 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 5,0 -5,5 z"
+ id="path4185"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <path
+ sodipodi:nodetypes="ccccccc"
+ inkscape:connector-curvature="0"
+ id="path4187"
+ d="m 4,1048.3622 0,-3 5,-5 3,0 0,3 -5,5 z"
+ style="fill:#7aff70;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_color_rect.svg b/tools/editor/icons/source/icon_color_rect.svg
new file mode 100644
index 0000000000..76bf6596a9
--- /dev/null
+++ b/tools/editor/icons/source/icon_color_rect.svg
@@ -0,0 +1,156 @@
+<?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_color_rect.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
+ id="clipPath4392"
+ clipPathUnits="userSpaceOnUse">
+ <path
+ inkscape:connector-curvature="0"
+ id="path4394"
+ d="m 8.072266,1041.3622 a 5,5 0 0 0 -3.607422,1.4648 5,5 0 0 0 0,7.0704 5,5 0 0 0 7.070312,0 l -1.416015,-1.4161 A 3,3 0 0 1 8,1049.3622 a 3,3 0 0 1 -3,-3 3,3 0 0 1 3,-3 3,3 0 0 1 2.119141,0.8809 l 1.416015,-1.4161 a 5,5 0 0 0 -3.46289,-1.4648 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" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath4196">
+ <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 8.0624999,1025.8622 a 3.375,2.9999997 0 0 0 -3.375,3 3.375,2.9999997 0 0 0 1.6875,2.5957 l 0,9.8115 a 3.375,2.9999997 0 0 0 -1.6875,2.5928 3.375,2.9999997 0 0 0 3.375,3 3.375,2.9999997 0 0 0 3.3750001,-3 3.375,2.9999997 0 0 0 -1.6875001,-2.5957 l 0,-8.7832 11.9311511,10.6054 a 3.375,2.9999997 0 0 0 -0.118651,0.7735 3.375,2.9999997 0 0 0 3.375,3 3.375,2.9999997 0 0 0 3.375,-3 3.375,2.9999997 0 0 0 -3.375,-3 3.375,2.9999997 0 0 0 -0.873413,0.1025 l -11.927857,-10.6025 9.884399,0 a 3.375,2.9999997 0 0 0 2.916871,1.5 3.375,2.9999997 0 0 0 3.375,-3 3.375,2.9999997 0 0 0 -3.375,-3 3.375,2.9999997 0 0 0 -2.920166,1.5 l -11.037964,0 a 3.375,2.9999997 0 0 0 -2.9168701,-1.5 z"
+ id="path4198"
+ 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="32"
+ inkscape:cx="9.9050022"
+ inkscape:cy="11.383887"
+ 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:snap-smooth-nodes="true"
+ inkscape:snap-midpoints="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></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" />
+ <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"
+ 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" />
+ <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"
+ id="path4172"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccc" />
+ </g>
+</svg>
diff --git a/tools/editor/icons/source/icon_connect.svg b/tools/editor/icons/source/icon_connect.svg
index 2261765bdf..745d3cc436 100644
--- a/tools/editor/icons/source/icon_connect.svg
+++ b/tools/editor/icons/source/icon_connect.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627418"
- inkscape:cx="9.0509434"
- inkscape:cy="11.261328"
+ inkscape:cx="0.78663326"
+ inkscape:cy="12.940707"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,52 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- y="1043.3622"
- x="1"
- height="1.9999478"
- width="5"
- id="rect4155"
- style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#e0e0e0;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="rect4157"
- width="4"
- height="12"
- x="7"
- y="1038.3622" />
- <rect
- style="opacity:1;fill:#e0e0e0;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="rect4159"
- width="3"
- height="2"
- x="11"
- y="1040.3622" />
- <rect
- y="1046.3622"
- x="11"
- height="2"
- width="3"
- id="rect4161"
- style="opacity:1;fill:#e0e0e0;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" />
- <circle
- style="opacity:1;fill:#e0e0e0;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="path4163"
- cx="7"
- cy="1040.3622"
- r="2" />
- <rect
- y="1040.3622"
- x="5"
- height="8.0000172"
- width="4"
- id="rect4165"
- style="opacity:1;fill:#e0e0e0;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" />
- <circle
- r="2"
- cy="1048.3622"
- cx="7"
- id="circle4167"
- style="opacity:1;fill:#e0e0e0;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="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 7 2 A 2 2 0 0 0 5 4 L 5 7 L 1 7 L 1 9 L 5 9 L 5 12 A 2 2 0 0 0 7 14 L 11 14 L 11 12 L 14 12 L 14 10 L 11 10 L 11 6 L 14 6 L 14 4 L 11 4 L 11 2 L 7 2 z "
+ transform="translate(0,1036.3622)"
+ id="rect4155" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_connection_and_groups.svg b/tools/editor/icons/source/icon_connection_and_groups.svg
index 97f615d9bc..5468312b4b 100644
--- a/tools/editor/icons/source/icon_connection_and_groups.svg
+++ b/tools/editor/icons/source/icon_connection_and_groups.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627418"
- inkscape:cx="4.8878469"
- inkscape:cy="12.667351"
+ inkscape:cx="-3.3764632"
+ inkscape:cy="12.578963"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -68,97 +68,10 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <rect
- y="1048.3622"
- x="2"
- height="0.99993038"
- width="6"
- id="rect4155"
- style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- <rect
- style="opacity:1;fill:#e0e0e0;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="rect4157"
- width="2"
- height="6.9999485"
- x="10"
- y="1045.3622" />
- <rect
- style="opacity:1;fill:#e0e0e0;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="rect4159"
- width="2"
- height="0.9999826"
- x="12"
- y="1046.3622" />
- <rect
- y="1050.3622"
- x="12"
- height="0.9999826"
- width="2"
- id="rect4161"
- style="opacity:1;fill:#e0e0e0;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" />
- <ellipse
- style="opacity:1;fill:#e0e0e0;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="path4163"
- cx="10"
- cy="1047.3622"
- rx="2"
- ry="1.9999913" />
- <circle
- r="2"
- cy="1050.3622"
- cx="10"
- id="circle4167"
- style="opacity:1;fill:#e0e0e0;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="1047.3623"
- x="8"
- height="2.9998953"
- width="2"
- id="rect4201"
- style="opacity:1;fill:#e0e0e0;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:#e0e0e0;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="rect4203"
- width="12"
- height="1"
- x="2"
- y="1036.3622" />
- <rect
- y="1042.3622"
- x="2"
- height="1"
- width="12"
- id="rect4205"
- style="opacity:1;fill:#e0e0e0;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="-3"
- x="1036.3622"
- height="1"
- width="6.0000348"
- id="rect4207"
- style="opacity:1;fill:#e0e0e0;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)" />
- <rect
- transform="matrix(0,1,-1,0,0,0)"
- style="opacity:1;fill:#e0e0e0;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="rect4209"
- width="6.0000348"
- height="1"
- x="1036.3622"
- y="-14" />
- <ellipse
- ry="1.5000032"
- rx="1.5"
- cy="1039.8622"
- cx="5.5"
- id="ellipse4214"
- style="opacity:1;fill:#e0e0e0;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" />
- <ellipse
- style="opacity:1;fill:#e0e0e0;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="ellipse4216"
- cx="10.5"
- cy="1039.8622"
- rx="1.5"
- ry="1.5000032" />
+ <path
+ style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 2 0 L 2 1 L 2 6 L 2 7 L 14 7 L 14 6 L 14 0 L 3 0 L 2 0 z M 3 1 L 13 1 L 13 6 L 3 6 L 3 1 z M 5.5 2 A 1.5 1.5000032 0 0 0 4 3.5 A 1.5 1.5000032 0 0 0 5.5 5 A 1.5 1.5000032 0 0 0 7 3.5 A 1.5 1.5000032 0 0 0 5.5 2 z M 10.5 2 A 1.5 1.5000032 0 0 0 9 3.5 A 1.5 1.5000032 0 0 0 10.5 5 A 1.5 1.5000032 0 0 0 12 3.5 A 1.5 1.5000032 0 0 0 10.5 2 z M 10 9 A 2 1.9999913 0 0 0 8 11 L 8 12 L 2 12 L 2 13 L 8 13 L 8 14 A 2 2 0 0 0 10 16 L 12 16 L 12 15 L 14 15 L 14 14 L 12 14 L 12 11 L 14 11 L 14 10 L 12 10 L 12 9 L 10 9 z "
+ transform="translate(0,1036.3622)"
+ id="rect4155" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_copy_node_path.svg b/tools/editor/icons/source/icon_copy_node_path.svg
new file mode 100644
index 0000000000..9f33c5e54d
--- /dev/null
+++ b/tools/editor/icons/source/icon_copy_node_path.svg
@@ -0,0 +1,98 @@
+<?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/godotengine/godot/tools/editor/icons/con_script_create.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_copy_node_path.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>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="21.189633"
+ inkscape:cx="12.640765"
+ inkscape:cy="9.6848443"
+ 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"
+ showguides="false"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-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)">
+ <circle
+ cy="1048.3622"
+ cx="3"
+ id="ellipse4234"
+ 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"
+ ry="1.0000174"
+ rx="1" />
+ <path
+ style="opacity:1;fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 2 1 C 1.4477381 1.0001 1.0000552 1.4477 1 2 L 1 14 C 1.0000552 14.5523 1.4477381 14.9999 2 15 L 14 15 C 14.552262 14.9999 14.999945 14.5523 15 14 L 15 6 L 10 1 L 2 1 z M 3 3 L 9 3 L 9 6 C 9 6.554 9.4459905 7 10 7 L 13 7 L 13 13 L 3 13 L 3 3 z M 6 8 L 4 12 L 6 12 L 8 8 L 6 8 z M 10 8 L 8 12 L 10 12 L 12 8 L 10 8 z "
+ transform="translate(0,1036.3622)"
+ id="rect4178" />
+ </g>
+</svg>
diff --git a/tools/editor/icons/source/icon_create_new_scene_from.svg b/tools/editor/icons/source/icon_create_new_scene_from.svg
index f5a456773c..529553bbd3 100644
--- a/tools/editor/icons/source/icon_create_new_scene_from.svg
+++ b/tools/editor/icons/source/icon_create_new_scene_from.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="4.1061535"
- inkscape:cy="9.360052"
+ inkscape:cx="-3.7255471"
+ inkscape:cy="8.1847434"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,10 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true">
<inkscape:grid
type="xygrid"
id="grid3336" />
@@ -59,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>
@@ -70,9 +73,11 @@
transform="translate(0,-1036.3622)">
<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:1"
- d="M 1 7 L 1 13 A 2 2 0 0 0 3 15 L 15 15 L 15 7 L 1 7 z M 4 9 L 5 9 L 5 11 L 7 11 L 7 12 L 5 12 L 5 14 L 4 14 L 4 12 L 2 12 L 2 11 L 4 11 L 4 9 z "
+ d="m 1,7 0,6 c 0,1.104569 0.8954305,2 2,2 l 7,0 0,-1 -2,0 0,-4 2,0 0,-2 4,0 0,2 1,0 0,-3 z"
transform="translate(0,1036.3622)"
- id="rect4136" />
+ id="rect4136"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cssccccccccccc" />
<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:1"
d="M 0.7112932,1040.3831 1,1042.3622 l 2.2438279,-0.3273 -0.8182578,-1.9018 -1.7142769,0.25 z m 3.6933293,-0.5387 0.8182578,1.9018 1.9790524,-0.2887 -0.8182579,-1.9018 -1.9790523,0.2887 z m 3.9581047,-0.5775 0.8182579,1.9018 1.9790519,-0.2887 -0.818257,-1.9018 -1.9790528,0.2887 z m 3.9581048,-0.5774 0.818258,1.9018 1.714277,-0.25 -0.288707,-1.9791 -2.243828,0.3273 z"
@@ -80,5 +85,17 @@
inkscape:connector-curvature="0"
inkscape:transform-center-x="-6.7823301"
inkscape:transform-center-y="-2" />
+ <circle
+ r="0"
+ cy="1047.3622"
+ cx="-14"
+ id="ellipse4234"
+ 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" />
+ <path
+ sodipodi:nodetypes="ccccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path4155"
+ d="m 13,1049.3622 2,0 0,-2 -2,0 0,-2 -2,0 0,2 -2,0 0,2 2,0 0,2 2,0 z"
+ style="fill:#84ffb1;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_dynamic_font_data.svg b/tools/editor/icons/source/icon_dynamic_font_data.svg
index 468b472d7e..9f06172fef 100644
--- a/tools/editor/icons/source/icon_dynamic_font_data.svg
+++ b/tools/editor/icons/source/icon_dynamic_font_data.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
- inkscape:cx="1.442498"
- inkscape:cy="7.5824259"
+ inkscape:cx="6.4667889"
+ inkscape:cy="8.2902868"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -69,10 +69,10 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- id="path4246"
- d="m 1,1037.3622 0,2 0,1 1,0 a 1,1 0 0 1 1,-1 l 2,0 0,6 a 1,1 0 0 1 -1,1 l 0,1 1,0 2,0 1,0 0,-1 a 1,1 0 0 1 -1,-1 l 0,-6 2,0 a 1,1 0 0 1 1,1 l 1,0 0,-1 0,-2 -4,0 -2,0 -4,0 z"
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"
- inkscape:connector-curvature="0" />
+ d="M 1 1 L 1 3 L 1 4 L 2 4 A 1 1 0 0 1 3 3 L 5 3 L 5 9 A 1 1 0 0 1 4 10 L 4 11 L 5 11 L 7 11 L 8 11 L 8 10 A 1 1 0 0 1 7 9 L 7 3 L 9 3 A 1 1 0 0 1 10 4 L 11 4 L 11 3 L 11 1 L 7 1 L 5 1 L 1 1 z M 1 6 L 1 8 L 3 8 L 3 6 L 1 6 z M 1 9 L 1 11 L 3 11 L 3 9 L 1 9 z M 1 12 L 1 14 L 3 14 L 3 12 L 1 12 z M 4 12 L 4 14 L 6 14 L 6 12 L 4 12 z "
+ transform="translate(0,1036.3622)"
+ id="path4246" />
<path
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:1"
d="M 4 5 L 4 7 L 4 8 L 5 8 A 1 1 0 0 1 6 7 L 8 7 L 8 13 A 1 1 0 0 1 7 14 L 7 15 L 8 15 L 10 15 L 11 15 L 11 14 A 1 1 0 0 1 10 13 L 10 7 L 12 7 A 1 1 0 0 1 13 8 L 14 8 L 14 7 L 14 5 L 10 5 L 8 5 L 4 5 z "
diff --git a/tools/editor/icons/source/icon_error.svg b/tools/editor/icons/source/icon_error.svg
index 831bac859a..a0b04a98cb 100644
--- a/tools/editor/icons/source/icon_error.svg
+++ b/tools/editor/icons/source/icon_error.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627416"
- inkscape:cx="-12.047246"
- inkscape:cy="6.3485985"
+ inkscape:cx="5.542036"
+ inkscape:cy="14.568715"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -75,6 +75,7 @@
width="8"
height="8"
x="2.220446e-16"
- y="1044.3622" />
+ y="1044.3622"
+ ry="1.0000174" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_fixed_spatial_material.svg b/tools/editor/icons/source/icon_fixed_spatial_material.svg
index 575b0d06c6..7ae0f93ffc 100644
--- a/tools/editor/icons/source/icon_fixed_spatial_material.svg
+++ b/tools/editor/icons/source/icon_fixed_spatial_material.svg
@@ -7,7 +7,6 @@
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"
@@ -22,38 +21,6 @@
sodipodi:docname="icon_fixed_spatial_material.svg">
<defs
id="defs4">
- <linearGradient
- inkscape:collect="always"
- id="linearGradient4257">
- <stop
- style="stop-color:#ff70ac;stop-opacity:1"
- offset="0"
- id="stop4259" />
- <stop
- id="stop4273"
- offset="0.17862372"
- style="stop-color:#9f70ff;stop-opacity:1" />
- <stop
- id="stop4271"
- offset="0.3572498"
- style="stop-color:#70deff;stop-opacity:1" />
- <stop
- id="stop4269"
- offset="0.53587586"
- style="stop-color:#70ffb9;stop-opacity:1" />
- <stop
- id="stop4267"
- offset="0.71450192"
- style="stop-color:#9dff70;stop-opacity:1" />
- <stop
- id="stop4265"
- offset="0.89312798"
- style="stop-color:#ffeb70;stop-opacity:1" />
- <stop
- style="stop-color:#ff7070;stop-opacity:1"
- offset="1"
- id="stop4261" />
- </linearGradient>
<clipPath
id="clipPath4189"
clipPathUnits="userSpaceOnUse">
@@ -63,17 +30,33 @@
d="m 6.3750001,1025.8622 a 1.6876688,1.5001498 0 0 0 -1.6875,1.5 l 0,18 a 1.6876688,1.5001498 0 0 0 1.6875,1.5 l 10.1217039,0 c -0.747392,-0.8796 -1.304338,-1.8888 -1.562256,-3 l -6.8719479,0 0,-15 16.8749999,0 0,3.3486 a 3.4281247,3.0472216 0 0 1 1.282105,1.1279 c 0.537834,0.828 1.294284,1.677 2.092895,2.5723 l 0,-8.5488 a 1.6876688,1.5001498 0 0 0 -1.6875,-1.5 l -20.2499999,0 z m 11.8124999,4.5 0,1.5 -1.6875,0 0,1.5 -3.375,0 0,1.5 -1.6875,0 0,1.5 -1.6874999,0 0,1.5 3.3749999,0 3.375,0 0.02637,0 c 0.246127,-0.317 0.496441,-0.6239 0.738282,-0.9053 1.145331,-1.3327 2.270672,-2.4711 3.015746,-3.6182 a 3.4281247,3.0472216 0 0 1 1.282105,-1.1279 l 0,-0.3486 -1.6875,0 0,-1.5 -1.6875,0 z m 5.0625,4.5 c -1.948558,3 -5.0625,5.0146 -5.0625,7.5 0,2.4853 2.266559,4.5 5.0625,4.5 2.795941,0 5.0625,-2.0147 5.0625,-4.5 0,-2.4854 -3.113942,-4.5 -5.0625,-7.5 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;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:#000000;fill-opacity:1;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" />
</clipPath>
- <radialGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4257"
- id="radialGradient4263"
- cx="13.333239"
- cy="1043.3622"
- fx="13.333239"
- fy="1043.3622"
- r="7"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(-0.93305925,0.79975529,-0.85714494,-0.99999821,914.75331,2076.0592)" />
+ <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
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath4208">
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 4.6875001,1042.3622 11.8124999,4.5 11.8125,-4.5 0,-12 -11.8125,-4.5 -11.8124999,4.5 z"
+ id="path4210"
+ 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>
</defs>
<sodipodi:namedview
id="base"
@@ -83,8 +66,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="12.314693"
- inkscape:cy="10.250946"
+ inkscape:cx="11.899872"
+ inkscape:cy="11.262807"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -118,7 +101,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>
@@ -127,21 +110,60 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <path
- inkscape:connector-curvature="0"
- style="fill:url(#radialGradient4263);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 8,1037.3622 -7,3 0,8 7,3 7,-3 0,-8 -7,-3 z"
- id="path4151" />
- <path
- style="fill:#ffffff;fill-opacity:0.72222221;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 1,1040.3622 7,3 7,-3 -7,-3 z"
- id="path4149"
- inkscape:connector-curvature="0" />
- <path
- inkscape:connector-curvature="0"
- id="path4145"
- d="m 8,1051.3622 7,-3 0,-8 -7,3 z"
- style="fill:#000000;fill-opacity:0.46969697;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- sodipodi:nodetypes="ccccc" />
+ <g
+ id="g4181"
+ mask="none"
+ clip-path="url(#clipPath4199)"
+ transform="matrix(0.59259259,0,0,0.66666674,-1.7777777,353.454)">
+ <rect
+ y="1025.8622"
+ x="3"
+ height="3.0000043"
+ width="27"
+ 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="27"
+ height="3.0000041"
+ x="3"
+ y="1028.8622" />
+ <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="27"
+ height="2.9999995"
+ x="3"
+ y="1031.8622" />
+ <rect
+ y="1034.8622"
+ x="3"
+ height="3.0000031"
+ width="27"
+ 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="1037.8622"
+ x="3"
+ height="3.0000029"
+ width="27"
+ 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="27"
+ height="2.9999976"
+ x="3"
+ y="1043.8622" />
+ <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="27"
+ height="3.0000029"
+ x="3"
+ y="1040.8622" />
+ </g>
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_key_next.svg b/tools/editor/icons/source/icon_key_next.svg
index 4155255434..942245305c 100644
--- a/tools/editor/icons/source/icon_key_next.svg
+++ b/tools/editor/icons/source/icon_key_next.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="3.6318496"
- inkscape:cy="7.8283625"
+ inkscape:zoom="45.254834"
+ inkscape:cx="8.9672408"
+ inkscape:cy="7.1977527"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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,23 +69,14 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
+ style="opacity:1;fill:#84ffb1;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 11 9 L 11 11 L 9 11 L 9 13 L 11 13 L 11 15 L 13 15 L 13 13 L 15 13 L 15 11 L 13 11 L 13 9 L 11 9 z "
+ transform="translate(0,1036.3622)"
+ id="rect4156" />
+ <path
style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;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 11 1 A 4 4.0000024 0 0 0 7.1308594 4 L 1 4 L 1 6 L 2 6 L 2 8 L 5 8 L 5 6 L 7.1328125 6 A 4 4.0000024 0 0 0 9 8.4589844 L 9 7 L 11 7 A 2.0000174 2.0000174 0 0 1 9 5 A 2.0000174 2.0000174 0 0 1 11 3 A 2.0000174 2.0000174 0 0 1 13 5 A 2.0000174 2.0000174 0 0 1 11 7 L 14.458984 7 A 4 4.0000024 0 0 0 15 5 A 4 4.0000024 0 0 0 11 1 z "
+ d="M 11 1 A 4 4.0000024 0 0 0 7.1308594 4 L 1 4 L 1 6 L 2 6 L 2 8 L 5 8 L 5 6 L 7.1328125 6 A 4 4.0000024 0 0 0 10 8.8691406 L 10 8 L 13.638672 8 A 4 4.0000024 0 0 0 15 5 A 4 4.0000024 0 0 0 11 1 z M 11 3 A 2.0000174 2.0000174 0 0 1 13 5 A 2.0000174 2.0000174 0 0 1 11 7 A 2.0000174 2.0000174 0 0 1 9 5 A 2.0000174 2.0000174 0 0 1 11 3 z "
transform="translate(0,1036.3622)"
- id="path4137" />
- <rect
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- id="rect4156"
- width="2"
- height="5.9999828"
- x="11"
- y="1045.3622" />
- <rect
- y="1047.3622"
- x="9"
- height="2.0000174"
- width="6"
- id="rect4158"
- style="opacity:1;fill:#e0e0e0;fill-opacity:0.99607843;stroke:none;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ id="path4137-6" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_line_2d.svg b/tools/editor/icons/source/icon_line_2d.svg
new file mode 100644
index 0000000000..7f833f4a9c
--- /dev/null
+++ b/tools/editor/icons/source/icon_line_2d.svg
@@ -0,0 +1,82 @@
+<?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="D:\PROJETS\INFO\GODOT\ENGINE\godot_fork\tools\editor\icons\2x\icon_line_2d.png"
+ inkscape:export-xdpi="180"
+ inkscape:export-ydpi="180"
+ sodipodi:docname="icon_line_2d.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="7.5587317"
+ inkscape:cy="9.1781644"
+ 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="1017"
+ inkscape:window-x="-8"
+ inkscape:window-y="32"
+ inkscape:window-maximized="1"
+ inkscape:snap-grids="true"
+ inkscape:object-nodes="true"
+ showguides="false">
+ <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:none;fill-opacity:1;fill-rule:evenodd;stroke:#a5b7f3;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98823529"
+ d="m 2,1045.3622 3,4 3,-10 3,6 3,-2"
+ id="path4135"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc" />
+ </g>
+</svg>
diff --git a/tools/editor/icons/source/icon_patch_9_frame.svg b/tools/editor/icons/source/icon_nine_patch_rect.svg
index f12789c19e..f12789c19e 100644
--- a/tools/editor/icons/source/icon_patch_9_frame.svg
+++ b/tools/editor/icons/source/icon_nine_patch_rect.svg
diff --git a/tools/editor/icons/source/icon_patch_9_rect.svg b/tools/editor/icons/source/icon_patch_9_rect.svg
new file mode 100644
index 0000000000..c5a09603a6
--- /dev/null
+++ b/tools/editor/icons/source/icon_patch_9_rect.svg
@@ -0,0 +1,130 @@
+<?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/tools/editor/icons/source/icon_reference_frame.svg b/tools/editor/icons/source/icon_reference_rect.svg
index 76c3247f1b..cee814360d 100644
--- a/tools/editor/icons/source/icon_reference_frame.svg
+++ b/tools/editor/icons/source/icon_reference_rect.svg
@@ -18,7 +18,7 @@
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_reference_frame.svg">
+ sodipodi:docname="icon_reference_rect.svg">
<defs
id="defs4" />
<sodipodi:namedview
diff --git a/tools/editor/icons/source/icon_reparent.svg b/tools/editor/icons/source/icon_reparent.svg
index 65f101c8f7..79543fe066 100644
--- a/tools/editor/icons/source/icon_reparent.svg
+++ b/tools/editor/icons/source/icon_reparent.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="11.313708"
- inkscape:cx="-1.4011549"
- inkscape:cy="8.7567876"
+ inkscape:zoom="22.627416"
+ inkscape:cx="11.980115"
+ inkscape:cy="8.5519429"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -46,7 +46,10 @@
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
- inkscape:window-maximized="1">
+ inkscape:window-maximized="1"
+ inkscape:snap-midpoints="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-nodes="true">
<inkscape:grid
type="xygrid"
id="grid3336" />
@@ -59,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>
@@ -68,45 +71,15 @@
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1036.3622)">
- <circle
- r="2"
- cy="1049.3622"
- cx="3"
- id="circle4277"
- style="opacity:1;fill:#e0e0e0;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" />
- <circle
- style="opacity:1;fill:#e0e0e0;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="circle4279"
- cx="3"
- cy="1039.3622"
- r="2" />
- <circle
- style="opacity:1;fill:#e0e0e0;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="circle4281"
- cx="13"
- cy="1049.3622"
- r="2" />
<path
- style="fill:none;fill-rule:evenodd;stroke:#e0e0e0;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
- d="m 3,1039.3622 0,10 10,0"
- id="path4287"
- inkscape:connector-curvature="0" />
- <path
- style="opacity:1;fill:#e0e0e0;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"
- d="m 9,1038.3622 0,2 a 3,3 0 0 1 3,3 l 2,0 a 5.0000172,5.0000172 0 0 0 -5,-5 z"
- id="path4289"
- inkscape:connector-curvature="0" />
- <rect
style="opacity:1;fill:#e0e0e0;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="rect4294"
- width="2"
- height="2"
- x="12"
- y="1043.3622" />
+ d="M 3 2 A 2 2 0 0 0 1 4 A 2 2 0 0 0 2 5.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 4.7304688 14 L 11.271484 14 A 2 2 0 0 0 13 15 A 2 2 0 0 0 15 13 A 2 2 0 0 0 13 11 A 2 2 0 0 0 11.269531 12 L 4.7285156 12 A 2 2 0 0 0 4 11.269531 L 4 5.7285156 A 2 2 0 0 0 5 4 A 2 2 0 0 0 3 2 z "
+ transform="translate(0,1036.3622)"
+ id="circle4277" />
<path
- style="fill:#e0e0e0;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
- d="m 9,1037.3622 0,4 -3,-2 z"
- id="path4296"
- inkscape:connector-curvature="0" />
+ style="opacity:1;fill:#84ffb1;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"
+ d="M 9 1 L 5 4 L 9 7 L 9 5 A 3 3 0 0 1 12 8 L 12 10 L 14 10 L 14 8 A 5.0000172 5.0000172 0 0 0 9 3 L 9 1 z "
+ transform="translate(0,1036.3622)"
+ id="path4289" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_script_remove.svg b/tools/editor/icons/source/icon_script_remove.svg
new file mode 100644
index 0000000000..1a0a0eebe3
--- /dev/null
+++ b/tools/editor/icons/source/icon_script_remove.svg
@@ -0,0 +1,99 @@
+<?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/godotengine/godot/tools/editor/icons/con_script_create.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90"
+ sodipodi:docname="icon_script_remove.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="42.379266"
+ inkscape:cx="6.774667"
+ inkscape:cy="6.9870579"
+ 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"
+ showguides="false"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:object-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 />
+ </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:2;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99607843"
+ d="M 6 1 L 6 2 C 5.4477153 2 5 2.4477153 5 3 L 5 13 L 4 13 L 4 11 L 2 11 L 2 13 C 2.0002826 13.356983 2.1908437 13.686743 2.5 13.865234 C 2.6519425 13.953279 2.8243914 13.999759 3 14 L 3 15 L 8.6347656 15 L 7.0507812 13.416016 L 8.4648438 12.001953 L 7.0507812 10.585938 L 10.585938 7.0507812 L 12 8.4648438 L 12 8 L 12 5 L 15 5 L 15 3 C 15 1.8954305 14.104569 1 13 1 L 6 1 z "
+ transform="translate(0,1036.3622)"
+ id="rect4255" />
+ <path
+ style="opacity:1;fill:#b4b4b4;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 6 1 C 4.8954305 1 4 1.8954305 4 3 L 4 10 L 2 10 L 1 10 L 1 11 L 1 13 C 1 14.104569 1.8954305 15 3 15 C 4.1045695 15 5 14.104569 5 13 L 5 3 C 5 2.4477153 5.4477153 2 6 2 C 6.5522847 2 7 2.4477153 7 3 L 7 4 L 7 5 L 7 6 L 8 6 L 12 6 L 12 5 L 8 5 L 8 4 L 8 3 C 8 1.8954305 7.1045695 1 6 1 z M 2 11 L 4 11 L 4 13 C 4 13.552285 3.5522847 14 3 14 C 2.4477153 14 2 13.552285 2 13 L 2 11 z "
+ id="path4265"
+ transform="translate(0,1036.3622)" />
+ <circle
+ cy="1048.3622"
+ cx="3"
+ id="ellipse4234"
+ 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"
+ ry="1.0000174"
+ rx="1" />
+ <path
+ style="fill:#ff8484;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 13.414214,1048.3622 1.414213,-1.4142 -1.414213,-1.4142 L 12,1046.948 l -1.414214,-1.4142 -1.4142131,1.4142 1.4142131,1.4142 -1.4142131,1.4142 1.4142131,1.4142 1.414214,-1.4142 1.414214,1.4142 1.414213,-1.4142 z"
+ id="path8069"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccc" />
+ </g>
+</svg>
diff --git a/tools/editor/icons/source/icon_shader.svg b/tools/editor/icons/source/icon_shader.svg
index ba12b007ad..1a2393fec2 100644
--- a/tools/editor/icons/source/icon_shader.svg
+++ b/tools/editor/icons/source/icon_shader.svg
@@ -32,12 +32,13 @@
</clipPath>
<clipPath
clipPathUnits="userSpaceOnUse"
- id="clipPath4199">
+ id="clipPath4207">
<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:#000000;fill-opacity:1;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 6.3749999,1025.8622 c -0.931942,10e-5 -1.6874069,0.6715 -1.6875,1.5 l 0,18 c 9.31e-5,0.8284 0.755558,1.4998 1.6875,1.5 l 20.2500001,0 c 0.931942,-2e-4 1.687407,-0.6716 1.6875,-1.5 l 0,-12 -8.4375,-7.5 z m 1.6875,3 10.1250001,0 0,4.5 c 0,0.831 0.752609,1.5 1.6875,1.5 l 5.0625,0 0,9 -16.8750001,0 z"
+ id="path4209"
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" />
+ sodipodi:nodetypes="ccccccccccccccccc" />
</clipPath>
</defs>
<sodipodi:namedview
@@ -48,8 +49,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.999999"
- inkscape:cx="6.7591143"
- inkscape:cy="9.6862321"
+ inkscape:cx="20.042938"
+ inkscape:cy="7.6712905"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -95,7 +96,7 @@
<g
id="g4181"
mask="none"
- clip-path="url(#clipPath4199)"
+ clip-path="url(#clipPath4207)"
transform="matrix(0.59259259,0,0,0.66666674,-1.7777777,353.454)">
<rect
y="1025.8622"
diff --git a/tools/editor/icons/source/icon_spot_light.svg b/tools/editor/icons/source/icon_spot_light.svg
index b9130eff37..04f5b42f4d 100644
--- a/tools/editor/icons/source/icon_spot_light.svg
+++ b/tools/editor/icons/source/icon_spot_light.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="31.999999"
- inkscape:cx="5.5818635"
- inkscape:cy="8.6161108"
+ inkscape:cx="-0.26188668"
+ inkscape:cy="8.5536108"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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>
@@ -71,48 +71,8 @@
transform="translate(0,-1036.3622)">
<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 14,1046.3622 -12,0 c 0,-2.7614 2.6862915,-5 6,-5 3.313708,0 6,2.2386 6,5 z"
- id="path4155"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccsc" />
- <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 6 1 A 1 1 0 0 0 5 2 L 5 7 L 11 7 L 11 2 A 1 1 0 0 0 10 1 L 6 1 z "
+ d="M 6 1 A 1 1 0 0 0 5 2 L 5 5.6933594 C 3.2138662 6.5594405 2 8.153847 2 10 L 6 10 A 2 2 0 0 0 8 12 A 2 2 0 0 0 10 10 L 14 10 C 14 8.153847 12.786134 6.5594405 11 5.6933594 L 11 2 A 1 1 0 0 0 10 1 L 6 1 z M 4.9023438 10.634766 L 3.1699219 11.634766 L 4.1699219 13.365234 L 5.9023438 12.365234 L 4.9023438 10.634766 z M 11.097656 10.634766 L 10.097656 12.365234 L 11.830078 13.365234 L 12.830078 11.634766 L 11.097656 10.634766 z M 7 13 L 7 15 L 9 15 L 9 13 L 7 13 z "
transform="translate(0,1036.3622)"
- id="rect4158" />
- <circle
- 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="path4160"
- cx="8"
- cy="1046.3622"
- r="2" />
- <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="rect4162"
- width="2"
- height="2"
- x="7"
- y="1049.3622"
- inkscape:transform-center-y="3.9999826" />
- <rect
- inkscape:transform-center-y="2.0000217"
- y="533.10931"
- x="-903.17627"
- height="2"
- width="2"
- id="rect4164"
- 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"
- transform="matrix(0.5,-0.8660254,0.8660254,0.5,0,0)"
- inkscape:transform-center-x="-3.4640975" />
- <rect
- inkscape:transform-center-x="3.4641473"
- transform="matrix(0.5,0.8660254,-0.8660254,0.5,0,0)"
- 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="rect4166"
- width="2"
- height="2"
- x="909.17621"
- y="519.25293"
- inkscape:transform-center-y="1.9999799" />
+ id="path4155" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_static_body.svg b/tools/editor/icons/source/icon_static_body.svg
index af1ebc8900..fcaa2b7d3e 100644
--- a/tools/editor/icons/source/icon_static_body.svg
+++ b/tools/editor/icons/source/icon_static_body.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="22.627417"
- inkscape:cx="7.2543819"
- inkscape:cy="7.4903504"
+ inkscape:zoom="11.313709"
+ inkscape:cx="10.872202"
+ inkscape:cy="6.7990901"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -72,67 +72,9 @@
id="layer1"
transform="translate(0,-1036.3622)">
<path
- style="fill:#a5b7f5;fill-opacity:0.98823529;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 25 3 C 22 3 21 6 21 6 C 20.879708 6.3608765 20.803605 6.6663233 20.707031 7 L 21 7 A 1 1 0 0 0 22 8 A 1 1 0 0 0 23 7 L 24 7 A 1 1 0 0 0 25 8 A 1 1 0 0 0 26 7 L 27 7 A 1 1 0 0 0 28 8 A 1 1 0 0 0 29 7 L 29.292969 7 C 29.196395 6.6663233 29.120292 6.3608765 29 6 C 29 6 28 3 25 3 z M 20.369141 8.1542969 C 19.864457 10.037394 19.478832 11.521168 18 13 L 32 13 C 30.521168 11.521168 30.135543 10.037394 29.630859 8.1542969 A 2 2 0 0 1 29 8.7324219 A 2 2 0 0 1 27 8.7324219 A 2 2 0 0 1 26.5 8.3203125 A 2 2 0 0 1 26 8.7324219 A 2 2 0 0 1 24 8.7324219 A 2 2 0 0 1 23.5 8.3203125 A 2 2 0 0 1 23 8.7324219 A 2 2 0 0 1 21 8.7324219 A 2 2 0 0 1 20.369141 8.1542969 z "
- transform="translate(0,1036.3622)"
- id="path4161" />
- <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:#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 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 "
+ 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 M 3 3 L 3 5 L 5 5 L 5 3 L 3 3 z M 11 3 L 11 5 L 13 5 L 13 3 L 11 3 z M 3 11 L 3 13 L 5 13 L 5 11 L 3 11 z M 11 11 L 11 13 L 13 13 L 13 11 L 11 11 z "
transform="translate(0,1036.3622)"
id="rect4179" />
- <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="rect4195"
- width="2"
- height="2"
- x="3"
- y="1039.3622" />
- <rect
- y="1047.3622"
- x="3"
- height="2"
- width="2"
- id="rect4197"
- 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" />
- <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="rect4199"
- width="2"
- height="2"
- x="11"
- y="1047.3622" />
- <rect
- y="1039.3622"
- x="11"
- height="2"
- width="2"
- id="rect4201"
- 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" />
- <g
- id="layer1-1"
- inkscape:label="Layer 1"
- transform="translate(-23.644738,-1.9878833)">
- <path
- id="path4139"
- transform="translate(0,1036.3622)"
- d="M 8,1 A 7,7 0 0 0 1,8 7,7 0 0 0 8,15 7,7 0 0 0 15,8 7,7 0 0 0 8,1 Z M 4,6 A 1,1 0 0 1 5,7 1,1 0 0 1 4,8 1,1 0 0 1 3,7 1,1 0 0 1 4,6 Z m 8,0 a 1,1 0 0 1 1,1 1,1 0 0 1 -1,1 1,1 0 0 1 -1,-1 1,1 0 0 1 1,-1 z m -7,3 6,0 a 3,3 0 0 1 -1.5,2.597656 3,3 0 0 1 -3,0 A 3,3 0 0 1 5,9 Z"
- style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- inkscape:connector-curvature="0" />
- </g>
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_static_body_2d.svg b/tools/editor/icons/source/icon_static_body_2d.svg
index d47e924e37..0ed3ef7cf0 100644
--- a/tools/editor/icons/source/icon_static_body_2d.svg
+++ b/tools/editor/icons/source/icon_static_body_2d.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="7.2543819"
- inkscape:cy="7.4903504"
+ inkscape:cx="-1.0099286"
+ inkscape:cy="7.4019621"
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,13 +72,6 @@
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"
@@ -87,36 +80,8 @@
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:#a5b7f6;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 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 "
+ 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 M 3 3 L 3 5 L 5 5 L 5 3 L 3 3 z M 11 3 L 11 5 L 13 5 L 13 3 L 11 3 z M 3 11 L 3 13 L 5 13 L 5 11 L 3 11 z M 11 11 L 11 13 L 13 13 L 13 11 L 11 11 z "
transform="translate(0,1036.3622)"
id="rect4179" />
- <rect
- style="opacity:1;fill:#a5b7f6;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"
- id="rect4195"
- width="2"
- height="2"
- x="3"
- y="1039.3622" />
- <rect
- y="1047.3622"
- x="3"
- height="2"
- width="2"
- id="rect4197"
- style="opacity:1;fill:#a5b7f6;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" />
- <rect
- style="opacity:1;fill:#a5b7f6;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"
- id="rect4199"
- width="2"
- height="2"
- x="11"
- y="1047.3622" />
- <rect
- y="1039.3622"
- x="11"
- height="2"
- width="2"
- id="rect4201"
- style="opacity:1;fill:#a5b7f6;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" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_tab_container.svg b/tools/editor/icons/source/icon_tab_container.svg
index b53747bf1c..6c197a86f6 100644
--- a/tools/editor/icons/source/icon_tab_container.svg
+++ b/tools/editor/icons/source/icon_tab_container.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="4.8125618"
- inkscape:cy="8.9338072"
+ inkscape:zoom="45.254834"
+ inkscape:cx="3.8596634"
+ inkscape:cy="10.446251"
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>
@@ -73,24 +73,8 @@
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.8954305,1 1,1.8954305 1,3 l 0,10 c 0,1.104569 0.8954305,2 2,2 l 10,0 c 1.104569,0 2,-0.895431 2,-2 L 15,3 C 15,1.8954305 14.104569,1 13,1 Z m 0,2 10,0 0,10 -10,0 z"
+ d="M 3 1 C 1.8954305 1 1 1.8954305 1 3 L 1 13 C 1 14.104569 1.8954305 15 3 15 L 13 15 C 14.104569 15 15 14.104569 15 13 L 15 3 C 15 1.8954305 14.104569 1 13 1 L 3 1 z M 3 3 L 8 3 L 8 5 L 8 7 L 13 7 L 13 13 L 3 13 L 3 3 z M 10 3 L 13 3 L 13 5 L 10 5 L 10 3 z "
transform="translate(0,1036.3622)"
- id="rect4140"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="sssssssssccccc" />
- <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="rect4158"
- width="10"
- height="2"
- x="3"
- y="1041.3622" />
- <rect
- y="1039.3622"
- x="8"
- height="2"
- width="5"
- id="rect4170"
- 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="rect4140" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_tabs.svg b/tools/editor/icons/source/icon_tabs.svg
index 1b389fc30c..79ed1e5910 100644
--- a/tools/editor/icons/source/icon_tabs.svg
+++ b/tools/editor/icons/source/icon_tabs.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="32"
- inkscape:cx="3.2506704"
- inkscape:cy="11.363584"
+ inkscape:zoom="22.627417"
+ inkscape:cx="11.687421"
+ inkscape:cy="9.3335226"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -75,21 +75,21 @@
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4156"
width="1"
- height="4.9999828"
+ height="9.0000172"
x="1"
- y="1042.3622" />
+ y="1040.3622" />
<rect
y="-8"
- x="1041.3622"
+ x="1039.3622"
height="6"
width="1"
id="rect4159"
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;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)" />
<rect
- y="1042.3622"
- x="8"
- height="4.9999828"
+ y="1040.3622"
+ x="7"
+ height="3.0000174"
width="1"
id="rect4161"
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
@@ -98,38 +98,26 @@
id="path4163"
sodipodi:type="arc"
sodipodi:cx="2"
- sodipodi:cy="1042.3622"
+ sodipodi:cy="1040.3622"
sodipodi:rx="1"
sodipodi:ry="1"
sodipodi:start="1.5707963"
sodipodi:end="0"
- d="m 2,1043.3622 a 1,1 0 0 1 -0.9238795,-0.6173 1,1 0 0 1 0.2167727,-1.0898 1,1 0 0 1 1.0897902,-0.2168 A 1,1 0 0 1 3,1042.3622 l -1,0 z" />
- <path
- d="m -8,1043.3622 a 1,1 0 0 1 -0.9238795,-0.6173 1,1 0 0 1 0.2167727,-1.0898 1,1 0 0 1 1.0897902,-0.2168 A 1,1 0 0 1 -7,1042.3622 l -1,0 z"
- sodipodi:end="0"
- sodipodi:start="1.5707963"
- sodipodi:ry="1"
- sodipodi:rx="1"
- sodipodi:cy="1042.3622"
- sodipodi:cx="-8"
- sodipodi:type="arc"
- id="path4165"
- style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- transform="scale(-1,1)" />
+ d="m 2,1041.3622 a 1,1 0 0 1 -0.9238795,-0.6173 1,1 0 0 1 0.2167727,-1.0898 1,1 0 0 1 1.0897902,-0.2168 A 1,1 0 0 1 3,1040.3622 l -1,0 z" />
<rect
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4167"
width="1"
- height="4.9999828"
+ height="9.0000172"
x="14"
- y="1042.3622" />
+ y="1040.3622" />
<rect
transform="matrix(0,1,-1,0,0,0)"
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4169"
width="1"
height="6"
- x="1041.3622"
+ x="1039.3622"
y="-14" />
<path
transform="scale(-1,1)"
@@ -137,19 +125,19 @@
id="path4171"
sodipodi:type="arc"
sodipodi:cx="-14"
- sodipodi:cy="1042.3622"
+ sodipodi:cy="1040.3622"
sodipodi:rx="1"
sodipodi:ry="1"
sodipodi:start="1.5707963"
sodipodi:end="0"
- d="m -14,1043.3622 a 1,1 0 0 1 -0.92388,-0.6173 1,1 0 0 1 0.216773,-1.0898 1,1 0 0 1 1.08979,-0.2168 1,1 0 0 1 0.617317,0.9239 l -1,0 z" />
+ d="m -14,1041.3622 a 1,1 0 0 1 -0.92388,-0.6173 1,1 0 0 1 0.216773,-1.0898 1,1 0 0 1 1.08979,-0.2168 1,1 0 0 1 0.617317,0.9239 l -1,0 z" />
<rect
transform="matrix(0,1,-1,0,0,0)"
style="opacity:1;fill:#a5efac;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4173"
width="1"
height="13"
- x="1046.3622"
+ x="1042.3622"
y="-15" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_text_edit.svg b/tools/editor/icons/source/icon_text_edit.svg
index 1daf1ac75a..4d08e9e3b2 100644
--- a/tools/editor/icons/source/icon_text_edit.svg
+++ b/tools/editor/icons/source/icon_text_edit.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
- inkscape:cx="13.881612"
- inkscape:cy="11.594783"
+ inkscape:cx="5.6173015"
+ inkscape:cy="11.506395"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -72,31 +72,16 @@
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" />
- <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="4"
- x="4"
- y="1040.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,1037.3622 c -1.1045695,0 -2,0.8954 -2,2 l 0,10 c 0,1.1046 0.8954305,2 2,2 l 10,0 c 1.104569,0 2,-0.8954 2,-2 l 0,-10 c 0,-1.1046 -0.895431,-2 -2,-2 z m 0,2 10,0 0,10 -10,0 z"
- id="rect4140"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="sssssssssccccc" />
+ 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 C 1.8954305 1 1 1.8954 1 3 L 1 13 C 1 14.1046 1.8954305 15 3 15 L 13 15 C 14.104569 15 15 14.1046 15 13 L 15 3 C 15 1.8954 14.104569 1 13 1 L 3 1 z M 3 3 L 13 3 L 13 13 L 3 13 L 3 3 z M 4 4 L 4 8 L 5 8 L 5 4 L 4 4 z "
+ transform="translate(0,1036.3622)"
+ id="rect4173" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_texture_frame.svg b/tools/editor/icons/source/icon_texture_rect.svg
index afab41de41..88d9b4081f 100644
--- a/tools/editor/icons/source/icon_texture_frame.svg
+++ b/tools/editor/icons/source/icon_texture_rect.svg
@@ -18,7 +18,7 @@
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_texture_frame.svg">
+ sodipodi:docname="icon_texture_rect.svg">
<defs
id="defs4" />
<sodipodi:namedview
diff --git a/tools/editor/icons/source/icon_track_add_key.svg b/tools/editor/icons/source/icon_track_add_key.svg
index 96761526a8..f550f922bb 100644
--- a/tools/editor/icons/source/icon_track_add_key.svg
+++ b/tools/editor/icons/source/icon_track_add_key.svg
@@ -29,8 +29,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="45.254834"
- inkscape:cx="6.0361164"
- inkscape:cy="4.9218153"
+ inkscape:cx="10.389243"
+ inkscape:cy="3.816961"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -69,7 +69,7 @@
id="layer1"
transform="translate(0,-1044.3622)">
<path
- style="fill:#a9e100;fill-opacity:0.99607843;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#84ffb1;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3 0 L 3 3 L 0 3 L 0 5 L 3 5 L 3 8 L 5 8 L 5 5 L 8 5 L 8 3 L 5 3 L 5 0 L 3 0 z "
transform="translate(0,1044.3622)"
id="rect4137" />
diff --git a/tools/editor/icons/source/icon_track_add_key_hl.svg b/tools/editor/icons/source/icon_track_add_key_hl.svg
index 79e566dde6..1b45cf8c4a 100644
--- a/tools/editor/icons/source/icon_track_add_key_hl.svg
+++ b/tools/editor/icons/source/icon_track_add_key_hl.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="5.3806528"
- inkscape:cy="6.0126016"
+ inkscape:zoom="32"
+ inkscape:cx="-4.0417082"
+ inkscape:cy="5.5439904"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -69,9 +69,14 @@
id="layer1"
transform="translate(0,-1044.3622)">
<path
- style="fill:#e3fe03;fill-opacity:0.98823529;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#84ffb1;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3 0 L 3 3 L 0 3 L 0 5 L 3 5 L 3 8 L 5 8 L 5 5 L 8 5 L 8 3 L 5 3 L 5 0 L 3 0 z "
+ id="rect4137"
+ transform="translate(0,1044.3622)" />
+ <path
transform="translate(0,1044.3622)"
- id="rect4137" />
+ id="path4143"
+ d="M 3 0 L 3 3 L 0 3 L 0 5 L 3 5 L 3 8 L 5 8 L 5 5 L 8 5 L 8 3 L 5 3 L 5 0 L 3 0 z "
+ style="fill:#ffffff;fill-opacity:0.42424244;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
diff --git a/tools/editor/icons/source/icon_viewport.svg b/tools/editor/icons/source/icon_viewport.svg
index fcbe094fca..631260ab33 100644
--- a/tools/editor/icons/source/icon_viewport.svg
+++ b/tools/editor/icons/source/icon_viewport.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="45.254834"
- inkscape:cx="7.693363"
- inkscape:cy="8.1399132"
+ inkscape:zoom="11.313709"
+ inkscape:cx="14.11111"
+ inkscape:cy="8.6614747"
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>
@@ -71,20 +71,6 @@
inkscape:groupmode="layer"
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:#e0e0e0;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 3,2 C 2.4695977,2.0000801 1.9609485,2.2108464 1.5859375,2.5859375 1.2108464,2.9609485 1.0000801,3.4695977 1,4 l 0,8 c 8.03e-5,0.530402 0.2108465,1.039051 0.5859375,1.414062 C 1.9609484,13.789153 2.4695976,13.99992 3,14 l 10,0 c 1.104569,0 2,-0.895431 2,-2 L 15,4 C 15,2.8954305 14.104569,2 13,2 Z m 0,1 10,0 c 0.552281,9.6e-6 0.99999,0.4477192 1,1 l 0,8 c -10e-6,0.552281 -0.447719,0.99999 -1,1 L 3,13 C 2.4477192,12.99999 2.0000096,12.552281 2,12 L 2,4 c 9.6e-6,-0.5522808 0.4477192,-0.9999904 1,-1 z"
diff --git a/tools/editor/icons/source/icon_viewport_container.svg b/tools/editor/icons/source/icon_viewport_container.svg
new file mode 100644
index 0000000000..300b8390c4
--- /dev/null
+++ b/tools/editor/icons/source/icon_viewport_container.svg
@@ -0,0 +1,82 @@
+<?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_viewport_container.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="13.216634"
+ inkscape:cy="7.7987238"
+ 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:snap-smooth-nodes="true"
+ inkscape:object-nodes="true"
+ 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 />
+ </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:#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.8954305,1 1,1.8954305 1,3 l 0,10 c 0,1.104569 0.8954305,2 2,2 l 10,0 c 1.104569,0 2,-0.895431 2,-2 L 15,3 C 15,1.8954305 14.104569,1 13,1 Z M 3,3 13,3 13,13 3,13 Z M 6,4 C 5.469598,4.0001 4.9609495,4.2108375 4.5859375,4.5859375 4.2108465,4.9609375 4.00008,5.4696 4,6 l 0,4 c 8e-5,0.5304 0.2108475,1.039063 0.5859375,1.414062 C 4.9609485,11.789162 5.469598,11.9999 6,12 l 4,0 c 1.104569,0 2,-0.8954 2,-2 L 12,6 C 12,4.8954 11.104569,4 10,4 Z m 0,1 4,0 c 0.552281,0 0.99999,0.4477 1,1 l 0,4 c -10e-6,0.5523 -0.447719,1 -1,1 L 6,11 C 5.447719,11 5.00001,10.5523 5,10 L 5,6 C 5.00001,5.4477 5.447719,5 6,5 Z"
+ transform="translate(0,1036.3622)"
+ id="rect4140"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccccccccccccccsssscssccssccs" />
+ </g>
+</svg>
diff --git a/tools/editor/icons/source/icon_warning.svg b/tools/editor/icons/source/icon_warning.svg
index ee89f3ec99..4d39141a58 100644
--- a/tools/editor/icons/source/icon_warning.svg
+++ b/tools/editor/icons/source/icon_warning.svg
@@ -28,9 +28,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="22.627416"
- inkscape:cx="1.5203658"
- inkscape:cy="5.6414917"
+ inkscape:zoom="45.254832"
+ inkscape:cx="2.2320862"
+ inkscape:cy="6.41947"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
@@ -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>
@@ -70,11 +70,12 @@
id="layer1"
transform="translate(0,-1044.3622)">
<rect
- style="opacity:1;fill:#ffd684;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"
+ style="opacity:1;fill:#ffd684;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect4142"
width="8"
height="8"
- x="2.220446e-16"
- y="1044.3622" />
+ x="0"
+ y="1044.3622"
+ ry="1" />
</g>
</svg>
diff --git a/tools/editor/import/SCsub b/tools/editor/import/SCsub
new file mode 100644
index 0000000000..f1fa50148f
--- /dev/null
+++ b/tools/editor/import/SCsub
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+Import('env')
+Export('env')
+env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/import/editor_import_collada.cpp
index 846a551121..a901de1faf 100644
--- a/tools/editor/io_plugins/editor_import_collada.cpp
+++ b/tools/editor/import/editor_import_collada.cpp
@@ -27,7 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_import_collada.h"
-#include "collada/collada.h"
+
+
#include "scene/3d/spatial.h"
#include "scene/3d/skeleton.h"
#include "scene/3d/path.h"
@@ -38,6 +39,7 @@
#include "scene/resources/animation.h"
#include "scene/resources/packed_scene.h"
#include "os/os.h"
+#include "tools/editor/collada/collada.h"
#include "tools/editor/editor_node.h"
#include <iostream>
@@ -63,6 +65,7 @@ struct ColladaImport {
bool found_directional;
bool force_make_tangents;
bool apply_mesh_xform_to_vertices;
+ bool use_mesh_builtin_materials;
float bake_fps;
@@ -85,7 +88,7 @@ struct ColladaImport {
Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
Error _create_resources(Collada::Node *p_node);
Error _create_material(const String& p_material);
- Error _create_mesh_surfaces(bool p_optimize, Ref<Mesh>& p_mesh, const Map<String,Collada::NodeGeometry::Material>& p_material_map, const Collada::MeshData &meshdata, const Transform& p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >(), bool p_for_morph=false);
+ Error _create_mesh_surfaces(bool p_optimize, Ref<Mesh>& p_mesh, const Map<String,Collada::NodeGeometry::Material>& p_material_map, const Collada::MeshData &meshdata, const Transform& p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_data, const Collada::MorphControllerData *p_morph_data, Vector<Ref<Mesh> > p_morph_meshes=Vector<Ref<Mesh> >(), bool p_for_morph=false, bool p_use_mesh_material=false);
Error load(const String& p_path, int p_flags, bool p_force_make_tangents=false);
void _fix_param_animation_tracks();
void create_animation(int p_clip,bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
@@ -236,20 +239,22 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
return OK;
//well, it's an ambient light..
Light *l = memnew( DirectionalLight );
-// l->set_color(Light::COLOR_AMBIENT,ld.color);
-// l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
-// l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
+ //l->set_color(Light::COLOR_AMBIENT,ld.color);
+ //l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
+ //l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
node = l;
} else if (ld.mode==Collada::LightData::MODE_DIRECTIONAL) {
//well, it's an ambient light..
Light *l = memnew( DirectionalLight );
- //if (found_ambient) //use it here
- // l->set_color(Light::COLOR_AMBIENT,ambient);
+ /*
+ if (found_ambient) //use it here
+ l->set_color(Light::COLOR_AMBIENT,ambient);
-// l->set_color(Light::COLOR_DIFFUSE,ld.color);
-// l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
+ l->set_color(Light::COLOR_DIFFUSE,ld.color);
+ l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
+ */
node = l;
} else {
@@ -259,14 +264,14 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
l=memnew( OmniLight );
else {
l=memnew( SpotLight );
-// l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
-// l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
+ //l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
+ //l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
}
//
-// l->set_color(Light::COLOR_DIFFUSE,ld.color);
-// l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
-// l->approximate_opengl_attenuation(ld.constant_att,ld.linear_att,ld.quad_att);
+ //l->set_color(Light::COLOR_DIFFUSE,ld.color);
+ //l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
+ //l->approximate_opengl_attenuation(ld.constant_att,ld.linear_att,ld.quad_att);
node=l;
}
@@ -396,13 +401,13 @@ Error ColladaImport::_create_material(const String& p_target) {
material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,texture);
material->set_albedo(Color(1,1,1,1));
-// material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1));
+ //material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
}
} else {
-// material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,effect.diffuse.color);
+ //material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,effect.diffuse.color);
}
// SPECULAR
@@ -417,17 +422,18 @@ Error ColladaImport::_create_material(const String& p_target) {
material->set_texture(FixedSpatialMaterial::TEXTURE_SPECULAR,texture);
material->set_specular(Color(1,1,1,1));
-// material->set_texture(FixedSpatialMaterial::PARAM_SPECULAR,texture);
-// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1));
+ //material->set_texture(FixedSpatialMaterial::PARAM_SPECULAR,texture);
+ //material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1));
} else {
missing_textures.push_back(texfile.get_file());
}
}
} else {
-// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR,effect.specular.color);
+ material->set_metalness(effect.specular.color.get_v());
}
+
// EMISSION
if (effect.emission.texture!="") {
@@ -438,17 +444,21 @@ Error ColladaImport::_create_material(const String& p_target) {
Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
if (texture.is_valid()) {
+ material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION,true);
material->set_texture(FixedSpatialMaterial::TEXTURE_EMISSION,texture);
material->set_emission(Color(1,1,1,1));
-// material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,Color(1,1,1,1));
+ //material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,Color(1,1,1,1));
}else {
-// missing_textures.push_back(texfile.get_file());
+ missing_textures.push_back(texfile.get_file());
}
}
} else {
-// material->set_parameter(FixedSpatialMaterial::PARAM_EMISSION,effect.emission.color);
+ if (effect.emission.color!=Color()) {
+ material->set_feature(FixedSpatialMaterial::FEATURE_EMISSION,true);
+ material->set_emission(effect.emission.color);
+ }
}
// NORMAL
@@ -460,19 +470,22 @@ Error ColladaImport::_create_material(const String& p_target) {
Ref<Texture> texture = ResourceLoader::load(texfile,"Texture");
if (texture.is_valid()) {
+ material->set_feature(FixedSpatialMaterial::FEATURE_NORMAL_MAPPING,true);
material->set_texture(FixedSpatialMaterial::TEXTURE_NORMAL,texture);
-// material->set_emission(Color(1,1,1,1));
+ //material->set_emission(Color(1,1,1,1));
- // material->set_texture(FixedSpatialMaterial::PARAM_NORMAL,texture);
+ //material->set_texture(FixedSpatialMaterial::PARAM_NORMAL,texture);
}else {
-// missing_textures.push_back(texfile.get_file());
+ //missing_textures.push_back(texfile.get_file());
}
}
}
-// material->set_parameter(FixedSpatialMaterial::PARAM_SPECULAR_EXP,effect.shininess);
+ float roughness = Math::sqrt(1.0-((Math::log(effect.shininess)/Math::log(2.0))/8.0)); //not very right..
+ material->set_roughness(roughness);
+
if (effect.double_sided) {
material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
}
@@ -606,7 +619,7 @@ static void _generate_tangents_and_binormals(const PoolVector<int>& p_indices,co
}
}
-Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes,bool p_for_morph) {
+Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,const Map<String,Collada::NodeGeometry::Material>& p_material_map,const Collada::MeshData &meshdata,const Transform& p_local_xform,const Vector<int> &bone_remap, const Collada::SkinControllerData *skin_controller, const Collada::MorphControllerData *p_morph_data,Vector<Ref<Mesh> > p_morph_meshes,bool p_for_morph,bool p_use_mesh_material) {
bool local_xform_mirror=p_local_xform.basis.determinant() < 0;
@@ -1171,11 +1184,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
narrayw = PoolVector<Vector3>::Write();
final_normal_array=narray;
- //PoolVector<Vector3> altnaray;
- //_generate_normals(index_array,final_vertex_array,altnaray);
+ /*
+ PoolVector<Vector3> altnaray;
+ _generate_normals(index_array,final_vertex_array,altnaray);
- //for(int i=0;i<altnaray.size();i++)
- // print_line(rtos(altnaray[i].dot(final_normal_array[i])));
+ for(int i=0;i<altnaray.size();i++)
+ print_line(rtos(altnaray[i].dot(final_normal_array[i])));
+ */
} else if (primitive==Mesh::PRIMITIVE_TRIANGLES) {
//generate normals (even if unused later)
@@ -1257,8 +1272,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
}
-// if (sum<0.8)
-// COLLADA_PRINT("ERROR SUMMING INDEX "+itos(k)+" had weights: "+itos(vertex_array[k].weights.size()));
+ /*
+ if (sum<0.8)
+ COLLADA_PRINT("ERROR SUMMING INDEX "+itos(k)+" had weights: "+itos(vertex_array[k].weights.size()));
+ */
}
@@ -1468,7 +1485,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
#endif
for(int mi=0;mi<p_morph_meshes.size();mi++) {
- // print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count()));
+ //print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count()));
Array a = p_morph_meshes[mi]->surface_get_arrays(surface);
//add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not)
@@ -1486,7 +1503,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize,Ref<Mesh>& p_mesh,con
p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,d,mr,p_for_morph?0:Mesh::ARRAY_COMPRESS_DEFAULT);
if (material.is_valid()) {
- p_mesh->surface_set_material(surface, material);
+ if (p_use_mesh_material) {
+ p_mesh->surface_set_material(surface, material);
+ }
p_mesh->surface_set_name(surface, material->get_name());
}
}
@@ -1745,7 +1764,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
mesh=Ref<Mesh>(memnew( Mesh ));
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
mesh->set_name( meshdata.name );
- Error err = _create_mesh_surfaces(morphs.size()==0,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,morph,morphs);
+ Error err = _create_mesh_surfaces(morphs.size()==0,mesh,ng->material_map,meshdata,apply_xform,bone_remap,skin,morph,morphs,false,use_mesh_builtin_materials);
ERR_FAIL_COND_V(err,err);
mesh_cache[meshid]=mesh;
@@ -1756,7 +1775,33 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
}
if (!mesh.is_null()) {
+
mi->set_mesh(mesh);
+ if (!use_mesh_builtin_materials) {
+ const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
+
+ for(int i=0;i<meshdata.primitives.size();i++) {
+
+ String matname=meshdata.primitives[i].material;
+
+ if (ng->material_map.has(matname)) {
+ String target=ng->material_map[matname].target;
+
+ Ref<Material> material;
+ if (!material_cache.has(target)) {
+ Error err = _create_material(target);
+ if (!err)
+ material=material_cache[target];
+ } else
+ material=material_cache[target];
+
+ mi->set_surface_material(i,material);
+ } else if (matname!=""){
+ print_line("Warning, unreferenced material in geometry instance: "+matname);
+ }
+
+ }
+ }
}
}
}
@@ -2367,6 +2412,7 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_
if (p_flags&IMPORT_ANIMATION)
flags|=Collada::IMPORT_FLAG_ANIMATION;
+ state.use_mesh_builtin_materials=!(p_flags&IMPORT_MATERIALS_IN_INSTANCES);
state.bake_fps=p_bake_fps;
Error err = state.load(p_path,flags,p_flags&EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
@@ -2375,9 +2421,11 @@ Node* EditorSceneImporterCollada::import_scene(const String& p_path, uint32_t p_
if (state.missing_textures.size()) {
- //for(int i=0;i<state.missing_textures.size();i++) {
-// EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
-// }
+ /*
+ for(int i=0;i<state.missing_textures.size();i++) {
+ EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]);
+ }
+ */
if (r_missing_deps) {
@@ -2425,6 +2473,8 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String& p_path
ColladaImport state;
+ state.use_mesh_builtin_materials=false;
+
Error err = state.load(p_path,Collada::IMPORT_FLAG_ANIMATION,p_flags&EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
ERR_FAIL_COND_V(err!=OK,RES());
@@ -2438,7 +2488,7 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String& p_path
Ref<Animation> anim=state.animations[0];
anim=state.animations[0];
print_line("Anim Load OK");
- String base = p_path.basename().to_lower();
+ String base = p_path.get_basename().to_lower();
if (p_flags&IMPORT_ANIMATION_DETECT_LOOP) {
if (base.begins_with("loop") || base.ends_with("loop") || base.begins_with("cycle") || base.ends_with("cycle")) {
@@ -2455,3 +2505,4 @@ EditorSceneImporterCollada::EditorSceneImporterCollada() {
}
+
diff --git a/tools/editor/io_plugins/editor_import_collada.h b/tools/editor/import/editor_import_collada.h
index f6642778ed..cd3614bb40 100644
--- a/tools/editor/io_plugins/editor_import_collada.h
+++ b/tools/editor/import/editor_import_collada.h
@@ -29,7 +29,7 @@
#ifndef EDITOR_IMPORT_COLLADA_H
#define EDITOR_IMPORT_COLLADA_H
-#include "tools/editor/io_plugins/editor_scene_import_plugin.h"
+#include "tools/editor/import/resource_importer_scene.h"
diff --git a/tools/editor/import/resource_importer_csv_translation.cpp b/tools/editor/import/resource_importer_csv_translation.cpp
new file mode 100644
index 0000000000..f14c10fb99
--- /dev/null
+++ b/tools/editor/import/resource_importer_csv_translation.cpp
@@ -0,0 +1,126 @@
+
+#include "resource_importer_csv_translation.h"
+#include "os/file_access.h"
+#include "translation.h"
+#include "io/resource_saver.h"
+#include "compressed_translation.h"
+
+String ResourceImporterCSVTranslation::get_importer_name() const {
+
+ return "csv_translation";
+}
+
+String ResourceImporterCSVTranslation::get_visible_name() const{
+
+ return "CSV Translation";
+}
+void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const{
+
+ p_extensions->push_back("csv");
+}
+
+String ResourceImporterCSVTranslation::get_save_extension() const {
+ return ""; //does not save a single resoure
+}
+
+String ResourceImporterCSVTranslation::get_resource_type() const{
+
+ return "StreamCSVTranslation";
+}
+
+bool ResourceImporterCSVTranslation::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ return true;
+}
+
+int ResourceImporterCSVTranslation::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const {
+
+ return "";
+}
+
+
+void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options,int p_preset) const {
+
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"compress"),true));
+
+}
+
+
+
+Error ResourceImporterCSVTranslation::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) {
+
+
+ bool compress = p_options["compress"];
+ FileAccessRef f = FileAccess::open(p_source_file,FileAccess::READ);
+
+ ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER );
+
+ Vector<String> line = f->get_csv_line();
+ if (line.size()<=1) {
+ return ERR_PARSE_ERROR;
+ }
+
+ Vector<String> locales;
+ Vector<Ref<Translation> > translations;
+
+ for(int i=1;i<line.size();i++) {
+
+ String locale = line[i];
+ if (!TranslationServer::is_locale_valid(locale)) {
+ return ERR_PARSE_ERROR;
+ }
+
+ locales.push_back(locale);
+ Ref<Translation> translation;
+ translation.instance();
+ translation->set_locale(locale);
+ translations.push_back(translation);
+ }
+
+ line = f->get_csv_line();
+
+ while(line.size()==locales.size()+1) {
+
+ String key = line[0];
+ if (key!="") {
+
+ for(int i=1;i<line.size();i++) {
+ translations[i-1]->add_message(key,line[i]);
+ }
+ }
+
+ line = f->get_csv_line();
+ }
+
+
+ for(int i=0;i<translations.size();i++) {
+ Ref<Translation> xlt = translations[i];
+
+ if (compress) {
+ Ref<PHashTranslation> cxl = memnew( PHashTranslation );
+ cxl->generate( xlt );
+ xlt=cxl;
+ }
+
+ String save_path = p_source_file.get_basename()+"."+translations[i]->get_locale()+".xl";
+
+ ResourceSaver::save(save_path,xlt);
+ if (r_gen_files) {
+ r_gen_files->push_back(save_path);
+ }
+ }
+
+
+
+ return OK;
+
+}
+
+ResourceImporterCSVTranslation::ResourceImporterCSVTranslation()
+{
+
+}
diff --git a/tools/editor/import/resource_importer_csv_translation.h b/tools/editor/import/resource_importer_csv_translation.h
new file mode 100644
index 0000000000..d08218e7d9
--- /dev/null
+++ b/tools/editor/import/resource_importer_csv_translation.h
@@ -0,0 +1,27 @@
+#ifndef RESOURCEIMPORTERCSVTRANSLATION_H
+#define RESOURCEIMPORTERCSVTRANSLATION_H
+
+#include "io/resource_import.h"
+
+
+class ResourceImporterCSVTranslation : public ResourceImporter {
+ GDCLASS(ResourceImporterCSVTranslation,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;
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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;
+
+ 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);
+
+ ResourceImporterCSVTranslation();
+};
+
+#endif // RESOURCEIMPORTERCSVTRANSLATION_H
diff --git a/tools/editor/import/resource_importer_obj.cpp b/tools/editor/import/resource_importer_obj.cpp
new file mode 100644
index 0000000000..aacb5fbb2d
--- /dev/null
+++ b/tools/editor/import/resource_importer_obj.cpp
@@ -0,0 +1,231 @@
+#include "resource_importer_obj.h"
+
+#include "io/resource_saver.h"
+#include "scene/resources/mesh.h"
+#include "scene/resources/surface_tool.h"
+#include "scene/resources/surface_tool.h"
+#include "os/file_access.h"
+
+String ResourceImporterOBJ::get_importer_name() const {
+
+ return "obj_mesh";
+}
+
+String ResourceImporterOBJ::get_visible_name() const{
+
+ return "OBJ As Mesh";
+}
+void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const{
+
+ p_extensions->push_back("obj");
+}
+String ResourceImporterOBJ::get_save_extension() const {
+ return "msh";
+}
+
+String ResourceImporterOBJ::get_resource_type() const{
+
+ return "Mesh";
+}
+
+bool ResourceImporterOBJ::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ return true;
+}
+
+int ResourceImporterOBJ::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterOBJ::get_preset_name(int p_idx) const {
+
+ return String();
+}
+
+
+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"));
+
+}
+
+
+
+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) {
+
+ FileAccessRef f = FileAccess::open(p_source_file,FileAccess::READ);
+ ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
+
+ Ref<Mesh> mesh = Ref<Mesh>( memnew( Mesh ) );
+ 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"];
+ Vector<Vector3> vertices;
+ Vector<Vector3> normals;
+ Vector<Vector2> uvs;
+ String name;
+
+ 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;
+
+ while(true) {
+
+
+ String l = f->get_line().strip_edges();
+
+ if (l.begins_with("v ")) {
+ //vertex
+ Vector<String> v = l.split(" ",false);
+ ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA);
+ Vector3 vtx;
+ vtx.x=v[1].to_float();
+ vtx.y=v[2].to_float();
+ vtx.z=v[3].to_float();
+ vertices.push_back(vtx);
+ } else if (l.begins_with("vt ")) {
+ //uv
+ Vector<String> v = l.split(" ",false);
+ ERR_FAIL_COND_V(v.size()<3,ERR_INVALID_DATA);
+ Vector2 uv;
+ uv.x=v[1].to_float();
+ uv.y=1.0-v[2].to_float();
+ uvs.push_back(uv);
+
+ } else if (l.begins_with("vn ")) {
+ //normal
+ Vector<String> v = l.split(" ",false);
+ ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA);
+ Vector3 nrm;
+ nrm.x=v[1].to_float();
+ nrm.y=v[2].to_float();
+ nrm.z=v[3].to_float();
+ normals.push_back(nrm);
+ } 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);
+
+ //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);
+ 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);
+ for(int j=0;j<3;j++) {
+
+ int idx=j;
+
+ if (!flip_faces && idx<2) {
+ idx=1^idx;
+ }
+
+
+ if (face[idx].size()==3) {
+ int norm = face[idx][2].to_int()-1;
+ ERR_FAIL_INDEX_V(norm,normals.size(),ERR_PARSE_ERROR);
+ surf_tool->add_normal(normals[norm]);
+ }
+
+ if (face[idx].size()>=2 && face[idx][1]!=String()) {
+
+ int uv = face[idx][1].to_int()-1;
+ ERR_FAIL_INDEX_V(uv,uvs.size(),ERR_PARSE_ERROR);
+ surf_tool->add_uv(uvs[uv]);
+ }
+
+ int vtx = face[idx][0].to_int()-1;
+ ERR_FAIL_INDEX_V(vtx,vertices.size(),ERR_PARSE_ERROR);
+
+ Vector3 vertex = vertices[vtx];
+ if (weld_vertices)
+ vertex=vertex.snapped(weld_tolerance);
+ surf_tool->add_vertex(vertex);
+ }
+
+ face[1]=face[2];
+ }
+ } else if (l.begins_with("s ") && !force_smooth) { //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)
+ surf_tool->generate_normals();
+ if (uvs.size() && (normals.size() || generate_normals) && generate_tangents)
+ surf_tool->generate_tangents();
+
+ surf_tool->index();
+ 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="";
+ surf_tool->clear();
+ surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
+ if (force_smooth)
+ surf_tool->add_smooth_group(true);
+
+ has_index_data=false;
+
+ if (f->eof_reached())
+ break;
+ }
+
+ if (l.begins_with("o ")) //name
+ name=l.substr(2,l.length()).strip_edges();
+ }
+ }
+
+/*
+ TODO, check existing materials and merge?
+ //re-apply materials if exist
+ for(int i=0;i<mesh->get_surface_count();i++) {
+
+ String n = mesh->surface_get_name(i);
+ if (name_map.has(n))
+ mesh->surface_set_material(i,name_map[n]);
+ }
+*/
+
+ Error err = ResourceSaver::save(p_save_path+".msh",mesh);
+
+ return err;
+
+}
+
+ResourceImporterOBJ::ResourceImporterOBJ()
+{
+
+}
diff --git a/tools/editor/import/resource_importer_obj.h b/tools/editor/import/resource_importer_obj.h
new file mode 100644
index 0000000000..d2a3c4fddd
--- /dev/null
+++ b/tools/editor/import/resource_importer_obj.h
@@ -0,0 +1,28 @@
+#ifndef RESOURCEIMPORTEROBJ_H
+#define RESOURCEIMPORTEROBJ_H
+
+
+#include "io/resource_import.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;
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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;
+
+ 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);
+
+ ResourceImporterOBJ();
+};
+
+
+#endif // RESOURCEIMPORTEROBJ_H
diff --git a/tools/editor/import/resource_importer_scene.cpp b/tools/editor/import/resource_importer_scene.cpp
new file mode 100644
index 0000000000..406058c59e
--- /dev/null
+++ b/tools/editor/import/resource_importer_scene.cpp
@@ -0,0 +1,1328 @@
+#include "resource_importer_scene.h"
+
+#include "scene/resources/packed_scene.h"
+#include "io/resource_saver.h"
+#include "tools/editor/editor_node.h"
+
+#include "scene/3d/mesh_instance.h"
+#include "scene/3d/navigation.h"
+#include "scene/3d/room_instance.h"
+#include "scene/3d/body_shape.h"
+#include "scene/3d/physics_body.h"
+#include "scene/3d/portal.h"
+#include "scene/3d/vehicle_body.h"
+#include "scene/resources/sphere_shape.h"
+#include "scene/resources/box_shape.h"
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/plane_shape.h"
+
+
+void EditorScenePostImport::_bind_methods() {
+
+ BIND_VMETHOD( MethodInfo("post_import",PropertyInfo(Variant::OBJECT,"scene")) );
+
+}
+
+Node *EditorScenePostImport::post_import(Node* p_scene) {
+
+ if (get_script_instance())
+ return get_script_instance()->call("post_import",p_scene);
+
+ return p_scene;
+}
+
+EditorScenePostImport::EditorScenePostImport() {
+
+
+}
+
+
+String ResourceImporterScene::get_importer_name() const {
+
+ return "scene";
+}
+
+String ResourceImporterScene::get_visible_name() const{
+
+ return "Scene";
+}
+
+void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const{
+
+ for (Set< Ref<EditorSceneImporter> >::Element *E=importers.front();E;E=E->next()) {
+ E->get()->get_extensions(p_extensions);
+ }
+}
+
+String ResourceImporterScene::get_save_extension() const {
+ return "scn";
+}
+
+String ResourceImporterScene::get_resource_type() const{
+
+ return "PackedScene";
+}
+
+bool ResourceImporterScene::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ if (p_option.begins_with("animation/")) {
+ if (p_option!="animation/import" && !bool(p_options["animation/import"]))
+ return false;
+
+ if (p_option.begins_with("animation/optimizer/") && p_option!="animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"]))
+ return false;
+
+ if (p_option.begins_with("animation/clip_")) {
+ int max_clip = p_options["animation/clips/amount"];
+ int clip = p_option.get_slice("/",1).get_slice("_",1).to_int()-1;
+ if (clip>=max_clip)
+ return false;
+ }
+ }
+
+ return true;
+
+}
+
+int ResourceImporterScene::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterScene::get_preset_name(int p_idx) const {
+
+ return "";
+}
+
+
+static bool _teststr(const String& p_what,const String& p_str) {
+
+ if (p_what.findn("$"+p_str)!=-1) //blender and other stuff
+ return true;
+ if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters
+ return true;
+ if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters
+ return true;
+ return false;
+}
+
+static String _fixstr(const String& p_what,const String& p_str) {
+
+ if (p_what.findn("$"+p_str)!=-1) //blender and other stuff
+ return p_what.replace("$"+p_str,"");
+ if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters
+ return p_what.substr(0,p_what.length()-(p_str.length()+1));
+ if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters
+ return p_what.substr(0,p_what.length()-(p_str.length()+1));
+ return p_what;
+}
+
+
+Node* ResourceImporterScene::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map) {
+
+ // children first..
+ for(int i=0;i<p_node->get_child_count();i++) {
+
+
+ Node *r = _fix_node(p_node->get_child(i),p_root,collision_map);
+ if (!r) {
+ print_line("was erased..");
+ i--; //was erased
+ }
+ }
+
+ String name = p_node->get_name();
+
+ bool isroot = p_node==p_root;
+
+
+ if (!isroot && _teststr(name,"noimp")) {
+
+ memdelete(p_node);
+ return NULL;
+ }
+
+
+ if (p_node->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ bool bb=false;
+
+ if ((_teststr(name,"bb"))) {
+ bb=true;
+ } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"bb"))) {
+ bb=true;
+
+ }
+
+ if (bb) {
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true);
+ if (mi->get_mesh().is_valid()) {
+
+ Ref<Mesh> m = mi->get_mesh();
+ for(int i=0;i<m->get_surface_count();i++) {
+
+ Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
+ if (fm.is_valid()) {
+ //fm->set_flag(Material::FLAG_UNSHADED,true);
+ //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
+ //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
+ //fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ }
+ }
+ }
+ }
+ }
+
+
+ if (p_node->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ Ref<Mesh> m = mi->get_mesh();
+
+ if (m.is_valid()) {
+
+ for(int i=0;i<m->get_surface_count();i++) {
+
+ Ref<FixedSpatialMaterial> mat = m->surface_get_material(i);
+ if (!mat.is_valid())
+ continue;
+
+ if (_teststr(mat->get_name(),"alpha")) {
+
+ mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
+ mat->set_name(_fixstr(mat->get_name(),"alpha"));
+ }
+ if (_teststr(mat->get_name(),"vcol")) {
+
+ mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
+ mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ mat->set_name(_fixstr(mat->get_name(),"vcol"));
+ }
+
+ }
+ }
+ }
+
+ if (p_node->cast_to<AnimationPlayer>()) {
+ //remove animations referencing non-importable nodes
+ AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
+
+ List<StringName> anims;
+ ap->get_animation_list(&anims);
+ for(List<StringName>::Element *E=anims.front();E;E=E->next()) {
+
+ Ref<Animation> anim=ap->get_animation(E->get());
+ ERR_CONTINUE(anim.is_null());
+ for(int i=0;i<anim->get_track_count();i++) {
+ NodePath path = anim->track_get_path(i);
+
+ for(int j=0;j<path.get_name_count();j++) {
+ String node = path.get_name(j);
+ if (_teststr(node,"noimp")) {
+ anim->remove_track(i);
+ i--;
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+
+ if (p_node->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ String str;
+
+ if ((_teststr(name,"imp"))) {
+ str=name;
+ } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"imp"))) {
+ str=mi->get_mesh()->get_name();
+
+ }
+
+
+ if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) {
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
+ String d=str.substr(str.find("imp")+3,str.length());
+ if (d!="") {
+ if ((d[0]<'0' || d[0]>'9'))
+ d=d.substr(1,d.length());
+ if (d.length() && d[0]>='0' && d[0]<='9') {
+ float dist = d.to_double();
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true);
+ mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y,true);
+ //mi->set_draw_range_begin(dist);
+ //mi->set_draw_range_end(100000);
+
+ //mip->set_draw_range_begin(0);
+ //mip->set_draw_range_end(dist);
+
+ if (mi->get_mesh().is_valid()) {
+
+ Ref<Mesh> m = mi->get_mesh();
+ for(int i=0;i<m->get_surface_count();i++) {
+
+ Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
+ if (fm.is_valid()) {
+ //fm->set_flag(Material::FLAG_UNSHADED,true);
+ //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
+ //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
+ //fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#if 0
+ if (p_flags&SCENE_FLAG_CREATE_LODS && p_node->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ String str;
+
+ if ((_teststr(name,"lod"))) {
+ str=name;
+ } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"lod"))) {
+ str=mi->get_mesh()->get_name();
+
+ }
+
+
+ if (p_node->get_parent() && p_node->get_parent()->cast_to<MeshInstance>()) {
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ MeshInstance *mip = p_node->get_parent()->cast_to<MeshInstance>();
+ String d=str.substr(str.find("lod")+3,str.length());
+ if (d!="") {
+ if ((d[0]<'0' || d[0]>'9'))
+ d=d.substr(1,d.length());
+ if (d.length() && d[0]>='0' && d[0]<='9') {
+ float dist = d.to_double();
+ /// mi->set_draw_range_begin(dist);
+ // mi->set_draw_range_end(100000);
+
+ // mip->set_draw_range_begin(0);
+ // mip->set_draw_range_end(dist);
+
+ /*if (mi->get_mesh().is_valid()) {
+
+ Ref<Mesh> m = mi->get_mesh();
+ for(int i=0;i<m->get_surface_count();i++) {
+
+ Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
+ if (fm.is_valid()) {
+ fm->set_flag(Material::FLAG_UNSHADED,true);
+ fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
+ fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ }
+ }
+ }*/
+ }
+ }
+ }
+ }
+
+
+ if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && p_node->cast_to<MeshInstance>()) {
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ String str=name;
+ int layer = str.substr(str.find("lm")+3,str.length()).to_int();
+ //mi->set_baked_light_texture_id(layer);
+ }
+#endif
+ if (_teststr(name,"colonly")) {
+
+ if (isroot)
+ return p_node;
+
+ if (p_node->cast_to<MeshInstance>()) {
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ Node * col = mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col,NULL);
+
+ col->set_name(_fixstr(name,"colonly"));
+ col->cast_to<Spatial>()->set_transform(mi->get_transform());
+ p_node->replace_by(col);
+ memdelete(p_node);
+ p_node=col;
+
+ StaticBody *sb = col->cast_to<StaticBody>();
+ CollisionShape *colshape = memnew( CollisionShape);
+ colshape->set_shape(sb->get_shape(0));
+ 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"));
+ print_line(empty_draw_type);
+ StaticBody *sb = memnew( StaticBody);
+ sb->set_name(_fixstr(name,"colonly"));
+ sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform());
+ p_node->replace_by(sb);
+ memdelete(p_node);
+ CollisionShape *colshape = memnew( CollisionShape);
+ if (empty_draw_type == "CUBE") {
+ BoxShape *boxShape = memnew( BoxShape);
+ boxShape->set_extents(Vector3(1, 1, 1));
+ colshape->set_shape(boxShape);
+ colshape->set_name("BoxShape");
+ } else if (empty_draw_type == "SINGLE_ARROW") {
+ RayShape *rayShape = memnew( RayShape);
+ rayShape->set_length(1);
+ colshape->set_shape(rayShape);
+ colshape->set_name("RayShape");
+ sb->cast_to<Spatial>()->rotate_x(Math_PI / 2);
+ } else if (empty_draw_type == "IMAGE") {
+ PlaneShape *planeShape = memnew( PlaneShape);
+ colshape->set_shape(planeShape);
+ colshape->set_name("PlaneShape");
+ } else {
+ SphereShape *sphereShape = memnew( SphereShape);
+ sphereShape->set_radius(1);
+ colshape->set_shape(sphereShape);
+ colshape->set_name("SphereShape");
+ }
+ sb->add_child(colshape);
+ colshape->set_owner(sb->get_owner());
+ }
+
+ } else if (_teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) {
+
+ if (isroot)
+ return p_node;
+
+ // get mesh instance and bounding box
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ Rect3 aabb = mi->get_aabb();
+
+ // create a new rigid body collision node
+ RigidBody * rigid_body = memnew( RigidBody );
+ Node * col = rigid_body;
+ ERR_FAIL_COND_V(!col,NULL);
+
+ // remove node name postfix
+ col->set_name(_fixstr(name,"rigid"));
+ // get mesh instance xform matrix to the rigid body collision node
+ col->cast_to<Spatial>()->set_transform(mi->get_transform());
+ // save original node by duplicating it into a new instance and correcting the name
+ Node * mesh = p_node->duplicate();
+ mesh->set_name(_fixstr(name,"rigid"));
+ // reset the xform matrix of the duplicated node so it can inherit parent node xform
+ mesh->cast_to<Spatial>()->set_transform(Transform(Basis()));
+ // reparent the new mesh node to the rigid body collision node
+ p_node->add_child(mesh);
+ mesh->set_owner(p_node->get_owner());
+ // replace the original node with the rigid body collision node
+ p_node->replace_by(col);
+ memdelete(p_node);
+ p_node=col;
+
+ // create an alias for the rigid body collision node
+ RigidBody *rb = col->cast_to<RigidBody>();
+ // create a new Box collision shape and set the right extents
+ Ref<BoxShape> shape = memnew( BoxShape );
+ shape->set_extents(aabb.get_size() * 0.5);
+ CollisionShape *colshape = memnew( CollisionShape);
+ colshape->set_name("shape");
+ colshape->set_shape(shape);
+ // reparent the new collision shape to the rigid body collision node
+ rb->add_child(colshape);
+ colshape->set_owner(p_node->get_owner());
+
+ } else if (_teststr(name,"col") && p_node->cast_to<MeshInstance>()) {
+
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ mi->set_name(_fixstr(name,"col"));
+ Node *col= mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col,NULL);
+
+ col->set_name("col");
+ p_node->add_child(col);
+
+ StaticBody *sb=col->cast_to<StaticBody>();
+ CollisionShape *colshape = memnew( CollisionShape);
+ colshape->set_shape(sb->get_shape(0));
+ colshape->set_name("shape");
+ col->add_child(colshape);
+ colshape->set_owner(p_node->get_owner());
+ sb->set_owner(p_node->get_owner());
+
+ } else if (_teststr(name,"navmesh") && p_node->cast_to<MeshInstance>()) {
+
+ if (isroot)
+ return p_node;
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ Ref<Mesh> mesh=mi->get_mesh();
+ ERR_FAIL_COND_V(mesh.is_null(),NULL);
+ NavigationMeshInstance *nmi = memnew( NavigationMeshInstance );
+
+
+ nmi->set_name(_fixstr(name,"navmesh"));
+ Ref<NavigationMesh> nmesh = memnew( NavigationMesh);
+ nmesh->create_from_mesh(mesh);
+ nmi->set_navigation_mesh(nmesh);
+ nmi->cast_to<Spatial>()->set_transform(mi->get_transform());
+ p_node->replace_by(nmi);
+ memdelete(p_node);
+ p_node=nmi;
+ } else if (_teststr(name,"vehicle")) {
+
+ if (isroot)
+ return p_node;
+
+ Node *owner = p_node->get_owner();
+ Spatial *s = p_node->cast_to<Spatial>();
+ VehicleBody *bv = memnew( VehicleBody );
+ String n = _fixstr(p_node->get_name(),"vehicle");
+ bv->set_name(n);
+ p_node->replace_by(bv);
+ p_node->set_name(n);
+ bv->add_child(p_node);
+ bv->set_owner(owner);
+ p_node->set_owner(owner);
+ bv->set_transform(s->get_transform());
+ s->set_transform(Transform());
+
+ p_node=bv;
+
+
+ } else if (_teststr(name,"wheel")) {
+
+ if (isroot)
+ return p_node;
+
+ Node *owner = p_node->get_owner();
+ Spatial *s = p_node->cast_to<Spatial>();
+ VehicleWheel *bv = memnew( VehicleWheel );
+ String n = _fixstr(p_node->get_name(),"wheel");
+ bv->set_name(n);
+ p_node->replace_by(bv);
+ p_node->set_name(n);
+ bv->add_child(p_node);
+ bv->set_owner(owner);
+ p_node->set_owner(owner);
+ bv->set_transform(s->get_transform());
+ s->set_transform(Transform());
+
+ p_node=bv;
+
+ } else if (_teststr(name,"room") && p_node->cast_to<MeshInstance>()) {
+
+
+ if (isroot)
+ return p_node;
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
+
+
+ BSP_Tree bsptree(faces);
+
+ Ref<RoomBounds> area = memnew( RoomBounds );
+ //area->set_bounds(faces);
+ //area->set_geometry_hint(faces);
+
+
+ Room * room = memnew( Room );
+ room->set_name(_fixstr(name,"room"));
+ room->set_transform(mi->get_transform());
+ room->set_room(area);
+
+ p_node->replace_by(room);
+ memdelete(p_node);
+ p_node=room;
+
+ } else if (_teststr(name,"room")) {
+
+ if (isroot)
+ return p_node;
+
+ Spatial *dummy = p_node->cast_to<Spatial>();
+ ERR_FAIL_COND_V(!dummy,NULL);
+
+ Room * room = memnew( Room );
+ room->set_name(_fixstr(name,"room"));
+ room->set_transform(dummy->get_transform());
+
+ p_node->replace_by(room);
+ memdelete(p_node);
+ p_node=room;
+
+ //room->compute_room_from_subtree();
+
+ } else if (_teststr(name,"portal") && p_node->cast_to<MeshInstance>()) {
+
+ if (isroot)
+ return p_node;
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+ PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID);
+
+ ERR_FAIL_COND_V(faces.size()==0,NULL);
+ //step 1 compute the plane
+ Set<Vector3> points;
+ Plane plane;
+
+ Vector3 center;
+
+ for(int i=0;i<faces.size();i++) {
+
+ Face3 f = faces.get(i);
+ Plane p = f.get_plane();
+ plane.normal+=p.normal;
+ plane.d+=p.d;
+
+ for(int i=0;i<3;i++) {
+
+ Vector3 v = f.vertex[i].snapped(0.01);
+ if (!points.has(v)) {
+ points.insert(v);
+ center+=v;
+ }
+ }
+ }
+
+ plane.normal.normalize();
+ plane.d/=faces.size();
+ center/=points.size();
+
+ //step 2, create points
+
+ Transform t;
+ t.basis.from_z(plane.normal);
+ t.basis.transpose();
+ t.origin=center;
+
+ Vector<Point2> portal_points;
+
+ for(Set<Vector3>::Element *E=points.front();E;E=E->next()) {
+
+ Vector3 local = t.xform_inv(E->get());
+ portal_points.push_back(Point2(local.x,local.y));
+ }
+ // step 3 bubbly sort points
+
+ int swaps=0;
+
+ do {
+ swaps=0;
+
+ for(int i=0;i<portal_points.size()-1;i++) {
+
+ float a = portal_points[i].angle();
+ float b = portal_points[i+1].angle();
+
+ if (a>b) {
+ SWAP( portal_points[i], portal_points[i+1] );
+ swaps++;
+ }
+
+ }
+
+ } while(swaps);
+
+
+ Portal *portal = memnew( Portal );
+
+ portal->set_shape(portal_points);
+ portal->set_transform( mi->get_transform() * t);
+
+ p_node->replace_by(portal);
+ memdelete(p_node);
+ p_node=portal;
+
+ } else if (p_node->cast_to<MeshInstance>()) {
+
+ //last attempt, maybe collision insde the mesh data
+
+ MeshInstance *mi = p_node->cast_to<MeshInstance>();
+
+ Ref<Mesh> mesh = mi->get_mesh();
+ if (!mesh.is_null()) {
+
+ if (_teststr(mesh->get_name(),"col")) {
+
+ mesh->set_name( _fixstr(mesh->get_name(),"col") );
+ Ref<Shape> shape;
+
+ if (collision_map.has(mesh)) {
+ shape = collision_map[mesh];
+
+ } else {
+
+ shape = mesh->create_trimesh_shape();
+ if (!shape.is_null())
+ collision_map[mesh]=shape;
+
+
+ }
+
+ if (!shape.is_null()) {
+#if 0
+ StaticBody* static_body = memnew( StaticBody );
+ ERR_FAIL_COND_V(!static_body,NULL);
+ static_body->set_name( String(mesh->get_name()) + "_col" );
+ shape->set_name(static_body->get_name());
+ static_body->add_shape(shape);
+
+ mi->add_child(static_body);
+ if (mi->get_owner())
+ static_body->set_owner( mi->get_owner() );
+#endif
+ }
+
+ }
+
+ for(int i=0;i<mesh->get_surface_count();i++) {
+
+ Ref<FixedSpatialMaterial> fm = mesh->surface_get_material(i);
+ if (fm.is_valid()) {
+ String name = fm->get_name();
+ /* if (_teststr(name,"alpha")) {
+ fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ name=_fixstr(name,"alpha");
+ }
+
+ if (_teststr(name,"vcol")) {
+ fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true);
+ name=_fixstr(name,"vcol");
+ }*/
+ fm->set_name(name);
+ }
+ }
+
+ }
+
+ }
+
+
+ return p_node;
+}
+
+
+void ResourceImporterScene::_create_clips(Node *scene, const Array& p_clips,bool p_bake_all) {
+
+ if (!scene->has_node(String("AnimationPlayer")))
+ return;
+
+ Node* n = scene->get_node(String("AnimationPlayer"));
+ ERR_FAIL_COND(!n);
+ AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
+ ERR_FAIL_COND(!anim);
+
+ if (!anim->has_animation("default"))
+ return;
+
+
+ Ref<Animation> default_anim = anim->get_animation("default");
+
+ for(int i=0;i<p_clips.size();i+=4) {
+
+ String name = p_clips[i];
+ float from=p_clips[i+1];
+ float to=p_clips[i+2];
+ bool loop=p_clips[i+3];
+ if (from>=to)
+ continue;
+
+ Ref<Animation> new_anim = memnew( Animation );
+
+ for(int j=0;j<default_anim->get_track_count();j++) {
+
+
+ List<float> keys;
+ int kc = default_anim->track_get_key_count(j);
+ int dtrack=-1;
+ for(int k=0;k<kc;k++) {
+
+ float kt = default_anim->track_get_key_time(j,k);
+ if (kt>=from && kt<to) {
+
+ //found a key within range, so create track
+ if (dtrack==-1) {
+ new_anim->add_track(default_anim->track_get_type(j));
+ dtrack = new_anim->get_track_count()-1;
+ new_anim->track_set_path(dtrack,default_anim->track_get_path(j));
+
+ if (kt>(from+0.01) && k>0) {
+
+ if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ Quat q;
+ Vector3 p;
+ Vector3 s;
+ default_anim->transform_track_interpolate(j,from,&p,&q,&s);
+ new_anim->transform_track_insert_key(dtrack,0,p,q,s);
+ }
+ }
+
+ }
+
+ if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ Quat q;
+ Vector3 p;
+ Vector3 s;
+ default_anim->transform_track_get_key(j,k,&p,&q,&s);
+ new_anim->transform_track_insert_key(dtrack,kt-from,p,q,s);
+ }
+
+ }
+
+ if (dtrack!=-1 && kt>=to) {
+
+ if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+ Quat q;
+ Vector3 p;
+ Vector3 s;
+ default_anim->transform_track_interpolate(j,to,&p,&q,&s);
+ new_anim->transform_track_insert_key(dtrack,to-from,p,q,s);
+ }
+ }
+
+ }
+
+ if (dtrack==-1 && p_bake_all) {
+ new_anim->add_track(default_anim->track_get_type(j));
+ dtrack = new_anim->get_track_count()-1;
+ new_anim->track_set_path(dtrack,default_anim->track_get_path(j));
+ if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) {
+
+
+ Quat q;
+ Vector3 p;
+ Vector3 s;
+ default_anim->transform_track_interpolate(j,from,&p,&q,&s);
+ new_anim->transform_track_insert_key(dtrack,0,p,q,s);
+ default_anim->transform_track_interpolate(j,to,&p,&q,&s);
+ new_anim->transform_track_insert_key(dtrack,to-from,p,q,s);
+ }
+
+ }
+ }
+
+
+ new_anim->set_loop(loop);
+ new_anim->set_length(to-from);
+ anim->add_animation(name,new_anim);
+ }
+
+ anim->remove_animation("default"); //remove default (no longer needed)
+}
+
+void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim,Set<String> &keep) {
+
+ Ref<Animation> a = anim;
+ ERR_FAIL_COND(!a.is_valid());
+
+ print_line("From Anim "+anim->get_name()+":");
+
+ for(int j=0;j<a->get_track_count();j++) {
+
+ String path = a->track_get_path(j);
+
+ if (!keep.has(path)) {
+
+ print_line("Remove: "+path);
+ a->remove_track(j);
+ j--;
+ }
+
+ }
+}
+
+
+void ResourceImporterScene::_filter_tracks(Node *scene, const String& p_text) {
+
+ if (!scene->has_node(String("AnimationPlayer")))
+ return;
+ Node* n = scene->get_node(String("AnimationPlayer"));
+ ERR_FAIL_COND(!n);
+ AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
+ ERR_FAIL_COND(!anim);
+
+ Vector<String> strings = p_text.split("\n");
+ for(int i=0;i<strings.size();i++) {
+
+ strings[i]=strings[i].strip_edges();
+ }
+
+ List<StringName> anim_names;
+ anim->get_animation_list(&anim_names);
+ for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) {
+
+ String name = E->get();
+ bool valid_for_this=false;
+ bool valid=false;
+
+ Set<String> keep;
+ Set<String> keep_local;
+
+
+ for(int i=0;i<strings.size();i++) {
+
+
+ if (strings[i].begins_with("@")) {
+
+ valid_for_this=false;
+ for(Set<String>::Element *F=keep_local.front();F;F=F->next()) {
+ keep.insert(F->get());
+ }
+ keep_local.clear();
+
+ Vector<String> filters=strings[i].substr(1,strings[i].length()).split(",");
+ for(int j=0;j<filters.size();j++) {
+
+ String fname = filters[j].strip_edges();
+ if (fname=="")
+ continue;
+ int fc = fname[0];
+ bool plus;
+ if (fc=='+')
+ plus=true;
+ else if (fc=='-')
+ plus=false;
+ else
+ continue;
+
+ String filter=fname.substr(1,fname.length()).strip_edges();
+
+ if (!name.matchn(filter))
+ continue;
+ valid_for_this=plus;
+ }
+
+ if (valid_for_this)
+ valid=true;
+
+ } else if (valid_for_this) {
+
+ Ref<Animation> a = anim->get_animation(name);
+ if (!a.is_valid())
+ continue;
+
+ for(int j=0;j<a->get_track_count();j++) {
+
+ String path = a->track_get_path(j);
+
+ String tname = strings[i];
+ if (tname=="")
+ continue;
+ int fc = tname[0];
+ bool plus;
+ if (fc=='+')
+ plus=true;
+ else if (fc=='-')
+ plus=false;
+ else
+ continue;
+
+ String filter=tname.substr(1,tname.length()).strip_edges();
+
+ if (!path.matchn(filter))
+ continue;
+
+ if (plus)
+ keep_local.insert(path);
+ else if (!keep.has(path)) {
+ keep_local.erase(path);
+ }
+ }
+
+ }
+
+ }
+
+ if (valid) {
+ for(Set<String>::Element *F=keep_local.front();F;F=F->next()) {
+ keep.insert(F->get());
+ }
+ _filter_anim_tracks(anim->get_animation(name),keep);
+ } else {
+
+ }
+
+ }
+
+
+
+}
+
+void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle) {
+
+ if (!scene->has_node(String("AnimationPlayer")))
+ return;
+ Node* n = scene->get_node(String("AnimationPlayer"));
+ ERR_FAIL_COND(!n);
+ AnimationPlayer *anim = n->cast_to<AnimationPlayer>();
+ ERR_FAIL_COND(!anim);
+
+
+ List<StringName> anim_names;
+ anim->get_animation_list(&anim_names);
+ for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) {
+
+ Ref<Animation> a = anim->get_animation(E->get());
+ a->optimize(p_max_lin_error,p_max_ang_error,Math::deg2rad(p_max_angle));
+ }
+}
+
+
+static String _make_extname(const String& p_str) {
+
+ String ext_name=p_str.replace(".","_");
+ ext_name=ext_name.replace(":","_");
+ ext_name=ext_name.replace("\"","_");
+ ext_name=ext_name.replace("<","_");
+ ext_name=ext_name.replace(">","_");
+ ext_name=ext_name.replace("/","_");
+ ext_name=ext_name.replace("|","_");
+ ext_name=ext_name.replace("\\","_");
+ ext_name=ext_name.replace("?","_");
+ ext_name=ext_name.replace("*","_");
+
+ 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<Mesh>,Ref<Mesh> >& p_meshes) {
+
+ List<PropertyInfo> pi;
+
+ p_node->get_property_list(&pi);
+
+ for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+
+ if (E->get().type==Variant::OBJECT) {
+
+ Ref<Material> mat = p_node->get(E->get().name);
+ if (p_make_materials && mat.is_valid() && mat->get_name()!="") {
+
+
+ if (!p_materials.has(mat)) {
+
+ String ext_name = p_base_path+"."+_make_extname(mat->get_name())+".mtl";
+ if (FileAccess::exists(ext_name)) {
+ //if exists, use it
+ Ref<Material> existing = ResourceLoader::load(ext_name);
+ p_materials[mat]=existing;
+ } else {
+
+ ResourceSaver::save(ext_name,mat,ResourceSaver::FLAG_CHANGE_PATH);
+ p_materials[mat]=mat;
+ }
+ }
+
+ if (p_materials[mat]!=mat) {
+
+ p_node->set(E->get().name,p_materials[mat]);
+ }
+ } else {
+
+ Ref<Mesh> mesh = p_node->get(E->get().name);
+
+ if (mesh.is_valid()) {
+
+ bool mesh_just_added=false;
+
+ if (p_make_meshes) {
+
+ if (!p_meshes.has(mesh)) {
+
+ String ext_name = p_base_path+"."+_make_extname(mesh->get_name())+".msh";
+ if (FileAccess::exists(ext_name)) {
+ //if exists, use it
+ Ref<Mesh> existing = ResourceLoader::load(ext_name);
+ p_meshes[mesh]=existing;
+ } else {
+
+ ResourceSaver::save(ext_name,mesh,ResourceSaver::FLAG_CHANGE_PATH);
+ p_meshes[mesh]=mesh;
+ mesh_just_added=true;
+ }
+
+
+ }
+ }
+
+
+ if (p_make_materials){
+
+ if (mesh_just_added || !p_meshes.has(mesh)) {
+
+
+ for(int i=0;i<mesh->get_surface_count();i++) {
+ mat=mesh->surface_get_material(i);
+ if (!mat.is_valid() || mat->get_name()=="")
+ continue;
+
+ if (!p_materials.has(mat)) {
+
+ String ext_name = p_base_path+"."+_make_extname(mat->get_name())+".mtl";
+ if (FileAccess::exists(ext_name)) {
+ //if exists, use it
+ Ref<Material> existing = ResourceLoader::load(ext_name);
+ p_materials[mat]=existing;
+ } else {
+
+ ResourceSaver::save(ext_name,mat,ResourceSaver::FLAG_CHANGE_PATH);
+ p_materials[mat]=mat;
+ }
+ }
+
+ if (p_materials[mat]!=mat) {
+
+ mesh->surface_set_material(i,p_materials[mat]);
+ }
+
+ }
+
+ if(!p_make_meshes) {
+ p_meshes[mesh]=Ref<Mesh>(); //save it anyway, so it won't be checked again
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ 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);
+ }
+}
+
+
+void ResourceImporterScene::get_import_options(List<ImportOption> *r_options,int p_preset) const {
+
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"nodes/root_type",PROPERTY_HINT_TYPE_STRING,"Node"),"Spatial"));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"nodes/root_name"),"Scene Root"));
+
+ List<String> script_extentions;
+ ResourceLoader::get_recognized_extensions_for_type("Script",&script_extentions);
+
+ String script_ext_hint;
+
+ for(List<String>::Element *E=script_extentions.front();E;E=E->next()) {
+ if (script_ext_hint!="")
+ script_ext_hint+=",";
+ script_ext_hint+="*."+E->get();
+ }
+
+ 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::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::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),""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/optimizer/enabled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_linear_error"),0.05));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_angular_error"),0.01));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"animation/optimizer/max_angle"),22));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/optimizer/remove_unused_tracks"),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clips/amount",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),0));
+ for(int i=0;i<256;i++) {
+ r_options->push_back(ImportOption(PropertyInfo(Variant::STRING,"animation/clip_"+itos(i+1)+"/name"),""));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clip_"+itos(i+1)+"/start_frame"),0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"animation/clip_"+itos(i+1)+"/end_frame"),0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"animation/clip_"+itos(i+1)+"/loops"),false));
+ }
+}
+
+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;
+
+ Ref<EditorSceneImporter> importer;
+ String ext=src_path.get_extension().to_lower();
+
+
+ EditorProgress progress("import",TTR("Import Scene"),104);
+ progress.step(TTR("Importing Scene.."),0);
+
+ for(Set< Ref<EditorSceneImporter> >::Element *E=importers.front();E;E=E->next()) {
+
+ List<String> extensions;
+ E->get()->get_extensions(&extensions);
+
+ for(List<String>::Element *F=extensions.front();F;F=F->next()) {
+
+ if (F->get().to_lower()==ext) {
+
+ importer = E->get();
+ break;
+ }
+ }
+
+ if (importer.is_valid())
+ break;
+ }
+
+ ERR_FAIL_COND_V(!importer.is_valid(),ERR_FILE_UNRECOGNIZED);
+
+ float fps=p_options["animation/fps"];
+
+
+
+ int import_flags=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP;
+ if (!bool(p_options["animation/optimizer/remove_unused_tracks"]))
+ import_flags|=EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS;
+
+ if (bool(p_options["animation/import"]))
+ import_flags|=EditorSceneImporter::IMPORT_ANIMATION;
+
+ if (bool(p_options["geometry/ensure_tangents"]))
+ import_flags|=EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
+
+ if (int(p_options["materials/location"])==0)
+ import_flags|=EditorSceneImporter::IMPORT_MATERIALS_IN_INSTANCES;
+
+
+ Error err=OK;
+ List<String> missing_deps; // for now, not much will be done with this
+ Node *scene = importer->import_scene(src_path,import_flags,fps,&missing_deps,&err);
+ if (!scene || err!=OK) {
+ return err;
+ }
+
+ String root_type = p_options["nodes/root_type"];
+
+ if (scene->get_class()!=root_type) {
+ Object *base = ClassDB::instance(root_type);
+ Node *base_node = NULL;
+ if (base)
+ base_node=base->cast_to<Node>();
+
+ if (base_node) {
+
+ scene->replace_by(base_node);
+ memdelete(scene);
+ scene=base_node;
+ }
+ }
+
+ scene->set_name(p_options["nodes/root_name"]);
+
+
+ err=OK;
+
+ String animation_filter = String(p_options["animation/filter_script"]).strip_edges();
+
+ bool use_optimizer = p_options["animation/optimizer/enabled"];
+ float anim_optimizer_linerr=p_options["animation/optimizer/max_linear_error"];
+ float anim_optimizer_angerr=p_options["animation/optimizer/max_angular_error"];
+ float anim_optimizer_maxang=p_options["animation/optimizer/max_angle"];
+
+ Map<Ref<Mesh>,Ref<Shape> > collision_map;
+
+ scene=_fix_node(scene,scene,collision_map);
+
+ if (use_optimizer) {
+ _optimize_animations(scene,anim_optimizer_linerr,anim_optimizer_angerr,anim_optimizer_maxang);
+ }
+
+ Array animation_clips;
+ {
+
+
+ int clip_count = p_options["animation/clips/amount"];
+
+ for(int i=0;i<clip_count;i++) {
+ String name = p_options["animation/clip_"+itos(i+1)+"/name"];
+ int from_frame = p_options["animation/clip_"+itos(i+1)+"/start_frame"];
+ int end_frame = p_options["animation/clip_"+itos(i+1)+"/end_frame"];
+ bool loop = p_options["animation/clip_"+itos(i+1)+"/loops"];
+
+ animation_clips.push_back(name);
+ animation_clips.push_back(from_frame/fps);
+ animation_clips.push_back(end_frame/fps);
+ animation_clips.push_back(loop);
+ }
+
+ }
+ if (animation_clips.size()) {
+ _create_clips(scene,animation_clips,!bool(p_options["animation/optimizer/remove_unused_tracks"]));
+ }
+
+ if (animation_filter!="") {
+ _filter_tracks(scene,animation_filter);
+ }
+
+
+ bool external_materials = p_options["materials/storage"];
+ bool external_meshes = p_options["geometry/storage"];
+
+ if (external_materials || external_meshes) {
+ Map<Ref<Material>, Ref<Material> > mat_map;
+ Map<Ref<Mesh>, Ref<Mesh> > mesh_map;
+ _make_external_resources(scene,p_source_file.get_basename(),external_materials,external_meshes,mat_map,mesh_map);
+ }
+
+ progress.step(TTR("Running Custom Script.."),2);
+
+ String post_import_script_path = p_options["nodes/custom_script"];
+ Ref<EditorScenePostImport> post_import_script;
+
+ if (post_import_script_path!="") {
+ post_import_script_path = post_import_script_path; // FIXME: is there a good reason for this?
+ Ref<Script> scr = ResourceLoader::load(post_import_script_path);
+ if (!scr.is_valid()) {
+ EditorNode::add_io_error(TTR("Couldn't load post-import script:")+" "+post_import_script_path);
+ } else {
+
+ post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) );
+ post_import_script->set_script(scr.get_ref_ptr());
+ if (!post_import_script->get_script_instance()) {
+ EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):")+" "+post_import_script_path);
+ post_import_script.unref();
+ return ERR_CANT_CREATE;
+ }
+ }
+ }
+
+
+ if (post_import_script.is_valid()) {
+ scene = post_import_script->post_import(scene);
+ if (!scene) {
+ EditorNode::add_io_error(TTR("Error running post-import script:")+" "+post_import_script_path);
+ return err;
+ }
+
+
+ }
+
+ progress.step(TTR("Saving.."),104);
+
+ 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
+
+ memdelete(scene);
+
+ EditorNode::get_singleton()->reload_scene(p_source_file);
+
+ return OK;
+}
+
+ResourceImporterScene *ResourceImporterScene::singleton=NULL;
+
+ResourceImporterScene::ResourceImporterScene()
+{
+ singleton=this;
+}
diff --git a/tools/editor/import/resource_importer_scene.h b/tools/editor/import/resource_importer_scene.h
new file mode 100644
index 0000000000..cfa44b160a
--- /dev/null
+++ b/tools/editor/import/resource_importer_scene.h
@@ -0,0 +1,93 @@
+#ifndef RESOURCEIMPORTERSCENE_H
+#define RESOURCEIMPORTERSCENE_H
+
+#include "io/resource_import.h"
+#include "scene/resources/animation.h"
+#include "scene/resources/shape.h"
+
+class Material;
+
+class EditorSceneImporter : public Reference {
+
+ GDCLASS(EditorSceneImporter,Reference );
+public:
+
+ enum ImportFlags {
+ IMPORT_SCENE=1,
+ IMPORT_ANIMATION=2,
+ IMPORT_ANIMATION_DETECT_LOOP=4,
+ IMPORT_ANIMATION_OPTIMIZE=8,
+ IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16,
+ IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32,
+ IMPORT_GENERATE_TANGENT_ARRAYS=256,
+ IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512,
+ IMPORT_MATERIALS_IN_INSTANCES=1024
+
+ };
+
+ virtual uint32_t get_import_flags() const=0;
+ virtual void get_extensions(List<String> *r_extensions) const=0;
+ 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)=0;
+ virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags)=0;
+
+
+
+ EditorSceneImporter() {}
+};
+
+class EditorScenePostImport : public Reference {
+
+ GDCLASS(EditorScenePostImport,Reference );
+protected:
+
+ static void _bind_methods();
+public:
+
+ virtual Node* post_import(Node* p_scene);
+ EditorScenePostImport();
+};
+
+
+class ResourceImporterScene : public ResourceImporter {
+ GDCLASS(ResourceImporterScene,ResourceImporter)
+
+ Set< Ref<EditorSceneImporter> > importers;
+
+ static ResourceImporterScene *singleton;
+public:
+
+ static ResourceImporterScene *get_singleton() { return singleton; }
+
+ const Set< Ref<EditorSceneImporter> >& get_importers() const { return importers; }
+
+ void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); }
+
+ 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;
+
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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<Mesh>, Ref<Mesh> > &p_meshes);
+
+ Node* _fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map);
+
+ void _create_clips(Node *scene, const Array& p_clips,bool p_bake_all);
+ void _filter_anim_tracks(Ref<Animation> anim,Set<String> &keep);
+ void _filter_tracks(Node *scene, const String& p_text);
+ void _optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle);
+
+ 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);
+
+ ResourceImporterScene();
+};
+
+
+#endif // RESOURCEIMPORTERSCENE_H
diff --git a/tools/editor/import/resource_importer_texture.cpp b/tools/editor/import/resource_importer_texture.cpp
new file mode 100644
index 0000000000..21e434fa11
--- /dev/null
+++ b/tools/editor/import/resource_importer_texture.cpp
@@ -0,0 +1,393 @@
+#include "resource_importer_texture.h"
+#include "io/image_loader.h"
+#include "scene/resources/texture.h"
+#include "tools/editor/editor_file_system.h"
+#include "io/config_file.h"
+
+
+void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture>& p_tex) {
+
+ singleton->mutex->lock();
+ StringName path = p_tex->get_path();
+
+ if (!singleton->make_flags.has(path)) {
+ singleton->make_flags[path]=0;
+ }
+
+ singleton->make_flags[path]|=MAKE_SRGB_FLAG;
+
+ print_line("requesting srgb for "+String(path));
+
+ singleton->mutex->unlock();
+
+}
+
+
+
+void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture>& p_tex) {
+
+
+ singleton->mutex->lock();
+ StringName path = p_tex->get_path();
+
+ if (!singleton->make_flags.has(path)) {
+ singleton->make_flags[path]=0;
+ }
+
+ singleton->make_flags[path]|=MAKE_3D_FLAG;
+
+ print_line("requesting 3d for "+String(path));
+
+ singleton->mutex->unlock();
+
+
+}
+
+void ResourceImporterTexture::update_imports() {
+
+ if (EditorFileSystem::get_singleton()->is_scanning() || EditorFileSystem::get_singleton()->is_importing()) {
+ return; // do nothing for noe
+ }
+ mutex->lock();
+
+ if (make_flags.empty()) {
+ mutex->unlock();
+ return;
+ }
+
+ Vector<String> to_reimport;
+ for (Map<StringName,int>::Element *E=make_flags.front();E;E=E->next()) {
+
+ print_line("checking for reimport "+String(E->key()));
+
+
+ Ref<ConfigFile> cf;
+ cf.instance();
+ String src_path = String(E->key())+".import";
+
+ Error err = cf->load(src_path);
+ ERR_CONTINUE(err!=OK);
+
+ bool changed=false;
+ if (E->get()&MAKE_SRGB_FLAG && int(cf->get_value("params","flags/srgb"))==2) {
+ cf->set_value("params","flags/srgb",1);
+ changed=true;
+ }
+
+ if (E->get()&MAKE_3D_FLAG && bool(cf->get_value("params","detect_3d"))) {
+ cf->set_value("params","detect_3d",false);
+ cf->set_value("params","compress/mode",2);
+ cf->set_value("params","flags/repeat",true);
+ cf->set_value("params","flags/filter",true);
+ cf->set_value("params","flags/mipmaps",true);
+ changed=true;
+ }
+
+ if (changed) {
+ cf->save(src_path);
+ to_reimport.push_back(E->key());
+ }
+
+ }
+
+ make_flags.clear();
+
+ mutex->unlock();
+
+ if (to_reimport.size()) {
+ EditorFileSystem::get_singleton()->reimport_files(to_reimport);
+ }
+
+}
+
+
+
+String ResourceImporterTexture::get_importer_name() const {
+
+ return "texture";
+}
+
+String ResourceImporterTexture::get_visible_name() const{
+
+ return "Texture";
+}
+void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const{
+
+ ImageLoader::get_recognized_extensions(p_extensions);
+}
+String ResourceImporterTexture::get_save_extension() const {
+ return "stex";
+}
+
+String ResourceImporterTexture::get_resource_type() const{
+
+ return "StreamTexture";
+}
+
+bool ResourceImporterTexture::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ if (p_option=="compress/lossy_quality" && int(p_options["compress/mode"])!=COMPRESS_LOSSY)
+ return false;
+
+ return true;
+}
+
+int ResourceImporterTexture::get_preset_count() const {
+ return 4;
+}
+String ResourceImporterTexture::get_preset_name(int p_idx) const {
+
+ static const char* preset_names[]={
+ "2D, Detect 3D",
+ "2D",
+ "2D Pixel",
+ "3D"
+ };
+
+ return preset_names[p_idx];
+}
+
+
+void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,int p_preset) const {
+
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"compress/mode",PROPERTY_HINT_ENUM,"Lossless,Lossy,Video RAM,Uncompressed",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED),p_preset==PRESET_3D?2:0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"compress/lossy_quality",PROPERTY_HINT_RANGE,"0,1,0.01"),0.7));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"flags/repeat",PROPERTY_HINT_ENUM,"Disabled,Enabled,Mirrored"),p_preset==PRESET_3D?1:0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/filter"),p_preset==PRESET_2D_PIXEL?false:true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/mipmaps"),p_preset==PRESET_3D?true:false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"flags/anisotropic"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"flags/srgb",PROPERTY_HINT_ENUM,"Disable,Enable,Detect"),2));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"process/fix_alpha_border"),p_preset!=PRESET_3D?true:false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"process/premult_alpha"),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"stream"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"size_limit",PROPERTY_HINT_RANGE,"0,4096,1"),0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"detect_3d"),p_preset==PRESET_DETECT));
+
+}
+
+
+void ResourceImporterTexture::_save_stex(const Image& p_image, const String& p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) {
+
+
+ FileAccess *f = FileAccess::open(p_to_path,FileAccess::WRITE);
+ f->store_8('G');
+ f->store_8('D');
+ f->store_8('S');
+ f->store_8('T'); //godot streamable texture
+
+ f->store_32(p_image.get_width());
+ f->store_32(p_image.get_height());
+ f->store_32(p_texture_flags);
+
+ uint32_t format=0;
+
+ if (p_streamable)
+ format|=StreamTexture::FORMAT_BIT_STREAM;
+ if (p_mipmaps || p_compress_mode==COMPRESS_VIDEO_RAM) //VRAM always uses mipmaps
+ format|=StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
+ if (p_detect_3d)
+ format|=StreamTexture::FORMAT_BIT_DETECT_3D;
+ if (p_detect_srgb)
+ format|=StreamTexture::FORMAT_BIT_DETECT_SRGB;
+
+
+ switch (p_compress_mode) {
+ case COMPRESS_LOSSLESS: {
+
+ Image image = p_image;
+ if (p_mipmaps) {
+ image.generate_mipmaps();
+ } else {
+ image.clear_mipmaps();
+ }
+
+ int mmc = image.get_mipmap_count() + 1;
+
+ format|=StreamTexture::FORMAT_BIT_LOSSLESS;
+ f->store_32(format);
+ f->store_32(mmc);
+
+ for(int i=0;i<mmc;i++) {
+
+ if (i>0) {
+ image.shrink_x2();
+ }
+
+ PoolVector<uint8_t> data = Image::lossless_packer(image);
+ int data_len = data.size();
+ f->store_32(data_len);
+
+ PoolVector<uint8_t>::Read r= data.read();
+ f->store_buffer(r.ptr(),data_len);
+
+ }
+
+
+ } break;
+ case COMPRESS_LOSSY: {
+ Image image = p_image;
+ if (p_mipmaps) {
+ image.generate_mipmaps();
+ } else {
+ image.clear_mipmaps();
+ }
+
+ int mmc = image.get_mipmap_count() + 1;
+
+ format|=StreamTexture::FORMAT_BIT_LOSSY;
+ f->store_32(format);
+ f->store_32(mmc);
+
+ for(int i=0;i<mmc;i++) {
+
+ if (i>0) {
+ image.shrink_x2();
+ }
+
+ PoolVector<uint8_t> data = Image::lossy_packer(image,p_lossy_quality);
+ int data_len = data.size();
+ f->store_32(data_len);
+
+ PoolVector<uint8_t>::Read r = data.read();
+ f->store_buffer(r.ptr(),data_len);
+
+ }
+ } break;
+ case COMPRESS_VIDEO_RAM: {
+
+ Image image = p_image;
+ image.generate_mipmaps();
+ image.compress(p_vram_compression);
+
+ format |= image.get_format();
+
+ f->store_32(format);
+
+ PoolVector<uint8_t> data=image.get_data();
+ int dl = data.size();
+ PoolVector<uint8_t>::Read r = data.read();
+ f->store_buffer(r.ptr(),dl);
+
+ } break;
+ case COMPRESS_UNCOMPRESSED: {
+
+ Image image = p_image;
+ if (p_mipmaps) {
+ image.generate_mipmaps();
+ } else {
+ image.clear_mipmaps();
+ }
+
+ format |= image.get_format();
+ f->store_32(format);
+
+ PoolVector<uint8_t> data=image.get_data();
+ int dl = data.size();
+ PoolVector<uint8_t>::Read r = data.read();
+
+ f->store_buffer(r.ptr(),dl);
+
+ } break;
+ }
+
+ memdelete(f);
+}
+
+Error ResourceImporterTexture::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) {
+
+ int compress_mode = p_options["compress/mode"];
+ float lossy= p_options["compress/lossy_quality"];
+ int repeat= p_options["flags/repeat"];
+ bool filter= p_options["flags/filter"];
+ bool mipmaps= p_options["flags/mipmaps"];
+ bool anisotropic= p_options["flags/anisotropic"];
+ int srgb= p_options["flags/srgb"];
+ bool fix_alpha_border= p_options["process/fix_alpha_border"];
+ bool premult_alpha= p_options["process/premult_alpha"];
+ bool stream = p_options["stream"];
+ int size_limit = p_options["size_limit"];
+
+
+ Image image;
+ Error err = ImageLoader::load_image(p_source_file,&image);
+ if (err!=OK)
+ return err;
+
+
+ int tex_flags=0;
+ if (repeat>0)
+ tex_flags|=Texture::FLAG_REPEAT;
+ if (repeat==2)
+ tex_flags|=Texture::FLAG_MIRRORED_REPEAT;
+ if (filter)
+ tex_flags|=Texture::FLAG_FILTER;
+ if (mipmaps || compress_mode==COMPRESS_VIDEO_RAM)
+ tex_flags|=Texture::FLAG_MIPMAPS;
+ if (anisotropic)
+ tex_flags|=Texture::FLAG_ANISOTROPIC_FILTER;
+ if (srgb==1)
+ tex_flags|=Texture::FLAG_CONVERT_TO_LINEAR;
+
+ if (size_limit >0 && (image.get_width()>size_limit || image.get_height()>size_limit )) {
+ //limit size
+ if (image.get_width() >= image.get_height()) {
+ int new_width = size_limit;
+ int new_height = image.get_height() * new_width / image.get_width();
+
+ image.resize(new_width,new_height,Image::INTERPOLATE_CUBIC);
+ } else {
+
+ int new_height = size_limit;
+ int new_width = image.get_width() * new_height / image.get_height();
+
+ image.resize(new_width,new_height,Image::INTERPOLATE_CUBIC);
+ }
+ }
+
+ if (fix_alpha_border) {
+ image.fix_alpha_edges();
+ }
+
+ if (premult_alpha) {
+ image.premultiply_alpha();
+ }
+
+ bool detect_3d = p_options["detect_3d"];
+ bool detect_srgb = srgb==2;
+
+ if (compress_mode==COMPRESS_VIDEO_RAM) {
+ //must import in all formats
+ //Android, GLES 2.x
+ _save_stex(image,p_save_path+".etc.stex",compress_mode,lossy,Image::COMPRESS_ETC,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ r_platform_variants->push_back("etc");
+ //_save_stex(image,p_save_path+".etc2.stex",compress_mode,lossy,Image::COMPRESS_ETC2,mipmaps,tex_flags,stream);
+ //r_platform_variants->push_back("etc2");
+ _save_stex(image,p_save_path+".s3tc.stex",compress_mode,lossy,Image::COMPRESS_S3TC,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ r_platform_variants->push_back("s3tc");
+
+ } else {
+ //import normally
+ _save_stex(image,p_save_path+".stex",compress_mode,lossy,Image::COMPRESS_16BIT /*this is ignored */,mipmaps,tex_flags,stream,detect_3d,detect_srgb);
+ }
+
+ return OK;
+}
+
+ResourceImporterTexture *ResourceImporterTexture::singleton=NULL;
+
+ResourceImporterTexture::ResourceImporterTexture()
+{
+
+ singleton=this;
+ StreamTexture::request_3d_callback=_texture_reimport_3d;
+ StreamTexture::request_srgb_callback=_texture_reimport_srgb;
+ mutex = Mutex::create();
+}
+
+ResourceImporterTexture::~ResourceImporterTexture()
+{
+
+ memdelete(mutex);
+}
+
diff --git a/tools/editor/import/resource_importer_texture.h b/tools/editor/import/resource_importer_texture.h
new file mode 100644
index 0000000000..4c795e132c
--- /dev/null
+++ b/tools/editor/import/resource_importer_texture.h
@@ -0,0 +1,70 @@
+#ifndef RESOURCEIMPORTTEXTURE_H
+#define RESOURCEIMPORTTEXTURE_H
+
+#include "io/resource_import.h"
+class StreamTexture;
+
+class ResourceImporterTexture : public ResourceImporter {
+ GDCLASS(ResourceImporterTexture,ResourceImporter)
+
+
+
+protected:
+
+ enum {
+ MAKE_3D_FLAG=1,
+ MAKE_SRGB_FLAG=2
+ };
+
+ Mutex *mutex;
+ Map<StringName,int> make_flags;
+
+ static void _texture_reimport_srgb(const Ref<StreamTexture>& p_tex);
+ static void _texture_reimport_3d(const Ref<StreamTexture>& p_tex);
+
+
+
+
+ static ResourceImporterTexture *singleton;
+public:
+
+ static ResourceImporterTexture *get_singleton() { return singleton; }
+ 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;
+
+
+ enum Preset {
+ PRESET_DETECT,
+ PRESET_2D,
+ PRESET_2D_PIXEL,
+ PRESET_3D,
+ };
+
+ enum CompressMode {
+ COMPRESS_LOSSLESS,
+ COMPRESS_LOSSY,
+ COMPRESS_VIDEO_RAM,
+ COMPRESS_UNCOMPRESSED
+ };
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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 _save_stex(const Image& p_image, const String& p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable,bool p_detect_3d,bool p_detect_srgb);
+
+ 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);
+
+
+ void update_imports();
+
+ ResourceImporterTexture();
+ ~ResourceImporterTexture();
+};
+
+#endif // RESOURCEIMPORTTEXTURE_H
diff --git a/tools/editor/import/resource_importer_wav.cpp b/tools/editor/import/resource_importer_wav.cpp
new file mode 100644
index 0000000000..ee53b740ca
--- /dev/null
+++ b/tools/editor/import/resource_importer_wav.cpp
@@ -0,0 +1,619 @@
+#include "resource_importer_wav.h"
+
+#include "scene/resources/audio_stream_sample.h"
+#include "os/file_access.h"
+#include "io/marshalls.h"
+#include "io/resource_saver.h"
+
+String ResourceImporterWAV::get_importer_name() const {
+
+ return "wav";
+}
+
+String ResourceImporterWAV::get_visible_name() const{
+
+ return "Microsoft WAV";
+}
+void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const{
+
+ p_extensions->push_back("wav");
+}
+String ResourceImporterWAV::get_save_extension() const {
+ return "smp";
+}
+
+String ResourceImporterWAV::get_resource_type() const{
+
+ return "AudioStreamSample";
+}
+
+bool ResourceImporterWAV::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const {
+
+ return true;
+}
+
+int ResourceImporterWAV::get_preset_count() const {
+ return 0;
+}
+String ResourceImporterWAV::get_preset_name(int p_idx) const {
+
+ return String();
+}
+
+
+void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options,int p_preset) const {
+
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/8_bit"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/mono"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"force/max_rate"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL,"force/max_rate_hz",PROPERTY_HINT_EXP_RANGE,"11025,192000,1"),44100));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/trim"),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/normalize"),true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"edit/loop"),false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT,"compress/mode",PROPERTY_HINT_ENUM,"Disabled,RAM (Ima-ADPCM)"),0));
+
+}
+
+
+Error ResourceImporterWAV::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) {
+
+ /* STEP 1, READ WAVE FILE */
+
+ Error err;
+ FileAccess *file=FileAccess::open(p_source_file, FileAccess::READ,&err);
+
+ ERR_FAIL_COND_V( err!=OK, ERR_CANT_OPEN );
+
+ /* CHECK RIFF */
+ char riff[5];
+ riff[4]=0;
+ file->get_buffer((uint8_t*)&riff,4); //RIFF
+
+ if (riff[0]!='R' || riff[1]!='I' || riff[2]!='F' || riff[3]!='F') {
+
+ file->close();
+ memdelete(file);
+ ERR_FAIL_V( ERR_FILE_UNRECOGNIZED );
+ }
+
+
+ /* GET FILESIZE */
+ uint32_t filesize=file->get_32();
+
+ /* CHECK WAVE */
+
+ char wave[4];
+
+ file->get_buffer((uint8_t*)&wave,4); //RIFF
+
+ if (wave[0]!='W' || wave[1]!='A' || wave[2]!='V' || wave[3]!='E') {
+
+
+ file->close();
+ memdelete(file);
+ ERR_EXPLAIN("Not a WAV file (no WAVE RIFF Header)")
+ ERR_FAIL_V( ERR_FILE_UNRECOGNIZED );
+ }
+
+ int format_bits=0;
+ int format_channels=0;
+
+ AudioStreamSample::LoopMode loop=AudioStreamSample::LOOP_DISABLED;
+ bool format_found=false;
+ bool data_found=false;
+ int format_freq=0;
+ int loop_begin=0;
+ int loop_end=0;
+ int frames;
+
+ Vector<float> data;
+
+ while (!file->eof_reached()) {
+
+
+ /* chunk */
+ char chunkID[4];
+ file->get_buffer((uint8_t*)&chunkID,4); //RIFF
+
+ /* chunk size */
+ uint32_t chunksize=file->get_32();
+ uint32_t file_pos=file->get_pos(); //save file pos, so we can skip to next chunk safely
+
+ if (file->eof_reached()) {
+
+ //ERR_PRINT("EOF REACH");
+ break;
+ }
+
+ if (chunkID[0]=='f' && chunkID[1]=='m' && chunkID[2]=='t' && chunkID[3]==' ' && !format_found) {
+ /* IS FORMAT CHUNK */
+
+ uint16_t compression_code=file->get_16();
+
+
+ if (compression_code!=1) {
+ ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
+ break;
+ }
+
+ format_channels=file->get_16();
+ if (format_channels!=1 && format_channels !=2) {
+
+ ERR_PRINT("Format not supported for WAVE file (not stereo or mono)");
+ break;
+
+ }
+
+ format_freq=file->get_32(); //sampling rate
+
+ file->get_32(); // average bits/second (unused)
+ file->get_16(); // block align (unused)
+ format_bits=file->get_16(); // bits per sample
+
+ if (format_bits%8) {
+
+ ERR_PRINT("Strange number of bits in sample (not 8,16,24,32)");
+ break;
+ }
+
+ /* Dont need anything else, continue */
+ format_found=true;
+ }
+
+
+ if (chunkID[0]=='d' && chunkID[1]=='a' && chunkID[2]=='t' && chunkID[3]=='a' && !data_found) {
+ /* IS FORMAT CHUNK */
+ data_found=true;
+
+ if (!format_found) {
+ ERR_PRINT("'data' chunk before 'format' chunk found.");
+ break;
+
+ }
+
+ frames=chunksize;
+
+ frames/=format_channels;
+ frames/=(format_bits>>3);
+
+ /*print_line("chunksize: "+itos(chunksize));
+ print_line("channels: "+itos(format_channels));
+ print_line("bits: "+itos(format_bits));
+*/
+
+ int len=frames;
+ if (format_channels==2)
+ len*=2;
+ if (format_bits>8)
+ len*=2;
+
+
+ data.resize(frames*format_channels);
+
+ for (int i=0;i<frames;i++) {
+
+
+ for (int c=0;c<format_channels;c++) {
+
+
+ if (format_bits==8) {
+ // 8 bit samples are UNSIGNED
+
+ uint8_t s = file->get_8();
+ s-=128;
+ int8_t *sp=(int8_t*)&s;
+
+ data[i*format_channels+c]=float(*sp)/128.0;
+
+ } else {
+ //16+ bits samples are SIGNED
+ // if sample is > 16 bits, just read extra bytes
+
+ uint32_t s=0;
+ for (int b=0;b<(format_bits>>3);b++) {
+
+ s|=((uint32_t)file->get_8())<<(b*8);
+ }
+ s<<=(32-format_bits);
+ int32_t ss=s;
+
+
+ data[i*format_channels+c]=(ss>>16)/32768.0;
+ }
+ }
+
+ }
+
+
+
+ if (file->eof_reached()) {
+ file->close();
+ memdelete(file);
+ ERR_EXPLAIN("Premature end of file.");
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
+ }
+ }
+
+ if (chunkID[0]=='s' && chunkID[1]=='m' && chunkID[2]=='p' && chunkID[3]=='l') {
+ //loop point info!
+
+ for(int i=0;i<10;i++)
+ file->get_32(); // i wish to know why should i do this... no doc!
+
+ loop=file->get_32()?AudioStreamSample::LOOP_PING_PONG:AudioStreamSample::LOOP_FORWARD;
+ loop_begin=file->get_32();
+ loop_end=file->get_32();
+
+ }
+ file->seek( file_pos+chunksize );
+ }
+
+ file->close();
+ memdelete(file);
+
+ // STEP 2, APPLY CONVERSIONS
+
+
+ bool is16=format_bits!=8;
+ int rate=format_freq;
+
+ print_line("Input Sample: ");
+ print_line("\tframes: "+itos(frames));
+ print_line("\tformat_channels: "+itos(format_channels));
+ print_line("\t16bits: "+itos(is16));
+ print_line("\trate: "+itos(rate));
+ print_line("\tloop: "+itos(loop));
+ print_line("\tloop begin: "+itos(loop_begin));
+ print_line("\tloop end: "+itos(loop_end));
+
+
+ //apply frequency limit
+
+ bool limit_rate = p_options["force/max_rate"];
+ int limit_rate_hz = p_options["force/max_rate_hz"];
+ if (limit_rate && rate > limit_rate_hz) {
+ //resampleeee!!!
+ int new_data_frames = frames * limit_rate_hz / rate;
+ Vector<float> new_data;
+ new_data.resize( new_data_frames * format_channels );
+ for(int c=0;c<format_channels;c++) {
+
+ for(int i=0;i<new_data_frames;i++) {
+
+ //simple cubic interpolation should be enough.
+ float pos = float(i) * frames / new_data_frames;
+ float mu = pos-Math::floor(pos);
+ int ipos = int(Math::floor(pos));
+
+ float y0=data[MAX(0,ipos-1)*format_channels+c];
+ float y1=data[ipos*format_channels+c];
+ float y2=data[MIN(frames-1,ipos+1)*format_channels+c];
+ float y3=data[MIN(frames-1,ipos+2)*format_channels+c];
+
+ float mu2 = mu*mu;
+ float a0 = y3 - y2 - y0 + y1;
+ float a1 = y0 - y1 - a0;
+ float a2 = y2 - y0;
+ float a3 = y1;
+
+ float res=(a0*mu*mu2+a1*mu2+a2*mu+a3);
+
+ new_data[i*format_channels+c]=res;
+ }
+ }
+
+ if (loop) {
+
+ loop_begin=loop_begin*new_data_frames/frames;
+ loop_end=loop_end*new_data_frames/frames;
+ }
+ data=new_data;
+ rate=limit_rate_hz;
+ frames=new_data_frames;
+ }
+
+
+ bool normalize = p_options["edit/normalize"];
+
+ if (normalize) {
+
+ float max=0;
+ for(int i=0;i<data.size();i++) {
+
+ float amp = Math::abs(data[i]);
+ if (amp>max)
+ max=amp;
+ }
+
+ if (max>0) {
+
+ float mult=1.0/max;
+ for(int i=0;i<data.size();i++) {
+
+ data[i]*=mult;
+ }
+
+ }
+ }
+
+ bool trim = p_options["edit/trim"];
+
+ if (trim && !loop) {
+
+ int first=0;
+ int last=(frames*format_channels)-1;
+ bool found=false;
+ float limit = Math::db2linear((float)-30);
+ for(int i=0;i<data.size();i++) {
+ float amp = Math::abs(data[i]);
+
+ if (!found && amp > limit) {
+ first=i;
+ found=true;
+ }
+
+ if (found && amp > limit) {
+ last=i;
+ }
+ }
+
+ first/=format_channels;
+ last/=format_channels;
+
+ if (first<last) {
+
+ Vector<float> new_data;
+ new_data.resize((last-first+1)*format_channels);
+ for(int i=first*format_channels;i<=last*format_channels;i++) {
+ new_data[i-first*format_channels]=data[i];
+ }
+
+ data=new_data;
+ frames=data.size()/format_channels;
+ }
+
+ }
+
+ bool make_loop = p_options["edit/loop"];
+
+ if (make_loop && !loop) {
+
+ loop=AudioStreamSample::LOOP_FORWARD;
+ loop_begin=0;
+ loop_end=frames;
+ }
+
+ int compression = p_options["compress/mode"];
+ bool force_mono = p_options["force/mono"];
+
+
+ if (force_mono && format_channels==2) {
+
+ Vector<float> new_data;
+ new_data.resize(data.size()/2);
+ for(int i=0;i<frames;i++) {
+ new_data[i]=(data[i*2+0]+data[i*2+1])/2.0;
+ }
+
+ data=new_data;
+ format_channels=1;
+ }
+
+ bool force_8_bit = p_options["force/8_bit"];
+ if (force_8_bit) {
+
+ is16=false;
+ }
+
+
+ PoolVector<uint8_t> dst_data;
+ AudioStreamSample::Format dst_format;
+
+ if ( compression == 1) {
+
+ dst_format=AudioStreamSample::FORMAT_IMA_ADPCM;
+ if (format_channels==1) {
+ _compress_ima_adpcm(data,dst_data);
+ } else {
+
+ //byte interleave
+ Vector<float> left;
+ Vector<float> right;
+
+ int tframes = data.size()/2;
+ left.resize(tframes);
+ right.resize(tframes);
+
+ for(int i=0;i<tframes;i++) {
+ left[i]=data[i*2+0];
+ right[i]=data[i*2+1];
+ }
+
+ PoolVector<uint8_t> bleft;
+ PoolVector<uint8_t> bright;
+
+ _compress_ima_adpcm(left,bleft);
+ _compress_ima_adpcm(right,bright);
+
+ int dl = bleft.size();
+ dst_data.resize( dl *2 );
+
+ PoolVector<uint8_t>::Write w=dst_data.write();
+ PoolVector<uint8_t>::Read rl=bleft.read();
+ PoolVector<uint8_t>::Read rr=bright.read();
+
+ for(int i=0;i<dl;i++) {
+ w[i*2+0]=rl[i];
+ w[i*2+1]=rr[i];
+ }
+ }
+
+ //print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size()));
+
+ } else {
+
+ dst_format=is16?AudioStreamSample::FORMAT_16_BITS:AudioStreamSample::FORMAT_8_BITS;
+ dst_data.resize( data.size() * (is16?2:1));
+ {
+ PoolVector<uint8_t>::Write w = dst_data.write();
+
+ int ds=data.size();
+ for(int i=0;i<ds;i++) {
+
+ if (is16) {
+ int16_t v = CLAMP(data[i]*32768,-32768,32767);
+ encode_uint16(v,&w[i*2]);
+ } else {
+ int8_t v = CLAMP(data[i]*128,-128,127);
+ w[i]=v;
+ }
+ }
+ }
+ }
+
+
+ Ref<AudioStreamSample> sample;
+ sample.instance();
+ sample->set_data(dst_data);
+ sample->set_format(dst_format);
+ sample->set_mix_rate(rate);
+ sample->set_loop_mode(loop);
+ sample->set_loop_begin(loop_begin);
+ sample->set_loop_end(loop_end);
+ sample->set_stereo(format_channels==2);
+
+ ResourceSaver::save(p_save_path+".smp",sample);
+
+
+ return OK;
+
+}
+
+void ResourceImporterWAV::_compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data) {
+
+
+ /*p_sample_data->data = (void*)malloc(len);
+ xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/
+
+ static const int16_t _ima_adpcm_step_table[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+ };
+
+ static const int8_t _ima_adpcm_index_table[16] = {
+ -1, -1, -1, -1, 2, 4, 6, 8,
+ -1, -1, -1, -1, 2, 4, 6, 8
+ };
+
+
+ int datalen = p_data.size();
+ int datamax=datalen;
+ if (datalen&1)
+ datalen++;
+
+ dst_data.resize(datalen/2+4);
+ PoolVector<uint8_t>::Write w = dst_data.write();
+
+
+ int i,step_idx=0,prev=0;
+ uint8_t *out = w.ptr();
+ //int16_t xm_prev=0;
+ const float *in=p_data.ptr();
+
+
+ /* initial value is zero */
+ *(out++) =0;
+ *(out++) =0;
+ /* Table index initial value */
+ *(out++) =0;
+ /* unused */
+ *(out++) =0;
+
+ for (i=0;i<datalen;i++) {
+ int step,diff,vpdiff,mask;
+ uint8_t nibble;
+ int16_t xm_sample;
+
+ if (i>=datamax)
+ xm_sample=0;
+ else {
+
+
+ xm_sample=CLAMP(in[i]*32767.0,-32768,32767);
+ /*
+ if (xm_sample==32767 || xm_sample==-32768)
+ printf("clippy!\n",xm_sample);
+ */
+ }
+
+ //xm_sample=xm_sample+xm_prev;
+ //xm_prev=xm_sample;
+
+ diff = (int)xm_sample - prev ;
+
+ nibble=0 ;
+ step = _ima_adpcm_step_table[ step_idx ];
+ vpdiff = step >> 3 ;
+ if (diff < 0) {
+ nibble=8;
+ diff=-diff ;
+ }
+ mask = 4 ;
+ while (mask) {
+
+ if (diff >= step) {
+
+ nibble |= mask;
+ diff -= step;
+ vpdiff += step;
+ }
+
+ step >>= 1 ;
+ mask >>= 1 ;
+ };
+
+ if (nibble&8)
+ prev-=vpdiff ;
+ else
+ prev+=vpdiff ;
+
+ if (prev > 32767) {
+ //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev);
+ prev=32767;
+ } else if (prev < -32768) {
+ //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev);
+ prev = -32768 ;
+ }
+
+ step_idx += _ima_adpcm_index_table[nibble];
+ if (step_idx< 0)
+ step_idx= 0 ;
+ else if (step_idx> 88)
+ step_idx= 88 ;
+
+
+ if (i&1) {
+ *out|=nibble<<4;
+ out++;
+ } else {
+ *out=nibble;
+ }
+ /*dataptr[i]=prev>>8;*/
+ }
+
+
+
+
+}
+
+ResourceImporterWAV::ResourceImporterWAV()
+{
+
+}
diff --git a/tools/editor/import/resource_importer_wav.h b/tools/editor/import/resource_importer_wav.h
new file mode 100644
index 0000000000..9f1bd57da7
--- /dev/null
+++ b/tools/editor/import/resource_importer_wav.h
@@ -0,0 +1,30 @@
+#ifndef RESOURCEIMPORTWAV_H
+#define RESOURCEIMPORTWAV_H
+
+
+#include "io/resource_import.h"
+
+class ResourceImporterWAV : public ResourceImporter {
+ GDCLASS(ResourceImporterWAV,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;
+
+
+ virtual int get_preset_count() const;
+ virtual String get_preset_name(int p_idx) const;
+
+ 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 _compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data);
+
+ 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);
+
+ ResourceImporterWAV();
+};
+
+#endif // RESOURCEIMPORTWAV_H
diff --git a/tools/editor/import_dock.cpp b/tools/editor/import_dock.cpp
new file mode 100644
index 0000000000..bf61ca4df0
--- /dev/null
+++ b/tools/editor/import_dock.cpp
@@ -0,0 +1,331 @@
+#include "import_dock.h"
+
+class ImportDockParameters : public Object {
+ GDCLASS(ImportDockParameters,Object)
+public:
+ Map<StringName,Variant> values;
+ List<PropertyInfo> properties;
+ Ref<ResourceImporter> importer;
+ Vector<String> paths;
+
+
+ bool _set(const StringName& p_name, const Variant& p_value) {
+
+ if (values.has(p_name)) {
+ values[p_name]=p_value;
+ return true;
+ }
+
+ return false;
+ }
+
+ bool _get(const StringName& p_name,Variant &r_ret) const {
+
+ if (values.has(p_name)) {
+ r_ret=values[p_name];
+ return true;
+ }
+
+ return false;
+
+ }
+ void _get_property_list( List<PropertyInfo> *p_list) const {
+
+ for (const List<PropertyInfo>::Element *E=properties.front();E;E=E->next()) {
+ if (!importer->get_option_visibility(E->get().name,values))
+ continue;
+ p_list->push_back(E->get());
+ }
+ }
+
+ void update() {
+ _change_notify();
+ }
+};
+
+void ImportDock::set_edit_path(const String& p_path) {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(p_path+".import");
+ if (err!=OK) {
+ clear();
+ return;
+ }
+
+
+ params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap","importer"));
+ if (params->importer.is_null()) {
+ clear();
+ return;
+ }
+
+ List<ResourceImporter::ImportOption> options;
+ params->importer->get_import_options(&options);
+
+ params->properties.clear();
+ params->values.clear();
+
+ for (List<ResourceImporter::ImportOption>::Element *E=options.front();E;E=E->next()) {
+
+ params->properties.push_back(E->get().option);
+ if (config->has_section_key("params",E->get().option.name)) {
+ params->values[E->get().option.name]=config->get_value("params",E->get().option.name);
+ } else {
+ params->values[E->get().option.name]=E->get().default_value;
+ }
+ }
+
+ params->update();
+
+ List<Ref<ResourceImporter> > importers;
+ ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(),&importers);
+ List<Pair<String,String> > importer_names;
+
+ for (List<Ref<ResourceImporter> > ::Element *E=importers.front();E;E=E->next()) {
+ importer_names.push_back(Pair<String,String>(E->get()->get_visible_name(),E->get()->get_importer_name()));
+ }
+
+ importer_names.sort_custom<PairSort<String,String> >();
+
+ import_as->clear();
+
+ for (List<Pair<String,String> >::Element *E=importer_names.front();E;E=E->next()) {
+ import_as->add_item(E->get().first);
+ import_as->set_item_metadata(import_as->get_item_count()-1,E->get().second);
+ if (E->get().second==params->importer->get_importer_name()) {
+ import_as->select(import_as->get_item_count()-1);
+ }
+ }
+
+ preset->get_popup()->clear();
+
+ if (params->importer->get_preset_count()==0) {
+ preset->get_popup()->add_item(TTR("Default"));
+ } else {
+ for (int i=0;i<params->importer->get_preset_count();i++) {
+ preset->get_popup()->add_item(params->importer->get_preset_name(i));
+ }
+ }
+
+ params->paths.clear();
+ params->paths.push_back(p_path);
+ import->set_disabled(false);
+ import_as->set_disabled(false);
+
+ imported->set_text(p_path.get_file());
+}
+
+void ImportDock::set_edit_multiple_paths(const Vector<String>& p_paths) {
+
+ clear();
+
+ //use the value that is repeated the mot
+ Map<String,Dictionary> value_frequency;
+
+ for(int i=0;i<p_paths.size();i++) {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(p_paths[i]+".import");
+ ERR_CONTINUE(err!=OK);
+
+ if (i==0) {
+ params->importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(config->get_value("remap","importer"));
+ if (params->importer.is_null()) {
+ clear();
+ return;
+ }
+ }
+
+ List<String> keys;
+ config->get_section_keys("params",&keys);
+
+
+ for (List<String>::Element *E=keys.front();E;E=E->next()) {
+
+ if (!value_frequency.has(E->get())) {
+ value_frequency[E->get()]=Dictionary();
+ }
+
+ Variant value = config->get_value("params",E->get());
+
+ if (value_frequency[E->get()].has(value)) {
+ value_frequency[E->get()][value]=int(value_frequency[E->get()][value])+1;
+ } else {
+ value_frequency[E->get()][value]=1;
+ }
+ }
+
+ }
+
+ ERR_FAIL_COND(params->importer.is_null());
+
+ List<ResourceImporter::ImportOption> options;
+ params->importer->get_import_options(&options);
+
+ params->properties.clear();
+ params->values.clear();
+
+ for (List<ResourceImporter::ImportOption>::Element *E=options.front();E;E=E->next()) {
+
+ params->properties.push_back(E->get().option);
+
+ if (value_frequency.has(E->get().option.name)) {
+
+ Dictionary d = value_frequency[E->get().option.name];
+ int freq=0;
+ List<Variant> v;
+ d.get_key_list(&v);
+ Variant value;
+ for (List<Variant>::Element *F=v.front();F;F=F->next()) {
+ int f = d[F->get()];
+ if (f>freq) {
+ value=F->get();
+ }
+ }
+
+ params->values[E->get().option.name]=value;
+ } else {
+ params->values[E->get().option.name]=E->get().default_value;
+ }
+ }
+
+ params->update();
+
+ List<Ref<ResourceImporter> > importers;
+ ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(),&importers);
+ List<Pair<String,String> > importer_names;
+
+ for (List<Ref<ResourceImporter> > ::Element *E=importers.front();E;E=E->next()) {
+ importer_names.push_back(Pair<String,String>(E->get()->get_visible_name(),E->get()->get_importer_name()));
+ }
+
+ importer_names.sort_custom<PairSort<String,String> >();
+
+ import_as->clear();
+
+ for (List<Pair<String,String> >::Element *E=importer_names.front();E;E=E->next()) {
+ import_as->add_item(E->get().first);
+ import_as->set_item_metadata(import_as->get_item_count()-1,E->get().second);
+ if (E->get().second==params->importer->get_importer_name()) {
+ import_as->select(import_as->get_item_count()-1);
+ }
+ }
+
+ preset->get_popup()->clear();
+
+ if (params->importer->get_preset_count()==0) {
+ preset->get_popup()->add_item(TTR("Default"));
+ } else {
+ for (int i=0;i<params->importer->get_preset_count();i++) {
+ preset->get_popup()->add_item(params->importer->get_preset_name(i));
+ }
+ }
+
+ params->paths=p_paths;
+ import->set_disabled(false);
+ import_as->set_disabled(false);
+
+ imported->set_text(itos(p_paths.size())+TTR(" Files"));
+}
+
+void ImportDock::_preset_selected(int p_idx) {
+
+ print_line("preset selected? "+p_idx);
+ 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();
+
+}
+
+
+void ImportDock::clear() {
+
+ imported->set_text("");
+ import->set_disabled(true);
+ import_as->clear();
+ import_as->set_disabled(true);
+ params->values.clear();
+ params->properties.clear();
+ params->update();
+ preset->get_popup()->clear();
+
+}
+
+void ImportDock::_reimport() {
+
+ for(int i=0;i<params->paths.size();i++) {
+
+ Ref<ConfigFile> config;
+ config.instance();
+ Error err = config->load(params->paths[i]+".import");
+ ERR_CONTINUE(err!=OK);
+
+ config->erase_section("params");
+
+ for (List<PropertyInfo>::Element *E=params->properties.front();E;E=E->next()) {
+ config->set_value("params",E->get().name,params->values[E->get().name]);
+ }
+
+ config->save(params->paths[i]+".import");
+ }
+
+ EditorFileSystem::get_singleton()->reimport_files(params->paths);
+ EditorFileSystem::get_singleton()->emit_signal("filesystem_changed"); //it changed, so force emitting the signal
+
+}
+
+void ImportDock::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("_reimport"),&ImportDock::_reimport);
+ ClassDB::bind_method(D_METHOD("_preset_selected"),&ImportDock::_preset_selected);
+}
+
+ImportDock::ImportDock() {
+
+
+ imported = memnew( LineEdit );
+ imported->set_editable(false);
+ add_child(imported);
+ HBoxContainer *hb = memnew(HBoxContainer);
+ add_margin_child(TTR("Import As:"),hb);
+ import_as = memnew( OptionButton );
+ hb->add_child(import_as);
+ import_as->set_h_size_flags(SIZE_EXPAND_FILL);
+ preset = memnew( MenuButton );
+ preset->set_text(TTR("Preset.."));
+ preset->get_popup()->connect("index_pressed",this,"_preset_selected");
+ hb->add_child(preset);
+
+ import_opts = memnew( PropertyEditor );
+ 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);
+ import = memnew( Button );
+ import->set_text(TTR("Reimport"));
+ import->connect("pressed",this,"_reimport");
+ hb->add_spacer();
+ hb->add_child(import);
+ hb->add_spacer();
+
+ params = memnew( ImportDockParameters );
+ import_opts->edit(params);
+
+}
+
+ImportDock::~ImportDock() {
+
+ memdelete(params);
+}
diff --git a/tools/editor/import_dock.h b/tools/editor/import_dock.h
new file mode 100644
index 0000000000..bddf5480b8
--- /dev/null
+++ b/tools/editor/import_dock.h
@@ -0,0 +1,42 @@
+#ifndef IMPORTDOCK_H
+#define IMPORTDOCK_H
+
+#include "io/resource_import.h"
+#include "editor_file_system.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/popup_menu.h"
+#include "property_editor.h"
+
+class ImportDockParameters;
+class ImportDock : public VBoxContainer {
+ GDCLASS(ImportDock,VBoxContainer)
+
+ LineEdit *imported;
+ OptionButton *import_as;
+ MenuButton *preset;
+ PropertyEditor *import_opts;
+
+ List<PropertyInfo> properties;
+ Map<StringName,Variant> property_values;
+
+ Button *import;
+
+ ImportDockParameters *params;
+
+ void _preset_selected(int p_idx);
+
+ void _reimport();
+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 clear();
+
+ ImportDock();
+ ~ImportDock();
+};
+
+#endif // IMPORTDOCK_H
diff --git a/tools/editor/io_plugins/SCsub b/tools/editor/io_plugins/SCsub
index 4bf55189cc..f1fa50148f 100644
--- a/tools/editor/io_plugins/SCsub
+++ b/tools/editor/io_plugins/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources, "*.cpp")
+env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp
index ac776f4ff5..c5f1ee73cf 100644
--- a/tools/editor/io_plugins/editor_atlas.cpp
+++ b/tools/editor/io_plugins/editor_atlas.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_atlas.h"
+
#include "print_string.h"
struct _EditorAtlasWorkRect {
diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp
index b4e0c4b82a..587353fef8 100644
--- a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp
@@ -1,4 +1,33 @@
+/*************************************************************************/
+/* editor_bitmask_import_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_bitmask_import_plugin.h"
+#if 0
#include "io/image_loader.h"
#include "tools/editor/editor_file_dialog.h"
#include "tools/editor/editor_dir_dialog.h"
@@ -145,7 +174,7 @@ public:
error_dialog->popup_centered(Size2(200, 100)*EDSCALE);
}
- dst = dst.plus_file(bitmasks[i].get_file().basename() + ".pbm");
+ dst = dst.plus_file(bitmasks[i].get_file().get_basename() + ".pbm");
plugin->import(dst, imd);
}
@@ -167,7 +196,7 @@ public:
ClassDB::bind_method("_import", &EditorBitMaskImportDialog::_import);
ClassDB::bind_method("_browse", &EditorBitMaskImportDialog::_browse);
ClassDB::bind_method("_browse_target", &EditorBitMaskImportDialog::_browse_target);
- // ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
+ //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
}
EditorBitMaskImportDialog(EditorBitMaskImportPlugin *p_plugin) {
@@ -225,7 +254,7 @@ public:
save_select = memnew(EditorDirDialog);
add_child(save_select);
- // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
save_select->connect("dir_selected", this, "_choose_save_dir");
get_ok()->connect("pressed", this, "_import");
@@ -235,7 +264,7 @@ public:
error_dialog = memnew(ConfirmationDialog);
add_child(error_dialog);
error_dialog->get_ok()->set_text(TTR("Accept"));
- // error_dialog->get_cancel()->hide();
+ //error_dialog->get_cancel()->hide();
set_hide_on_ok(false);
}
@@ -294,7 +323,7 @@ void EditorBitMaskImportPlugin::import_from_drop(const Vector<String>& p_drop, c
ImageLoader::get_recognized_extensions(&valid_extensions);
for(int i=0;i<p_drop.size();i++) {
- String extension=p_drop[i].extension().to_lower();
+ String extension=p_drop[i].get_extension().to_lower();
for (List<String>::Element *E=valid_extensions.front();E;E=E->next()) {
@@ -355,3 +384,4 @@ EditorBitMaskImportPlugin::EditorBitMaskImportPlugin(EditorNode* p_editor) {
EditorBitMaskExportPlugin::EditorBitMaskExportPlugin() {
}
+#endif
diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.h b/tools/editor/io_plugins/editor_bitmask_import_plugin.h
index 28dddca50a..89ff58ec93 100644
--- a/tools/editor/io_plugins/editor_bitmask_import_plugin.h
+++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.h
@@ -1,6 +1,34 @@
+/*************************************************************************/
+/* editor_bitmask_import_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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_BITMASK_IMPORT_PLUGIN_H
#define EDITOR_BITMASK_IMPORT_PLUGIN_H
-
+#if 0
#include "tools/editor/editor_import_export.h"
#include "scene/resources/font.h"
@@ -38,4 +66,5 @@ public:
EditorBitMaskExportPlugin();
};
+#endif
#endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H
diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp
index c2e037cfd7..265526aace 100644
--- a/tools/editor/io_plugins/editor_export_scene.cpp
+++ b/tools/editor/io_plugins/editor_export_scene.cpp
@@ -27,13 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_export_scene.h"
+#if 0
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "os/file_access.h"
#include "tools/editor/editor_settings.h"
#include "scene/resources/packed_scene.h"
-#include "globals.h"
+#include "global_config.h"
Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
@@ -42,7 +43,7 @@ Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<
}
- String extension = p_path.extension();
+ String extension = p_path.get_extension();
//step 1 check if scene
@@ -138,3 +139,4 @@ Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<
EditorSceneExportPlugin::EditorSceneExportPlugin()
{
}
+#endif
diff --git a/tools/editor/io_plugins/editor_export_scene.h b/tools/editor/io_plugins/editor_export_scene.h
index 13493220cb..c067e835a3 100644
--- a/tools/editor/io_plugins/editor_export_scene.h
+++ b/tools/editor/io_plugins/editor_export_scene.h
@@ -29,9 +29,9 @@
#ifndef EDITOR_EXPORT_SCENE_H
#define EDITOR_EXPORT_SCENE_H
-#include "tools/editor/editor_import_export.h"
-
+#include "tools/editor/editor_export.h"
+#if 0
class EditorSceneExportPlugin : public EditorExportPlugin {
GDCLASS( EditorSceneExportPlugin, EditorExportPlugin );
public:
@@ -40,5 +40,5 @@ public:
EditorSceneExportPlugin();
};
-
+#endif
#endif // EDITOR_EXPORT_SCENE_H
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp
index 388ca4ca89..417aad0db8 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_font_import_plugin.h"
+#if 0
#include "scene/gui/dialogs.h"
#include "tools/editor/editor_file_dialog.h"
#include "tools/editor/editor_node.h"
@@ -34,11 +35,10 @@
#include "editor_atlas.h"
#include "io/image_loader.h"
#include "io/resource_saver.h"
-#ifdef FREETYPE_ENABLED
+#ifdef FREETYPE_ENABLED
#include <ft2build.h>
#include FT_FREETYPE_H
-
#endif
@@ -439,7 +439,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
test_label->set_text("");
test_label->set_text(test_string->get_text());
- test_label->add_color_override("font_color",test_color->get_color());
+ test_label->add_color_override("font_color",test_color->get_pick_color());
}
void _update() {
@@ -468,7 +468,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
Ref<ImageTexture> tex = font->get_texture(0);
if (tex.is_null())
return;
- FileAccessRef f=FileAccess::open(p_font.basename()+".inc",FileAccess::WRITE);
+ FileAccessRef f=FileAccess::open(p_font.get_basename()+".inc",FileAccess::WRITE);
Vector<CharType> ck = font->get_char_keys();
f->store_line("static const int _builtin_font_height="+itos(font->get_height())+";");
@@ -499,7 +499,7 @@ class EditorFontImportDialog : public ConfirmationDialog {
f->store_line("static const int _builtin_font_img_width="+itos(img.get_width())+";");
f->store_line("static const int _builtin_font_img_height="+itos(img.get_height())+";");
- String fname = p_font.basename()+".sv.png";
+ String fname = p_font.get_basename()+".sv.png";
ResourceSaver::save(fname,tex);
Vector<uint8_t> data=FileAccess::get_file_as_array(fname);
@@ -533,14 +533,14 @@ class EditorFontImportDialog : public ConfirmationDialog {
}
if (dest->get_line_edit()->get_text().get_file()==".fnt") {
- dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().basename() + ".fnt" );
+ dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().get_basename() + ".fnt" );
}
- if (dest->get_line_edit()->get_text().extension() == dest->get_line_edit()->get_text()) {
+ if (dest->get_line_edit()->get_text().get_extension() == dest->get_line_edit()->get_text()) {
dest->get_line_edit()->set_text(dest->get_line_edit()->get_text() + ".fnt");
}
- if (dest->get_line_edit()->get_text().extension().to_lower() != "fnt") {
+ if (dest->get_line_edit()->get_text().get_extension().to_lower() != "fnt") {
error_dialog->set_text(TTR("Invalid file extension.\nPlease use .fnt."));
error_dialog->popup_centered(Size2(200,100));
return;
@@ -665,10 +665,12 @@ public:
List<String> fl;
Ref<BitmapFont> font= memnew(BitmapFont);
dest->get_file_dialog()->add_filter("*.fnt ; Font" );
- //ResourceSaver::get_recognized_extensions(font,&fl);
- //for(List<String>::Element *E=fl.front();E;E=E->next()) {
- // dest->get_file_dialog()->add_filter("*."+E->get());
- //}
+ /*
+ ResourceSaver::get_recognized_extensions(font,&fl);
+ for(List<String>::Element *E=fl.front();E;E=E->next()) {
+ dest->get_file_dialog()->add_filter("*."+E->get());
+ }
+ */
vbl->add_margin_child(TTR("Dest Resource:"),dest);
HBoxContainer *testhb = memnew( HBoxContainer );
@@ -679,7 +681,7 @@ public:
testhb->add_child(test_string);
test_color = memnew( ColorPickerButton );
- test_color->set_color(get_color("font_color","Label"));
+ test_color->set_pick_color(get_color("font_color","Label"));
test_color->set_h_size_flags(SIZE_EXPAND_FILL);
test_color->set_stretch_ratio(1);
test_color->connect("color_changed",this,"_update_text3");
@@ -689,7 +691,7 @@ public:
vbl->add_margin_child(TTR("Test:")+" ",testhb);
/*
HBoxContainer *upd_hb = memnew( HBoxContainer );
-// vbl->add_child(upd_hb);
+ //vbl->add_child(upd_hb);
upd_hb->add_spacer();
Button *update = memnew( Button);
upd_hb->add_child(update);
@@ -754,7 +756,7 @@ struct _EditorFontData {
int texture;
Image blit;
Point2i blit_ofs;
-// bool printable;
+ //bool printable;
};
@@ -780,13 +782,13 @@ static unsigned char get_SDF_radial(
int x, int y,
int max_radius )
{
- // hideous brute force method
+ //hideous brute force method
float d2 = max_radius*max_radius+1.0;
unsigned char v = fontmap[x+y*w];
for( int radius = 1; (radius <= max_radius) && (radius*radius < d2); ++radius )
{
int line, lo, hi;
- // north
+ //north
line = y - radius;
if( (line >= 0) && (line < h) )
{
@@ -797,7 +799,7 @@ static unsigned char get_SDF_radial(
int idx = line * w + lo;
for( int i = lo; i <= hi; ++i )
{
- // check this pixel
+ //check this pixel
if( fontmap[idx] != v )
{
float nx = i - x;
@@ -808,11 +810,11 @@ static unsigned char get_SDF_radial(
d2 = nd2;
}
}
- // move on
+ //move on
++idx;
}
}
- // south
+ //south
line = y + radius;
if( (line >= 0) && (line < h) )
{
@@ -823,7 +825,7 @@ static unsigned char get_SDF_radial(
int idx = line * w + lo;
for( int i = lo; i <= hi; ++i )
{
- // check this pixel
+ //check this pixel
if( fontmap[idx] != v )
{
float nx = i - x;
@@ -834,11 +836,11 @@ static unsigned char get_SDF_radial(
d2 = nd2;
}
}
- // move on
+ //move on
++idx;
}
}
- // west
+ //west
line = x - radius;
if( (line >= 0) && (line < w) )
{
@@ -849,7 +851,7 @@ static unsigned char get_SDF_radial(
int idx = lo * w + line;
for( int i = lo; i <= hi; ++i )
{
- // check this pixel
+ //check this pixel
if( fontmap[idx] != v )
{
float nx = line - x;
@@ -860,11 +862,11 @@ static unsigned char get_SDF_radial(
d2 = nd2;
}
}
- // move on
+ //move on
idx += w;
}
}
- // east
+ //east
line = x + radius;
if( (line >= 0) && (line < w) )
{
@@ -875,7 +877,7 @@ static unsigned char get_SDF_radial(
int idx = lo * w + line;
for( int i = lo; i <= hi; ++i )
{
- // check this pixel
+ //check this pixel
if( fontmap[idx] != v )
{
float nx = line - x;
@@ -886,7 +888,7 @@ static unsigned char get_SDF_radial(
d2 = nd2;
}
}
- // move on
+ //move on
idx += w;
}
}
@@ -913,7 +915,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0));
- if (src_path.extension().to_lower()=="fnt") {
+ if (src_path.get_extension().to_lower()=="fnt") {
if (ResourceLoader::load(src_path).is_valid()) {
EditorNode::get_singleton()->show_warning(TTR("Path:")+" "+src_path+"\n"+TTR("This file is already a Godot font file, please supply a BMFont type file instead."));
@@ -981,14 +983,14 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
FT_GlyphSlot slot = face->glyph;
-// error = FT_Set_Charmap(face,ft_encoding_unicode ); /* encoding.. */
+ //error = FT_Set_Charmap(face,ft_encoding_unicode ); /* encoding.. */
/* PRINT CHARACTERS TO INDIVIDUAL BITMAPS */
-// int space_size=5; //size for space, if none found.. 5!
-// int min_valign=500; //some ridiculous number
+ //int space_size=5; //size for space, if none found.. 5!
+ //int min_valign=500; //some ridiculous number
FT_ULong charcode;
FT_UInt gindex;
@@ -1080,10 +1082,10 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
- // oversize the holding buffer so I can smooth it!
+ //oversize the holding buffer so I can smooth it!
int sw = w + scaler * 4;
int sh = h + scaler * 4;
- // do the SDF
+ //do the SDF
int sdfw = sw / scaler;
int sdfh = sh / scaler;
@@ -1139,7 +1141,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) {
- // oversize the holding buffer so I can smooth it!
+ //oversize the holding buffer so I can smooth it!
int sw = w + scaler * 4;
int sh = h + scaler * 4;
@@ -1471,7 +1473,7 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
sum+=w2[ofs_l];
}
- wa[ofs]=Math::pow(float(sum/(r*2+1))/255.0,tr)*255.0;
+ wa[ofs]=Math::pow(float(sum/(r*2+1))/255.0f,tr)*255.0f;
}
}
@@ -1578,8 +1580,8 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
//debug the texture
Ref<ImageTexture> atlast = memnew( ImageTexture );
atlast->create_from_image(atlas);
-// atlast->create_from_image(font_data_list[5]->blit);
- TextureFrame *tf = memnew( TextureFrame );
+ //atlast->create_from_image(font_data_list[5]->blit);
+ TextureRect *tf = memnew( TextureRect );
tf->set_texture(atlast);
dialog->add_child(tf);
}
@@ -1682,12 +1684,12 @@ Error EditorFontImportPlugin::import(const String& p_path, const Ref<ResourceImp
void EditorFontImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) {
for(int i=0;i<p_drop.size();i++) {
- String ext = p_drop[i].extension().to_lower();
+ String ext = p_drop[i].get_extension().to_lower();
String file = p_drop[i].get_file();
if (ext=="ttf" || ext=="otf" || ext=="fnt") {
import_dialog();
- dialog->set_source_and_dest(p_drop[i],p_dest_path.plus_file(file.basename()+".fnt"));
+ dialog->set_source_and_dest(p_drop[i],p_dest_path.plus_file(file.get_basename()+".fnt"));
break;
}
}
@@ -1699,3 +1701,4 @@ EditorFontImportPlugin::EditorFontImportPlugin(EditorNode* p_editor) {
dialog = memnew( EditorFontImportDialog(this) );
p_editor->get_gui_base()->add_child(dialog);
}
+#endif
diff --git a/tools/editor/io_plugins/editor_font_import_plugin.h b/tools/editor/io_plugins/editor_font_import_plugin.h
index 73c699c090..bed1463aeb 100644
--- a/tools/editor/io_plugins/editor_font_import_plugin.h
+++ b/tools/editor/io_plugins/editor_font_import_plugin.h
@@ -29,9 +29,9 @@
#ifndef EDITOR_FONT_IMPORT_PLUGIN_H
#define EDITOR_FONT_IMPORT_PLUGIN_H
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "scene/resources/font.h"
-
+#if 0
class EditorNode;
class EditorFontImportDialog;
@@ -55,3 +55,4 @@ public:
};
#endif // EDITOR_FONT_IMPORT_PLUGIN_H
+#endif
diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
index f33693c304..fc3f8fd8c9 100644
--- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp
@@ -28,11 +28,13 @@
/*************************************************************************/
#include "editor_mesh_import_plugin.h"
+#if 0
+
#include "tools/editor/editor_file_dialog.h"
#include "tools/editor/editor_dir_dialog.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/property_editor.h"
-#include "scene/resources/sample.h"
+//#include "scene/resources/sample.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "io/marshalls.h"
@@ -259,7 +261,7 @@ public:
imd->add_source(EditorImportPlugin::validate_source_path(meshes[i]));
- String file_path = dst.plus_file(meshes[i].get_file().basename()+".msh");
+ String file_path = dst.plus_file(meshes[i].get_file().get_basename()+".msh");
plugin->import(file_path,imd);
}
@@ -568,7 +570,7 @@ void EditorMeshImportPlugin::import_from_drop(const Vector<String>& p_drop, cons
Vector<String> files;
for(int i=0;i<p_drop.size();i++) {
- String ext = p_drop[i].extension().to_lower();
+ String ext = p_drop[i].get_extension().to_lower();
String file = p_drop[i].get_file();
if (ext=="obj") {
@@ -588,3 +590,4 @@ EditorMeshImportPlugin::EditorMeshImportPlugin(EditorNode* p_editor) {
dialog = memnew( EditorMeshImportDialog(this));
p_editor->get_gui_base()->add_child(dialog);
}
+#endif
diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.h b/tools/editor/io_plugins/editor_mesh_import_plugin.h
index 1f15fee3a7..ba8ec58191 100644
--- a/tools/editor/io_plugins/editor_mesh_import_plugin.h
+++ b/tools/editor/io_plugins/editor_mesh_import_plugin.h
@@ -29,7 +29,7 @@
#ifndef EDITOR_MESH_IMPORT_PLUGIN_H
#define EDITOR_MESH_IMPORT_PLUGIN_H
-
+#if 0
#include "tools/editor/editor_import_export.h"
#include "scene/resources/font.h"
@@ -55,4 +55,5 @@ public:
EditorMeshImportPlugin(EditorNode* p_editor);
};
+#endif
#endif // EDITOR_MESH_IMPORT_PLUGIN_H
diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
index da4e24dc84..631291ec1b 100644
--- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp
@@ -27,16 +27,18 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_sample_import_plugin.h"
+
#include "tools/editor/editor_file_dialog.h"
#include "tools/editor/editor_dir_dialog.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/property_editor.h"
-#include "scene/resources/sample.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "io/marshalls.h"
#include "tools/editor/editor_settings.h"
+#if 0
+
class _EditorSampleImportOptions : public Object {
GDCLASS(_EditorSampleImportOptions,Object);
@@ -296,7 +298,7 @@ public:
error_dialog->popup_centered(Size2(200,100)*EDSCALE);
}
- dst = dst.plus_file(samples[i].get_file().basename()+".smp");
+ dst = dst.plus_file(samples[i].get_file().get_basename()+".smp");
plugin->import(dst,imd);
}
@@ -323,7 +325,7 @@ public:
ClassDB::bind_method("_import",&EditorSampleImportDialog::_import);
ClassDB::bind_method("_browse",&EditorSampleImportDialog::_browse);
ClassDB::bind_method("_browse_target",&EditorSampleImportDialog::_browse_target);
- // ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
+ //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
}
EditorSampleImportDialog(EditorSampleImportPlugin *p_plugin) {
@@ -373,7 +375,7 @@ public:
save_select = memnew( EditorDirDialog );
add_child(save_select);
- // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
save_select->connect("dir_selected", this,"_choose_save_dir");
get_ok()->connect("pressed", this,"_import");
@@ -383,7 +385,7 @@ public:
error_dialog = memnew ( ConfirmationDialog );
add_child(error_dialog);
error_dialog->get_ok()->set_text(TTR("Accept"));
- // error_dialog->get_cancel()->hide();
+ //error_dialog->get_cancel()->hide();
set_hide_on_ok(false);
options = memnew( _EditorSampleImportOptions );
@@ -539,7 +541,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI
int first=0;
int last=(len*chans)-1;
bool found=false;
- float limit = Math::db2linear(-30);
+ float limit = Math::db2linear((float)-30);
for(int i=0;i<data.size();i++) {
float amp = Math::abs(data[i]);
@@ -648,7 +650,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI
}
}
-// print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size()));
+ //print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size()));
} else {
@@ -758,12 +760,14 @@ void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector<float>& p_data,P
xm_sample=CLAMP(in[i]*32767.0,-32768,32767);
- //if (xm_sample==32767 || xm_sample==-32768)
- // printf("clippy!\n",xm_sample);
+ /*
+ if (xm_sample==32767 || xm_sample==-32768)
+ printf("clippy!\n",xm_sample);
+ */
}
- // xm_sample=xm_sample+xm_prev;
- // xm_prev=xm_sample;
+ //xm_sample=xm_sample+xm_prev;
+ //xm_prev=xm_sample;
diff = (int)xm_sample - prev ;
@@ -828,7 +832,7 @@ void EditorSampleImportPlugin::import_from_drop(const Vector<String>& p_drop, co
Vector<String> files;
for(int i=0;i<p_drop.size();i++) {
- String ext = p_drop[i].extension().to_lower();
+ String ext = p_drop[i].get_extension().to_lower();
if (ext=="wav") {
@@ -887,7 +891,7 @@ Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref
- if (EditorImportExport::get_singleton()->sample_get_action()==EditorImportExport::SAMPLE_ACTION_NONE || p_path.extension().to_lower()!="wav") {
+ if (EditorImportExport::get_singleton()->sample_get_action()==EditorImportExport::SAMPLE_ACTION_NONE || p_path.get_extension().to_lower()!="wav") {
return Vector<uint8_t>();
}
@@ -911,7 +915,7 @@ Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref
ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>());
- p_path=p_path.basename()+".converted.smp";
+ p_path=p_path.get_basename()+".converted.smp";
return FileAccess::get_file_as_array(savepath);
}
@@ -921,3 +925,5 @@ Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref
EditorSampleExportPlugin::EditorSampleExportPlugin() {
}
+
+#endif
diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.h b/tools/editor/io_plugins/editor_sample_import_plugin.h
index 6d781756b2..8e02d0e11d 100644
--- a/tools/editor/io_plugins/editor_sample_import_plugin.h
+++ b/tools/editor/io_plugins/editor_sample_import_plugin.h
@@ -29,6 +29,7 @@
#ifndef EDITOR_SAMPLE_IMPORT_PLUGIN_H
#define EDITOR_SAMPLE_IMPORT_PLUGIN_H
+#if 0
#include "tools/editor/editor_import_export.h"
#include "scene/resources/font.h"
@@ -70,3 +71,4 @@ public:
};
#endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H
+#endif
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
index 8fd78f11f3..957072c20a 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp
@@ -27,7 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_scene_import_plugin.h"
-#include "globals.h"
+#if 0
+#include "global_config.h"
#include "tools/editor/editor_node.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/box_shape.h"
@@ -377,7 +378,7 @@ void EditorImportAnimationOptions::_bind_methods() {
ClassDB::bind_method("_changed",&EditorImportAnimationOptions::_changed);
ClassDB::bind_method("_item_edited",&EditorImportAnimationOptions::_item_edited);
ClassDB::bind_method("_button_action",&EditorImportAnimationOptions::_button_action);
-// ClassDB::bind_method("_changedp",&EditorImportAnimationOptions::_changedp);
+ //ClassDB::bind_method("_changedp",&EditorImportAnimationOptions::_changedp);
ADD_SIGNAL(MethodInfo("changed"));
}
@@ -390,7 +391,7 @@ void EditorImportAnimationOptions::_notification(int p_what) {
flags->connect("item_edited",this,"_changed");
clips_tree->connect("item_edited",this,"_item_edited");
clips_tree->connect("button_pressed",this,"_button_action",varray(),CONNECT_DEFERRED);
-// format->connect("item_selected",this,"_changedp");
+ //format->connect("item_selected",this,"_changedp");
}
}
@@ -659,7 +660,7 @@ void EditorSceneImportDialog::_choose_file(const String& p_path) {
import_path->set_text(p_path);
if (root_node_name->get_text().size()==0){
- root_node_name->set_text(import_path->get_text().get_file().basename());
+ root_node_name->set_text(import_path->get_text().get_file().get_basename());
}
}
@@ -763,7 +764,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
// Scenes should always be imported as binary format since vertex data is large and would take
// up a lot of space and time to load if imported as text format (GH-5778)
- String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+".scn");
+ String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().get_basename()+".scn");
print_line("Saving to: "+save_file);
@@ -794,7 +795,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) {
rim->set_option("root_type",root_type->get_text());
}
if (root_node_name->get_text().size()==0) {
- root_node_name->set_text(import_path->get_text().get_file().basename());
+ root_node_name->set_text(import_path->get_text().get_file().get_basename());
}
rim->set_option("root_name",root_node_name->get_text());
@@ -1237,7 +1238,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
error_dialog = memnew ( ConfirmationDialog );
add_child(error_dialog);
error_dialog->get_ok()->set_text(TTR("Accept"));
-// error_dialog->get_cancel()->hide();
+ //error_dialog->get_cancel()->hide();
HBoxContainer *custom_root_hb = memnew( HBoxContainer );
@@ -1302,7 +1303,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
add_child(confirm_import);
VBoxContainer *cvb = memnew( VBoxContainer );
confirm_import->add_child(cvb);
-// confirm_import->set_child_rect(cvb);
+ //confirm_import->set_child_rect(cvb);
PanelContainer *pc = memnew( PanelContainer );
pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
@@ -1421,9 +1422,11 @@ void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<Imag
if (tex.is_valid()) {
image_map.insert(tex,TEXTURE_ROLE_NORMALMAP);
- //if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY)
- // res->cast_to<FixedSpatialMaterial>()->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_XY_NORMALMAP,true);
- }//
+ /*
+ if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY)
+ res->cast_to<FixedSpatialMaterial>()->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_XY_NORMALMAP,true);
+ */
+ }
} else {
@@ -1531,10 +1534,10 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
if (fm.is_valid()) {
- // fm->set_flag(Material::FLAG_UNSHADED,true);
- // fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- // fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
- // fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ //fm->set_flag(Material::FLAG_UNSHADED,true);
+ //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
+ //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
+ //fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
}
}
}
@@ -1558,8 +1561,8 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (p_flags&SCENE_FLAG_DETECT_ALPHA && _teststr(mat->get_name(),"alpha")) {
- // mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
- // mat->set_name(_fixstr(mat->get_name(),"alpha"));
+ //mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ //mat->set_name(_fixstr(mat->get_name(),"alpha"));
}
if (p_flags&SCENE_FLAG_DETECT_VCOLOR && _teststr(mat->get_name(),"vcol")) {
@@ -1640,10 +1643,10 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
Ref<FixedSpatialMaterial> fm = m->surface_get_material(i);
if (fm.is_valid()) {
- // fm->set_flag(Material::FLAG_UNSHADED,true);
- // fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- // fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
- // fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
+ //fm->set_flag(Material::FLAG_UNSHADED,true);
+ //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
+ //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
+ //fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
}
}
}
@@ -2124,7 +2127,7 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from
String src_path=EditorImportPlugin::expand_source_path(from->get_source_path(0));
Ref<EditorSceneImporter> importer;
- String ext=src_path.extension().to_lower();
+ String ext=src_path.get_extension().to_lower();
EditorProgress progress("import",TTR("Import Scene"),104);
@@ -2172,8 +2175,10 @@ Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from
import_flags|=EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS;
if (scene_flags&SCENE_FLAG_IMPORT_ANIMATIONS)
import_flags|=EditorSceneImporter::IMPORT_ANIMATION;
- //if (scene_flags&SCENE_FLAG_FAIL_ON_MISSING_IMAGES)
- // import_flags|=EditorSceneImporter::IMPORT_FAIL_ON_MISSING_DEPENDENCIES;
+ /*
+ if (scene_flags&SCENE_FLAG_FAIL_ON_MISSING_IMAGES)
+ import_flags|=EditorSceneImporter::IMPORT_FAIL_ON_MISSING_DEPENDENCIES;
+ */
if (scene_flags&SCENE_FLAG_GENERATE_TANGENT_ARRAYS)
import_flags|=EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
@@ -2821,7 +2826,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
{
- target_path=target_path.basename()+".tex";
+ target_path=target_path.get_basename()+".tex";
Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
@@ -2936,7 +2941,7 @@ void EditorSceneImportPlugin::import_from_drop(const Vector<String>& p_drop,cons
//bool warn_compatible=false;
for(int i=0;i<p_drop.size();i++) {
- String extension = p_drop[i].extension().to_lower();
+ String extension = p_drop[i].get_extension().to_lower();
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
@@ -2984,3 +2989,4 @@ EditorSceneAnimationImportPlugin::EditorSceneAnimationImportPlugin(EditorNode* p
}
+#endif
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.h b/tools/editor/io_plugins/editor_scene_import_plugin.h
index 61153e3654..bbafc126bb 100644
--- a/tools/editor/io_plugins/editor_scene_import_plugin.h
+++ b/tools/editor/io_plugins/editor_scene_import_plugin.h
@@ -28,7 +28,7 @@
/*************************************************************************/
#ifndef EDITOR_SCENE_IMPORT_PLUGIN_H
#define EDITOR_SCENE_IMPORT_PLUGIN_H
-
+#if 0
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
#include "scene/gui/label.h"
@@ -196,5 +196,5 @@ public:
};
-
+#endif
#endif // EDITOR_SCENE_IMPORT_PLUGIN_H
diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp
index e1b0719941..af12d85650 100644
--- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp
+++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_scene_importer_fbxconv.h"
+
#include "os/file_access.h"
#include "os/os.h"
#include "tools/editor/editor_settings.h"
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
index 3bf2551778..cc8d47c6a9 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_texture_import_plugin.h"
+#if 0
#include "io/image_loader.h"
#include "tools/editor/editor_node.h"
#include "io/resource_saver.h"
@@ -34,7 +35,7 @@
#include "tools/editor/editor_settings.h"
#include "io/md5.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/gui/check_button.h"
#include "scene/gui/button_group.h"
#include "scene/gui/margin_container.h"
@@ -344,7 +345,7 @@ void EditorTextureImportDialog::_choose_save_dir(const String& p_path) {
void EditorTextureImportDialog::_import() {
-// ImportMonitorBlock imb;
+ //ImportMonitorBlock imb;
Vector<String> files=import_path->get_text().split(",");
@@ -448,7 +449,7 @@ void EditorTextureImportDialog::_import() {
for(int i=0;i<files.size();i++) {
String dst_file = dst_path.plus_file(files[i].get_file());
- dst_file=dst_file.basename()+".tex";
+ dst_file=dst_file.get_basename()+".tex";
Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
//imd->set_editor();
imd->add_source(EditorImportPlugin::validate_source_path(files[i]));
@@ -539,7 +540,7 @@ void EditorTextureImportDialog::_notification(int p_what) {
List<String> extensions;
ImageLoader::get_recognized_extensions(&extensions);
- // ResourceLoader::get_recognized_extensions_for_type("PackedTexture",&extensions);
+ //ResourceLoader::get_recognized_extensions_for_type("PackedTexture",&extensions);
file_select->clear_filters();
for(int i=0;i<extensions.size();i++) {
@@ -643,7 +644,7 @@ void EditorTextureImportDialog::_bind_methods() {
ClassDB::bind_method("_browse",&EditorTextureImportDialog::_browse);
ClassDB::bind_method("_browse_target",&EditorTextureImportDialog::_browse_target);
ClassDB::bind_method("_mode_changed",&EditorTextureImportDialog::_mode_changed);
-// ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
+ //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
}
EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* p_plugin) {
@@ -760,32 +761,34 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin*
save_select = memnew( EditorDirDialog );
add_child(save_select);
-// save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
save_select->connect("dir_selected", this,"_choose_save_dir");
get_ok()->connect("pressed", this,"_import");
get_ok()->set_text(TTR("Import"));
//move stuff up
- //for(int i=0;i<4;i++)
- // vbc->move_child( vbc->get_child( vbc->get_child_count() -1), 0);
+ /*
+ for(int i=0;i<4;i++)
+ vbc->move_child( vbc->get_child( vbc->get_child_count() -1), 0);
+ */
error_dialog = memnew ( ConfirmationDialog );
add_child(error_dialog);
error_dialog->get_ok()->set_text(TTR("Accept"));
-// error_dialog->get_cancel()->hide();
+ //error_dialog->get_cancel()->hide();
set_hide_on_ok(false);
- texture_options = memnew( EditorImportTextureOptions );;
+ texture_options = memnew( EditorImportTextureOptions );
vbc->add_child(texture_options);
texture_options->set_v_size_flags(SIZE_EXPAND_FILL);
_mode_changed(EditorTextureImportPlugin::MODE_TEXTURE_3D);
-// GLOBAL_DEF("import/shared_textures","res://");
-// Globals::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR));
+ //GLOBAL_DEF("import/shared_textures","res://");
+ //Globals::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR));
}
@@ -944,10 +947,12 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur
image.normalmap_to_xy();
}
- //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
+ /*
+ if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
- // image.srgb_to_linear();
- //}
+ image.srgb_to_linear();
+ }
+ */
if (shrink>1) {
@@ -1003,11 +1008,13 @@ Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &textur
image.normalmap_to_xy();
}
- //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
-//
- // print_line("CONVERT BECAUSE: "+itos(flags));
- // image.srgb_to_linear();
- //}
+ /*
+ if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
+
+ print_line("CONVERT BECAUSE: "+itos(flags));
+ image.srgb_to_linear();
+ }
+ */
int orig_w=image.get_width();
int orig_h=image.get_height();
@@ -1307,9 +1314,9 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
String spath = from->get_source_path(E->get()).get_file();
if (p_external) {
- apath = p_path.get_base_dir().plus_file(spath.basename()+"."+from->get_source_path(E->get()).md5_text()+".atex");
+ apath = p_path.get_base_dir().plus_file(spath.get_basename()+"."+from->get_source_path(E->get()).md5_text()+".atex");
} else {
- apath = p_path.get_base_dir().plus_file(spath.basename()+".atex");
+ apath = p_path.get_base_dir().plus_file(spath.get_basename()+".atex");
}
Ref<AtlasTexture> at;
@@ -1425,10 +1432,12 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
image.normalmap_to_xy();
}
- //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
+ /*
+ if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
- // image.srgb_to_linear();
- //}
+ image.srgb_to_linear();
+ }
+ */
if (shrink>1) {
@@ -1484,11 +1493,13 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
image.normalmap_to_xy();
}
- //if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
-//
- // print_line("CONVERT BECAUSE: "+itos(flags));
- // image.srgb_to_linear();
- //}
+ /*
+ if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) {
+
+ print_line("CONVERT BECAUSE: "+itos(flags));
+ image.srgb_to_linear();
+ }
+ */
int orig_w=image.get_width();
int orig_h=image.get_height();
@@ -1597,7 +1608,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c
rimd->set_option("shrink",group_shrink);
rimd->add_source(validated_path,FileAccess::get_md5(p_path));
- } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) {
+ } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.get_extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) {
//handled by general image export settings
rimd = Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) );
@@ -1743,7 +1754,7 @@ void EditorTextureImportPlugin::import_from_drop(const Vector<String>& p_drop,co
ImageLoader::get_recognized_extensions(&valid_extensions);
for(int i=0;i<p_drop.size();i++) {
- String extension=p_drop[i].extension().to_lower();
+ String extension=p_drop[i].get_extension().to_lower();
for (List<String>::Element *E=valid_extensions.front();E;E=E->next()) {
@@ -1851,21 +1862,21 @@ EditorTextureImportPlugin::EditorTextureImportPlugin(EditorNode *p_editor) {
if (pl.is_valid()) {
Vector<uint8_t> ce = pl->custom_export(p_path,p_platform);
if (ce.size()) {
- p_path=p_path.basename()+".converted.tex";
+ p_path=p_path.get_basename()+".converted.tex";
return ce;
}
}
} else if (EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE){
- String xt = p_path.extension().to_lower();
+ String xt = p_path.get_extension().to_lower();
if (EditorImportExport::get_singleton()->get_image_formats().has(xt)) { //should check for more I guess?
Ref<EditorImportPlugin> pl = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture");
if (pl.is_valid()) {
Vector<uint8_t> ce = pl->custom_export(p_path,p_platform);
if (ce.size()) {
- p_path=p_path.basename()+".converted.tex";
+ p_path=p_path.get_basename()+".converted.tex";
return ce;
}
}
@@ -1879,3 +1890,4 @@ EditorTextureExportPlugin::EditorTextureExportPlugin() {
}
+#endif
diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h
index b2117f1475..ce15df0f18 100644
--- a/tools/editor/io_plugins/editor_texture_import_plugin.h
+++ b/tools/editor/io_plugins/editor_texture_import_plugin.h
@@ -29,6 +29,12 @@
#ifndef EDITOR_TEXTURE_IMPORT_PLUGIN_H
#define EDITOR_TEXTURE_IMPORT_PLUGIN_H
+
+
+
+
+
+#if 0
#include "tools/editor/editor_import_export.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
@@ -170,3 +176,4 @@ public:
};
#endif // EDITOR_TEXTURE_IMPORT_PLUGIN_H
+#endif
diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
index 73d9e989ac..5ecb0b1abf 100644
--- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp
+++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -27,11 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_translation_import_plugin.h"
+
+#if 0
#include "scene/gui/file_dialog.h"
#include "tools/editor/editor_dir_dialog.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/property_editor.h"
-#include "scene/resources/sample.h"
+//#include "scene/resources/sample.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "translation.h"
@@ -255,7 +257,7 @@ public:
imd->set_option("skip_first",ignore_first->is_pressed());
imd->set_option("compress",compress->is_pressed());
- String savefile = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+"."+locale+".xl");
+ String savefile = save_path->get_text().plus_file(import_path->get_text().get_file().get_basename()+"."+locale+".xl");
Error err = plugin->import(savefile,imd);
if (err!=OK) {
error_dialog->set_text(TTR("Couldn't import!"));
@@ -287,7 +289,7 @@ public:
ClassDB::bind_method("_import",&EditorTranslationImportDialog::_import);
ClassDB::bind_method("_browse",&EditorTranslationImportDialog::_browse);
ClassDB::bind_method("_browse_target",&EditorTranslationImportDialog::_browse_target);
- // ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
+ //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) );
}
EditorTranslationImportDialog(EditorTranslationImportPlugin *p_plugin) {
@@ -344,7 +346,7 @@ public:
add_to_project = memnew( CheckButton);
add_to_project->set_pressed(true);
- add_to_project->set_text(TTR("Add to Project (engine.cfg)"));
+ add_to_project->set_text(TTR("Add to Project (godot.cfg)"));
tcomp->add_child(add_to_project);
file_select = memnew(EditorFileDialog);
@@ -356,7 +358,7 @@ public:
save_select = memnew( EditorDirDialog );
add_child(save_select);
- // save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
+ //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
save_select->connect("dir_selected", this,"_choose_save_dir");
get_ok()->connect("pressed", this,"_import");
@@ -366,7 +368,7 @@ public:
error_dialog = memnew ( ConfirmationDialog );
add_child(error_dialog);
error_dialog->get_ok()->set_text(TTR("Accept"));
- // error_dialog->get_cancel()->hide();
+ //error_dialog->get_cancel()->hide();
set_hide_on_ok(false);
@@ -400,7 +402,7 @@ void EditorTranslationImportPlugin::import_from_drop(const Vector<String>& p_dro
for(int i=0;i<p_drop.size();i++) {
- String ext = p_drop[i].extension().to_lower();
+ String ext = p_drop[i].get_extension().to_lower();
if (ext=="csv") {
@@ -473,3 +475,5 @@ EditorTranslationImportPlugin::EditorTranslationImportPlugin(EditorNode* p_edito
dialog = memnew(EditorTranslationImportDialog(this));
p_editor->get_gui_base()->add_child(dialog);
}
+
+#endif
diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.h b/tools/editor/io_plugins/editor_translation_import_plugin.h
index 38727bd778..22065599b9 100644
--- a/tools/editor/io_plugins/editor_translation_import_plugin.h
+++ b/tools/editor/io_plugins/editor_translation_import_plugin.h
@@ -29,9 +29,9 @@
#ifndef EDITOR_TRANSLATION_IMPORT_PLUGIN_H
#define EDITOR_TRANSLATION_IMPORT_PLUGIN_H
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "scene/resources/font.h"
-
+#if 0
class EditorNode;
class EditorTranslationImportDialog;
@@ -52,4 +52,5 @@ public:
EditorTranslationImportPlugin(EditorNode* p_editor);
};
+#endif
#endif // EDITOR_TRANSLATION_IMPORT_PLUGIN_H
diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp
index 47b776ed06..0428d7ef30 100644
--- a/tools/editor/multi_node_edit.cpp
+++ b/tools/editor/multi_node_edit.cpp
@@ -27,18 +27,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "multi_node_edit.h"
+
#include "editor_node.h"
+#include "core/helper/math_fieldwise.h"
bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){
+ return _set_impl(p_name, p_value, "");
+}
+
+bool MultiNodeEdit::_set_impl(const StringName& p_name, const Variant& p_value, const String& p_field) {
+
Node *es = EditorNode::get_singleton()->get_edited_scene();
if (!es)
return false;
String name = p_name;
- if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
- name="script/script";
+ if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
+ name="script";
}
UndoRedo *ur=EditorNode::get_singleton()->get_undo_redo();
@@ -58,7 +65,15 @@ bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){
NodePath p_path = n->get_path_to(tonode);
ur->add_do_property(n,name,p_path);
} else {
- ur->add_do_property(n,name,p_value);
+ Variant new_value;
+ if (p_field=="") {
+ // whole value
+ new_value=p_value;
+ } else {
+ // only one field
+ new_value=fieldwise_assign(n->get(name),p_value,p_field);
+ }
+ ur->add_do_property(n,name,new_value);
}
ur->add_undo_property(n,name,n->get(name));
@@ -79,8 +94,8 @@ bool MultiNodeEdit::_get(const StringName& p_name,Variant &r_ret) const {
return false;
String name=p_name;
- if (name=="scripts/script") { // script/script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
- name="script/script";
+ if (name=="scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name
+ name="script";
}
for (const List<NodePath>::Element *E=nodes.front();E;E=E->next()) {
@@ -128,7 +143,7 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
for(List<PropertyInfo>::Element *F=plist.front();F;F=F->next()) {
- if (F->get().name=="script/script")
+ if (F->get().name=="script")
continue; //added later manually, since this is intercepted before being set (check Variant Object::get() )
if (!usage.has(F->get().name)) {
PLData pld;
@@ -151,7 +166,7 @@ void MultiNodeEdit::_get_property_list( List<PropertyInfo> *p_list) const{
}
}
- p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts/script",PROPERTY_HINT_RESOURCE_TYPE,"Script"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT,"scripts",PROPERTY_HINT_RESOURCE_TYPE,"Script"));
}
@@ -166,6 +181,11 @@ void MultiNodeEdit::add_node(const NodePath& p_node){
nodes.push_back(p_node);
}
+void MultiNodeEdit::set_property_field(const StringName& p_property, const Variant& p_value, const String& p_field) {
+
+ _set_impl(p_property, p_value, p_field);
+}
+
MultiNodeEdit::MultiNodeEdit()
{
}
diff --git a/tools/editor/multi_node_edit.h b/tools/editor/multi_node_edit.h
index 290c529d48..26e557c1cb 100644
--- a/tools/editor/multi_node_edit.h
+++ b/tools/editor/multi_node_edit.h
@@ -41,6 +41,8 @@ class MultiNodeEdit : public Reference {
PropertyInfo info;
};
+ bool _set_impl(const StringName& p_name, const Variant& p_value, const String& p_field);
+
protected:
@@ -55,6 +57,8 @@ public:
void clear_nodes();
void add_node(const NodePath& p_node);
+ void set_property_field(const StringName& p_property, const Variant& p_value, const String& p_field);
+
MultiNodeEdit();
};
diff --git a/tools/editor/node_dock.cpp b/tools/editor/node_dock.cpp
index a8e66a8680..fed3d2efb4 100644
--- a/tools/editor/node_dock.cpp
+++ b/tools/editor/node_dock.cpp
@@ -1,4 +1,33 @@
+/*************************************************************************/
+/* node_dock.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "node_dock.h"
+
#include "editor_node.h"
void NodeDock::show_groups() {
@@ -20,8 +49,8 @@ void NodeDock::show_connections(){
void NodeDock::_bind_methods() {
- ClassDB::bind_method(_MD("show_groups"),&NodeDock::show_groups);
- ClassDB::bind_method(_MD("show_connections"),&NodeDock::show_connections);
+ ClassDB::bind_method(D_METHOD("show_groups"),&NodeDock::show_groups);
+ ClassDB::bind_method(D_METHOD("show_connections"),&NodeDock::show_connections);
}
void NodeDock::_notification(int p_what) {
diff --git a/tools/editor/node_dock.h b/tools/editor/node_dock.h
index fd4105d1b2..df41ecf5bd 100644
--- a/tools/editor/node_dock.h
+++ b/tools/editor/node_dock.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* node_dock.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 NODE_DOCK_H
#define NODE_DOCK_H
diff --git a/tools/editor/output_strings.cpp b/tools/editor/output_strings.cpp
index 9ba97451c0..cb43bb9230 100644
--- a/tools/editor/output_strings.cpp
+++ b/tools/editor/output_strings.cpp
@@ -82,7 +82,7 @@ void OutputStrings::_notification(int p_what) {
Ref<Texture> icon_error = get_icon("Error","EditorIcons");
Ref<Texture> icon_warning = get_icon("Warning","EditorIcons");
- // int lines = (size_height-(int)margin.y) / font_height;
+ //int lines = (size_height-(int)margin.y) / font_height;
Point2 ofs=tree_st->get_offset();
LineMap::Element *E = line_map.find(v_scroll->get_value());
diff --git a/tools/editor/plugins/SCsub b/tools/editor/plugins/SCsub
index 4bf55189cc..f1fa50148f 100644
--- a/tools/editor/plugins/SCsub
+++ b/tools/editor/plugins/SCsub
@@ -2,4 +2,4 @@
Import('env')
Export('env')
-env.add_source_files(env.tool_sources, "*.cpp")
+env.add_source_files(env.editor_sources, "*.cpp")
diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp
index 3201db1116..71173038e9 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_player_editor_plugin.cpp
@@ -27,7 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "animation_player_editor_plugin.h"
-#include "globals.h"
+
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/keyboard.h"
@@ -94,7 +95,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
-// editor->connect("hide_animation_player_editors",this,"_hide_anim_editors");
+ //editor->connect("hide_animation_player_editors",this,"_hide_anim_editors");
add_anim->set_icon( get_icon("New","EditorIcons") );
rename_anim->set_icon( get_icon("Rename","EditorIcons") );
duplicate_anim->set_icon( get_icon("Duplicate","EditorIcons") );
@@ -377,8 +378,10 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource>& p_resou
int flg = 0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg |= ResourceSaver::FLAG_COMPRESS;
- //if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- // flg |= ResourceSaver::FLAG_RELATIVE_PATHS;
+ /*
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
+ flg |= ResourceSaver::FLAG_RELATIVE_PATHS;
+ */
String path = GlobalConfig::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -388,7 +391,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource>& p_resou
accept->popup_centered_minsize();
return;
}
- // EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
+ //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource*)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved", p_resource);
@@ -421,7 +424,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource)
if (p_resource->get_path() != "") {
file->set_current_path(p_resource->get_path());
if (extensions.size()) {
- String ext = p_resource->get_path().extension().to_lower();
+ String ext = p_resource->get_path().get_extension().to_lower();
if (extensions.find(ext) == NULL) {
file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get()));
}
@@ -431,7 +434,12 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource)
String existing;
if (extensions.size()) {
- existing = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower();
+ if( p_resource->get_name() != "" ) {
+ existing = p_resource->get_name() + "." + extensions.front()->get().to_lower();
+ }
+ else {
+ existing = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower();
+ }
}
file->set_current_path(existing);
@@ -440,22 +448,27 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource>& p_resource)
file->set_title(TTR("Save Resource As.."));
current_option = RESOURCE_SAVE;
}
+
void AnimationPlayerEditor::_animation_remove() {
- if (animation->get_item_count()==0)
+ if (animation->get_item_count() == 0)
return;
- String current = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim = player->get_animation(current);
+ delete_dialog->set_text(TTR("Delete Animation?"));
+ delete_dialog->popup_centered_minsize();
+}
+void AnimationPlayerEditor::_animation_remove_confirmed() {
+
+ String current = animation->get_item_text(animation->get_selected());
+ Ref<Animation> anim = player->get_animation(current);
undo_redo->create_action(TTR("Remove Animation"));
- undo_redo->add_do_method(player,"remove_animation",current);
- undo_redo->add_undo_method(player,"add_animation",current,anim);
- undo_redo->add_do_method(this,"_animation_player_changed",player);
- undo_redo->add_undo_method(this,"_animation_player_changed",player);
+ undo_redo->add_do_method(player, "remove_animation", current);
+ undo_redo->add_undo_method(player, "add_animation", current, anim);
+ undo_redo->add_do_method(this, "_animation_player_changed", player);
+ undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
-
}
void AnimationPlayerEditor::_select_anim_by_name(const String& p_anim) {
@@ -648,8 +661,8 @@ Dictionary AnimationPlayerEditor::get_state() const {
Dictionary d;
- d["visible"]=is_visible();
- if (EditorNode::get_singleton()->get_edited_scene() && is_visible() && player) {
+ d["visible"]=is_visible_in_tree();
+ if (EditorNode::get_singleton()->get_edited_scene() && is_visible_in_tree() && player) {
d["player"]=EditorNode::get_singleton()->get_edited_scene()->get_path_to(player);
d["animation"]=player->get_current_animation();
@@ -672,7 +685,7 @@ void AnimationPlayerEditor::set_state(const Dictionary& p_state) {
show();
set_process(true);
ensure_visibility();
-// EditorNode::get_singleton()->animation_panel_make_visible(true);
+ //EditorNode::get_singleton()->animation_panel_make_visible(true);
if (p_state.has("animation")) {
String anim = p_state["animation"];
@@ -768,7 +781,7 @@ void AnimationPlayerEditor::_dialog_action(String p_file) {
void AnimationPlayerEditor::_scale_changed(const String& p_scale) {
- player->set_speed(p_scale.to_double());
+ player->set_speed_scale(p_scale.to_double());
}
void AnimationPlayerEditor::_update_animation() {
@@ -790,7 +803,7 @@ void AnimationPlayerEditor::_update_animation() {
stop->set_pressed(true);
}
- scale->set_text( String::num(player->get_speed(),2) );
+ scale->set_text( String::num(player->get_speed_scale(),2) );
String current=player->get_current_animation();
for (int i=0;i<animation->get_item_count();i++) {
@@ -897,7 +910,7 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
} else {
key_editor->show_select_node_warning(true);
-// hide();
+ //hide();
}
@@ -999,10 +1012,10 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value,bool p_set) {
void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
- if (player==p_pl && is_visible()) {
+ if (player==p_pl && is_visible_in_tree()) {
_update_player();
- if (blend_editor.dialog->is_visible())
+ if (blend_editor.dialog->is_visible_in_tree())
_animation_blend(); //update
}
}
@@ -1011,7 +1024,7 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
void AnimationPlayerEditor::_list_changed() {
- if(is_visible())
+ if(is_visible_in_tree())
_update_player();
}
#if 0
@@ -1099,7 +1112,7 @@ void AnimationPlayerEditor::_animation_key_editor_anim_step_changed(float p_len)
void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos,bool p_drag) {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
if (!player)
return;
@@ -1128,7 +1141,7 @@ void AnimationPlayerEditor::_hide_anim_editors() {
key_editor->set_animation(Ref<Animation>());
key_editor->set_root(NULL);
key_editor->show_select_node_warning(true);
-// editor->animation_editor_make_visible(false);
+ //editor->animation_editor_make_visible(false);
}
@@ -1220,7 +1233,7 @@ void AnimationPlayerEditor::_animation_save_menu(int p_option) {
void AnimationPlayerEditor::_unhandled_key_input(const InputEvent& p_ev) {
- if (is_visible() && p_ev.type==InputEvent::KEY && p_ev.key.pressed && !p_ev.key.echo && !p_ev.key.mod.alt && !p_ev.key.mod.control && !p_ev.key.mod.meta) {
+ if (is_visible_in_tree() && p_ev.type==InputEvent::KEY && p_ev.key.pressed && !p_ev.key.echo && !p_ev.key.mod.alt && !p_ev.key.mod.control && !p_ev.key.mod.meta) {
switch(p_ev.key.scancode) {
@@ -1245,42 +1258,43 @@ void AnimationPlayerEditor::_unhandled_key_input(const InputEvent& p_ev) {
void AnimationPlayerEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&AnimationPlayerEditor::_gui_input);
- ClassDB::bind_method(_MD("_node_removed"),&AnimationPlayerEditor::_node_removed);
- ClassDB::bind_method(_MD("_play_pressed"),&AnimationPlayerEditor::_play_pressed);
- ClassDB::bind_method(_MD("_play_from_pressed"),&AnimationPlayerEditor::_play_from_pressed);
- ClassDB::bind_method(_MD("_play_bw_pressed"),&AnimationPlayerEditor::_play_bw_pressed);
- ClassDB::bind_method(_MD("_play_bw_from_pressed"),&AnimationPlayerEditor::_play_bw_from_pressed);
- ClassDB::bind_method(_MD("_stop_pressed"),&AnimationPlayerEditor::_stop_pressed);
- ClassDB::bind_method(_MD("_autoplay_pressed"),&AnimationPlayerEditor::_autoplay_pressed);
- ClassDB::bind_method(_MD("_pause_pressed"),&AnimationPlayerEditor::_pause_pressed);
- ClassDB::bind_method(_MD("_animation_selected"),&AnimationPlayerEditor::_animation_selected);
- ClassDB::bind_method(_MD("_animation_name_edited"),&AnimationPlayerEditor::_animation_name_edited);
- ClassDB::bind_method(_MD("_animation_new"),&AnimationPlayerEditor::_animation_new);
- ClassDB::bind_method(_MD("_animation_rename"),&AnimationPlayerEditor::_animation_rename);
- ClassDB::bind_method(_MD("_animation_load"),&AnimationPlayerEditor::_animation_load);
- ClassDB::bind_method(_MD("_animation_remove"),&AnimationPlayerEditor::_animation_remove);
- ClassDB::bind_method(_MD("_animation_blend"),&AnimationPlayerEditor::_animation_blend);
- ClassDB::bind_method(_MD("_animation_edit"),&AnimationPlayerEditor::_animation_edit);
- ClassDB::bind_method(_MD("_animation_resource_edit"),&AnimationPlayerEditor::_animation_resource_edit);
- ClassDB::bind_method(_MD("_dialog_action"),&AnimationPlayerEditor::_dialog_action);
- ClassDB::bind_method(_MD("_seek_value_changed"),&AnimationPlayerEditor::_seek_value_changed,DEFVAL(true));
- ClassDB::bind_method(_MD("_animation_player_changed"),&AnimationPlayerEditor::_animation_player_changed);
- ClassDB::bind_method(_MD("_blend_edited"),&AnimationPlayerEditor::_blend_edited);
-// ClassDB::bind_method(_MD("_seek_frame_changed"),&AnimationPlayerEditor::_seek_frame_changed);
- ClassDB::bind_method(_MD("_scale_changed"),&AnimationPlayerEditor::_scale_changed);
- //ClassDB::bind_method(_MD("_editor_store_all"),&AnimationPlayerEditor::_editor_store_all);
- ///jectTypeDB::bind_method(_MD("_editor_load_all"),&AnimationPlayerEditor::_editor_load_all);
- ClassDB::bind_method(_MD("_list_changed"),&AnimationPlayerEditor::_list_changed);
- ClassDB::bind_method(_MD("_animation_key_editor_seek"),&AnimationPlayerEditor::_animation_key_editor_seek);
- ClassDB::bind_method(_MD("_animation_key_editor_anim_len_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
- ClassDB::bind_method(_MD("_animation_key_editor_anim_step_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_step_changed);
- ClassDB::bind_method(_MD("_hide_anim_editors"),&AnimationPlayerEditor::_hide_anim_editors);
- ClassDB::bind_method(_MD("_animation_duplicate"),&AnimationPlayerEditor::_animation_duplicate);
- ClassDB::bind_method(_MD("_blend_editor_next_changed"),&AnimationPlayerEditor::_blend_editor_next_changed);
- ClassDB::bind_method(_MD("_unhandled_key_input"),&AnimationPlayerEditor::_unhandled_key_input);
- ClassDB::bind_method(_MD("_animation_tool_menu"),&AnimationPlayerEditor::_animation_tool_menu);
- ClassDB::bind_method(_MD("_animation_save_menu"), &AnimationPlayerEditor::_animation_save_menu);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&AnimationPlayerEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&AnimationPlayerEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_play_pressed"),&AnimationPlayerEditor::_play_pressed);
+ ClassDB::bind_method(D_METHOD("_play_from_pressed"),&AnimationPlayerEditor::_play_from_pressed);
+ ClassDB::bind_method(D_METHOD("_play_bw_pressed"),&AnimationPlayerEditor::_play_bw_pressed);
+ ClassDB::bind_method(D_METHOD("_play_bw_from_pressed"),&AnimationPlayerEditor::_play_bw_from_pressed);
+ ClassDB::bind_method(D_METHOD("_stop_pressed"),&AnimationPlayerEditor::_stop_pressed);
+ ClassDB::bind_method(D_METHOD("_autoplay_pressed"),&AnimationPlayerEditor::_autoplay_pressed);
+ ClassDB::bind_method(D_METHOD("_pause_pressed"),&AnimationPlayerEditor::_pause_pressed);
+ ClassDB::bind_method(D_METHOD("_animation_selected"),&AnimationPlayerEditor::_animation_selected);
+ ClassDB::bind_method(D_METHOD("_animation_name_edited"),&AnimationPlayerEditor::_animation_name_edited);
+ ClassDB::bind_method(D_METHOD("_animation_new"),&AnimationPlayerEditor::_animation_new);
+ ClassDB::bind_method(D_METHOD("_animation_rename"),&AnimationPlayerEditor::_animation_rename);
+ ClassDB::bind_method(D_METHOD("_animation_load"),&AnimationPlayerEditor::_animation_load);
+ ClassDB::bind_method(D_METHOD("_animation_remove"),&AnimationPlayerEditor::_animation_remove);
+ ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"),&AnimationPlayerEditor::_animation_remove_confirmed);
+ ClassDB::bind_method(D_METHOD("_animation_blend"),&AnimationPlayerEditor::_animation_blend);
+ ClassDB::bind_method(D_METHOD("_animation_edit"),&AnimationPlayerEditor::_animation_edit);
+ ClassDB::bind_method(D_METHOD("_animation_resource_edit"),&AnimationPlayerEditor::_animation_resource_edit);
+ ClassDB::bind_method(D_METHOD("_dialog_action"),&AnimationPlayerEditor::_dialog_action);
+ ClassDB::bind_method(D_METHOD("_seek_value_changed"),&AnimationPlayerEditor::_seek_value_changed,DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("_animation_player_changed"),&AnimationPlayerEditor::_animation_player_changed);
+ ClassDB::bind_method(D_METHOD("_blend_edited"),&AnimationPlayerEditor::_blend_edited);
+ //ClassDB::bind_method(D_METHOD("_seek_frame_changed"),&AnimationPlayerEditor::_seek_frame_changed);
+ ClassDB::bind_method(D_METHOD("_scale_changed"),&AnimationPlayerEditor::_scale_changed);
+ //ClassDB::bind_method(D_METHOD("_editor_store_all"),&AnimationPlayerEditor::_editor_store_all);
+ //ClassDB::bind_method(D_METHOD("_editor_load_all"),&AnimationPlayerEditor::_editor_load_all);
+ ClassDB::bind_method(D_METHOD("_list_changed"),&AnimationPlayerEditor::_list_changed);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_seek"),&AnimationPlayerEditor::_animation_key_editor_seek);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_len_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_len_changed);
+ ClassDB::bind_method(D_METHOD("_animation_key_editor_anim_step_changed"),&AnimationPlayerEditor::_animation_key_editor_anim_step_changed);
+ ClassDB::bind_method(D_METHOD("_hide_anim_editors"),&AnimationPlayerEditor::_hide_anim_editors);
+ ClassDB::bind_method(D_METHOD("_animation_duplicate"),&AnimationPlayerEditor::_animation_duplicate);
+ ClassDB::bind_method(D_METHOD("_blend_editor_next_changed"),&AnimationPlayerEditor::_blend_editor_next_changed);
+ ClassDB::bind_method(D_METHOD("_unhandled_key_input"),&AnimationPlayerEditor::_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("_animation_tool_menu"),&AnimationPlayerEditor::_animation_tool_menu);
+ ClassDB::bind_method(D_METHOD("_animation_save_menu"), &AnimationPlayerEditor::_animation_save_menu);
@@ -1384,6 +1398,10 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
add_child(accept);
accept->connect("confirmed", this, "_menu_confirm_current");
+ delete_dialog = memnew(ConfirmationDialog);
+ add_child(delete_dialog);
+ delete_dialog->connect("confirmed", this, "_animation_remove_confirmed");
+
duplicate_anim = memnew( ToolButton );
hb->add_child(duplicate_anim);
ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation"));
@@ -1397,7 +1415,6 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
rename_anim->set_tooltip(TTR("Rename Animation"));
remove_anim = memnew( ToolButton );
-
hb->add_child(remove_anim);
ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation"));
remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation"));
@@ -1552,11 +1569,11 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
editor->make_bottom_panel_item_visible(anim_editor);
anim_editor->set_process(true);
anim_editor->ensure_visibility();
-// editor->animation_panel_make_visible(true);
+ //editor->animation_panel_make_visible(true);
} else {
-// anim_editor->hide();
-// anim_editor->set_idle_process(false);
+ //anim_editor->hide();
+ //anim_editor->set_idle_process(false);
}
}
diff --git a/tools/editor/plugins/animation_player_editor_plugin.h b/tools/editor/plugins/animation_player_editor_plugin.h
index 9074eb127b..e28600a7ab 100644
--- a/tools/editor/plugins/animation_player_editor_plugin.h
+++ b/tools/editor/plugins/animation_player_editor_plugin.h
@@ -73,7 +73,7 @@ class AnimationPlayerEditor : public VBoxContainer {
Button *play_bw;
Button *play_bw_from;
-// Button *pause;
+ //Button *pause;
Button *add_anim;
Button *autoplay;
Button *rename_anim;
@@ -97,6 +97,7 @@ class AnimationPlayerEditor : public VBoxContainer {
EditorFileDialog *file;
AcceptDialog *accept;
+ ConfirmationDialog* delete_dialog;
int current_option;
struct BlendEditor {
@@ -138,6 +139,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_save_as(const Ref<Resource>& p_resource);
void _animation_remove();
+ void _animation_remove_confirmed();
void _animation_blend();
void _animation_edit();
void _animation_duplicate();
diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp
index 3b28e8610b..988136d475 100644
--- a/tools/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp
@@ -32,7 +32,7 @@
#include "scene/gui/panel.h"
#include "scene/main/viewport.h"
#include "core/io/resource_loader.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "os/input.h"
#include "os/keyboard.h"
@@ -261,9 +261,9 @@ void AnimationTreeEditor::_popup_edit_dialog() {
}
edit_option->hide();
- edit_button->hide();;
+ edit_button->hide();
filter_button->hide();
- edit_check->hide();;
+ edit_check->hide();
Point2 pos = anim_tree->node_get_pos(edited_node)-Point2(h_scroll->get_value(),v_scroll->get_value());
Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
@@ -450,7 +450,7 @@ void AnimationTreeEditor::_popup_edit_dialog() {
edit_label[1]->show();
edit_option->set_begin(Point2(15,75));
- edit_option->clear();;
+ edit_option->clear();
for(int i=0;i<anim_tree->transition_node_get_input_count(edited_node);i++) {
edit_option->add_item(itos(i),i);
@@ -621,9 +621,9 @@ void AnimationTreeEditor::_draw_node(const StringName& p_node) {
#if 0
void AnimationTreeEditor::_node_param_changed() {
-// anim_tree->node_set_param( click_node,property_editor->get_variant() );
-// update();
-// _write_anim_tree_graph();
+ //anim_tree->node_set_param( click_node,property_editor->get_variant() );
+ //update();
+ //_write_anim_tree_graph();
}
#endif
@@ -792,7 +792,7 @@ void AnimationTreeEditor::_gui_input(InputEvent p_event) {
renaming_edit=false;
_popup_edit_dialog();
//open editor
- // _node_edit_property(click_node);
+ //_node_edit_property(click_node);
} break;
default:{}
}
@@ -856,12 +856,12 @@ void AnimationTreeEditor::_gui_input(InputEvent p_event) {
if (dst_click_type==CLICK_INPUT_SLOT && click_type==CLICK_OUTPUT_SLOT) {
- anim_tree->connect(click_node,id,slot);
+ anim_tree->connect_nodes(click_node,id,slot);
}
if (click_type==CLICK_INPUT_SLOT && dst_click_type==CLICK_OUTPUT_SLOT) {
- anim_tree->connect(id,click_node,click_slot);
+ anim_tree->connect_nodes(id,click_node,click_slot);
}
} break;
@@ -1057,7 +1057,7 @@ void AnimationTreeEditor::_node_menu_item(int p_item) {
if (rclick_type==CLICK_INPUT_SLOT) {
- anim_tree->disconnect(rclick_node,rclick_slot);
+ anim_tree->disconnect_nodes(rclick_node,rclick_slot);
update();
}
@@ -1072,7 +1072,7 @@ void AnimationTreeEditor::_node_menu_item(int p_item) {
const AnimationTreePlayer::Connection &c=E->get();
if( c.dst_node==rclick_node) {
- anim_tree->disconnect(c.dst_node,c.dst_input);
+ anim_tree->disconnect_nodes(c.dst_node,c.dst_input);
}
}
update();
@@ -1325,7 +1325,7 @@ void AnimationTreeEditor::_bind_methods() {
ClassDB::bind_method( "_add_menu_item", &AnimationTreeEditor::_add_menu_item );
ClassDB::bind_method( "_node_menu_item", &AnimationTreeEditor::_node_menu_item );
ClassDB::bind_method( "_gui_input", &AnimationTreeEditor::_gui_input );
-// ClassDB::bind_method( "_node_param_changed", &AnimationTreeEditor::_node_param_changed );
+ //ClassDB::bind_method( "_node_param_changed", &AnimationTreeEditor::_node_param_changed );
ClassDB::bind_method( "_scroll_moved", &AnimationTreeEditor::_scroll_moved );
ClassDB::bind_method( "_edit_dialog_changeds", &AnimationTreeEditor::_edit_dialog_changeds );
ClassDB::bind_method( "_edit_dialog_changede", &AnimationTreeEditor::_edit_dialog_changede );
@@ -1414,8 +1414,8 @@ AnimationTreeEditor::AnimationTreeEditor() {
updating_edit=false;
edit_dialog = memnew( PopupPanel );
-// edit_dialog->get_ok()->hide();
-// edit_dialog->get_cancel()->hide();
+ //edit_dialog->get_ok()->hide();
+ //edit_dialog->get_cancel()->hide();
add_child(edit_dialog);
edit_option = memnew( OptionButton );
@@ -1451,14 +1451,14 @@ AnimationTreeEditor::AnimationTreeEditor() {
edit_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
edit_button->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_button);
- edit_button->hide();;
+ edit_button->hide();
edit_button->connect("pressed", this,"_edit_oneshot_start");
edit_check = memnew( CheckButton );
edit_check->set_anchor( MARGIN_RIGHT, ANCHOR_END );
edit_check->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(edit_check);
- edit_check->hide();;
+ edit_check->hide();
edit_check->connect("pressed", this,"_edit_dialog_changed");
file_dialog = memnew( EditorFileDialog );
@@ -1480,7 +1480,7 @@ AnimationTreeEditor::AnimationTreeEditor() {
filter_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
filter_button->set_margin(MARGIN_RIGHT, 10);
edit_dialog->add_child(filter_button);
- filter_button->hide();;
+ filter_button->hide();
filter_button->set_text(TTR("Filters.."));
filter_button->connect("pressed", this,"_edit_filters");
@@ -1502,14 +1502,14 @@ bool AnimationTreeEditorPlugin::handles(Object *p_object) const {
void AnimationTreeEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
-// editor->hide_animation_player_editors();
-// editor->animation_panel_make_visible(true);
+ //editor->hide_animation_player_editors();
+ //editor->animation_panel_make_visible(true);
button->show();
editor->make_bottom_panel_item_visible(anim_tree_editor);
anim_tree_editor->set_fixed_process(true);
} else {
- if (anim_tree_editor->is_visible())
+ if (anim_tree_editor->is_visible_in_tree())
editor->hide_bottom_panel();
button->hide();
anim_tree_editor->set_fixed_process(false);
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index 2d91524ef9..4219e791d1 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "baked_light_baker.h"
+
#include <stdlib.h>
#include <cmath>
#include "io/marshalls.h"
@@ -1006,8 +1007,10 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
Triangle *triangle=NULL;
- //for(int i=0;i<max_depth;i++)
- // stack[i]=0;
+ /*
+ for(int i=0;i<max_depth;i++)
+ stack[i]=0;
+ */
int level=0;
//AABB ray_aabb;
@@ -1059,7 +1062,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
bool valid = b.aabb.smits_intersect_ray(p_begin,n,0,len);
//bool valid = b.aabb.intersects_segment(p_begin,p_end);
- // bool valid = b.aabb.intersects(ray_aabb);
+ //bool valid = b.aabb.intersects(ray_aabb);
if (!valid) {
@@ -1234,7 +1237,7 @@ float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,c
}
//specular later
-// _plot_light_point(r_point,octree,octree_aabb,p_light);
+ //_plot_light_point(r_point,octree,octree_aabb,p_light);
Color plot_light=res_light.linear_interpolate(diffuse_at_point,tint);
@@ -1331,7 +1334,7 @@ void BakedLightBaker::_make_octree_texture() {
base<<=16;
base|=int((pos.z+cell_size*0.5)/cell_size);
- uint32_t hash = HashMapHahserDefault::hash(base);
+ uint32_t hash = HashMapHasherDefault::hash(base);
uint32_t idx = hash % hash_table_size;
octhashptr[oct_idx].next=hashptr[idx];
octhashptr[oct_idx].hash=hash;
@@ -1359,7 +1362,7 @@ void BakedLightBaker::_make_octree_texture() {
base<<=16;
base|=int((pos.z+cell_size*0.5)/cell_size);
- uint32_t hash = HashMapHahserDefault::hash(base);
+ uint32_t hash = HashMapHasherDefault::hash(base);
uint32_t idx = hash % hash_table_size;
uint32_t bucket = hashptr[idx];
@@ -1571,7 +1574,7 @@ double BakedLightBaker::get_normalization(int p_light_idx) const {
double nrg=0;
const LightData &dl=lights[p_light_idx];
- double cell_area = cell_size*cell_size;;
+ double cell_area = cell_size*cell_size;
//nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area);
nrg=dl.rays_thrown * cell_area;
nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel
@@ -1589,7 +1592,7 @@ double BakedLightBaker::get_modifier(int p_light_idx) const {
double nrg=0;
const LightData &dl=lights[p_light_idx];
- double cell_area = cell_size*cell_size;;
+ double cell_area = cell_size*cell_size;
//nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area);
nrg=cell_area;
nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel
@@ -1678,7 +1681,7 @@ void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) {
dl.rays_thrown++;
baked_light_baker_add_64i(&total_rays,1);
_throw_ray(thread_stack,dl.bake_direct,from,to,dl.radius,col,dl.attenuation_table.ptr(),0,dl.radius,max_bounces,true);
-// _throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true);
+ //_throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true);
}
} break;
@@ -1710,7 +1713,7 @@ void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) {
dl.rays_thrown++;
baked_light_baker_add_64i(&total_rays,1);
_throw_ray(thread_stack,dl.bake_direct,from,to,dl.radius,col,dl.attenuation_table.ptr(),0,dl.radius,max_bounces,true);
- // _throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true);
+ //_throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true);
}
} break;
@@ -2010,8 +2013,10 @@ void BakedLightBaker::update_octree_images(PoolVector<uint8_t> &p_octree,PoolVec
//write colors
for(int j=0;j<8;j++) {
- //if (!oct.children[j])
- // continue;
+ /*
+ if (!oct.children[j])
+ continue;
+ */
uint8_t *iptr=&lptr[ofs+lchild_offsets[j]];
float r=oct.light_accum[j][0]*norm;
@@ -2291,7 +2296,7 @@ void BakedLightBaker::_plot_pixel_to_lightmap(int x, int y, int width, int heigh
bool valid = b.aabb.smits_intersect_ray(from,n,0,len);
//bool valid = b.aabb.intersects_segment(p_begin,p_end);
- // bool valid = b.aabb.intersects(ray_aabb);
+ //bool valid = b.aabb.intersects(ray_aabb);
if (!valid) {
@@ -2649,10 +2654,13 @@ void BakedLightBaker::clear() {
/*
* ???
for(int i=0;i<octant_pool.size();i++) {
- //if (octant_pool[i].leaf) {
- // memdelete_arr( octant_pool[i].light );
- //} Vector<double> norm_arr;
- //norm_arr.resize(lights.size());
+ /*
+ if (octant_pool[i].leaf) {
+ memdelete_arr( octant_pool[i].light );
+ }
+ Vector<double> norm_arr;
+ norm_arr.resize(lights.size());
+ */
for(int i=0;i<lights.size();i++) {
norm_arr[i] = 1.0/get_normalization(i);
@@ -2674,7 +2682,7 @@ void BakedLightBaker::clear() {
materials.clear();
textures.clear();
lights.clear();
- triangles.clear();;
+ triangles.clear();
endpoint_normal.clear();
endpoint_normal_bits.clear();
baked_octree_texture_w=0;
diff --git a/tools/editor/plugins/baked_light_baker.h b/tools/editor/plugins/baked_light_baker.h
index 6fcf78dd0a..89788338d9 100644
--- a/tools/editor/plugins/baked_light_baker.h
+++ b/tools/editor/plugins/baked_light_baker.h
@@ -45,10 +45,11 @@ public:
OCTANT_POOL_CHUNK=1000000
};
- //struct OctantLight {
-
- // double accum[8][3];
- //};
+ /*
+ struct OctantLight {
+ double accum[8][3];
+ };
+ */
struct Octant {
bool leaf;
diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp
index 8f564a3247..6a7e708b85 100644
--- a/tools/editor/plugins/baked_light_editor_plugin.cpp
+++ b/tools/editor/plugins/baked_light_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "baked_light_editor_plugin.h"
+
#include "scene/gui/box_container.h"
#include "scene/3d/mesh_instance.h"
#include "io/marshalls.h"
@@ -105,8 +106,10 @@ void BakedLightEditor::_notification(int p_option) {
colors[i].b=oct->light_accum[i][2]/norm;
float lum = colors[i].get_v();
- //if (lum<0.05)
- // color.a=0;
+ /*
+ if (lum<0.05)
+ color.a=0;
+ */
if (lum>max_lum)
max_lum=lum;
@@ -141,7 +144,7 @@ void BakedLightEditor::_notification(int p_option) {
baker->update_octree_images(octree_texture,light_texture);
baker->update_octree_sampler(octree_sampler);
- // print_line("sampler size: "+itos(octree_sampler.size()*4));
+ //print_line("sampler size: "+itos(octree_sampler.size()*4));
#if 1
//debug
diff --git a/tools/editor/plugins/camera_editor_plugin.cpp b/tools/editor/plugins/camera_editor_plugin.cpp
index 67f776ba0b..7073acd2c0 100644
--- a/tools/editor/plugins/camera_editor_plugin.cpp
+++ b/tools/editor/plugins/camera_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "camera_editor_plugin.h"
+
#include "spatial_editor_plugin.h"
@@ -61,7 +62,7 @@ void CameraEditor::_pressed() {
void CameraEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_pressed"),&CameraEditor::_pressed);
+ ClassDB::bind_method(D_METHOD("_pressed"),&CameraEditor::_pressed);
}
@@ -114,10 +115,8 @@ bool CameraEditorPlugin::handles(Object *p_object) const {
void CameraEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
-// SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>());
-
+ //SpatialEditor::get_singleton()->set_can_preview(p_object->cast_to<Camera>());
} else {
-
SpatialEditor::get_singleton()->set_can_preview(NULL);
}
diff --git a/tools/editor/plugins/camera_editor_plugin.h b/tools/editor/plugins/camera_editor_plugin.h
index 56702f174b..7e79d0ec74 100644
--- a/tools/editor/plugins/camera_editor_plugin.h
+++ b/tools/editor/plugins/camera_editor_plugin.h
@@ -60,7 +60,7 @@ class CameraEditorPlugin : public EditorPlugin {
GDCLASS( CameraEditorPlugin, EditorPlugin );
-// CameraEditor *camera_editor;
+ //CameraEditor *camera_editor;
EditorNode *editor;
public:
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index 1abbac4539..8af925db7a 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "canvas_item_editor_plugin.h"
+
#include "print_string.h"
#include "tools/editor/editor_node.h"
#include "os/keyboard.h"
@@ -37,11 +38,11 @@
#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/screen_button.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/input.h"
#include "tools/editor/editor_settings.h"
#include "scene/gui/grid_container.h"
-#include "scene/gui/patch_9_frame.h"
+#include "scene/gui/patch_9_rect.h"
#include "tools/editor/animation_editor.h"
#include "tools/editor/plugins/animation_player_editor_plugin.h"
#include "tools/editor/script_editor_debugger.h"
@@ -79,7 +80,7 @@ public:
container = memnew( VBoxContainer );
add_child(container);
- // set_child_rect(container);
+ //set_child_rect(container);
child_container = memnew( GridContainer );
child_container->set_columns(3);
@@ -209,7 +210,7 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2& mouse_pos) {
void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
- if (!is_visible() || get_viewport()->gui_has_modal_stack())
+ if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return;
if (p_ev.key.mod.control)
@@ -287,7 +288,7 @@ Dictionary CanvasItemEditor::get_state() const {
Dictionary state;
state["zoom"]=zoom;
state["ofs"]=Point2(h_scroll->get_value(),v_scroll->get_value());
-// state["ofs"]=-transform.get_origin();
+ //state["ofs"]=-transform.get_origin();
state["snap_offset"]=snap_offset;
state["snap_step"]=snap_step;
state["snap_rotation_offset"]=snap_rotation_offset;
@@ -391,7 +392,7 @@ void CanvasItemEditor::_remove_canvas_item(CanvasItem *p_canvas_item) {
}
void CanvasItemEditor::_clear_canvas_items() {
- editor_selection->clear();;
+ editor_selection->clear();
#if 0
while(canvas_items.size())
_remove_canvas_item(canvas_items.front()->key());
@@ -425,7 +426,7 @@ void CanvasItemEditor::_node_removed(Node *p_node) {
void CanvasItemEditor::_keying_changed() {
- if (AnimationPlayerEditor::singleton->get_key_editor()->is_visible())
+ if (AnimationPlayerEditor::singleton->get_key_editor()->is_visible_in_tree())
animation_hb->show();
else
animation_hb->hide();
@@ -465,7 +466,7 @@ CanvasItem* CanvasItemEditor::_select_canvas_item_at_pos(const Point2& p_pos,Nod
return r;
}
- if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !_is_part_of_subscene(c) && !c->cast_to<CanvasLayer>()) {
+ 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);
@@ -498,7 +499,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos,Node* p_nod
}
- if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
+ if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !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);
@@ -547,7 +548,7 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_no
}
}
- if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
+ if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !c->cast_to<CanvasLayer>()) {
Rect2 rect = c->get_item_rect();
Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform();
@@ -601,7 +602,7 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
if (!item) {
//clear because nothing clicked
- editor_selection->clear();;
+ editor_selection->clear();
if (p_drag) {
drag_from=transform.affine_inverse().xform(p_click_pos);
@@ -633,7 +634,7 @@ bool CanvasItemEditor::_select(CanvasItem *item, Point2 p_click_pos, bool p_appe
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -676,7 +677,7 @@ void CanvasItemEditor::_key_move(const Vector2& p_dir, bool p_snap, KeyMoveMODE
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -738,7 +739,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -769,7 +770,7 @@ int CanvasItemEditor::get_item_count() {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -791,7 +792,7 @@ CanvasItem *CanvasItemEditor::get_single_item() {
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -1152,7 +1153,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -1187,8 +1188,10 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
}
return;
}
- //if (!canvas_items.size())
- // return;
+ /*
+ if (!canvas_items.size())
+ return;
+ */
if (b.button_index==BUTTON_LEFT && tool==TOOL_LIST_SELECT) {
if (b.pressed)
@@ -1247,7 +1250,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -1317,7 +1320,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
{
bone_ik_list.clear();
float closest_dist=1e20;
- int bone_width = EditorSettings::get_singleton()->get("editors/2dbone_width");
+ int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width");
for(Map<ObjectID,BoneList>::Element *E=bone_list.front();E;E=E->next()) {
if (E->get().from == E->get().to)
@@ -1417,7 +1420,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
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!
+ //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);
@@ -1458,7 +1461,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -1535,7 +1538,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION) {
- if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
+ if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
viewport->call_deferred("grab_focus");
const InputEventMouseMotion &m=p_event.mouse_motion;
@@ -1553,7 +1556,6 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
if ( (m.button_mask&BUTTON_MASK_LEFT && tool == TOOL_PAN) || m.button_mask&BUTTON_MASK_MIDDLE || (m.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
-
h_scroll->set_value( h_scroll->get_value() - m.relative_x/zoom);
v_scroll->set_value( v_scroll->get_value() - m.relative_y/zoom);
}
@@ -1568,7 +1570,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -1652,7 +1654,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent& p_event) {
Vector2 minsize = canvas_item->edit_get_minimum_size();
if (uniform) {
- float aspect = local_rect.size.get_aspect();
+ float aspect = local_rect.size.aspect();
switch(drag) {
case DRAG_BOTTOM_LEFT:
case DRAG_TOP_RIGHT: {
@@ -1947,9 +1949,9 @@ void CanvasItemEditor::_viewport_draw() {
if (viewport->has_focus()) {
Size2 size = viewport->get_size();
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
size.width-=v_scroll->get_size().width;
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
size.height-=h_scroll->get_size().height;
get_stylebox("EditorFocus","EditorStyles")->draw(ci,Rect2(Point2(),size));
@@ -1969,7 +1971,7 @@ void CanvasItemEditor::_viewport_draw() {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
continue;
@@ -2069,7 +2071,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/width"), GlobalConfig::get_singleton()->get("display/height") );
+ Size2 screen_size = Size2( GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height") );
Vector2 screen_endpoints[4]= {
transform.xform(Vector2(0,0)),
@@ -2112,11 +2114,11 @@ void CanvasItemEditor::_viewport_draw() {
}
if (skeleton_show_bones) {
- int bone_width = EditorSettings::get_singleton()->get("editors/2dbone_width");
- Color bone_color1 = EditorSettings::get_singleton()->get("editors/2dbone_color1");
- Color bone_color2 = EditorSettings::get_singleton()->get("editors/2dbone_color2");
- Color bone_ik_color = EditorSettings::get_singleton()->get("editors/2dbone_ik_color");
- Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2dbone_selected_color");
+ int bone_width = EditorSettings::get_singleton()->get("editors/2d/bone_width");
+ Color bone_color1 = EditorSettings::get_singleton()->get("editors/2d/bone_color1");
+ Color bone_color2 = EditorSettings::get_singleton()->get("editors/2d/bone_color2");
+ Color bone_ik_color = EditorSettings::get_singleton()->get("editors/2d/bone_ik_color");
+ Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2d/bone_selected_color");
for(Map<ObjectID,BoneList>::Element*E=bone_list.front();E;E=E->next()) {
@@ -2198,7 +2200,7 @@ void CanvasItemEditor::_notification(int p_what) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2226,7 +2228,7 @@ void CanvasItemEditor::_notification(int p_what) {
}
bool show_anchor = all_control && has_control;
- if (show_anchor != !anchor_menu->is_hidden()) {
+ if (show_anchor != anchor_menu->is_visible()) {
if (show_anchor)
anchor_menu->show();
else
@@ -2342,7 +2344,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, cons
for (int i=p_node->get_child_count()-1;i>=0;i--) {
-// CanvasItem *r=NULL;
+ //CanvasItem *r=NULL;
if (c && !c->is_set_as_toplevel())
_find_canvas_items_span(p_node->get_child(i),r_rect,p_xform * c->get_transform());
@@ -2352,7 +2354,7 @@ void CanvasItemEditor::_find_canvas_items_span(Node *p_node, Rect2& r_rect, cons
- if (c) {
+ if (c && c->is_visible_in_tree()) {
Rect2 rect = c->get_item_rect();
Transform2D xform = p_xform * c->get_transform();
@@ -2404,13 +2406,14 @@ void CanvasItemEditor::_update_scrollbars() {
h_scroll->set_end( Point2(size.width-vmin.width, size.height) );
- Size2 screen_rect = Size2( GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height") );
+ Size2 screen_rect = Size2( GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height") );
+
Rect2 local_rect = Rect2(Point2(),viewport->get_size()-Size2(vmin.width,hmin.height));
Rect2 canvas_item_rect=Rect2(Point2(),screen_rect);
- lock_list.clear();;
+ lock_list.clear();
bone_last_frame++;
@@ -2473,14 +2476,15 @@ void CanvasItemEditor::_update_scrollbars() {
ofs.x=h_scroll->get_value();
}
-// transform=Matrix32();
+ //transform=Matrix32();
transform.elements[2]=-ofs*zoom;
+
editor->get_scene_root()->set_global_canvas_transform(transform);
updating_scroll=false;
-// transform.scale_basis(Vector2(zoom,zoom));
+ //transform.scale_basis(Vector2(zoom,zoom));
}
@@ -2495,7 +2499,7 @@ void CanvasItemEditor::_update_scroll(float) {
ofs.x=h_scroll->get_value();
ofs.y=v_scroll->get_value();
-// current_window->set_scroll(-ofs);
+ //current_window->set_scroll(-ofs);
transform=Transform2D();
@@ -2619,7 +2623,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2637,7 +2641,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2658,7 +2662,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2676,7 +2680,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2697,7 +2701,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2818,7 +2822,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2923,7 +2927,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;*/
case ANIM_COPY_POSE: {
- pose_clipboard.clear();;
+ pose_clipboard.clear();
Map<Node*,Object*> &selection = editor_selection->get_selection();
@@ -2931,7 +2935,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -2983,7 +2987,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
for(Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
CanvasItem *canvas_item = E->key()->cast_to<CanvasItem>();
- if (!canvas_item || !canvas_item->is_visible())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -3004,8 +3008,10 @@ void CanvasItemEditor::_popup_callback(int p_op) {
if (key_pos)
ctrl->set_pos(Point2());
- //if (key_scale)
- // AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
+ /*
+ if (key_scale)
+ AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size());
+ */
}
}
@@ -3029,7 +3035,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Node2D *n2d = E->key()->cast_to<Node2D>();
if (!n2d)
continue;
- if (!n2d->is_visible())
+ if (!n2d->is_visible_in_tree())
continue;
if (!n2d->get_parent_item())
continue;
@@ -3051,7 +3057,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
Node2D *n2d = E->key()->cast_to<Node2D>();
if (!n2d)
continue;
- if (!n2d->is_visible())
+ if (!n2d->is_visible_in_tree())
continue;
n2d->set_meta("_edit_bone_",Variant());
@@ -3069,7 +3075,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
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())
+ if (!canvas_item || !canvas_item->is_visible_in_tree())
continue;
if (canvas_item->get_viewport()!=EditorNode::get_singleton()->get_scene_root())
@@ -3093,7 +3099,7 @@ void CanvasItemEditor::_popup_callback(int p_op) {
CanvasItem *n2d = E->key()->cast_to<CanvasItem>();
if (!n2d)
continue;
- if (!n2d->is_visible())
+ if (!n2d->is_visible_in_tree())
continue;
n2d->set_meta("_edit_ik_",Variant());
@@ -3151,7 +3157,7 @@ void CanvasItemEditor::_focus_selection(int p_op) {
// counting invisible items, for now
- //if (!canvas_item->is_visible()) continue;
+ //if (!canvas_item->is_visible_in_tree()) continue;
++count;
Rect2 item_rect = canvas_item->get_item_rect();
@@ -3206,8 +3212,8 @@ void CanvasItemEditor::_bind_methods() {
ClassDB::bind_method("_viewport_draw",&CanvasItemEditor::_viewport_draw);
ClassDB::bind_method("_viewport_gui_input",&CanvasItemEditor::_viewport_gui_input);
ClassDB::bind_method("_snap_changed",&CanvasItemEditor::_snap_changed);
- ClassDB::bind_method(_MD("_selection_result_pressed"),&CanvasItemEditor::_selection_result_pressed);
- ClassDB::bind_method(_MD("_selection_menu_hide"),&CanvasItemEditor::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("_selection_result_pressed"),&CanvasItemEditor::_selection_result_pressed);
+ ClassDB::bind_method(D_METHOD("_selection_menu_hide"),&CanvasItemEditor::_selection_menu_hide);
ADD_SIGNAL( MethodInfo("item_lock_status_changed") );
ADD_SIGNAL( MethodInfo("item_group_status_changed") );
@@ -3350,8 +3356,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport->connect("gui_input",this,"_viewport_gui_input");
- h_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),true);
- v_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),true);
+ h_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),Object::CONNECT_DEFERRED);
+ v_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),Object::CONNECT_DEFERRED);
h_scroll->hide();
v_scroll->hide();
@@ -3615,14 +3621,14 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
canvas_item_editor->show();
canvas_item_editor->set_fixed_process(true);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),false);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(),false);
canvas_item_editor->viewport->grab_focus();
} else {
canvas_item_editor->hide();
canvas_item_editor->set_fixed_process(false);
- VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport(),true);
+ VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(),true);
}
}
@@ -3654,7 +3660,7 @@ CanvasItemEditorPlugin::~CanvasItemEditorPlugin()
void CanvasItemEditorViewport::_on_mouse_exit() {
- if (selector->is_hidden()){
+ if (!selector->is_visible()){
_remove_preview();
}
}
@@ -3734,7 +3740,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String& p_targe
}
void CanvasItemEditorViewport::_create_nodes(Node* parent, Node* child, String& path, const Point2& p_point) {
- child->set_name(path.get_file().basename());
+ child->set_name(path.get_file().get_basename());
Ref<ImageTexture> texture=Ref<ImageTexture> ( ResourceCache::get(path)->cast_to<ImageTexture>() );
Size2 texture_size = texture->get_size();
@@ -3767,7 +3773,7 @@ void CanvasItemEditorViewport::_create_nodes(Node* parent, Node* child, String&
editor_data->get_undo_redo().add_do_property(child,property,texture);
// make visible for certain node type
- if (default_type=="Patch9Frame") {
+ if (default_type=="Patch9Rect") {
editor_data->get_undo_redo().add_do_property(child,"rect/size",texture_size);
} else if (default_type=="Polygon2D") {
PoolVector<Vector2> list;
@@ -3785,7 +3791,7 @@ void CanvasItemEditorViewport::_create_nodes(Node* parent, Node* child, String&
}
Transform2D trans=canvas->get_canvas_transform();
Point2 target_pos = (p_point-trans.get_origin())/trans.get_scale().x-pos;
- if (default_type=="Polygon2D" || default_type=="TouchScreenButton" || default_type=="TextureFrame" || default_type=="Patch9Frame") {
+ if (default_type=="Polygon2D" || default_type=="TouchScreenButton" || default_type=="TextureRect" || default_type=="Patch9Rect") {
target_pos -= texture_size/2;
}
editor_data->get_undo_redo().add_do_method(child,"set_pos",target_pos);
@@ -3857,8 +3863,8 @@ void CanvasItemEditorViewport::_perform_drop_data(){
else if (default_type=="Particles2D") child=memnew(Particles2D);
else if (default_type=="Polygon2D") child=memnew(Polygon2D);
else if (default_type=="TouchScreenButton") child=memnew(TouchScreenButton);
- else if (default_type=="TextureFrame") child=memnew(TextureFrame);
- else if (default_type=="Patch9Frame") child=memnew(Patch9Frame);
+ else if (default_type=="TextureRect") child=memnew(TextureRect);
+ else if (default_type=="Patch9Rect") child=memnew(NinePatchRect);
else child=memnew(Sprite); // default
_create_nodes(target_node, child, path, drop_pos);
@@ -3875,7 +3881,7 @@ void CanvasItemEditorViewport::_perform_drop_data(){
if (error_files.size()>0) {
String files_str;
for (int i=0;i<error_files.size();i++) {
- files_str += error_files[i].get_file().basename() + ",";
+ files_str += error_files[i].get_file().get_basename() + ",";
}
files_str=files_str.substr(0,files_str.length()-1);
accept->get_ok()->set_text(TTR("Ugh"));
@@ -3978,9 +3984,9 @@ void CanvasItemEditorViewport::_notification(int p_what) {
}
void CanvasItemEditorViewport::_bind_methods() {
- ClassDB::bind_method(_MD("_on_select_type"),&CanvasItemEditorViewport::_on_select_type);
- ClassDB::bind_method(_MD("_on_change_type"),&CanvasItemEditorViewport::_on_change_type);
- ClassDB::bind_method(_MD("_on_mouse_exit"),&CanvasItemEditorViewport::_on_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_on_select_type"),&CanvasItemEditorViewport::_on_select_type);
+ ClassDB::bind_method(D_METHOD("_on_change_type"),&CanvasItemEditorViewport::_on_change_type);
+ ClassDB::bind_method(D_METHOD("_on_mouse_exit"),&CanvasItemEditorViewport::_on_mouse_exit);
}
CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor* p_canvas) {
@@ -3992,8 +3998,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
types.push_back("Polygon2D");
types.push_back("TouchScreenButton");
// Control
- types.push_back("TextureFrame");
- types.push_back("Patch9Frame");
+ types.push_back("TextureRect");
+ types.push_back("Patch9Rect");
target_node=NULL;
editor=p_node;
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.h b/tools/editor/plugins/canvas_item_editor_plugin.h
index f4f628fe28..dac8af5ae9 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.h
+++ b/tools/editor/plugins/canvas_item_editor_plugin.h
@@ -454,8 +454,8 @@ public:
};
-class CanvasItemEditorViewport : public VBoxContainer {
- GDCLASS( CanvasItemEditorViewport, VBoxContainer );
+class CanvasItemEditorViewport : public Control {
+ GDCLASS( CanvasItemEditorViewport, Control );
String default_type;
Vector<String> types;
diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 263d96ecdf..1149cdcfe1 100644
--- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -268,7 +268,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
}
- } if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
@@ -398,9 +398,9 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) {
void CollisionPolygon2DEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&CollisionPolygon2DEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&CollisionPolygon2DEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_node_removed"),&CollisionPolygon2DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&CollisionPolygon2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&CollisionPolygon2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&CollisionPolygon2DEditor::_node_removed);
}
diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
index 010d6f1a47..406c12b00a 100644
--- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_polygon_editor_plugin.h"
+
#include "spatial_editor_plugin.h"
#include "os/file_access.h"
#include "tools/editor/editor_settings.h"
@@ -529,9 +530,9 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) {
void CollisionPolygonEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&CollisionPolygonEditor::_menu_option);
- ClassDB::bind_method(_MD("_polygon_draw"),&CollisionPolygonEditor::_polygon_draw);
- ClassDB::bind_method(_MD("_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);
}
diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 626ca9e132..a05eeb7a27 100644
--- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -29,7 +29,6 @@
#include "collision_shape_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
-
#include "scene/resources/segment_shape_2d.h"
#include "scene/resources/shape_line_2d.h"
#include "scene/resources/circle_shape_2d.h"
diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp
index 90ec1e9f4e..82674fabb8 100644
--- a/tools/editor/plugins/color_ramp_editor_plugin.cpp
+++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "color_ramp_editor_plugin.h"
+
#include "spatial_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
@@ -106,6 +107,6 @@ ColorRampEditorPlugin::~ColorRampEditorPlugin(){
}
void ColorRampEditorPlugin::_bind_methods() {
- ClassDB::bind_method(_MD("ramp_changed"),&ColorRampEditorPlugin::_ramp_changed);
- ClassDB::bind_method(_MD("undo_redo_color_ramp","offsets","colors"),&ColorRampEditorPlugin::_undo_redo_color_ramp);
+ ClassDB::bind_method(D_METHOD("ramp_changed"),&ColorRampEditorPlugin::_ramp_changed);
+ ClassDB::bind_method(D_METHOD("undo_redo_color_ramp","offsets","colors"),&ColorRampEditorPlugin::_undo_redo_color_ramp);
}
diff --git a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
index da5c07221e..563b8298eb 100644
--- a/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
+++ b/tools/editor/plugins/cube_grid_theme_editor_plugin.cpp
@@ -203,7 +203,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
it->create_from_image(img);
p_library->set_item_preview(id,it);
-// print_line("loaded image, size: "+rtos(m)+" dist: "+rtos(dist)+" empty?"+itos(img.empty())+" w: "+itos(it->get_width())+" h: "+itos(it->get_height()));
+ //print_line("loaded image, size: "+rtos(m)+" dist: "+rtos(dist)+" empty?"+itos(img.empty())+" w: "+itos(it->get_width())+" h: "+itos(it->get_height()));
VS::get_singleton()->free(inst);
}
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index 9dcfc2fa94..5d9b281874 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -27,12 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_preview_plugins.h"
+
#include "io/resource_loader.h"
#include "tools/editor/editor_settings.h"
#include "io/file_access_memory.h"
#include "os/os.h"
#include "scene/resources/material.h"
-#include "scene/resources/sample.h"
+//#include "scene/resources/sample.h"
#include "scene/resources/mesh.h"
#include "scene/resources/bit_mask.h"
#include "tools/editor/editor_scale.h"
@@ -248,7 +249,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES& p_from) {
VS::get_singleton()->viewport_queue_screen_capture(viewport);
VS::get_singleton()->viewport_set_render_target_update_mode(viewport,VS::RENDER_TARGET_UPDATE_ONCE); //once used for capture
-// print_line("queue capture!");
+ //print_line("queue capture!");
Image img;
int timeout=1000;
@@ -521,7 +522,7 @@ EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() {
}
///////////////////////////////////////////////////////////////////
-
+#if 0
bool EditorSamplePreviewPlugin::handles(const String& p_type) const {
return ClassDB::is_type(p_type,"Sample");
@@ -788,7 +789,7 @@ EditorSamplePreviewPlugin::EditorSamplePreviewPlugin() {
}
-
+#endif
///////////////////////////////////////////////////////////////////////////
bool EditorMeshPreviewPlugin::handles(const String& p_type) const {
@@ -825,7 +826,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES& p_from) {
VS::get_singleton()->viewport_queue_screen_capture(viewport);
VS::get_singleton()->viewport_set_render_target_update_mode(viewport,VS::RENDER_TARGET_UPDATE_ONCE); //once used for capture
-// print_line("queue capture!");
+ //print_line("queue capture!");
Image img;
int timeout=1000;
@@ -867,7 +868,7 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
camera = VS::get_singleton()->camera_create();
VS::get_singleton()->viewport_attach_camera(viewport,camera);
VS::get_singleton()->camera_set_transform(camera,Transform(Matrix3(),Vector3(0,0,3)));
-// VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
+ //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
VS::get_singleton()->camera_set_orthogonal(camera,1.0,0.01,1000.0);
light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
@@ -881,7 +882,7 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
VS::get_singleton()->instance_set_transform(light_instance2,Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
-// sphere = VS::get_singleton()->mesh_create();
+ //sphere = VS::get_singleton()->mesh_create();
mesh_instance = VS::get_singleton()->instance_create();
VS::get_singleton()->instance_set_scenario(mesh_instance,scenario);
diff --git a/tools/editor/plugins/editor_preview_plugins.h b/tools/editor/plugins/editor_preview_plugins.h
index 3c1689e61e..078e4cf8b5 100644
--- a/tools/editor/plugins/editor_preview_plugins.h
+++ b/tools/editor/plugins/editor_preview_plugins.h
@@ -94,7 +94,7 @@ public:
EditorScriptPreviewPlugin();
};
-
+#if 0
class EditorSamplePreviewPlugin : public EditorResourcePreviewGenerator {
public:
@@ -104,7 +104,7 @@ public:
EditorSamplePreviewPlugin();
};
-
+#endif
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
RID scenario;
diff --git a/tools/editor/plugins/gi_probe_editor_plugin.cpp b/tools/editor/plugins/gi_probe_editor_plugin.cpp
index f550b7972a..925ac8ef11 100644
--- a/tools/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* gi_probe_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "gi_probe_editor_plugin.h"
@@ -44,7 +72,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
editor=p_node;
bake = memnew( Button );
bake->set_icon(editor->get_gui_base()->get_icon("BakedLight","EditorIcons"));
- bake->hide();;
+ bake->hide();
bake->connect("pressed",this,"_bake");
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,bake);
gi_probe=NULL;
@@ -52,6 +80,4 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) {
GIProbeEditorPlugin::~GIProbeEditorPlugin() {
-
- memdelete(bake);
}
diff --git a/tools/editor/plugins/gi_probe_editor_plugin.h b/tools/editor/plugins/gi_probe_editor_plugin.h
index 8d2ec17d2f..35e0b93aae 100644
--- a/tools/editor/plugins/gi_probe_editor_plugin.h
+++ b/tools/editor/plugins/gi_probe_editor_plugin.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* gi_probe_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 GIPROBEEDITORPLUGIN_H
#define GIPROBEEDITORPLUGIN_H
diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
index f6a51632a0..cc8bb63d78 100644
--- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -283,7 +283,7 @@ bool LightOccluder2DEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
}
- } if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
@@ -427,10 +427,10 @@ void LightOccluder2DEditor::_create_poly() {
void LightOccluder2DEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&LightOccluder2DEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&LightOccluder2DEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_node_removed"),&LightOccluder2DEditor::_node_removed);
- ClassDB::bind_method(_MD("_create_poly"),&LightOccluder2DEditor::_create_poly);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&LightOccluder2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&LightOccluder2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&LightOccluder2DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_create_poly"),&LightOccluder2DEditor::_create_poly);
}
diff --git a/tools/editor/plugins/line_2d_editor_plugin.cpp b/tools/editor/plugins/line_2d_editor_plugin.cpp
new file mode 100644
index 0000000000..c90d1c4754
--- /dev/null
+++ b/tools/editor/plugins/line_2d_editor_plugin.cpp
@@ -0,0 +1,283 @@
+#include "line_2d_editor_plugin.h"
+
+#include "canvas_item_editor_plugin.h"
+#include "os/file_access.h"
+#include "tools/editor/editor_settings.h"
+#include "os/keyboard.h"
+
+
+//----------------------------------------------------------------------------
+// Line2DEditor
+//----------------------------------------------------------------------------
+
+void Line2DEditor::_node_removed(Node *p_node) {
+ if(p_node == node) {
+ node=NULL;
+ hide();
+ }
+}
+
+void Line2DEditor::_notification(int p_what) {
+ switch(p_what) {
+ case NOTIFICATION_VISIBILITY_CHANGED:
+ // This widget is not a child but should have the same visibility state
+ base_hb->set_visible(is_visible());
+ break;
+ }
+}
+
+Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpoint, bool alt) {
+ Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
+ return !alt? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint))
+ : node->get_global_transform().affine_inverse().xform(
+ canvas_item_editor->snap_point(
+ canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)) );
+}
+
+int Line2DEditor::get_point_index_at(Vector2 gpos) {
+ ERR_FAIL_COND_V(node == 0, -1);
+
+ real_t grab_treshold = EDITOR_DEF("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) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+bool Line2DEditor::forward_gui_input(const InputEvent& p_event) {
+
+ if (!node)
+ return false;
+
+ if (!node->is_visible())
+ return false;
+
+ switch(p_event.type) {
+
+ case InputEvent::MOUSE_BUTTON: {
+
+ const InputEventMouseButton &mb = p_event.mouse_button;
+
+ Vector2 gpoint = Point2(mb.x,mb.y);
+ Vector2 cpoint = mouse_to_local_pos(gpoint, mb.mod.alt);
+
+ if(mb.pressed && _dragging == false) {
+ int i = get_point_index_at(gpoint);
+ if(i != -1) {
+ if (mb.button_index == BUTTON_LEFT && !mb.mod.shift && mode == MODE_EDIT) {
+ _dragging = true;
+ action_point = i;
+ moving_from = node->get_point_pos(i);
+ moving_screen_from = gpoint;
+ }
+ else if((mb.button_index == BUTTON_RIGHT && mode == MODE_EDIT) || (mb.button_index == BUTTON_LEFT && mode == MODE_DELETE)) {
+ undo_redo->create_action(TTR("Remove Point from Line2D"));
+ undo_redo->add_do_method(node, "remove_point", i);
+ undo_redo->add_undo_method(node, "add_point", node->get_point_pos(i), i);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->commit_action();
+ }
+ return true;
+ }
+ }
+
+ if(mb.pressed && mb.button_index == BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {
+
+ undo_redo->create_action(TTR("Add Point to Line2D"));
+ undo_redo->add_do_method(node, "add_point", cpoint);
+ undo_redo->add_undo_method(node, "remove_point", node->get_point_count());
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->commit_action();
+
+ _dragging = true;
+ action_point = node->get_point_count()-1;
+ moving_from = node->get_point_pos(action_point);
+ moving_screen_from = gpoint;
+
+ canvas_item_editor->get_viewport_control()->update();
+
+ return true;
+ }
+
+ if(!mb.pressed && mb.button_index == BUTTON_LEFT && _dragging) {
+ undo_redo->create_action(TTR("Move Point in Line2D"));
+ undo_redo->add_do_method(node, "set_point_pos", action_point, cpoint);
+ undo_redo->add_undo_method(node, "set_point_pos", action_point, moving_from);
+ undo_redo->add_do_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(), "update");
+ undo_redo->commit_action();
+ _dragging = false;
+ return true;
+ }
+ }
+ break;
+
+ case InputEvent::MOUSE_MOTION: {
+ if (_dragging) {
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
+ Vector2 cpoint = mouse_to_local_pos(Vector2(mm.x, mm.y), mm.mod.alt);
+ node->set_point_pos(action_point,cpoint);
+ canvas_item_editor->get_viewport_control()->update();
+ return true;
+ }
+ }
+ break;
+ }
+
+ return false;
+}
+
+void Line2DEditor::_canvas_draw() {
+
+ if (!node)
+ return;
+
+ if (!node->is_visible())
+ return;
+
+ Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
+ Size2 handle_size = handle->get_size();
+
+ int len = node->get_point_count();
+ Control *vpc = canvas_item_editor->get_viewport_control();
+
+ for(int i=0; i < len; ++i) {
+ Vector2 point = xform.xform(node->get_point_pos(i));
+ vpc->draw_texture_rect(handle, Rect2(point - handle_size * 0.5, handle_size), false);
+ }
+}
+
+void Line2DEditor::_node_visibility_changed() {
+ if (!node)
+ return;
+ canvas_item_editor->get_viewport_control()->update();
+}
+
+void Line2DEditor::edit(Node *p_line2d) {
+
+ if (!canvas_item_editor)
+ canvas_item_editor = CanvasItemEditor::get_singleton();
+
+ if (p_line2d) {
+ node = p_line2d->cast_to<Line2D>();
+ if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw");
+ if (!node->is_connected("visibility_changed", this, "_node_visibility_changed"))
+ node->connect("visibility_changed", this, "_node_visibility_changed");
+ }
+ else {
+ if (canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw"))
+ canvas_item_editor->get_viewport_control()->disconnect("draw", this, "_canvas_draw");
+ // node may have been deleted at this point
+ if (node && node->is_connected("visibility_changed", this, "_node_visibility_changed"))
+ node->disconnect("visibility_changed", this, "_node_visibility_changed");
+ node = NULL;
+ }
+}
+
+void Line2DEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_canvas_draw"), &Line2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_visibility_changed"), &Line2DEditor::_node_visibility_changed);
+ ClassDB::bind_method(D_METHOD("_mode_selected"), &Line2DEditor::_mode_selected);
+}
+
+void Line2DEditor::_mode_selected(int p_mode) {
+ for(unsigned int i = 0; i < _MODE_COUNT; ++i) {
+ toolbar_buttons[i]->set_pressed(i == p_mode);
+ }
+ mode = Mode(p_mode);
+}
+
+Line2DEditor::Line2DEditor(EditorNode *p_editor) {
+
+ canvas_item_editor = NULL;
+ editor = p_editor;
+ undo_redo = editor->get_undo_redo();
+
+ _dragging = false;
+
+ base_hb = memnew( HBoxContainer );
+ CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb);
+
+ sep = memnew( VSeparator);
+ base_hb->add_child(sep);
+
+ {
+ ToolButton * b = memnew(ToolButton);
+ b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
+ b->set_toggle_mode(true);
+ b->set_focus_mode(Control::FOCUS_NONE);
+ b->set_tooltip(
+ TTR("Select Points")+"\n"
+ + TTR("Shift+Drag: Select Control Points")+"\n"
+ + keycode_get_string(KEY_MASK_CMD)
+ + TTR("Click: Add Point")+"\n"
+ + TTR("Right Click: Delete Point"));
+ b->connect("pressed", this, "_mode_selected", varray(MODE_EDIT));
+ toolbar_buttons[MODE_EDIT] = b;
+ base_hb->add_child(b);
+ }
+
+ {
+ ToolButton * b = memnew(ToolButton);
+ b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
+ b->set_toggle_mode(true);
+ b->set_focus_mode(Control::FOCUS_NONE);
+ b->set_tooltip(TTR("Add Point (in empty space)")+"\n"+TTR("Split Segment (in line)"));
+ b->connect("pressed", this, "_mode_selected", varray(MODE_CREATE));
+ toolbar_buttons[MODE_CREATE] = b;
+ base_hb->add_child(b);
+ }
+
+ {
+ ToolButton * b = memnew( ToolButton );
+ b->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
+ b->set_toggle_mode(true);
+ b->set_focus_mode(Control::FOCUS_NONE);
+ b->set_tooltip(TTR("Delete Point"));
+ b->connect("pressed", this, "_mode_selected", varray(MODE_DELETE));
+ toolbar_buttons[MODE_DELETE] = b;
+ base_hb->add_child(b);
+ }
+
+ base_hb->hide();
+ hide();
+
+ _mode_selected(MODE_CREATE);
+}
+
+//----------------------------------------------------------------------------
+// Line2DEditorPlugin
+//----------------------------------------------------------------------------
+
+void Line2DEditorPlugin::edit(Object *p_object) {
+ line2d_editor->edit(p_object->cast_to<Node>());
+}
+
+bool Line2DEditorPlugin::handles(Object *p_object) const {
+ return p_object->is_class("Line2D");
+}
+
+void Line2DEditorPlugin::make_visible(bool p_visible) {
+ line2d_editor->set_visible(p_visible);
+ if(p_visible == false)
+ line2d_editor->edit(NULL);
+}
+
+Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) {
+ editor=p_node;
+ line2d_editor = memnew( Line2DEditor(p_node) );
+ CanvasItemEditor::get_singleton()->add_control_to_menu_panel(line2d_editor);
+ line2d_editor->hide();
+}
+
+
diff --git a/tools/editor/plugins/line_2d_editor_plugin.h b/tools/editor/plugins/line_2d_editor_plugin.h
new file mode 100644
index 0000000000..231f4c6ca7
--- /dev/null
+++ b/tools/editor/plugins/line_2d_editor_plugin.h
@@ -0,0 +1,90 @@
+#ifndef LINE_2D_EDITOR_PLUGIN_H
+#define LINE_2D_EDITOR_PLUGIN_H
+
+#include "tools/editor/editor_plugin.h"
+#include "tools/editor/editor_node.h"
+#include "scene/2d/path_2d.h"
+#include "scene/gui/tool_button.h"
+#include "scene/gui/button_group.h"
+#include "scene/2d/line_2d.h"
+
+
+class CanvasItemEditor;
+
+class Line2DEditor : public HBoxContainer {
+ GDCLASS(Line2DEditor, HBoxContainer)
+
+public:
+ bool forward_gui_input(const InputEvent& p_event);
+ void edit(Node *p_line2d);
+ Line2DEditor(EditorNode *p_editor);
+
+protected:
+ void _node_removed(Node *p_node);
+ void _notification(int p_what);
+
+ Vector2 mouse_to_local_pos(Vector2 mpos);
+
+ static void _bind_methods();
+
+private:
+ void _mode_selected(int p_mode);
+ void _canvas_draw();
+ void _node_visibility_changed();
+
+ int get_point_index_at(Vector2 gpos);
+ Vector2 mouse_to_local_pos(Vector2 gpos, bool alt);
+
+ UndoRedo *undo_redo;
+
+ CanvasItemEditor *canvas_item_editor;
+ EditorNode *editor;
+ Panel *panel;
+ Line2D *node;
+
+ HBoxContainer *base_hb;
+ Separator *sep;
+
+ enum Mode {
+ MODE_CREATE = 0,
+ MODE_EDIT,
+ MODE_DELETE,
+ _MODE_COUNT
+ };
+
+ Mode mode;
+ ToolButton* toolbar_buttons[_MODE_COUNT];
+
+ bool _dragging;
+ int action_point;
+ Point2 moving_from;
+ Point2 moving_screen_from;
+};
+
+class Line2DEditorPlugin : public EditorPlugin {
+ GDCLASS( Line2DEditorPlugin, EditorPlugin )
+
+public:
+ virtual bool forward_canvas_gui_input(
+ const Transform2D& p_canvas_xform,
+ const InputEvent& p_event)
+ {
+ return line2d_editor->forward_gui_input(p_event);
+ }
+
+ virtual String get_name() const { return "Line2D"; }
+ bool has_main_screen() const { return false; }
+ virtual void edit(Object *p_node);
+ virtual bool handles(Object *p_node) const;
+ virtual void make_visible(bool p_visible);
+
+ Line2DEditorPlugin(EditorNode *p_node);
+
+private:
+ Line2DEditor *line2d_editor;
+ EditorNode *editor;
+
+};
+
+#endif // LINE_2D_EDITOR_PLUGIN_H
+
diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp
index d5ddd3804b..cdf7c70d39 100644
--- a/tools/editor/plugins/material_editor_plugin.cpp
+++ b/tools/editor/plugins/material_editor_plugin.cpp
@@ -1,4 +1,33 @@
+/*************************************************************************/
+/* material_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "material_editor_plugin.h"
+
#include "scene/main/viewport.h"
#if 0
@@ -93,8 +122,8 @@ void MaterialEditor::_button_pressed(Node* p_button) {
void MaterialEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&MaterialEditor::_gui_input);
- ClassDB::bind_method(_MD("_button_pressed"),&MaterialEditor::_button_pressed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&MaterialEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_button_pressed"),&MaterialEditor::_button_pressed);
}
@@ -355,11 +384,11 @@ void MaterialEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
material_editor->show();
-// material_editor->set_process(true);
+ //material_editor->set_process(true);
} else {
material_editor->hide();
-// material_editor->set_process(false);
+ //material_editor->set_process(false);
}
}
diff --git a/tools/editor/plugins/material_editor_plugin.h b/tools/editor/plugins/material_editor_plugin.h
index 556e56e66b..5daae124e0 100644
--- a/tools/editor/plugins/material_editor_plugin.h
+++ b/tools/editor/plugins/material_editor_plugin.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* material_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 MATERIAL_EDITOR_PLUGIN_H
#define MATERIAL_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp
index db96a60808..93f417247e 100644
--- a/tools/editor/plugins/mesh_editor_plugin.cpp
+++ b/tools/editor/plugins/mesh_editor_plugin.cpp
@@ -136,8 +136,8 @@ void MeshEditor::_button_pressed(Node* p_button) {
void MeshEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&MeshEditor::_gui_input);
- ClassDB::bind_method(_MD("_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);
}
@@ -218,11 +218,11 @@ void MeshEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
mesh_editor->show();
-// mesh_editor->set_process(true);
+ //mesh_editor->set_process(true);
} else {
mesh_editor->hide();
-// mesh_editor->set_process(false);
+ //mesh_editor->set_process(false);
}
}
diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.cpp b/tools/editor/plugins/mesh_instance_editor_plugin.cpp
index de29991057..322e212534 100644
--- a/tools/editor/plugins/mesh_instance_editor_plugin.cpp
+++ b/tools/editor/plugins/mesh_instance_editor_plugin.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* mesh_instance_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "mesh_instance_editor_plugin.h"
#include "scene/3d/physics_body.h"
diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.h b/tools/editor/plugins/mesh_instance_editor_plugin.h
index 23dcbfc9b1..441d4d1d3f 100644
--- a/tools/editor/plugins/mesh_instance_editor_plugin.h
+++ b/tools/editor/plugins/mesh_instance_editor_plugin.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* mesh_instance_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 MESH_INSTANCE_EDITOR_PLUGIN_H
#define MESH_INSTANCE_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp
index cce1c52215..6259ddf473 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.cpp
+++ b/tools/editor/plugins/multimesh_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "multimesh_editor_plugin.h"
+
#include "scene/gui/box_container.h"
#include "scene/3d/mesh_instance.h"
#include "spatial_editor_plugin.h"
@@ -177,7 +178,7 @@ void MultiMeshEditor::_populate() {
Map<float,int> triangle_area_map;
for(int i=0;i<facecount;i++) {
- float area = r[i].get_area();;
+ float area = r[i].get_area();
if (area<CMP_EPSILON)
continue;
triangle_area_map[area_accum]=i;
@@ -215,7 +216,7 @@ void MultiMeshEditor::_populate() {
for(int i=0;i<instance_count;i++) {
- float areapos = Math::random(0,area_accum);
+ float areapos = Math::random(0.0f,area_accum);
Map<float,int>::Element *E = triangle_area_map.find_closest(areapos);
ERR_FAIL_COND(!E)
diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
index b2d62af7bb..dfc9b2d6e2 100644
--- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -127,7 +127,7 @@ bool NavigationPolygonEditor::forward_gui_input(const InputEvent& p_event) {
create_nav->set_text("No NavigationPolygon resource on this node.\nCreate and assign one?");
create_nav->popup_centered_minsize();
}
- return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);;
+ return (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1);
}
@@ -312,7 +312,7 @@ bool NavigationPolygonEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
}
- } if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
int closest_outline=-1;
int closest_idx=-1;
@@ -477,10 +477,10 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) {
void NavigationPolygonEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&NavigationPolygonEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&NavigationPolygonEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_node_removed"),&NavigationPolygonEditor::_node_removed);
- ClassDB::bind_method(_MD("_create_nav"),&NavigationPolygonEditor::_create_nav);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&NavigationPolygonEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&NavigationPolygonEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&NavigationPolygonEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_create_nav"),&NavigationPolygonEditor::_create_nav);
}
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp
index 331a958518..1efdbe9e68 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "particles_2d_editor_plugin.h"
+
#include "canvas_item_editor_plugin.h"
#include "io/image_loader.h"
#include "scene/gui/separator.h"
@@ -152,8 +152,8 @@ void Particles2DEditorPlugin::_notification(int p_what) {
void Particles2DEditorPlugin::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_callback"),&Particles2DEditorPlugin::_menu_callback);
- ClassDB::bind_method(_MD("_file_selected"),&Particles2DEditorPlugin::_file_selected);
+ ClassDB::bind_method(D_METHOD("_menu_callback"),&Particles2DEditorPlugin::_menu_callback);
+ ClassDB::bind_method(D_METHOD("_file_selected"),&Particles2DEditorPlugin::_file_selected);
}
diff --git a/tools/editor/plugins/particles_editor_plugin.cpp b/tools/editor/plugins/particles_editor_plugin.cpp
index 382dc29c61..fd5ec5b5b9 100644
--- a/tools/editor/plugins/particles_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_editor_plugin.cpp
@@ -212,7 +212,7 @@ void ParticlesEditor::_generate_emission_points() {
for(int i=0;i<geometry.size();i++) {
- float area = geometry[i].get_area();;
+ float area = geometry[i].get_area();
if (area<CMP_EPSILON)
continue;
triangle_area_map[area_accum]=i;
diff --git a/tools/editor/plugins/path_2d_editor_plugin.cpp b/tools/editor/plugins/path_2d_editor_plugin.cpp
index 69be969c51..88dded72ae 100644
--- a/tools/editor/plugins/path_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/path_2d_editor_plugin.cpp
@@ -38,7 +38,7 @@ void Path2DEditor::_notification(int p_what) {
case NOTIFICATION_READY: {
-// button_create->set_icon( get_icon("Edit","EditorIcons"));
+ //button_create->set_icon( get_icon("Edit","EditorIcons"));
//button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
//set_pressed_button(button_edit);
//button_edit->set_pressed(true);
@@ -67,7 +67,7 @@ bool Path2DEditor::forward_gui_input(const InputEvent& p_event) {
if (!node)
return false;
- if (!node->is_visible())
+ if (!node->is_visible_in_tree())
return false;
if (!node->get_curve().is_valid())
@@ -475,7 +475,7 @@ void Path2DEditor::_canvas_draw() {
if (!node)
return ;
- if (!node->is_visible())
+ if (!node->is_visible_in_tree())
return;
if (!node->get_curve().is_valid())
@@ -550,10 +550,10 @@ void Path2DEditor::edit(Node *p_path2d) {
void Path2DEditor::_bind_methods() {
- //ClassDB::bind_method(_MD("_menu_option"),&Path2DEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&Path2DEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_node_visibility_changed"),&Path2DEditor::_node_visibility_changed);
- ClassDB::bind_method(_MD("_mode_selected"),&Path2DEditor::_mode_selected);
+ //ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&Path2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_node_visibility_changed"),&Path2DEditor::_node_visibility_changed);
+ ClassDB::bind_method(D_METHOD("_mode_selected"),&Path2DEditor::_mode_selected);
}
void Path2DEditor::_mode_selected(int p_mode) {
diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp
index a69de2e78d..a3df39fdaa 100644
--- a/tools/editor/plugins/path_editor_plugin.cpp
+++ b/tools/editor/plugins/path_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "path_editor_plugin.h"
+
#include "spatial_editor_plugin.h"
#include "scene/resources/curve.h"
#include "os/keyboard.h"
@@ -376,7 +377,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve
ur->create_action(TTR("Split Path"));
ur->add_do_method(c.ptr(),"add_point",closest_seg_point,Vector3(),Vector3(),closest_seg+1);
ur->add_undo_method(c.ptr(),"remove_point",closest_seg+1);
- ur->commit_action();;
+ ur->commit_action();
return true;
} else {
@@ -396,7 +397,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve
ur->create_action(TTR("Add Point to Curve"));
ur->add_do_method(c.ptr(),"add_point",it.xform(inters),Vector3(),Vector3(),-1);
ur->add_undo_method(c.ptr(),"remove_point",c->get_point_count());
- ur->commit_action();;
+ ur->commit_action();
return true;
}
@@ -449,7 +450,7 @@ void PathEditorPlugin::edit(Object *p_object) {
pre->get_curve()->emit_signal("changed");
}
}
-// collision_polygon_editor->edit(p_object->cast_to<Node>());
+ //collision_polygon_editor->edit(p_object->cast_to<Node>());
}
bool PathEditorPlugin::handles(Object *p_object) const {
@@ -516,8 +517,8 @@ void PathEditorPlugin::_notification(int p_what) {
void PathEditorPlugin::_bind_methods() {
- ClassDB::bind_method(_MD("_mode_changed"),&PathEditorPlugin::_mode_changed);
- ClassDB::bind_method(_MD("_close_curve"),&PathEditorPlugin::_close_curve);
+ ClassDB::bind_method(D_METHOD("_mode_changed"),&PathEditorPlugin::_mode_changed);
+ ClassDB::bind_method(D_METHOD("_close_curve"),&PathEditorPlugin::_close_curve);
}
PathEditorPlugin* PathEditorPlugin::singleton=NULL;
@@ -543,7 +544,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
path_thin_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
path_thin_material->set_flag(Material::FLAG_UNSHADED,true);
-// SpatialEditor::get_singleton()->add_gizmo_plugin(this);
+ //SpatialEditor::get_singleton()->add_gizmo_plugin(this);
sep = memnew( VSeparator);
sep->hide();
diff --git a/tools/editor/plugins/path_editor_plugin.h b/tools/editor/plugins/path_editor_plugin.h
index e446dfa7c7..79e978dc1d 100644
--- a/tools/editor/plugins/path_editor_plugin.h
+++ b/tools/editor/plugins/path_editor_plugin.h
@@ -83,7 +83,7 @@ public:
Ref<FixedSpatialMaterial> path_thin_material;
virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event);
-// virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
+ //virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
virtual String get_name() const { return "Path"; }
bool has_main_screen() const { return false; }
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
index ee625cf703..efb3e6c4bc 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -26,8 +26,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "polygon_2d_editor_plugin.h"
+
#include "canvas_item_editor_plugin.h"
#include "os/file_access.h"
#include "tools/editor/editor_settings.h"
@@ -385,7 +385,7 @@ bool Polygon2DEditor::forward_gui_input(const InputEvent& p_event) {
return true;
}
}
- } if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
+ } else if (mb.button_index==BUTTON_RIGHT && mb.pressed && edited_point==-1) {
@@ -775,19 +775,19 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
void Polygon2DEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&Polygon2DEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&Polygon2DEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_uv_mode"),&Polygon2DEditor::_uv_mode);
- ClassDB::bind_method(_MD("_uv_draw"),&Polygon2DEditor::_uv_draw);
- ClassDB::bind_method(_MD("_uv_input"),&Polygon2DEditor::_uv_input);
- ClassDB::bind_method(_MD("_uv_scroll_changed"),&Polygon2DEditor::_uv_scroll_changed);
- ClassDB::bind_method(_MD("_node_removed"),&Polygon2DEditor::_node_removed);
- ClassDB::bind_method(_MD("_set_use_snap"),&Polygon2DEditor::_set_use_snap);
- ClassDB::bind_method(_MD("_set_show_grid"),&Polygon2DEditor::_set_show_grid);
- ClassDB::bind_method(_MD("_set_snap_off_x"),&Polygon2DEditor::_set_snap_off_x);
- ClassDB::bind_method(_MD("_set_snap_off_y"),&Polygon2DEditor::_set_snap_off_y);
- ClassDB::bind_method(_MD("_set_snap_step_x"),&Polygon2DEditor::_set_snap_step_x);
- ClassDB::bind_method(_MD("_set_snap_step_y"),&Polygon2DEditor::_set_snap_step_y);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&Polygon2DEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&Polygon2DEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_uv_mode"),&Polygon2DEditor::_uv_mode);
+ ClassDB::bind_method(D_METHOD("_uv_draw"),&Polygon2DEditor::_uv_draw);
+ ClassDB::bind_method(D_METHOD("_uv_input"),&Polygon2DEditor::_uv_input);
+ ClassDB::bind_method(D_METHOD("_uv_scroll_changed"),&Polygon2DEditor::_uv_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&Polygon2DEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_set_use_snap"),&Polygon2DEditor::_set_use_snap);
+ ClassDB::bind_method(D_METHOD("_set_show_grid"),&Polygon2DEditor::_set_show_grid);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_x"),&Polygon2DEditor::_set_snap_off_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_y"),&Polygon2DEditor::_set_snap_off_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_x"),&Polygon2DEditor::_set_snap_step_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_y"),&Polygon2DEditor::_set_snap_step_y);
}
@@ -949,7 +949,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) {
uv_mode_hb->add_child(sb_step_y);
uv_mode_hb->add_child( memnew( VSeparator ));
- uv_icon_zoom = memnew( TextureFrame );
+ uv_icon_zoom = memnew( TextureRect );
uv_mode_hb->add_child( uv_icon_zoom );
uv_zoom = memnew( HSlider );
uv_zoom->set_min(0.01);
diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.h b/tools/editor/plugins/polygon_2d_editor_plugin.h
index bff7f4c44c..6011ee1f87 100644
--- a/tools/editor/plugins/polygon_2d_editor_plugin.h
+++ b/tools/editor/plugins/polygon_2d_editor_plugin.h
@@ -77,7 +77,7 @@ class Polygon2DEditor : public HBoxContainer {
HScrollBar *uv_hscroll;
VScrollBar *uv_vscroll;
MenuButton *uv_menu;
- TextureFrame *uv_icon_zoom;
+ TextureRect *uv_icon_zoom;
Vector2 uv_draw_ofs;
float uv_draw_zoom;
diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
index fc6a548595..de2245d98f 100644
--- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -27,13 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_preloader_editor_plugin.h"
+
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/editor_settings.h"
-
-
void ResourcePreloaderEditor::_gui_input(InputEvent p_event) {
@@ -52,7 +51,7 @@ void ResourcePreloaderEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_READY) {
-// NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
+ //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
if (p_what==NOTIFICATION_DRAW) {
@@ -79,7 +78,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String>& p_paths)
}
- String basename = path.get_file().basename();
+ String basename = path.get_file().get_basename();
String name=basename;
int counter=1;
while(preloader->has_resource(name)) {
@@ -347,7 +346,7 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2& p_point,const Variant&
if (r->get_name()!="") {
basename=r->get_name();
} else if (r->get_path().is_resource_file()) {
- basename = r->get_path().basename();
+ basename = r->get_path().get_basename();
} else {
basename="Resource";
}
@@ -381,19 +380,19 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2& p_point,const Variant&
void ResourcePreloaderEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&ResourcePreloaderEditor::_gui_input);
- ClassDB::bind_method(_MD("_load_pressed"),&ResourcePreloaderEditor::_load_pressed);
- ClassDB::bind_method(_MD("_item_edited"),&ResourcePreloaderEditor::_item_edited);
- ClassDB::bind_method(_MD("_delete_pressed"),&ResourcePreloaderEditor::_delete_pressed);
- ClassDB::bind_method(_MD("_paste_pressed"),&ResourcePreloaderEditor::_paste_pressed);
- ClassDB::bind_method(_MD("_delete_confirm_pressed"),&ResourcePreloaderEditor::_delete_confirm_pressed);
- ClassDB::bind_method(_MD("_files_load_request"),&ResourcePreloaderEditor::_files_load_request);
- ClassDB::bind_method(_MD("_update_library"),&ResourcePreloaderEditor::_update_library);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&ResourcePreloaderEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_load_pressed"),&ResourcePreloaderEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_item_edited"),&ResourcePreloaderEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_delete_pressed"),&ResourcePreloaderEditor::_delete_pressed);
+ ClassDB::bind_method(D_METHOD("_paste_pressed"),&ResourcePreloaderEditor::_paste_pressed);
+ ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"),&ResourcePreloaderEditor::_delete_confirm_pressed);
+ ClassDB::bind_method(D_METHOD("_files_load_request"),&ResourcePreloaderEditor::_files_load_request);
+ ClassDB::bind_method(D_METHOD("_update_library"),&ResourcePreloaderEditor::_update_library);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &ResourcePreloaderEditor::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &ResourcePreloaderEditor::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &ResourcePreloaderEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ResourcePreloaderEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ResourcePreloaderEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &ResourcePreloaderEditor::drop_data_fw);
}
@@ -471,14 +470,14 @@ void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) {
//preloader_editor->show();
button->show();
editor->make_bottom_panel_item_visible(preloader_editor);
-// preloader_editor->set_process(true);
+ //preloader_editor->set_process(true);
} else {
- if (preloader_editor->is_visible())
+ if (preloader_editor->is_visible_in_tree())
editor->hide_bottom_panel();
button->hide();
//preloader_editor->hide();
-// preloader_editor->set_process(false);
+ //preloader_editor->set_process(false);
}
}
@@ -492,8 +491,8 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node)
button=editor->add_bottom_panel_item("ResourcePreloader",preloader_editor);
button->hide();
-// preloader_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
-// preloader_editor->set_margin( MARGIN_TOP, 120 );
+ //preloader_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
+ //preloader_editor->set_margin( MARGIN_TOP, 120 );
diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp
index f91af2fa60..797ee8e8ea 100644
--- a/tools/editor/plugins/rich_text_editor_plugin.cpp
+++ b/tools/editor/plugins/rich_text_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rich_text_editor_plugin.h"
+
#include "os/file_access.h"
#include "canvas_item_editor_plugin.h"
@@ -89,8 +90,8 @@ void RichTextEditor::_menu_option(int p_option) {
void RichTextEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_menu_option"),&RichTextEditor::_menu_option);
- ClassDB::bind_method(_MD("_file_selected"),&RichTextEditor::_file_selected);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&RichTextEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_file_selected"),&RichTextEditor::_file_selected);
}
diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp
index 12ec7c8260..9445095771 100644
--- a/tools/editor/plugins/sample_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_editor_plugin.cpp
@@ -28,8 +28,9 @@
/*************************************************************************/
#include "sample_editor_plugin.h"
+#if 0
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/editor_settings.h"
@@ -348,9 +349,9 @@ void SampleEditor::edit(Ref<Sample> p_sample) {
void SampleEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&SampleEditor::_gui_input);
- ClassDB::bind_method(_MD("_play_pressed"),&SampleEditor::_play_pressed);
- ClassDB::bind_method(_MD("_stop_pressed"),&SampleEditor::_stop_pressed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&SampleEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_play_pressed"),&SampleEditor::_play_pressed);
+ ClassDB::bind_method(D_METHOD("_stop_pressed"),&SampleEditor::_stop_pressed);
}
@@ -361,7 +362,7 @@ SampleEditor::SampleEditor() {
add_style_override("panel", get_stylebox("panel","Panel"));
library = Ref<SampleLibrary>(memnew(SampleLibrary));
player->set_sample_library(library);
- sample_texframe = memnew( TextureFrame );
+ sample_texframe = memnew( TextureRect );
add_child(sample_texframe);
sample_texframe->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
sample_texframe->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
@@ -422,11 +423,11 @@ void SampleEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
sample_editor->show();
-// sample_editor->set_process(true);
+ //sample_editor->set_process(true);
} else {
sample_editor->hide();
-// sample_editor->set_process(false);
+ //sample_editor->set_process(false);
}
}
@@ -447,4 +448,4 @@ SampleEditorPlugin::~SampleEditorPlugin()
{
}
-
+#endif
diff --git a/tools/editor/plugins/sample_editor_plugin.h b/tools/editor/plugins/sample_editor_plugin.h
index 59cdb10304..651cd14a84 100644
--- a/tools/editor/plugins/sample_editor_plugin.h
+++ b/tools/editor/plugins/sample_editor_plugin.h
@@ -29,7 +29,7 @@
#ifndef SAMPLE_EDITOR_PLUGIN_H
#define SAMPLE_EDITOR_PLUGIN_H
-
+#if 0
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/audio/sample_player.h"
@@ -47,7 +47,7 @@ class SampleEditor : public Panel {
Ref<ImageTexture> peakdisplay;
Ref<Sample> sample;
Ref<SampleLibrary> library;
- TextureFrame *sample_texframe;
+ TextureRect *sample_texframe;
Button *stop;
Button *play;
@@ -87,4 +87,6 @@ public:
};
+#endif
+
#endif // SAMPLE_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp
index a7ccfb6978..b996cafd1f 100644
--- a/tools/editor/plugins/sample_library_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_library_editor_plugin.cpp
@@ -26,10 +26,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+#if 0
#include "sample_library_editor_plugin.h"
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/editor_settings.h"
#include "scene/main/viewport.h"
#include "sample_editor_plugin.h"
@@ -58,7 +60,7 @@ void SampleLibraryEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_READY) {
-// NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
+ //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
if (p_what==NOTIFICATION_DRAW) {
@@ -81,7 +83,7 @@ void SampleLibraryEditor::_file_load_request(const PoolVector<String>& p_path) {
dialog->popup_centered_minsize();
return; ///beh should show an error i guess
}
- String basename = path.get_file().basename();
+ String basename = path.get_file().get_basename();
String name=basename;
int counter=0;
while(sample_library->has_sample(name)) {
@@ -376,7 +378,7 @@ void SampleLibraryEditor::drop_data_fw(const Point2& p_point,const Variant& p_da
if (sample->get_name()!="") {
basename=sample->get_name();
} else if (sample->get_path().is_resource_file()) {
- basename = sample->get_path().basename();
+ basename = sample->get_path().get_basename();
} else {
basename="Sample";
}
@@ -411,17 +413,17 @@ void SampleLibraryEditor::drop_data_fw(const Point2& p_point,const Variant& p_da
void SampleLibraryEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&SampleLibraryEditor::_gui_input);
- ClassDB::bind_method(_MD("_load_pressed"),&SampleLibraryEditor::_load_pressed);
- ClassDB::bind_method(_MD("_item_edited"),&SampleLibraryEditor::_item_edited);
- ClassDB::bind_method(_MD("_delete_pressed"),&SampleLibraryEditor::_delete_pressed);
- ClassDB::bind_method(_MD("_file_load_request"),&SampleLibraryEditor::_file_load_request);
- ClassDB::bind_method(_MD("_update_library"),&SampleLibraryEditor::_update_library);
- ClassDB::bind_method(_MD("_button_pressed"),&SampleLibraryEditor::_button_pressed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&SampleLibraryEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_load_pressed"),&SampleLibraryEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_item_edited"),&SampleLibraryEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_delete_pressed"),&SampleLibraryEditor::_delete_pressed);
+ ClassDB::bind_method(D_METHOD("_file_load_request"),&SampleLibraryEditor::_file_load_request);
+ ClassDB::bind_method(D_METHOD("_update_library"),&SampleLibraryEditor::_update_library);
+ ClassDB::bind_method(D_METHOD("_button_pressed"),&SampleLibraryEditor::_button_pressed);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &SampleLibraryEditor::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &SampleLibraryEditor::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &SampleLibraryEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SampleLibraryEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SampleLibraryEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &SampleLibraryEditor::drop_data_fw);
}
@@ -506,14 +508,14 @@ void SampleLibraryEditorPlugin::make_visible(bool p_visible) {
//sample_library_editor->show();
button->show();
editor->make_bottom_panel_item_visible(sample_library_editor);
-// sample_library_editor->set_process(true);
+ //sample_library_editor->set_process(true);
} else {
- if (sample_library_editor->is_visible())
+ if (sample_library_editor->is_visible_in_tree())
editor->hide_bottom_panel();
button->hide();
-// sample_library_editor->set_process(false);
+ //sample_library_editor->set_process(false);
}
}
@@ -529,8 +531,8 @@ SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) {
button->hide();
//sample_library_editor->set_area_as_parent_rect();
-// sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
-// sample_library_editor->set_margin( MARGIN_TOP, 120 );
+ //sample_library_editor->set_anchor( MARGIN_TOP, Control::ANCHOR_END);
+ //sample_library_editor->set_margin( MARGIN_TOP, 120 );
//sample_library_editor->hide();
@@ -541,3 +543,4 @@ SampleLibraryEditorPlugin::SampleLibraryEditorPlugin(EditorNode *p_node) {
SampleLibraryEditorPlugin::~SampleLibraryEditorPlugin()
{
}
+#endif
diff --git a/tools/editor/plugins/sample_library_editor_plugin.h b/tools/editor/plugins/sample_library_editor_plugin.h
index 1856d338ed..35028df859 100644
--- a/tools/editor/plugins/sample_library_editor_plugin.h
+++ b/tools/editor/plugins/sample_library_editor_plugin.h
@@ -30,7 +30,7 @@
#define SAMPLE_LIBRARY_EDITOR_PLUGIN_H
-
+#if 0
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/audio/sample_player.h"
@@ -104,4 +104,5 @@ public:
};
+#endif
#endif // SAMPLE_LIBRARY_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/sample_player_editor_plugin.cpp b/tools/editor/plugins/sample_player_editor_plugin.cpp
index ae958a5c6e..7e2683dedf 100644
--- a/tools/editor/plugins/sample_player_editor_plugin.cpp
+++ b/tools/editor/plugins/sample_player_editor_plugin.cpp
@@ -26,7 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+#if 0
#include "sample_player_editor_plugin.h"
+
+
#include "scene/resources/sample_library.h"
@@ -50,8 +54,8 @@ void SamplePlayerEditor::_node_removed(Node *p_node) {
void SamplePlayerEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_play"),&SamplePlayerEditor::_play);
- ClassDB::bind_method(_MD("_stop"),&SamplePlayerEditor::_stop);
+ ClassDB::bind_method(D_METHOD("_play"),&SamplePlayerEditor::_play);
+ ClassDB::bind_method(D_METHOD("_stop"),&SamplePlayerEditor::_stop);
}
@@ -89,7 +93,7 @@ void SamplePlayerEditor::_update_sample_library() {
Ref<SampleLibrary> sl = node->call("get_sample_library");
if (sl.is_null()) {
samples->add_item("<NO SAMPLE LIBRARY>");
- return; //no sample library;;
+ return; //no sample library;
}
List<StringName> samplenames;
@@ -196,3 +200,4 @@ SamplePlayerEditorPlugin::~SamplePlayerEditorPlugin()
}
+#endif
diff --git a/tools/editor/plugins/sample_player_editor_plugin.h b/tools/editor/plugins/sample_player_editor_plugin.h
index d18496b4fd..ba1684497c 100644
--- a/tools/editor/plugins/sample_player_editor_plugin.h
+++ b/tools/editor/plugins/sample_player_editor_plugin.h
@@ -29,6 +29,8 @@
#ifndef SAMPLE_PLAYER_EDITOR_PLUGIN_H
#define SAMPLE_PLAYER_EDITOR_PLUGIN_H
+#if 0
+
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/3d/spatial_sample_player.h"
@@ -84,4 +86,5 @@ public:
};
+#endif
#endif // SAMPLE_PLAYER_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 89a85b4ba0..c7639dd4d3 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_editor_plugin.h"
+
#include "tools/editor/editor_settings.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
@@ -34,7 +35,7 @@
#include "os/os.h"
#include "tools/editor/editor_node.h"
#include "tools/editor/script_editor_debugger.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "scene/main/viewport.h"
#include "os/keyboard.h"
@@ -240,9 +241,9 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
void ScriptEditorQuickOpen::_bind_methods() {
- ClassDB::bind_method(_MD("_text_changed"),&ScriptEditorQuickOpen::_text_changed);
- ClassDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed);
- ClassDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&ScriptEditorQuickOpen::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"),&ScriptEditorQuickOpen::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input);
ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line")));
@@ -278,7 +279,7 @@ ScriptEditor *ScriptEditor::script_editor=NULL;
String ScriptEditor::_get_debug_tooltip(const String&p_text,Node *_se) {
-// ScriptEditorBase *se=_se->cast_to<ScriptEditorBase>();
+ //ScriptEditorBase *se=_se->cast_to<ScriptEditorBase>();
String val = debugger->get_var_value(p_text);
if (val!=String()) {
@@ -291,6 +292,10 @@ String ScriptEditor::_get_debug_tooltip(const String&p_text,Node *_se) {
void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) {
+ if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
+ return;
+ }
+
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), !(p_breaked && p_can_debug));
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_STEP), !(p_breaked && p_can_debug) );
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_BREAK), p_breaked );
@@ -311,7 +316,7 @@ void ScriptEditor::_breaked(bool p_breaked,bool p_can_debug) {
void ScriptEditor::_show_debugger(bool p_show) {
-// debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), p_show);
+ //debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), p_show);
}
void ScriptEditor::_script_created(Ref<Script> p_script) {
@@ -426,14 +431,14 @@ void ScriptEditor::_go_to_tab(int p_idx) {
script_name_label->set_text(c->cast_to<ScriptEditorBase>()->get_name());
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
- if (is_visible())
+ if (is_visible_in_tree())
c->cast_to<ScriptEditorBase>()->ensure_focus();
}
if (c->cast_to<EditorHelp>()) {
script_name_label->set_text(c->cast_to<EditorHelp>()->get_class());
script_icon->set_texture(get_icon("Help","EditorIcons"));
- if (is_visible())
+ if (is_visible_in_tree())
c->cast_to<EditorHelp>()->set_focused();
}
@@ -445,7 +450,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
_update_selected_editor_menu();
}
-void ScriptEditor::_close_tab(int p_idx) {
+void ScriptEditor::_close_tab(int p_idx, bool p_save) {
int selected = p_idx;
if (selected<0 || selected>=tab_container->get_child_count())
@@ -454,7 +459,9 @@ void ScriptEditor::_close_tab(int p_idx) {
Node *tselected = tab_container->get_child(selected);
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
if (current) {
- apply_scripts();
+ if (p_save) {
+ apply_scripts();
+ }
if (current->get_edit_menu()) {
memdelete(current->get_edit_menu());
}
@@ -504,6 +511,11 @@ void ScriptEditor::_close_current_tab() {
}
+void ScriptEditor::_close_discard_current_tab(const String& p_str) {
+ _close_tab(tab_container->get_current_tab(), false);
+ erase_tab_confirm->hide();
+}
+
void ScriptEditor::_close_docs_tab() {
int child_count = tab_container->get_child_count();
@@ -1104,7 +1116,7 @@ static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_
Dictionary ScriptEditor::get_state() const {
-// apply_scripts();
+ //apply_scripts();
Dictionary state;
#if 0
@@ -1281,7 +1293,7 @@ void ScriptEditor::ensure_select_current() {
Ref<Script> script = se->get_edited_script();
- if (!grab_focus_block && is_visible())
+ if (!grab_focus_block && is_visible_in_tree())
se->ensure_focus();
@@ -1326,6 +1338,7 @@ void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script>
struct _ScriptEditorItemData {
String name;
+ String sort_key;
Ref<Texture> icon;
int index;
String tooltip;
@@ -1335,7 +1348,7 @@ struct _ScriptEditorItemData {
bool operator<(const _ScriptEditorItemData& id) const {
- return category==id.category?name.nocasecmp_to(id.name)<0:category<id.category;
+ return category==id.category?sort_key<id.sort_key:category<id.category;
}
};
@@ -1396,6 +1409,8 @@ void ScriptEditor::_update_script_names() {
script_list->clear();
bool split_script_help = EditorSettings::get_singleton()->get("text_editor/open_scripts/group_help_pages");
+ ScriptSortBy sort_by = (ScriptSortBy) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/sort_scripts_by");
+ ScriptListName display_as = (ScriptListName) (int) EditorSettings::get_singleton()->get("text_editor/open_scripts/list_script_names_as");
Vector<_ScriptEditorItemData> sedata;
@@ -1407,15 +1422,41 @@ void ScriptEditor::_update_script_names() {
String name = se->get_name();
Ref<Texture> icon = se->get_icon();
- String tooltip = se->get_edited_script()->get_path();
+ String path = se->get_edited_script()->get_path();
_ScriptEditorItemData sd;
sd.icon=icon;
sd.name=name;
- sd.tooltip=tooltip;
+ sd.tooltip=path;
sd.index=i;
sd.used=used.has(se->get_edited_script());
sd.category=0;
+
+ switch (sort_by) {
+ case SORT_BY_NAME: {
+ sd.sort_key=name.to_lower();
+ } break;
+ case SORT_BY_PATH: {
+ sd.sort_key=path;
+ } break;
+ }
+
+ switch (display_as) {
+ case DISPLAY_NAME: {
+ sd.name=name;
+ } break;
+ case DISPLAY_DIR_AND_NAME: {
+ if (!path.get_base_dir().get_file().empty()) {
+ sd.name=path.get_base_dir().get_file() + "/" + name;
+ } else {
+ sd.name=name;
+ }
+ } break;
+ case DISPLAY_FULL_PATH: {
+ sd.name=path;
+ } break;
+ }
+
sedata.push_back(sd);
}
@@ -1430,6 +1471,7 @@ void ScriptEditor::_update_script_names() {
_ScriptEditorItemData sd;
sd.icon=icon;
sd.name=name;
+ sd.sort_key=name;
sd.tooltip=tooltip;
sd.index=i;
sd.used=false;
@@ -1516,7 +1558,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script, bool p_grab_focus) {
_go_to_tab(i);
script_list->select( script_list->find_metadata(i) );
}
- if (is_visible())
+ if (is_visible_in_tree())
se->ensure_focus();
}
return;
@@ -1719,6 +1761,7 @@ void ScriptEditor::_editor_settings_changed() {
se->update_settings();
}
_update_script_colors();
+ _update_script_names();
ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/files/auto_reload_and_parse_scripts_on_save",true));
@@ -1744,7 +1787,7 @@ void ScriptEditor::_script_split_dragged(float) {
}
void ScriptEditor::_unhandled_input(const InputEvent& p_event) {
- if (p_event.key.pressed || !is_visible()) return;
+ if (p_event.key.pressed || !is_visible_in_tree()) return;
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
int next_tab = script_list->get_current() + 1;
next_tab %= script_list->get_item_count();
@@ -2033,6 +2076,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed);
ClassDB::bind_method("_menu_option",&ScriptEditor::_menu_option);
ClassDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab);
+ ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab);
ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab);
ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs);
ClassDB::bind_method("_editor_play",&ScriptEditor::_editor_play);
@@ -2178,7 +2222,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
menu_hb->add_spacer();
- script_icon = memnew( TextureFrame );
+ script_icon = memnew( TextureRect );
menu_hb->add_child(script_icon);
script_name_label = memnew( Label );
menu_hb->add_child(script_name_label);
@@ -2225,8 +2269,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
tab_container->connect("tab_changed", this,"_tab_changed");
erase_tab_confirm = memnew( ConfirmationDialog );
- add_child(erase_tab_confirm);
+ erase_tab_confirm->get_ok()->set_text(TTR("Save"));
+ erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard");
erase_tab_confirm->connect("confirmed", this,"_close_current_tab");
+ erase_tab_confirm->connect("custom_action", this, "_close_discard_current_tab");
+ add_child(erase_tab_confirm);
script_create_dialog = memnew(ScriptCreateDialog);
script_create_dialog->set_title(TTR("Create Script"));
@@ -2247,7 +2294,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
{
VBoxContainer *vbc = memnew( VBoxContainer );
disk_changed->add_child(vbc);
- // disk_changed->set_child_rect(vbc);
+ //disk_changed->set_child_rect(vbc);
Label *dl = memnew( Label );
dl->set_text(TTR("The following files are newer on disk.\nWhat action should be taken?:"));
@@ -2293,7 +2340,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
help_index->connect("open_class",this,"_help_class_open");
history_pos=-1;
-// debugger_gui->hide();
+ //debugger_gui->hide();
edit_pass=0;
trim_trailing_whitespace_on_save = false;
@@ -2428,9 +2475,13 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color",Color(0,0,1,0.3));
EDITOR_DEF("text_editor/open_scripts/current_script_background_color",Color(0.81,0.81,0.14,0.63));
EDITOR_DEF("text_editor/open_scripts/group_help_pages",true);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/sort_scripts_by",PROPERTY_HINT_ENUM,"Name,Path"));
+ EDITOR_DEF("text_editor/open_scripts/sort_scripts_by",0);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"text_editor/open_scripts/list_script_names_as",PROPERTY_HINT_ENUM,"Name,Parent Directory And Name,Full Path"));
+ EDITOR_DEF("text_editor/open_scripts/list_script_names_as",0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"text_editor/external/exec_path",PROPERTY_HINT_GLOBAL_FILE));
EDITOR_DEF("text_editor/external/exec_flags","");
-
+
}
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 26120c8497..75099fc5ec 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -154,6 +154,17 @@ class ScriptEditor : public VBoxContainer {
WINDOW_PREV,
WINDOW_SELECT_BASE=100
};
+
+ enum ScriptSortBy {
+ SORT_BY_NAME,
+ SORT_BY_PATH,
+ };
+
+ enum ScriptListName {
+ DISPLAY_NAME,
+ DISPLAY_DIR_AND_NAME,
+ DISPLAY_FULL_PATH,
+ };
HBoxContainer *menu_hb;
MenuButton *file_menu;
@@ -179,7 +190,7 @@ class ScriptEditor : public VBoxContainer {
String current_theme;
- TextureFrame *script_icon;
+ TextureRect *script_icon;
Label *script_name_label;
ToolButton *script_back;
@@ -219,9 +230,10 @@ class ScriptEditor : public VBoxContainer {
bool _test_script_times_on_disk(Ref<Script> p_for_script=Ref<Script>());
- void _close_tab(int p_idx);
+ void _close_tab(int p_idx, bool p_save=true);
void _close_current_tab();
+ void _close_discard_current_tab(const String& p_str);
void _close_docs_tab();
void _close_all_tabs();
diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp
index 05a2bfdba0..9ec6266419 100644
--- a/tools/editor/plugins/script_text_editor.cpp
+++ b/tools/editor/plugins/script_text_editor.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_text_editor.h"
+
#include "tools/editor/editor_settings.h"
#include "os/keyboard.h"
#include "tools/editor/script_editor_debugger.h"
@@ -60,7 +61,7 @@ void ScriptTextEditor::apply_code() {
if (script.is_null())
return;
-// print_line("applying code");
+ //print_line("applying code");
script->set_source_code(code_editor->get_text_edit()->get_text());
script->update_exports();
}
@@ -114,6 +115,7 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_color_override("selection_color",EDITOR_DEF("text_editor/highlighting/selection_color",Color(0.2,0.2,1)));
text_edit->add_color_override("brace_mismatch_color",EDITOR_DEF("text_editor/highlighting/brace_mismatch_color",Color(1,0.2,0.2)));
text_edit->add_color_override("current_line_color",EDITOR_DEF("text_editor/highlighting/current_line_color",Color(0.3,0.5,0.8,0.15)));
+ text_edit->add_color_override("line_length_guideline_color", EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0,0,0)));
text_edit->add_color_override("word_highlighted_color",EDITOR_DEF("text_editor/highlighting/word_highlighted_color",Color(0.8,0.9,0.9,0.15)));
text_edit->add_color_override("number_color",EDITOR_DEF("text_editor/highlighting/number_color",Color(0.9,0.6,0.0,2)));
text_edit->add_color_override("function_color",EDITOR_DEF("text_editor/highlighting/function_color",Color(0.4,0.6,0.8)));
@@ -484,7 +486,7 @@ void ScriptTextEditor::_code_complete_scripts(void* p_ud,const String& p_code, L
void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) {
- if (color_panel->is_visible()) return;
+ if (color_panel->is_visible_in_tree()) return;
Node *base = get_tree()->get_edited_scene_root();
if (base) {
base = _find_node_for_script(base,base,script);
@@ -1194,7 +1196,7 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent& ev) {
Vector<float> color = stripped.split_floats(",");
if (color.size() > 2) {
float alpha = color.size() > 3 ? color[3] : 1.0f;
- color_picker->set_color(Color(color[0], color[1], color[2], alpha));
+ color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha));
}
color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos()));
Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height+10);
diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp
index 17b10ecd70..56a8fccb9c 100644
--- a/tools/editor/plugins/shader_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_editor_plugin.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader_editor_plugin.h"
-#include "tools/editor/editor_settings.h"
+#include "tools/editor/editor_settings.h"
#include "spatial_editor_plugin.h"
#include "scene/resources/shader_graph.h"
#include "io/resource_loader.h"
@@ -127,7 +127,7 @@ void ShaderTextEditor::_load_theme_settings() {
}
//colorize core types
-// Color basetype_color= EDITOR_DEF("text_editor/base_type_color",Color(0.3,0.3,0.0));
+ //Color basetype_color= EDITOR_DEF("text_editor/base_type_color",Color(0.3,0.3,0.0));
//colorize comments
@@ -253,9 +253,9 @@ void ShaderEditor::_menu_option(int p_option) {
current->get_find_replace_bar()->popup_replace();
} break;
-// case SEARCH_LOCATE_SYMBOL: {
+ //case SEARCH_LOCATE_SYMBOL: {
-// } break;
+ //} break;
case SEARCH_GOTO_LINE: {
goto_line_dialog->popup_find_line(current->get_text_edit());
@@ -396,7 +396,7 @@ void ShaderEditor::_bind_methods() {
ClassDB::bind_method("_menu_option",&ShaderEditor::_menu_option);
ClassDB::bind_method("_params_changed",&ShaderEditor::_params_changed);
ClassDB::bind_method("apply_shaders",&ShaderEditor::apply_shaders);
-// ClassDB::bind_method("_close_current_tab",&ShaderEditor::_close_current_tab);
+ //ClassDB::bind_method("_close_current_tab",&ShaderEditor::_close_current_tab);
}
void ShaderEditor::ensure_select_current() {
@@ -481,7 +481,7 @@ ShaderEditor::ShaderEditor() {
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT|KEY_F3), SEARCH_FIND_PREV);
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE);
search_menu->get_popup()->add_separator();
-// search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K);
+ //search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K);
search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE);
search_menu->get_popup()->connect("id_pressed", this,"_menu_option");
@@ -512,8 +512,10 @@ bool ShaderEditorPlugin::handles(Object *p_object) const {
bool handles = true;
Shader *shader=p_object->cast_to<Shader>();
- //if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's
- // handles = false;
+ /*
+ if (!shader || shader->cast_to<ShaderGraph>()) // Dont handle ShaderGraph's
+ handles = false;
+ */
return shader!=NULL;
}
@@ -527,7 +529,7 @@ void ShaderEditorPlugin::make_visible(bool p_visible) {
} else {
button->hide();
- if (shader_editor->is_visible())
+ if (shader_editor->is_visible_in_tree())
editor->hide_bottom_panel();
shader_editor->apply_shaders();
diff --git a/tools/editor/plugins/shader_graph_editor_plugin.cpp b/tools/editor/plugins/shader_graph_editor_plugin.cpp
index 2ff9f94d99..dac63b4a9f 100644
--- a/tools/editor/plugins/shader_graph_editor_plugin.cpp
+++ b/tools/editor/plugins/shader_graph_editor_plugin.cpp
@@ -296,8 +296,8 @@ Vector<Color> GraphColorRampEdit::get_colors() const{
void GraphColorRampEdit::_bind_methods(){
- ClassDB::bind_method(_MD("_gui_input"),&GraphColorRampEdit::_gui_input);
- ClassDB::bind_method(_MD("_color_changed"),&GraphColorRampEdit::_color_changed);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&GraphColorRampEdit::_gui_input);
+ ClassDB::bind_method(D_METHOD("_color_changed"),&GraphColorRampEdit::_color_changed);
ADD_SIGNAL(MethodInfo("ramp_changed"));
}
@@ -464,8 +464,7 @@ void GraphCurveMapEdit::_plot_curve(const Vector2& p_a,const Vector2& p_b,const
/* compose the basis and geometry matrices */
- static const float CR_basis[4][4] =
- {
+ static const float CR_basis[4][4] = {
{ -0.5, 1.5, -1.5, 0.5 },
{ 1.0, -2.5, 2.0, -0.5 },
{ -0.5, 0.0, 0.5, 0.0 },
@@ -658,7 +657,7 @@ Vector<Vector2> GraphCurveMapEdit::get_points() const {
void GraphCurveMapEdit::_bind_methods(){
- ClassDB::bind_method(_MD("_gui_input"),&GraphCurveMapEdit::_gui_input);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&GraphCurveMapEdit::_gui_input);
ADD_SIGNAL(MethodInfo("curve_changed"));
}
@@ -2315,7 +2314,7 @@ void ShaderGraphView::_create_node(int p_id) {
gn->add_child(le);
le->set_text(graph->input_node_get_name(type,p_id));
le->connect("text_entered",this,"_input_name_changed",varray(p_id,le));
- TextureFrame *tex = memnew( TextureFrame );
+ TextureRect *tex = memnew( TextureRect );
tex->set_expand(true);
tex->set_custom_minimum_size(Size2(80,80));
tex->set_drag_forwarding(this);
@@ -2530,7 +2529,7 @@ void ShaderGraphView::_sg_updated() {
Variant ShaderGraphView::get_drag_data_fw(const Point2 &p_point, Control *p_from)
{
- TextureFrame* frame = p_from->cast_to<TextureFrame>();
+ TextureRect* frame = p_from->cast_to<TextureRect>();
if (!frame)
return Variant();
@@ -2576,7 +2575,7 @@ void ShaderGraphView::drop_data_fw(const Point2 &p_point, const Variant &p_data,
if (!can_drop_data_fw(p_point, p_data, p_from))
return;
- TextureFrame *frame = p_from->cast_to<TextureFrame>();
+ TextureRect *frame = p_from->cast_to<TextureRect>();
if (!frame)
return;
@@ -2733,9 +2732,9 @@ void ShaderGraphView::_bind_methods() {
ClassDB::bind_method("_color_ramp_changed",&ShaderGraphView::_color_ramp_changed);
ClassDB::bind_method("_curve_changed",&ShaderGraphView::_curve_changed);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &ShaderGraphView::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &ShaderGraphView::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &ShaderGraphView::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ShaderGraphView::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ShaderGraphView::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &ShaderGraphView::drop_data_fw);
ClassDB::bind_method("_sg_updated",&ShaderGraphView::_sg_updated);
}
@@ -2933,9 +2932,9 @@ ShaderGraphEditorPlugin::ShaderGraphEditorPlugin(EditorNode *p_node, bool p_2d)
SpatialEditor::get_singleton()->get_shader_split()->add_child(shader_editor);
- // editor->get_viewport()->add_child(shader_editor);
- // shader_editor->set_area_as_parent_rect();
- // shader_editor->hide();
+ //editor->get_viewport()->add_child(shader_editor);
+ //shader_editor->set_area_as_parent_rect();
+ //shader_editor->hide();
}
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index f508ab95c2..ef971034cd 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "spatial_editor_plugin.h"
-#include "print_string.h"
+#include "print_string.h"
#include "os/keyboard.h"
#include "scene/3d/visual_instance.h"
#include "scene/3d/camera.h"
@@ -38,7 +38,7 @@
#include "tools/editor/editor_settings.h"
#include "scene/resources/surface_tool.h"
#include "tools/editor/spatial_editor_gizmos.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/plugins/animation_player_editor_plugin.h"
#include "tools/editor/animation_editor.h"
@@ -277,12 +277,10 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
Vector<ObjectID> instances=VisualServer::get_singleton()->instances_cull_ray(pos,ray,get_tree()->get_root()->get_world()->get_scenario() );
Set<Ref<SpatialEditorGizmo> > found_gizmos;
- //uint32_t closest=0;
-// float closest_dist=0;
-
- r_includes_current=false;
-
- List<_RayResult> results;
+ ObjectID closest=0;
+ Spatial *item=NULL;
+ float closest_dist=1e20;
+ int selected_handle=-1;
for (int i=0;i<instances.size();i++) {
@@ -318,84 +316,30 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2& p_pos, bool p_append,b
if (dist<0)
continue;
+ if (dist < closest_dist) {
+ closest=instances[i];
+ closest_dist=dist;
+ selected_handle=handle;
+ item=spat;
+ }
+ // if (editor_selection->is_selected(spat))
+ // r_includes_current=true;
- if (editor_selection->is_selected(spat))
- r_includes_current=true;
-
- _RayResult res;
- res.item=spat;
- res.depth=dist;
- res.handle=handle;
- results.push_back(res);
}
- if (results.empty())
+ if (!item)
return 0;
- results.sort();
- Spatial *s=NULL;
-
+ if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle>=0)) {
- if (!r_includes_current || results.size()==1 || (r_gizmo_handle && results.front()->get().handle>=0)) {
-
- //return the nearest one
- s = results.front()->get().item;
if (r_gizmo_handle)
- *r_gizmo_handle=results.front()->get().handle;
-
- } else {
-
- //returns the next one from a curent selection
- List<_RayResult>::Element *E=results.front();
- List<_RayResult>::Element *S=NULL;
-
-
- while(true) {
+ *r_gizmo_handle=selected_handle;
- //very strange loop algorithm that complies with object selection standards (tm).
-
- if (S==E) {
- //went all around and anothing was found
- //since can't rotate the selection
- //just return the first one
-
- s=results.front()->get().item;
- break;
-
- }
-
- if (!S && editor_selection->is_selected(E->get().item)) {
- //found an item currently in the selection,
- //so start from this one
- S=E;
- }
-
- if (S && !editor_selection->is_selected(E->get().item)) {
- // free item after a selected item, this one is desired.
- s=E->get().item;
- break;
- }
-
- E=E->next();
- if (!E) {
-
- if (!S) {
- //did a loop but nothing was selected, select first
- s=results.front()->get().item;
- break;
-
- }
- E=results.front();
- }
- }
}
- if (!s)
- return 0;
-
- return s->get_instance_ID();
+ return closest;
}
@@ -468,7 +412,7 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3& p_pos) {
CameraMatrix cm;
- cm.set_perspective(get_fov(),get_size().get_aspect(),get_znear(),get_zfar());
+ cm.set_perspective(get_fov(),get_size().aspect(),get_znear(),get_zfar());
float screen_w,screen_h;
cm.get_viewport_size(screen_w,screen_h);
@@ -580,8 +524,8 @@ void SpatialEditorViewport::_compute_edit(const Point2& p_point) {
List<Node*> &selection = editor_selection->get_selected_node_list();
-// Vector3 center;
-// int nc=0;
+ //Vector3 center;
+ //int nc=0;
for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
Spatial *sp = E->get()->cast_to<Spatial>();
@@ -593,16 +537,14 @@ void SpatialEditorViewport::_compute_edit(const Point2& p_point) {
continue;
se->original=se->sp->get_global_transform();
-// center+=se->original.origin;
-// nc++;
+ //center+=se->original.origin;
+ //nc++;
}
-
-// if (nc)
-// _edit.center=center/float(nc);
-
-
-
+ /*
+ if (nc)
+ _edit.center=center/float(nc);
+ */
}
static int _get_key_modifier(const String& p_property) {
@@ -618,23 +560,6 @@ static int _get_key_modifier(const String& p_property) {
return 0;
}
-SpatialEditorViewport::NavigationScheme SpatialEditorViewport::_get_navigation_schema(const String& p_property) {
- switch(EditorSettings::get_singleton()->get(p_property).operator int()) {
- case 0: return NAVIGATION_GODOT;
- case 1: return NAVIGATION_MAYA;
- case 2: return NAVIGATION_MODO;
- }
- return NAVIGATION_GODOT;
-}
-
-SpatialEditorViewport::NavigationZoomStyle SpatialEditorViewport::_get_navigation_zoom_style(const String& p_property) {
- switch(EditorSettings::get_singleton()->get(p_property).operator int()) {
- case 0: return NAVIGATION_ZOOM_VERTICAL;
- case 1: return NAVIGATION_ZOOM_HORIZONTAL;
- }
- return NAVIGATION_ZOOM_VERTICAL;
-}
-
bool SpatialEditorViewport::_gizmo_select(const Vector2& p_screenpos,bool p_hilite_only) {
if (!spatial_editor->is_gizmo_visible())
@@ -854,7 +779,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
} break;
case BUTTON_RIGHT: {
- NavigationScheme nav_scheme = _get_navigation_schema("editors/3d/navigation_scheme");
+ NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation_scheme").operator int();
if (b.pressed && _edit.gizmo.is_valid()) {
//restore
@@ -1014,7 +939,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (b.pressed) {
- NavigationScheme nav_scheme = _get_navigation_schema("editors/3d/navigation_scheme");
+ NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation_scheme").operator int();
if ( (nav_scheme==NAVIGATION_MAYA || nav_scheme==NAVIGATION_MODO) && b.mod.alt) {
break;
}
@@ -1251,7 +1176,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
}
- NavigationScheme nav_scheme = _get_navigation_schema("editors/3d/navigation_scheme");
+ NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation_scheme").operator int();
NavigationMode nav_mode = NAVIGATION_NONE;
if (_edit.gizmo.is_valid()) {
@@ -1546,11 +1471,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (m.mod.meta)
mod=KEY_META;
- if (mod == _get_key_modifier("3d_editor/pan_modifier"))
+ if (mod == _get_key_modifier("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
- else if (mod == _get_key_modifier("3d_editor/zoom_modifier"))
+ else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
nav_mode = NAVIGATION_ZOOM;
- else if (mod == _get_key_modifier("3d_editor/orbit_modifier"))
+ else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
nav_mode = NAVIGATION_ORBIT;
} else if (nav_scheme == NAVIGATION_MAYA) {
@@ -1558,7 +1483,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
nav_mode = NAVIGATION_PAN;
}
- } else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
+ } else if (EditorSettings::get_singleton()->get("editors/3d/emulate_3_button_mouse")) {
// Handle trackpad (no external mouse) use case
int mod = 0;
if (m.mod.shift)
@@ -1571,11 +1496,11 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
mod=KEY_META;
if(mod){
- if (mod == _get_key_modifier("3d_editor/pan_modifier"))
+ if (mod == _get_key_modifier("editors/3d/pan_modifier"))
nav_mode = NAVIGATION_PAN;
- else if (mod == _get_key_modifier("3d_editor/zoom_modifier"))
+ else if (mod == _get_key_modifier("editors/3d/zoom_modifier"))
nav_mode = NAVIGATION_ZOOM;
- else if (mod == _get_key_modifier("3d_editor/orbit_modifier"))
+ else if (mod == _get_key_modifier("editors/3d/orbit_modifier"))
nav_mode = NAVIGATION_ORBIT;
}
}
@@ -1606,7 +1531,7 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (nav_scheme==NAVIGATION_MAYA && m.mod.shift)
zoom_speed *= zoom_speed_modifier;
- NavigationZoomStyle zoom_style = _get_navigation_zoom_style("3d_editor/zoom_style");
+ NavigationZoomStyle zoom_style = (NavigationZoomStyle)EditorSettings::get_singleton()->get("editors/3d/zoom_style").operator int();
if (zoom_style == NAVIGATION_ZOOM_HORIZONTAL) {
if ( m.relative_x > 0)
cursor.distance*=1-m.relative_x*zoom_speed;
@@ -1740,7 +1665,7 @@ void SpatialEditorViewport::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- bool visible=is_visible();
+ bool visible=is_visible_in_tree();
set_process(visible);
@@ -1840,10 +1765,10 @@ void SpatialEditorViewport::_notification(int p_what) {
//update msaa if changed
- int msaa_mode = GlobalConfig::get_singleton()->get("rendering/antialias/msaa");
+ int msaa_mode = GlobalConfig::get_singleton()->get("rendering/quality/msaa");
viewport->set_msaa(Viewport::MSAA(msaa_mode));
- bool hdr = GlobalConfig::get_singleton()->get("rendering/dynamic_range/hdr");
+ bool hdr = GlobalConfig::get_singleton()->get("rendering/quality/hdr");
viewport->set_hdr(hdr);
@@ -1915,7 +1840,7 @@ void SpatialEditorViewport::_draw() {
Size2 ss = Size2( GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height") );
- float aspect = ss.get_aspect();
+ float aspect = ss.aspect();
Size2 s = get_size();
Rect2 draw_rect;
@@ -2152,7 +2077,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
previewing->disconnect("tree_exited",this,"_preview_exited_scene");
previewing=NULL;
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport(), camera->get_camera() ); //restore
+ VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), camera->get_camera() ); //restore
if (!preview)
preview_camera->hide();
view_menu->show();
@@ -2162,7 +2087,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
previewing=preview;
previewing->connect("tree_exited",this,"_preview_exited_scene");
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport(), preview->get_camera() ); //replace
+ VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), preview->get_camera() ); //replace
view_menu->hide();
surface->update();
@@ -2205,7 +2130,7 @@ void SpatialEditorViewport::set_can_preview(Camera* p_preview) {
void SpatialEditorViewport::update_transform_gizmo_view() {
- if (!is_visible())
+ if (!is_visible_in_tree())
return;
Transform xform = spatial_editor->get_gizmo_transform();
@@ -2267,7 +2192,7 @@ void SpatialEditorViewport::set_state(const Dictionary& p_state) {
if (pv && pv->cast_to<Camera>()) {
previewing=pv->cast_to<Camera>();
previewing->connect("tree_exited",this,"_preview_exited_scene");
- VS::get_singleton()->viewport_attach_camera( viewport->get_viewport(), previewing->get_camera() ); //replace
+ VS::get_singleton()->viewport_attach_camera( viewport->get_viewport_rid(), previewing->get_camera() ); //replace
view_menu->hide();
surface->update();
preview_camera->set_pressed(true);
@@ -2296,15 +2221,15 @@ Dictionary SpatialEditorViewport::get_state() const {
void SpatialEditorViewport::_bind_methods(){
- ClassDB::bind_method(_MD("_draw"),&SpatialEditorViewport::_draw);
- ClassDB::bind_method(_MD("_smouseenter"),&SpatialEditorViewport::_smouseenter);
- ClassDB::bind_method(_MD("_sinput"),&SpatialEditorViewport::_sinput);
- ClassDB::bind_method(_MD("_menu_option"),&SpatialEditorViewport::_menu_option);
- ClassDB::bind_method(_MD("_toggle_camera_preview"),&SpatialEditorViewport::_toggle_camera_preview);
- ClassDB::bind_method(_MD("_preview_exited_scene"),&SpatialEditorViewport::_preview_exited_scene);
- ClassDB::bind_method(_MD("update_transform_gizmo_view"),&SpatialEditorViewport::update_transform_gizmo_view);
- ClassDB::bind_method(_MD("_selection_result_pressed"),&SpatialEditorViewport::_selection_result_pressed);
- ClassDB::bind_method(_MD("_selection_menu_hide"),&SpatialEditorViewport::_selection_menu_hide);
+ ClassDB::bind_method(D_METHOD("_draw"),&SpatialEditorViewport::_draw);
+ ClassDB::bind_method(D_METHOD("_smouseenter"),&SpatialEditorViewport::_smouseenter);
+ ClassDB::bind_method(D_METHOD("_sinput"),&SpatialEditorViewport::_sinput);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&SpatialEditorViewport::_menu_option);
+ ClassDB::bind_method(D_METHOD("_toggle_camera_preview"),&SpatialEditorViewport::_toggle_camera_preview);
+ ClassDB::bind_method(D_METHOD("_preview_exited_scene"),&SpatialEditorViewport::_preview_exited_scene);
+ ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"),&SpatialEditorViewport::update_transform_gizmo_view);
+ ClassDB::bind_method(D_METHOD("_selection_result_pressed"),&SpatialEditorViewport::_selection_result_pressed);
+ ClassDB::bind_method(D_METHOD("_selection_menu_hide"),&SpatialEditorViewport::_selection_menu_hide);
ADD_SIGNAL( MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport")) );
}
@@ -2316,10 +2241,10 @@ void SpatialEditorViewport::reset() {
message_time=0;
message="";
last_message="";
- name=TTR("Top");
+ name="";
- cursor.x_rot=0;
- cursor.y_rot=0;
+ cursor.x_rot=0.5;
+ cursor.y_rot=0.5;
cursor.distance=4;
cursor.region_select=false;
_update_name();
@@ -2369,7 +2294,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
index=p_index;
editor=p_editor;
- editor_selection=editor->get_editor_selection();;
+ editor_selection=editor->get_editor_selection();
undo_redo=editor->get_undo_redo();
clicked=0;
clicked_includes_current=false;
@@ -2515,7 +2440,7 @@ void SpatialEditor::update_transform_gizmo() {
center.expand_to(xf.origin);
gizmo_basis=Basis();
}
-// count++;
+ //count++;
}
Vector3 pcenter = center.pos+center.size*0.5;
@@ -2625,12 +2550,12 @@ Dictionary SpatialEditor::get_state() const {
d["viewports"]=vpdata;
- d["default_light"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT) );;
- d["ambient_light_color"]=settings_ambient_color->get_color();
+ d["default_light"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_LIGHT) );
+ d["ambient_light_color"]=settings_ambient_color->get_pick_color();
- d["default_srgb"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB) );;
- d["show_grid"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID) );;
- d["show_origin"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN) );;
+ d["default_srgb"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_USE_DEFAULT_SRGB) );
+ d["show_grid"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_GRID) );
+ d["show_origin"]=view_menu->get_popup()->is_item_checked( view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN) );
d["fov"]=get_fov();
d["znear"]=get_znear();
d["zfar"]=get_zfar();
@@ -2715,7 +2640,7 @@ void SpatialEditor::set_state(const Dictionary& p_state) {
}
if (d.has("ambient_light_color")) {
- settings_ambient_color->set_color(d["ambient_light_color"]);
+ settings_ambient_color->set_pick_color(d["ambient_light_color"]);
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,d["ambient_light_color"]);
}
@@ -2778,16 +2703,16 @@ void SpatialEditor::edit(Spatial *p_spatial) {
}
}
+ /*
if (p_spatial) {
- //_validate_selection();
- //if (selected.has(p_spatial->get_instance_ID()) && selected.size()==1)
- // return;
- //_select(p_spatial->get_instance_ID(),false,true);
+ _validate_selection();
+ if (selected.has(p_spatial->get_instance_ID()) && selected.size()==1)
+ return;
+ _select(p_spatial->get_instance_ID(),false,true);
// should become the selection
}
-
-
+ */
}
void SpatialEditor::_xform_dialog_action() {
@@ -2854,8 +2779,8 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
tool_button[i]->set_pressed(i==p_option);
tool_mode=(ToolMode)p_option;
- // static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."};
-// set_message(_mode[p_option],3);
+ //static const char *_mode[]={"Selection Mode.","Translation Mode.","Rotation Mode.","Scale Mode.","List Selection Mode."};
+ //set_message(_mode[p_option],3);
update_transform_gizmo();
} break;
@@ -3160,9 +3085,9 @@ void SpatialEditor::_init_indicators() {
{
- indicator_mat.instance();;
+ indicator_mat.instance();
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
- indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ //indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
@@ -3231,9 +3156,9 @@ void SpatialEditor::_init_indicators() {
VisualServer::get_singleton()->mesh_surface_set_material(origin,0,indicator_mat->get_rid());
-// origin = VisualServer::get_singleton()->poly_create();
-// VisualServer::get_singleton()->poly_add_primitive(origin,origin_points,Vector<Vector3>(),origin_colors,Vector<Vector3>());
-// VisualServer::get_singleton()->poly_set_material(origin,indicator_mat,true);
+ //origin = VisualServer::get_singleton()->poly_create();
+ //VisualServer::get_singleton()->poly_add_primitive(origin,origin_points,Vector<Vector3>(),origin_colors,Vector<Vector3>());
+ //VisualServer::get_singleton()->poly_set_material(origin,indicator_mat,true);
origin_instance = VisualServer::get_singleton()->instance_create2(origin,get_tree()->get_root()->get_world()->get_scenario());
VS::get_singleton()->instance_set_layer_mask(origin_instance,1<<SpatialEditorViewport::GIZMO_GRID_LAYER);
@@ -3456,7 +3381,7 @@ void SpatialEditor::_instance_scene() {
#if 0
EditorNode *en = get_scene()->get_root_node()->cast_to<EditorNode>();
ERR_FAIL_COND(!en);
- String path = en->get_scenes_dock()->get_selected_path();
+ String path = en->get_filesystem_dock()->get_selected_path();
if (path=="") {
set_message(TTR("No scene selected to instance!"));
return;
@@ -3484,7 +3409,7 @@ void SpatialEditor::_instance_scene() {
void SpatialEditor::_unhandled_key_input(InputEvent p_event) {
- if (!is_visible() || get_viewport()->gui_has_modal_stack())
+ if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return;
#if 0
@@ -3691,7 +3616,7 @@ void SpatialEditor::_node_removed(Node* p_node) {
void SpatialEditor::_bind_methods() {
-// ClassDB::bind_method("_gui_input",&SpatialEditor::_gui_input);
+ //ClassDB::bind_method("_gui_input",&SpatialEditor::_gui_input);
ClassDB::bind_method("_unhandled_key_input",&SpatialEditor::_unhandled_key_input);
ClassDB::bind_method("_node_removed",&SpatialEditor::_node_removed);
ClassDB::bind_method("_menu_item_pressed",&SpatialEditor::_menu_item_pressed);
@@ -3743,7 +3668,7 @@ void SpatialEditor::clear() {
settings_default_light_rot_y=Math_PI*0.2;
//viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
- settings_ambient_color->set_color(Color(0.15,0.15,0.15));
+ settings_ambient_color->set_pick_color(Color(0.15,0.15,0.15));
if (!light_instance.is_valid())
_menu_item_pressed(MENU_VIEW_USE_DEFAULT_LIGHT);
@@ -3755,7 +3680,7 @@ void SpatialEditor::clear() {
void SpatialEditor::_update_ambient_light_color(const Color& p_color) {
-// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color());
+ //viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,settings_ambient_color->get_color());
}
@@ -4024,10 +3949,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
settings_ambient_color = memnew( ColorPickerButton );
settings_vbc->add_margin_child(TTR("Ambient Light Color:"),settings_ambient_color);
settings_ambient_color->connect("color_changed",this,"_update_ambient_light_color");
-
-// viewport_environment->set_enable_fx(Environment::FX_AMBIENT_LIGHT,true);
-// viewport_environment->fx_set_param(Environment::FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0.15,0.15,0.15));
- settings_ambient_color->set_color(Color(0.15,0.15,0.15));
+ settings_ambient_color->set_pick_color(Color(0.15,0.15,0.15));
settings_fov = memnew( SpinBox );
@@ -4117,7 +4039,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
add_to_group("_spatial_editor_group");
EDITOR_DEF("editors/3d/manipulator_gizmo_size",80);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"3d_editor/manipulator_gizmo_size",PROPERTY_HINT_RANGE,"16,1024,1"));
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT,"editors/3d/manipulator_gizmo_size",PROPERTY_HINT_RANGE,"16,1024,1"));
EDITOR_DEF("editors/3d/manipulator_gizmo_opacity",0.2);
over_gizmo_handle=-1;
@@ -4171,7 +4093,7 @@ void SpatialEditorPlugin::set_state(const Dictionary& p_state) {
void SpatialEditor::snap_cursor_to_plane(const Plane& p_plane) {
-// cursor.pos=p_plane.project(cursor.pos);
+ //cursor.pos=p_plane.project(cursor.pos);
}
void SpatialEditorPlugin::_bind_methods() {
diff --git a/tools/editor/plugins/spatial_editor_plugin.h b/tools/editor/plugins/spatial_editor_plugin.h
index b05b7d8545..36f807c11f 100644
--- a/tools/editor/plugins/spatial_editor_plugin.h
+++ b/tools/editor/plugins/spatial_editor_plugin.h
@@ -156,13 +156,11 @@ private:
NAVIGATION_MAYA,
NAVIGATION_MODO,
};
- NavigationScheme _get_navigation_schema(const String& p_property);
enum NavigationZoomStyle {
NAVIGATION_ZOOM_VERTICAL,
NAVIGATION_ZOOM_HORIZONTAL
};
- NavigationZoomStyle _get_navigation_zoom_style(const String& p_property);
enum NavigationMode {
NAVIGATION_NONE,
@@ -210,7 +208,7 @@ private:
bool region_select;
Point2 region_begin,region_end;
- Cursor() { x_rot=y_rot=0; distance=4; region_select=false; }
+ Cursor() { x_rot=y_rot=0.5; distance=4; region_select=false; }
} cursor;
RID move_gizmo_instance[3], rotate_gizmo_instance[3];
diff --git a/tools/editor/plugins/sprite_frames_editor_plugin.cpp b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
index 67948b0302..c3c68e471e 100644
--- a/tools/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/tools/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -29,7 +29,7 @@
#include "sprite_frames_editor_plugin.h"
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/editor_settings.h"
#include "scene/3d/sprite_3d.h"
@@ -56,7 +56,7 @@ void SpriteFramesEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_READY) {
-// NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
+ //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true);
}
if (p_what==NOTIFICATION_DRAW) {
@@ -754,27 +754,27 @@ void SpriteFramesEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
void SpriteFramesEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&SpriteFramesEditor::_gui_input);
- ClassDB::bind_method(_MD("_load_pressed"),&SpriteFramesEditor::_load_pressed);
- ClassDB::bind_method(_MD("_empty_pressed"),&SpriteFramesEditor::_empty_pressed);
- ClassDB::bind_method(_MD("_empty2_pressed"),&SpriteFramesEditor::_empty2_pressed);
- ClassDB::bind_method(_MD("_item_edited"),&SpriteFramesEditor::_item_edited);
- ClassDB::bind_method(_MD("_delete_pressed"),&SpriteFramesEditor::_delete_pressed);
- ClassDB::bind_method(_MD("_paste_pressed"),&SpriteFramesEditor::_paste_pressed);
- ClassDB::bind_method(_MD("_delete_confirm_pressed"),&SpriteFramesEditor::_delete_confirm_pressed);
- ClassDB::bind_method(_MD("_file_load_request","files","atpos"),&SpriteFramesEditor::_file_load_request,DEFVAL(-1));
- ClassDB::bind_method(_MD("_update_library","skipsel"),&SpriteFramesEditor::_update_library,DEFVAL(false));
- ClassDB::bind_method(_MD("_up_pressed"),&SpriteFramesEditor::_up_pressed);
- ClassDB::bind_method(_MD("_down_pressed"),&SpriteFramesEditor::_down_pressed);
- ClassDB::bind_method(_MD("_animation_select"),&SpriteFramesEditor::_animation_select);
- ClassDB::bind_method(_MD("_animation_name_edited"),&SpriteFramesEditor::_animation_name_edited);
- ClassDB::bind_method(_MD("_animation_add"),&SpriteFramesEditor::_animation_add);
- ClassDB::bind_method(_MD("_animation_remove"),&SpriteFramesEditor::_animation_remove);
- ClassDB::bind_method(_MD("_animation_loop_changed"),&SpriteFramesEditor::_animation_loop_changed);
- ClassDB::bind_method(_MD("_animation_fps_changed"),&SpriteFramesEditor::_animation_fps_changed);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &SpriteFramesEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&SpriteFramesEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_load_pressed"),&SpriteFramesEditor::_load_pressed);
+ ClassDB::bind_method(D_METHOD("_empty_pressed"),&SpriteFramesEditor::_empty_pressed);
+ ClassDB::bind_method(D_METHOD("_empty2_pressed"),&SpriteFramesEditor::_empty2_pressed);
+ ClassDB::bind_method(D_METHOD("_item_edited"),&SpriteFramesEditor::_item_edited);
+ ClassDB::bind_method(D_METHOD("_delete_pressed"),&SpriteFramesEditor::_delete_pressed);
+ ClassDB::bind_method(D_METHOD("_paste_pressed"),&SpriteFramesEditor::_paste_pressed);
+ ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"),&SpriteFramesEditor::_delete_confirm_pressed);
+ ClassDB::bind_method(D_METHOD("_file_load_request","files","atpos"),&SpriteFramesEditor::_file_load_request,DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("_update_library","skipsel"),&SpriteFramesEditor::_update_library,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_up_pressed"),&SpriteFramesEditor::_up_pressed);
+ ClassDB::bind_method(D_METHOD("_down_pressed"),&SpriteFramesEditor::_down_pressed);
+ ClassDB::bind_method(D_METHOD("_animation_select"),&SpriteFramesEditor::_animation_select);
+ ClassDB::bind_method(D_METHOD("_animation_name_edited"),&SpriteFramesEditor::_animation_name_edited);
+ ClassDB::bind_method(D_METHOD("_animation_add"),&SpriteFramesEditor::_animation_add);
+ ClassDB::bind_method(D_METHOD("_animation_remove"),&SpriteFramesEditor::_animation_remove);
+ ClassDB::bind_method(D_METHOD("_animation_loop_changed"),&SpriteFramesEditor::_animation_loop_changed);
+ ClassDB::bind_method(D_METHOD("_animation_fps_changed"),&SpriteFramesEditor::_animation_fps_changed);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpriteFramesEditor::drop_data_fw);
}
@@ -937,14 +937,14 @@ void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button->show();
editor->make_bottom_panel_item_visible(frames_editor);
-// frames_editor->set_process(true);
+ //frames_editor->set_process(true);
} else {
button->hide();
- if (frames_editor->is_visible())
+ if (frames_editor->is_visible_in_tree())
editor->hide_bottom_panel();
-// frames_editor->set_process(false);
+ //frames_editor->set_process(false);
}
}
diff --git a/tools/editor/plugins/stream_editor_plugin.cpp b/tools/editor/plugins/stream_editor_plugin.cpp
index 00d7b208c8..449f6f610e 100644
--- a/tools/editor/plugins/stream_editor_plugin.cpp
+++ b/tools/editor/plugins/stream_editor_plugin.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "stream_editor_plugin.h"
-
+#if 0
void StreamEditor::_notification(int p_what) {
@@ -59,8 +59,8 @@ void StreamEditor::_stop() {
void StreamEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_play"),&StreamEditor::_play);
- ClassDB::bind_method(_MD("_stop"),&StreamEditor::_stop);
+ ClassDB::bind_method(D_METHOD("_play"),&StreamEditor::_play);
+ ClassDB::bind_method(D_METHOD("_stop"),&StreamEditor::_stop);
}
@@ -146,3 +146,4 @@ StreamEditorPlugin::~StreamEditorPlugin()
{
}
+#endif
diff --git a/tools/editor/plugins/stream_editor_plugin.h b/tools/editor/plugins/stream_editor_plugin.h
index af29f64f93..cc853d4661 100644
--- a/tools/editor/plugins/stream_editor_plugin.h
+++ b/tools/editor/plugins/stream_editor_plugin.h
@@ -29,7 +29,7 @@
#ifndef STREAM_EDITOR_PLUGIN_H
#define STREAM_EDITOR_PLUGIN_H
-
+#if 0
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/audio/stream_player.h"
@@ -81,3 +81,4 @@ public:
};
#endif // STREAM_EDITOR_PLUGIN_H
+#endif
diff --git a/tools/editor/plugins/style_box_editor_plugin.cpp b/tools/editor/plugins/style_box_editor_plugin.cpp
index 4319832adb..396ebd0052 100644
--- a/tools/editor/plugins/style_box_editor_plugin.cpp
+++ b/tools/editor/plugins/style_box_editor_plugin.cpp
@@ -49,9 +49,9 @@ void StyleBoxEditor::_sb_changed() {
void StyleBoxEditor::_bind_methods() {
ClassDB::bind_method("_sb_changed",&StyleBoxEditor::_sb_changed);
-// ClassDB::bind_method("_import",&StyleBoxEditor::_import);
-// ClassDB::bind_method("_import_accept",&StyleBoxEditor::_import_accept);
-// ClassDB::bind_method("_preview_text_changed",&StyleBoxEditor::_preview_text_changed);
+ //ClassDB::bind_method("_import",&StyleBoxEditor::_import);
+ //ClassDB::bind_method("_import_accept",&StyleBoxEditor::_import_accept);
+ //ClassDB::bind_method("_preview_text_changed",&StyleBoxEditor::_preview_text_changed);
}
StyleBoxEditor::StyleBoxEditor() {
@@ -95,7 +95,7 @@ void StyleBoxEditorPlugin::make_visible(bool p_visible){
EditorNode::get_singleton()->make_bottom_panel_item_visible(stylebox_editor);
} else {
- if (stylebox_editor->is_visible())
+ if (stylebox_editor->is_visible_in_tree())
EditorNode::get_singleton()->hide_bottom_panel();
button->hide();
}
diff --git a/tools/editor/plugins/style_box_editor_plugin.h b/tools/editor/plugins/style_box_editor_plugin.h
index b2288b8e74..29e98efd8b 100644
--- a/tools/editor/plugins/style_box_editor_plugin.h
+++ b/tools/editor/plugins/style_box_editor_plugin.h
@@ -30,7 +30,7 @@
#define STYLE_BOX_EDITOR_PLUGIN_H
#include "scene/resources/style_box.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/option_button.h"
#include "tools/editor/editor_node.h"
diff --git a/tools/editor/plugins/texture_editor_plugin.cpp b/tools/editor/plugins/texture_editor_plugin.cpp
index 7ff7d0f2f7..90a798667f 100644
--- a/tools/editor/plugins/texture_editor_plugin.cpp
+++ b/tools/editor/plugins/texture_editor_plugin.cpp
@@ -1,7 +1,35 @@
+/*************************************************************************/
+/* texture_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "texture_editor_plugin.h"
#include "io/resource_loader.h"
-#include "globals.h"
+#include "global_config.h"
#include "tools/editor/editor_settings.h"
void TextureEditor::_gui_input(InputEvent p_event) {
@@ -84,7 +112,7 @@ void TextureEditor::edit(Ref<Texture> p_texture) {
void TextureEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_gui_input"),&TextureEditor::_gui_input);
+ ClassDB::bind_method(D_METHOD("_gui_input"),&TextureEditor::_gui_input);
}
@@ -113,11 +141,11 @@ void TextureEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
texture_editor->show();
-// texture_editor->set_process(true);
+ //texture_editor->set_process(true);
} else {
texture_editor->hide();
-// texture_editor->set_process(false);
+ //texture_editor->set_process(false);
}
}
diff --git a/tools/editor/plugins/texture_editor_plugin.h b/tools/editor/plugins/texture_editor_plugin.h
index 4b05f7f7ab..456a5249de 100644
--- a/tools/editor/plugins/texture_editor_plugin.h
+++ b/tools/editor/plugins/texture_editor_plugin.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* texture_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 TEXTURE_EDITOR_PLUGIN_H
#define TEXTURE_EDITOR_PLUGIN_H
diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp
index 50e2cfb199..aabf938577 100644
--- a/tools/editor/plugins/texture_region_editor_plugin.cpp
+++ b/tools/editor/plugins/texture_region_editor_plugin.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_region_editor_plugin.cpp */
+/* texture_region_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,9 +28,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "texture_region_editor_plugin.h"
#include "core/core_string_names.h"
-#include "texture_region_editor_plugin.h"
#include "scene/gui/check_box.h"
#include "os/input.h"
#include "os/keyboard.h"
@@ -353,6 +353,7 @@ void TextureRegionEditor::_region_input(const InputEvent& p_input)
undo_redo->add_undo_method(atlas_tex.ptr(),"set_region",rect_prev);
}
else if(node_patch9){
+ // FIXME: Is this intentional?
} else if(node_patch9){
undo_redo->add_do_method(node_patch9 ,"set_region_rect",node_patch9->get_region_rect());
undo_redo->add_undo_method(node_patch9,"set_region_rect",rect_prev);
@@ -614,21 +615,21 @@ void TextureRegionEditor::_node_removed(Object *p_obj)
void TextureRegionEditor::_bind_methods()
{
- ClassDB::bind_method(_MD("_edit_region"),&TextureRegionEditor::_edit_region);
- ClassDB::bind_method(_MD("_region_draw"),&TextureRegionEditor::_region_draw);
- ClassDB::bind_method(_MD("_region_input"),&TextureRegionEditor::_region_input);
- ClassDB::bind_method(_MD("_scroll_changed"),&TextureRegionEditor::_scroll_changed);
- ClassDB::bind_method(_MD("_node_removed"),&TextureRegionEditor::_node_removed);
- ClassDB::bind_method(_MD("_set_snap_mode"),&TextureRegionEditor::_set_snap_mode);
- ClassDB::bind_method(_MD("_set_snap_off_x"),&TextureRegionEditor::_set_snap_off_x);
- ClassDB::bind_method(_MD("_set_snap_off_y"),&TextureRegionEditor::_set_snap_off_y);
- ClassDB::bind_method(_MD("_set_snap_step_x"),&TextureRegionEditor::_set_snap_step_x);
- ClassDB::bind_method(_MD("_set_snap_step_y"),&TextureRegionEditor::_set_snap_step_y);
- ClassDB::bind_method(_MD("_set_snap_sep_x"),&TextureRegionEditor::_set_snap_sep_x);
- ClassDB::bind_method(_MD("_set_snap_sep_y"),&TextureRegionEditor::_set_snap_sep_y);
- ClassDB::bind_method(_MD("_zoom_in"),&TextureRegionEditor::_zoom_in);
- ClassDB::bind_method(_MD("_zoom_reset"),&TextureRegionEditor::_zoom_reset);
- ClassDB::bind_method(_MD("_zoom_out"),&TextureRegionEditor::_zoom_out);
+ ClassDB::bind_method(D_METHOD("_edit_region"),&TextureRegionEditor::_edit_region);
+ ClassDB::bind_method(D_METHOD("_region_draw"),&TextureRegionEditor::_region_draw);
+ ClassDB::bind_method(D_METHOD("_region_input"),&TextureRegionEditor::_region_input);
+ ClassDB::bind_method(D_METHOD("_scroll_changed"),&TextureRegionEditor::_scroll_changed);
+ ClassDB::bind_method(D_METHOD("_node_removed"),&TextureRegionEditor::_node_removed);
+ ClassDB::bind_method(D_METHOD("_set_snap_mode"),&TextureRegionEditor::_set_snap_mode);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_x"),&TextureRegionEditor::_set_snap_off_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_off_y"),&TextureRegionEditor::_set_snap_off_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_x"),&TextureRegionEditor::_set_snap_step_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_step_y"),&TextureRegionEditor::_set_snap_step_y);
+ ClassDB::bind_method(D_METHOD("_set_snap_sep_x"),&TextureRegionEditor::_set_snap_sep_x);
+ ClassDB::bind_method(D_METHOD("_set_snap_sep_y"),&TextureRegionEditor::_set_snap_sep_y);
+ ClassDB::bind_method(D_METHOD("_zoom_in"),&TextureRegionEditor::_zoom_in);
+ ClassDB::bind_method(D_METHOD("_zoom_reset"),&TextureRegionEditor::_zoom_reset);
+ ClassDB::bind_method(D_METHOD("_zoom_out"),&TextureRegionEditor::_zoom_out);
}
void TextureRegionEditor::edit(Object *p_obj)
@@ -643,7 +644,7 @@ void TextureRegionEditor::edit(Object *p_obj)
atlas_tex->disconnect("atlas_changed",this,"_edit_region");
if (p_obj) {
node_sprite = p_obj->cast_to<Sprite>();
- node_patch9 = p_obj->cast_to<Patch9Frame>();
+ node_patch9 = p_obj->cast_to<NinePatchRect>();
if (p_obj->cast_to<StyleBoxTexture>())
obj_styleBox = Ref<StyleBoxTexture>(p_obj->cast_to<StyleBoxTexture>());
if (p_obj->cast_to<AtlasTexture>()) {
@@ -897,7 +898,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode* p_editor)
separator->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb_tools->add_child(separator);
- icon_zoom = memnew( TextureFrame );
+ icon_zoom = memnew( TextureRect );
hb_tools->add_child(icon_zoom);
zoom_out = memnew( ToolButton );
@@ -935,7 +936,7 @@ void TextureRegionEditorPlugin::edit(Object *p_node)
bool TextureRegionEditorPlugin::handles(Object *p_obj) const
{
- return p_obj->is_class("Sprite") || p_obj->is_class("Patch9Frame") || p_obj->is_class("StyleBoxTexture") || p_obj->is_class("AtlasTexture");
+ return p_obj->is_class("Sprite") || p_obj->is_class("Patch9Rect") || p_obj->is_class("StyleBoxTexture") || p_obj->is_class("AtlasTexture");
}
void TextureRegionEditorPlugin::make_visible(bool p_visible)
diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h
index 32cf389c35..da713a53d3 100644
--- a/tools/editor/plugins/texture_region_editor_plugin.h
+++ b/tools/editor/plugins/texture_region_editor_plugin.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* texture_region_editor_plugin.h */
+/* texture_region_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -36,7 +36,7 @@
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
#include "scene/2d/sprite.h"
-#include "scene/gui/patch_9_frame.h"
+#include "scene/gui/patch_9_rect.h"
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
@@ -53,7 +53,7 @@ class TextureRegionEditor : public Control {
friend class TextureRegionEditorPlugin;
MenuButton *snap_mode_button;
- TextureFrame *icon_zoom;
+ TextureRect *icon_zoom;
ToolButton *zoom_in;
ToolButton *zoom_reset;
ToolButton *zoom_out;
@@ -81,7 +81,7 @@ class TextureRegionEditor : public Control {
Vector2 snap_step;
Vector2 snap_separation;
- Patch9Frame *node_patch9;
+ NinePatchRect *node_patch9;
Sprite *node_sprite;
Ref<StyleBoxTexture> obj_styleBox;
Ref<AtlasTexture> atlas_tex;
diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp
index a700ddce7a..4b8fea5a45 100644
--- a/tools/editor/plugins/theme_editor_plugin.cpp
+++ b/tools/editor/plugins/theme_editor_plugin.cpp
@@ -26,8 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "theme_editor_plugin.h"
+
+#include "version.h"
#include "os/file_access.h"
void ThemeEditor::edit(const Ref<Theme>& p_theme) {
@@ -584,7 +585,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
List<StringName> types;
base_theme->get_type_list(&types);
- type_menu->get_popup()->clear();;
+ type_menu->get_popup()->clear();
if (p_option==0 || p_option==1) {//add
@@ -693,9 +694,9 @@ ThemeEditor::ThemeEditor() {
-// main_panel->add_child(panel);
-// panel->set_area_as_parent_rect();
-// panel->set_margin( MARGIN_TOP,20 );
+ //main_panel->add_child(panel);
+ //panel->set_area_as_parent_rect();
+ //panel->set_margin( MARGIN_TOP,20 );
first_vb->add_child(memnew( Label("Label") ));
@@ -975,7 +976,7 @@ void ThemeEditorPlugin::make_visible(bool p_visible){
} else {
theme_editor->set_process(false);
- if (theme_editor->is_visible())
+ if (theme_editor->is_visible_in_tree())
editor->hide_bottom_panel();
button->hide();
}
@@ -987,7 +988,7 @@ ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
theme_editor = memnew( ThemeEditor );
theme_editor->set_custom_minimum_size(Size2(0,200));
-// p_node->get_viewport()->add_child(theme_editor);
+ //p_node->get_viewport()->add_child(theme_editor);
button=editor->add_bottom_panel_item("Theme",theme_editor);
button->hide();
diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h
index 0af9128bf2..9251da8e07 100644
--- a/tools/editor/plugins/theme_editor_plugin.h
+++ b/tools/editor/plugins/theme_editor_plugin.h
@@ -30,7 +30,7 @@
#define THEME_EDITOR_PLUGIN_H
#include "scene/resources/theme.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/option_button.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/check_box.h"
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 2c64f7cd89..16b354c8b1 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -26,12 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "tile_map_editor_plugin.h"
#include "os/keyboard.h"
#include "os/input.h"
-
#include "canvas_item_editor_plugin.h"
#include "tools/editor/editor_settings.h"
#include "tools/editor/editor_scale.h"
@@ -53,7 +51,7 @@ void TileMapEditor::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
_update_palette();
}
} break;
@@ -597,7 +595,7 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
bool TileMapEditor::forward_gui_input(const InputEvent& p_event) {
- if (!node || !node->get_tileset().is_valid() || !node->is_visible())
+ if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree())
return false;
Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
@@ -1346,20 +1344,20 @@ void TileMapEditor::_icon_size_changed(float p_value) {
void TileMapEditor::_bind_methods() {
- ClassDB::bind_method(_MD("_text_entered"),&TileMapEditor::_text_entered);
- ClassDB::bind_method(_MD("_text_changed"),&TileMapEditor::_text_changed);
- ClassDB::bind_method(_MD("_sbox_input"),&TileMapEditor::_sbox_input);
- ClassDB::bind_method(_MD("_menu_option"),&TileMapEditor::_menu_option);
- ClassDB::bind_method(_MD("_canvas_draw"),&TileMapEditor::_canvas_draw);
- ClassDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
- ClassDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
- ClassDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
- ClassDB::bind_method(_MD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
+ ClassDB::bind_method(D_METHOD("_text_entered"),&TileMapEditor::_text_entered);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&TileMapEditor::_text_changed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&TileMapEditor::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_menu_option"),&TileMapEditor::_menu_option);
+ ClassDB::bind_method(D_METHOD("_canvas_draw"),&TileMapEditor::_canvas_draw);
+ ClassDB::bind_method(D_METHOD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
+ ClassDB::bind_method(D_METHOD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
+ ClassDB::bind_method(D_METHOD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
+ ClassDB::bind_method(D_METHOD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
- ClassDB::bind_method(_MD("_fill_points"),&TileMapEditor::_fill_points);
- ClassDB::bind_method(_MD("_erase_points"),&TileMapEditor::_erase_points);
+ ClassDB::bind_method(D_METHOD("_fill_points"),&TileMapEditor::_fill_points);
+ ClassDB::bind_method(D_METHOD("_erase_points"),&TileMapEditor::_erase_points);
- ClassDB::bind_method(_MD("_icon_size_changed"), &TileMapEditor::_icon_size_changed);
+ ClassDB::bind_method(D_METHOD("_icon_size_changed"), &TileMapEditor::_icon_size_changed);
}
TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp
index 34002ee863..3db6c94917 100644
--- a/tools/editor/plugins/tile_set_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_set_editor_plugin.cpp
@@ -27,8 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tile_set_editor_plugin.h"
+
#include "scene/2d/sprite.h"
#include "scene/2d/physics_body_2d.h"
+
void TileSetEditor::edit(const Ref<TileSet>& p_tileset) {
tileset=p_tileset;
@@ -76,6 +78,8 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
p_library->tile_set_texture(id,texture);
p_library->tile_set_material(id,material);
+ p_library->tile_set_modulate(id,mi->get_modulate());
+
Vector2 phys_offset;
Size2 s;
diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp
index 03303b8c48..76626c4556 100644
--- a/tools/editor/progress_dialog.cpp
+++ b/tools/editor/progress_dialog.cpp
@@ -27,10 +27,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "progress_dialog.h"
+
#include "main/main.h"
#include "message_queue.h"
#include "os/os.h"
#include "editor_scale.h"
+
void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) {
_THREAD_SAFE_METHOD_
diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp
index 27f2f7dbc9..fc6d8793d8 100644
--- a/tools/editor/project_export.cpp
+++ b/tools/editor/project_export.cpp
@@ -27,18 +27,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "project_export.h"
-
#include "os/dir_access.h"
#include "os/file_access.h"
-#include "globals.h"
-
+#include "global_config.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/os.h"
#include "scene/gui/box_container.h"
-
#include "scene/gui/tab_container.h"
#include "scene/gui/scroll_container.h"
+#include "scene/gui/margin_container.h"
#include "editor_data.h"
#include "io/image_loader.h"
#include "compressed_translation.h"
@@ -46,2082 +44,785 @@
#include "io_plugins/editor_texture_import_plugin.h"
#include "editor_settings.h"
-const char *ProjectExportDialog::da_string[ProjectExportDialog::ACTION_MAX]={
- "",
- "Copy",
- "Bundle"
-};
-
-bool ProjectExportDialog::_create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir) {
-
- TreeItem *item = tree->create_item(p_parent);
- item->set_text(0,p_dir->get_name()+"/");
- item->set_icon(0,get_icon("Folder","EditorIcons"));
-
-
- bool has_items=false;
-
- for(int i=0;i<p_dir->get_subdir_count();i++) {
+void ProjectExportDialog::_notification(int p_what) {
- if (_create_tree(item,p_dir->get_subdir(i)))
- has_items=true;
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ delete_preset->set_icon(get_icon("Del","EditorIcons"));
+ connect("confirmed",this,"_export_pck_zip");
+ } break;
+ case NOTIFICATION_POPUP_HIDE: {
+ EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
+ } break;
}
+}
-// int cc = p_options.get_slice_count(",");
-
- for (int i=0;i<p_dir->get_file_count();i++) {
- TreeItem *fitem = tree->create_item(item);
- //fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- //fitem->set_editable(0,true);
- // fitem->set_checked(0,isfave);
- fitem->set_text(0,p_dir->get_file(i));
- String path = p_dir->get_file_path(i);
- fitem->set_tooltip(0,path);
- fitem->set_metadata(0,path);
- Ref<Texture> icon = get_icon( (has_icon(p_dir->get_file_type(i),ei)?p_dir->get_file_type(i):ot),ei);
- fitem->set_icon(0,icon);
+void ProjectExportDialog::popup_export() {
- fitem->set_cell_mode(1,TreeItem::CELL_MODE_RANGE);
- fitem->set_range_config(1,0,2,1);
- fitem->set_text(1,expopt);
- fitem->set_editable(1,true);
+ add_preset->get_popup()->clear();
+ for(int i=0;i<EditorExport::get_singleton()->get_export_platform_count();i++) {
- EditorImportExport::FileAction fa = EditorImportExport::get_singleton()->get_export_file_action(path);
- fitem->set_range(1,fa);
+ Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i);
- has_items=true;
+ add_preset->get_popup()->add_icon_item(plat->get_logo(),plat->get_name());
}
- if (!has_items) {
-
- memdelete(item);
- return false;
+ _update_presets();
+ // Restore valid window bounds or pop up at default size.
+ if (EditorSettings::get_singleton()->has("interface/dialogs/export_bounds")) {
+ popup(EditorSettings::get_singleton()->get("interface/dialogs/export_bounds"));
+ } else {
+ popup_centered_ratio();
}
-
- return true;
}
+void ProjectExportDialog::_add_preset(int p_platform) {
-void ProjectExportDialog::_tree_changed() {
-
- TreeItem *t=tree->get_selected();
- if (!t)
- return;
-
- String selected = t->get_metadata(0);
-
- EditorImportExport::get_singleton()->set_export_file_action(selected,EditorImportExport::FileAction(int(t->get_range(1))));
- _save_export_cfg();
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
+ ERR_FAIL_COND(!preset.is_valid());
- //editor->save_import_export(true);
- //EditorImportDB::get_singleton()->save_settings();
-
-}
+ String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
+ bool make_runnable=true;
+ int attempt=1;
+ while(true) {
-void ProjectExportDialog::popup_export() {
- popup_centered_ratio();
- if (pending_update_tree) {
- _update_tree();
- _update_group_tree();
- pending_update_tree=false;
- }
-}
+ bool valid=true;
-void ProjectExportDialog::_update_tree() {
+ for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
+ if (p->get_platform()==preset->get_platform() && p->is_runnable()) {
+ make_runnable=false;
+ }
+ if (p->get_name()==name) {
+ valid=false;
+ break;
+ }
+ }
+ if (valid)
+ break;
- updating_tree=true;
- tree->clear();
- EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
+ attempt++;
+ name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name()+" "+itos(attempt);
- if (efsd) {
- _create_tree(NULL,efsd);
}
- updating_tree=false;
-}
-
-
-
-
-void ProjectExportDialog::_update_platform() {
+ preset->set_name(name);
+ if (make_runnable)
+ preset->set_runnable(make_runnable);
+ EditorExport::get_singleton()->add_export_preset(preset);
+ _update_presets();
+ _edit_preset(EditorExport::get_singleton()->get_export_preset_count()-1);
- _validate_platform();
- TreeItem *selected = platforms->get_selected();
- if (!selected)
- return;
-
- String platform = selected->get_metadata(0);
- Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
- platform_options->edit( exporter.ptr() );
}
-void ProjectExportDialog::_platform_selected() {
- String p =platforms->get_selected()->get_metadata(0);
- _update_platform();
-// editor->save_import_export();
-// EditorFileSystem::get_singleton()->scan();
+void ProjectExportDialog::_update_presets() {
-}
+ updating=true;
-void ProjectExportDialog::_scan_finished() {
+ Ref<EditorExportPreset> current;
+ if (presets->get_current()>=0 && presets->get_current()<presets->get_item_count())
+ current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
-/* print_line("**********SCAN DONEEE********");
- print_line("**********SCAN DONEEE********");
- print_line("**********SCAN DONEEE********");
- print_line("**********SCAN DONEEE********");*/
+ int current_idx=-1;
+ presets->clear();
+ for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i);
+ if (preset==current) {
+ current_idx=i;
+ }
- if (!is_visible()) {
- pending_update_tree=true;
- return;
+ String name = preset->get_name();
+ if (preset->is_runnable())
+ name+=" ("+TTR("Runnable")+")";
+ presets->add_item(name,preset->get_platform()->get_logo());
}
- _update_tree();
- _update_group_tree();
-}
-
-void ProjectExportDialog::_rescan() {
-
- EditorFileSystem::get_singleton()->scan();
-
-}
-
-void ProjectExportDialog::_update_exporter() {
-
-
-}
-
+ if (current_idx!=-1) {
+ presets->select(current_idx);
+ //_edit_preset(current_idx);
+ }
-void ProjectExportDialog::_save_export_cfg() {
+ updating=false;
- EditorImportExport::get_singleton()->save_config();
}
-void ProjectExportDialog::_prop_edited(String what) {
+void ProjectExportDialog::_edit_preset(int p_index) {
- _save_export_cfg();
+ if (p_index<0 || p_index>=presets->get_item_count()) {
+ name->set_text("");
+ name->set_editable(false);
+ runnable->set_disabled(true);
+ parameters->edit(NULL);
+ delete_preset->set_disabled(true);
+ sections->hide();
+ patches->clear();
+ return;
+ }
- _validate_platform();
-}
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(p_index);
+ ERR_FAIL_COND(current.is_null());
-void ProjectExportDialog::_filters_edited(String what) {
- EditorImportExport::get_singleton()->set_export_custom_filter(what);
- _save_export_cfg();
-}
+ updating=true;
-void ProjectExportDialog::_filters_exclude_edited(String what) {
- EditorImportExport::get_singleton()->set_export_custom_filter_exclude(what);
- _save_export_cfg();
-}
+ presets->select(p_index);
+ sections->show();
+
+ name->set_editable(true);
+ delete_preset->set_disabled(false);
+ name->set_text(current->get_name());
+ runnable->set_disabled(false);
+ runnable->set_pressed(current->is_runnable());
+ parameters->edit(current.ptr());
+
+ export_filter->select(current->get_export_filter());
+ include_filters->set_text(current->get_include_filter());
+ exclude_filters->set_text(current->get_exclude_filter());
+
+
+ patches->clear();
+ TreeItem *patch_root = patches->create_item();
+ Vector<String> patchlist = current->get_patches();
+ for(int i=0;i<patchlist.size();i++) {
+ TreeItem *patch = patches->create_item(patch_root);
+ patch->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ String file = patchlist[i].get_file();
+ patch->set_editable(0,true);
+ patch->set_text(0,file.get_file().replace("*",""));
+ if (file.ends_with("*"))
+ patch->set_checked(0,true);
+ patch->set_tooltip(0,patchlist[i]);
+ patch->set_metadata(0,i);
+ patch->add_button(0,get_icon("Del","EditorIcons"),0);
+ patch->add_button(0,get_icon("folder","FileDialog"),1);
+ }
+
+ TreeItem *patch_add = patches->create_item(patch_root);
+ patch_add->set_metadata(0,patchlist.size());
+ if (patchlist.size()==0)
+ patch_add->set_text(0,"Add initial export..");
+ else
+ patch_add->set_text(0,"Add previous patches..");
-void ProjectExportDialog::_quality_edited(float what) {
+ patch_add->add_button(0,get_icon("folder","FileDialog"),1);
- EditorImportExport::get_singleton()->set_export_image_quality(what);
- _save_export_cfg();
-}
+ _fill_resource_tree();
-void ProjectExportDialog::_shrink_edited(float what) {
+ updating=false;
- EditorImportExport::get_singleton()->set_export_image_shrink(what);
- _save_export_cfg();
}
-void ProjectExportDialog::_image_export_edited(int what) {
+void ProjectExportDialog::_patch_button_pressed(Object* p_item,int p_column,int p_id) {
- EditorImportExport::get_singleton()->set_export_image_action(EditorImportExport::ImageAction(what));
- _save_export_cfg();
-}
-void ProjectExportDialog::_format_toggled() {
+ TreeItem *ti = (TreeItem*)p_item;
- EditorImportExport::get_singleton()->get_image_formats().clear();
+ patch_index=ti->get_metadata(0);
- for(int i=0;i<formats.size();i++) {
- if (formats[i]->is_checked(0))
- EditorImportExport::get_singleton()->get_image_formats().insert( formats[i]->get_text(0));
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
+ if (p_id==0) {
+ Vector<String> patches = current->get_patches();
+ ERR_FAIL_INDEX(patch_index,patches.size());
+ patch_erase->set_text(vformat(TTR("Delete patch '"+patches[patch_index].get_file()+"' from list?")));
+ patch_erase->popup_centered_minsize();
+ } else {
+ patch_dialog->popup_centered_ratio();
}
- _save_export_cfg();
}
+void ProjectExportDialog::_patch_edited() {
-void ProjectExportDialog::_script_edited(Variant v) {
-
- if (updating_script)
+ TreeItem *item = patches->get_edited();
+ if (!item)
return;
- updating_script=true;
- EditorNode::get_undo_redo()->create_action(TTR("Edit Script Options"));
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_action",script_mode->get_selected());
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"script_set_action",EditorImportExport::get_singleton()->script_get_action());
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"script_set_encryption_key",script_key->get_text());
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"script_set_encryption_key",EditorImportExport::get_singleton()->script_get_encryption_key());
- EditorNode::get_undo_redo()->add_do_method(this,"_update_script");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_script");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->commit_action();
- updating_script=false;
-
-
-}
-
-void ProjectExportDialog::_sample_convert_edited(int what) {
- EditorImportExport::get_singleton()->sample_set_action( EditorImportExport::SampleAction(sample_mode->get_selected()));
- EditorImportExport::get_singleton()->sample_set_max_hz( sample_max_hz->get_value() );
- EditorImportExport::get_singleton()->sample_set_trim( sample_trim->is_pressed() );
- _save_export_cfg();
-
-}
-
-void ProjectExportDialog::_notification(int p_what) {
-
- switch(p_what) {
-
- case NOTIFICATION_ENTER_TREE: {
+ int index = item->get_metadata(0);
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
- CenterContainer *cc = memnew( CenterContainer );
- TextureFrame *tf = memnew( TextureFrame);
- tf->set_texture(get_icon("ErrorSign","EditorIcons"));
- cc->add_child(tf);
- plat_errors->add_child(cc);
- platform_error_string->raise();
+ Vector<String> patches = current->get_patches();
- TreeItem *root = platforms->create_item(NULL);
- List<StringName> ep;
- EditorImportExport::get_singleton()->get_export_platforms(&ep);
- ep.sort_custom<StringName::AlphCompare>();
+ ERR_FAIL_INDEX(index,patches.size());
- for(List<StringName>::Element *E=ep.front();E;E=E->next()) {
-
-
- Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->get());
- TreeItem *p = platforms->create_item(root);
- p->set_text(0,eep->get_name());
- p->set_icon(0,eep->get_logo());
- p->set_metadata(0,eep->get_name());
- if (eep->get_name()==OS::get_singleton()->get_name())
- p->select(0);
-
- }
-
- EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_scan_finished");
-// _rescan();
- _update_platform();
- export_mode->select( EditorImportExport::get_singleton()->get_export_filter() );
- convert_text_scenes->set_pressed( EditorImportExport::get_singleton()->get_convert_text_scenes() );
- filters->set_text( EditorImportExport::get_singleton()->get_export_custom_filter() );
- filters_exclude->set_text( EditorImportExport::get_singleton()->get_export_custom_filter_exclude() );
- if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED)
- tree_vb->hide();
- else
- tree_vb->show();
-
- image_action->select(EditorImportExport::get_singleton()->get_export_image_action());
- image_quality->set_value(EditorImportExport::get_singleton()->get_export_image_quality());
- image_shrink->set_value(EditorImportExport::get_singleton()->get_export_image_shrink());
- _update_script();
-
-
- image_quality->connect("value_changed",this,"_quality_edited");
- image_shrink->connect("value_changed",this,"_shrink_edited");
- image_action->connect("item_selected",this,"_image_export_edited");
-
- script_mode->connect("item_selected",this,"_script_edited");
- script_key->connect("text_changed",this,"_script_edited");
-
- for(int i=0;i<formats.size();i++) {
- if (EditorImportExport::get_singleton()->get_image_formats().has(formats[i]->get_text(0)))
- formats[i]->set_checked(0,true);
- }
- image_formats->connect("item_edited",this,"_format_toggled");
- group_add->set_icon(get_icon("Add","EditorIcons"));
-// group_del->set_icon(get_icon("Del","EditorIcons"));
-
- _update_group_list();
- _update_group();
- _update_group_tree();
-
- sample_mode->select( EditorImportExport::get_singleton()->sample_get_action() );
- sample_max_hz->set_value( EditorImportExport::get_singleton()->sample_get_max_hz() );
- sample_trim->set_pressed( EditorImportExport::get_singleton()->sample_get_trim() );
-
- sample_mode->connect("item_selected",this,"_sample_convert_edited");
- sample_max_hz->connect("value_changed",this,"_sample_convert_edited");
- sample_trim->connect("toggled",this,"_sample_convert_edited");
-
-
- } break;
- case NOTIFICATION_EXIT_TREE: {
-
- } break;
- case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
- //something may have changed
- _validate_platform();
-
- } break;
- case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible())
- _validate_platform();
+ String patch = patches[index].replace("*","");
- } break;
- case NOTIFICATION_PROCESS: {
-
- } break;
+ if (item->is_checked(0)) {
+ patch+="*";
}
-}
+ current->set_patch(index,patch);
-void ProjectExportDialog::_validate_platform() {
- get_ok()->set_disabled(true);
- button_export->set_disabled(true);
- TreeItem *selected = platforms->get_selected();
- plat_errors->hide();
- if (!selected) {
- return;
- }
+}
- String platform = selected->get_metadata(0);
- Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
- if (!exporter.is_valid()) {
- return;
- }
+void ProjectExportDialog::_patch_selected(const String& p_path) {
- String err;
- if (!exporter->can_export(&err)) {
- Vector<String> items = err.strip_edges().split("\n");
- err="";
- for(int i=0;i<items.size();i++) {
- if (i!=0)
- err+="\n";
- err+=" -"+items[i];
- }
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
- platform_error_string->set_text(err);
- plat_errors->show();
- return;
- }
+ Vector<String> patches = current->get_patches();
- List<String> pl;
- EditorFileSystem::get_singleton()->get_changed_sources(&pl);
+ if (patch_index >=patches.size()) {
- if (false && pl.size()) {
- if (pl.size()==1)
- platform_error_string->set_text(" -One Resource is pending re-import.");
- else
- platform_error_string->set_text(" "+itos(pl.size())+" Resources are pending re-import.");
+ current->add_patch(GlobalConfig::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);
- plat_errors->show();
- return;
}
- get_ok()->set_disabled(false);
- button_export->set_disabled(false);
-
-}
-
-void ProjectExportDialog::_export_mode_changed(int p_idx) {
-
- if (EditorImportExport::get_singleton()->get_export_filter()==p_idx)
- return;
- EditorImportExport::get_singleton()->set_export_filter(EditorImportExport::ExportFilter(p_idx));
-
- if (p_idx!=EditorImportExport::EXPORT_SELECTED)
- tree_vb->hide();
- else
- tree_vb->show();
-
- EditorImportExport::get_singleton()->set_convert_text_scenes( convert_text_scenes->is_pressed() );
-
- _save_export_cfg();
+ _edit_preset(presets->get_current());
}
-void ProjectExportDialog::_export_action(const String& p_file) {
-
- String location = GlobalConfig::get_singleton()->globalize_path(p_file).get_base_dir().replace("\\","/");
-
- while(true) {
-
- print_line("TESTING: "+location.plus_file("engine.cfg"));
- if (FileAccess::exists(location.plus_file("engine.cfg"))) {
-
- error->set_text(TTR("Please export outside the project folder!"));
- error->popup_centered_minsize();
- return;
- }
- String nl = (location+"/..").simplify_path();
- if (nl.find("/")==location.find_last("/"))
- break;
- location=nl;
- }
-
- /* Checked if the export location is outside the project directory,
- * now will check if a file name has been entered */
- if (p_file.ends_with("/")) {
+void ProjectExportDialog::_patch_deleted() {
- error->set_text("Please enter a file name!");
- error->popup_centered_minsize();
- return;
- }
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
- TreeItem *selected = platforms->get_selected();
- if (!selected)
- return;
+ Vector<String> patches = current->get_patches();
+ if (patch_index <patches.size()) {
- String platform = selected->get_metadata(0);
- bool debugging_enabled = EditorImportExport::get_singleton()->get_export_platform(platform)->is_debugging_enabled();
- Error err = export_platform(platform,p_file,debugging_enabled,file_export_password->get_text(),false);
- if (err!=OK) {
- error->set_text(TTR("Error exporting project!"));
- error->popup_centered_minsize();
+ current->remove_patch(patch_index);
+ _edit_preset(presets->get_current());
}
}
-void ProjectExportDialog::_export_action_pck(const String& p_file) {
+void ProjectExportDialog::_runnable_pressed() {
- TreeItem *selected = platforms->get_selected();
- if (!selected)
+ if (updating)
return;
- Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(selected->get_metadata(0));
- if (exporter.is_null()) {
- ERR_PRINT("Invalid platform for export of PCK");
- return;
- }
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
- if (p_file.ends_with(".pck")) {
- FileAccess *f = FileAccess::open(p_file,FileAccess::WRITE);
- if (!f) {
- error->set_text(TTR("Error writing the project PCK!"));
- error->popup_centered_minsize();
- }
- ERR_FAIL_COND(!f);
+ if (runnable->is_pressed()) {
- Error err = exporter->save_pack(f,false);
- memdelete(f);
-
- if (err!=OK) {
- error->set_text(TTR("Error exporting project!"));
- error->popup_centered_minsize();
- return;
- }
- } else if (p_file.ends_with(".zip")) {
-
- Error err = exporter->save_zip(p_file,false);
-
- if (err!=OK) {
- error->set_text(TTR("Error exporting project!"));
- error->popup_centered_minsize();
- return;
- }
- }
-}
-
-
-Error ProjectExportDialog::export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password, bool p_quit_after) {
-
- Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(p_platform);
- if (exporter.is_null()) {
- ERR_PRINT("Invalid platform for export");
-
- List<StringName> platforms;
- EditorImportExport::get_singleton()->get_export_platforms(&platforms);
- print_line("Valid export plaftorms are:");
- for (List<StringName>::Element *E=platforms.front();E;E=E->next())
- print_line(" \""+E->get()+"\"");
-
- if (p_quit_after) {
- OS::get_singleton()->set_exit_code(255);
- get_tree()->quit();
- }
-
- return ERR_INVALID_PARAMETER;
- }
- Error err = exporter->export_project(p_path,p_debug);
- if (err!=OK) {
- error->set_text(TTR("Error exporting project!"));
- error->popup_centered_minsize();
- ERR_PRINT("Exporting failed!");
- if (p_quit_after) {
- OS::get_singleton()->set_exit_code(255);
- get_tree()->quit();
+ for(int i=0;i<EditorExport::get_singleton()->get_export_preset_count();i++) {
+ Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
+ if (p->get_platform()==current->get_platform()) {
+ p->set_runnable(current==p);
+ }
}
- return ERR_CANT_CREATE;
} else {
- if (p_quit_after) {
- get_tree()->quit();
- }
- }
- return OK;
+ current->set_runnable(false);
+ }
+ _update_presets();
}
-void ProjectExportDialog::ok_pressed() {
- //export pck
- pck_export->popup_centered_ratio();
-
-}
-void ProjectExportDialog::custom_action(const String&) {
- //real export
+void ProjectExportDialog::_name_changed(const String& p_string) {
- TreeItem *selected = platforms->get_selected();
- if (!selected)
- return;
-
- String platform = selected->get_metadata(0);
- Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
-
- if (exporter.is_null()) {
- error->set_text(vformat(TTR("No exporter for platform '%s' yet."),platform));
- error->popup_centered_minsize();
- return;
- }
-
- if (platform.to_lower()=="android" && _check_android_setting(exporter)==false){
- // not filled all field for Android release
+ if (updating)
return;
- }
-
- String extension = exporter->get_binary_extension();
- file_export_password->set_editable( exporter->requires_password(exporter->is_debugging_enabled()) );
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND(current.is_null());
- file_export->clear_filters();
- if (extension!="") {
- file_export->add_filter("*."+extension);
- }
- file_export->popup_centered_ratio();
+ current->set_name(p_string);
+ _update_presets();
}
-LineEdit* ProjectExportDialog::_create_keystore_input(Control* container, const String& p_label, const String& name) {
-
- HBoxContainer* hb=memnew(HBoxContainer);
- Label* lb=memnew(Label);
- LineEdit* input=memnew(LineEdit);
-
- lb->set_text(p_label);
- lb->set_custom_minimum_size(Size2(140*EDSCALE,0));
- lb->set_align(Label::ALIGN_RIGHT);
-
- input->set_custom_minimum_size(Size2(170*EDSCALE,0));
- input->set_name(name);
+void ProjectExportDialog::_delete_preset() {
- hb->add_constant_override("separation", 10*EDSCALE);
- hb->add_child(lb);
- hb->add_child(input);
- container->add_child(hb);
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ if (current.is_null())
+ return;
- return input;
+ delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"),current->get_name()));
+ delete_confirm->popup_centered_minsize();
}
-void ProjectExportDialog::_create_android_keystore_window() {
-
- keystore_file_dialog = memnew( EditorFileDialog );
- add_child(keystore_file_dialog);
- keystore_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR);
- keystore_file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- keystore_file_dialog->set_current_dir( "res://" );
-
- keystore_file_dialog->set_title(TTR("Target Path:"));
- keystore_file_dialog->connect("dir_selected", this,"_keystore_dir_selected");
-
- keystore_create_dialog=memnew(ConfirmationDialog);
- VBoxContainer* vb=memnew(VBoxContainer);
- vb->set_size(Size2(340*EDSCALE,0));
- keystore_create_dialog->set_title(TTR("Create Android keystore"));
-
- _create_keystore_input(vb, TTR("Full name"), "name");
- _create_keystore_input(vb, TTR("Organizational unit"), "unit");
- _create_keystore_input(vb, TTR("Organization"), "org");
- _create_keystore_input(vb, TTR("City"), "city");
- _create_keystore_input(vb, TTR("State"), "state");
- _create_keystore_input(vb, TTR("2 letter country code"), "code");
- _create_keystore_input(vb, TTR("User alias"), "alias");
- LineEdit* pass=_create_keystore_input(vb, TTR("Password"), "pass");
- pass->set_placeholder(TTR("at least 6 characters"));
- _create_keystore_input(vb, TTR("File name"), "file");
-
- Label* lb_path=memnew(Label);
- LineEdit* path=memnew(LineEdit);
- Button* btn=memnew(Button);
- HBoxContainer* hb=memnew(HBoxContainer);
-
- lb_path->set_text(TTR("Path : (better to save outside of project)"));
- path->set_h_size_flags(SIZE_EXPAND_FILL);
- path->set_name("path");
- btn->set_text(" .. ");
- btn->connect("pressed", keystore_file_dialog, "popup_centered_ratio");
-
- vb->add_spacer();
- vb->add_child(lb_path);
- hb->add_child(path);
- hb->add_child(btn);
- vb->add_child(hb);
-
- keystore_create_dialog->add_child(vb);
- //keystore_create_dialog->set_child_rect(vb);
- add_child(keystore_create_dialog);
-
- keystore_create_dialog->connect("confirmed", this, "_create_android_keystore");
- path->connect("text_changed", this, "_check_keystore_path");
-
- confirm_keystore = memnew(ConfirmationDialog);
- confirm_keystore->connect("confirmed", keystore_create_dialog, "popup_centered_minsize");
- add_child(confirm_keystore);
+void ProjectExportDialog::_delete_preset_confirm() {
+ int idx = presets->get_current();
+ parameters->edit(NULL);//to avoid crash
+ EditorExport::get_singleton()->remove_export_preset(idx);
+ _update_presets();
+ _edit_preset(-1);
}
-void ProjectExportDialog::_keystore_dir_selected(const String& path) {
-
- LineEdit* edit=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>();
- edit->set_text(path.simplify_path());
-}
+Variant ProjectExportDialog::get_drag_data_fw(const Point2& p_point,Control* p_from) {
-void ProjectExportDialog::_keystore_created() {
+ if (p_from==presets) {
+ int pos = presets->get_item_at_pos(p_point,true);
- if (error->is_connected("popup_hide", this, "_keystore_created")){
- error->disconnect("popup_hide", this, "_keystore_created");
- }
- custom_action("export_pck");
+ if (pos>=0) {
+ Dictionary d;
+ d["type"]="export_preset";
+ d["preset"]=pos;
-}
+ HBoxContainer *drag = memnew( HBoxContainer);
+ TextureRect *tr = memnew(TextureRect);
+ tr->set_texture(presets->get_item_icon(pos));
+ drag->add_child(tr);
+ Label *label = memnew( Label );
+ label->set_text(presets->get_item_text(pos));
+ drag->add_child(label);
-void ProjectExportDialog::_check_keystore_path(const String& path) {
+ set_drag_preview(drag);
- LineEdit* edit=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>();
- bool exists = DirAccess::exists(path);
- if (!exists) {
- edit->add_color_override("font_color", Color(1,0,0,1));
- } else {
- edit->add_color_override("font_color", Color(0,1,0,1));
- }
+ return d;
-}
+ }
+ } else if (p_from==patches) {
-void ProjectExportDialog::_create_android_keystore() {
+ TreeItem *item = patches->get_item_at_pos(p_point);
- Vector<String> names=String("name,unit,org,city,state,code,alias,pass").split(",");
- String path=keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>()->get_text();
- String file=keystore_create_dialog->find_node("file", true, false)->cast_to<LineEdit>()->get_text();
+ if (item && item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK) {
- if (file.ends_with(".keystore")==false) {
- file+=".keystore";
- }
- String fullpath=path.plus_file(file);
- String info="CN=$name, OU=$unit, O=$org, L=$city, S=$state, C=$code";
- Dictionary dic;
-
- for (int i=0;i<names.size();i++){
- LineEdit* edit = keystore_create_dialog->find_node(names[i], true, false)->cast_to<LineEdit>();
- dic[names[i]]=edit->get_text();
- info=info.replace("$"+names[i], edit->get_text());
- }
+ int metadata = item->get_metadata(0);
+ Dictionary d;
+ d["type"]="export_patch";
+ d["patch"]=metadata;
- String jarsigner=EditorSettings::get_singleton()->get("export/android/jarsigner");
- String keytool=jarsigner.get_base_dir().plus_file("keytool");
- String os_name=OS::get_singleton()->get_name();
- if (os_name.to_lower()=="windows") {
- keytool+=".exe";
- }
+ Label *label = memnew( Label );
+ label->set_text(item->get_text(0));
+ set_drag_preview(label);
- bool exist=FileAccess::exists(keytool);
- if (!exist) {
- error->set_text("Can't find 'keytool'");
- error->popup_centered_minsize();
- return;
- }
+ return d;
+ }
- List<String> args;
- args.push_back("-genkey");
- args.push_back("-v");
- args.push_back("-keystore");
- args.push_back(fullpath);
- args.push_back("-alias");
- args.push_back(dic["alias"]);
- args.push_back("-storepass");
- args.push_back(dic["pass"]);
- args.push_back("-keypass");
- args.push_back(dic["pass"]);
- args.push_back("-keyalg");
- args.push_back("RSA");
- args.push_back("-keysize");
- args.push_back("2048");
- args.push_back("-validity");
- args.push_back("10000");
- args.push_back("-dname");
- args.push_back(info);
- int retval;
- OS::get_singleton()->execute(keytool,args,true,NULL,NULL,&retval);
-
- if (retval==0) { // success
- platform_options->_edit_set("keystore/release", fullpath);
- platform_options->_edit_set("keystore/release_user", dic["alias"]);
- platform_options->_edit_set("keystore/release_password", dic["pass"]);
-
- error->set_text("Android keystore created at \n"+fullpath);
- error->connect("popup_hide", this, "_keystore_created");
- error->popup_centered_minsize();
- } else { // fail
- error->set_text("Fail to create android keystore at \n"+fullpath);
- error->popup_centered_minsize();
}
+ return Variant();
}
-bool ProjectExportDialog::_check_android_setting(const Ref<EditorExportPlatform>& exporter) {
-
- bool is_debugging = exporter->get("debug/debugging_enabled");
- String release = exporter->get("keystore/release");
- String user = exporter->get("keystore/release_user");
- String password = exporter->get("keystore/release_password");
-
- if (!is_debugging && (release=="" || user=="" || password=="")){
- if (release==""){
- confirm_keystore->set_text(TTR("Release keystore is not set.\nDo you want to create one?"));
- confirm_keystore->popup_centered_minsize();
- } else {
- error->set_text(TTR("Fill Keystore/Release User and Release Password"));
- error->popup_centered_minsize();
- }
- return false;
- }
-
- return true;
+bool ProjectExportDialog::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const{
-}
+ if (p_from==presets) {
+ Dictionary d = p_data;
+ if (!d.has("type") || String(d["type"])!="export_preset")
+ return false;
-void ProjectExportDialog::_group_selected() {
+ if (presets->get_item_at_pos(p_point,true)<0 && !presets->is_pos_at_end_of_items(p_point))
+ return false;
+ } else if (p_from==patches) {
- _update_group(); //?
+ Dictionary d = p_data;
+ if (!d.has("type") || String(d["type"])!="export_patch")
+ return false;
- _update_group_tree();
-}
+ patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
-String ProjectExportDialog::_get_selected_group() {
+ TreeItem *item = patches->get_item_at_pos(p_point);
- TreeItem *sel = groups->get_selected();
- if (!sel)
- return String();
+ if (!item) {
- return sel->get_text(0);
+ return false;
+ }
+ }
+ return true;
}
-void ProjectExportDialog::_update_group_list() {
+void ProjectExportDialog::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
- String current = _get_selected_group();
+ if (p_from==presets) {
+ Dictionary d=p_data;
+ int from_pos = d["preset"];
- groups->clear();
- List<StringName> grouplist;
- EditorImportExport::get_singleton()->image_export_get_groups(&grouplist);
- grouplist.sort_custom<StringName::AlphCompare>();
+ int to_pos=-1;
- TreeItem *r = groups->create_item();
- for (List<StringName>::Element *E=grouplist.front();E;E=E->next()) {
-
- TreeItem *ti = groups->create_item(r);
- ti->set_text(0,E->get());
- ti->add_button(0,get_icon("Remove","EditorIcons"));
- if (E->get()==current) {
- ti->select(0);
+ if (presets->get_item_at_pos(p_point,true)>=0) {
+ to_pos = presets->get_item_at_pos(p_point,true);
}
- }
- _update_group();
-}
-
-void ProjectExportDialog::_select_group(const String& p_by_name) {
-
- TreeItem *c = groups->get_root();
- if (!c)
- return;
- c=c->get_children();
-
- if (!c)
- return;
-
- while(c) {
+ if (to_pos==-1 && !presets->is_pos_at_end_of_items(p_point))
+ return;
- if (c->get_text(0)==p_by_name) {
- c->select(0);
- _update_group();
+ if (to_pos==from_pos)
return;
+ else if (to_pos>from_pos) {
+ to_pos--;
}
- c=c->get_next();
- }
-}
-
-void ProjectExportDialog::_update_group() {
-
- if (updating)
- return;
- updating=true;
- if (_get_selected_group()=="") {
- group_options->hide();
- //group_del->set_disabled(true);
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(from_pos);
+ EditorExport::get_singleton()->remove_export_preset(from_pos);
+ EditorExport::get_singleton()->add_export_preset(preset,to_pos);
- } else {
- group_options->show();
- //group_del->set_disabled(false);
- StringName name = _get_selected_group();
- group_image_action->select(EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
- group_atlas->set_pressed(EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
- group_shrink->set_value(EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
- group_lossy_quality->set_value(EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
- if (group_atlas->is_pressed())
- atlas_preview->show();
+ _update_presets();
+ if (to_pos>=0)
+ _edit_preset(to_pos);
else
- atlas_preview->hide();
+ _edit_preset(presets->get_item_count()-1);
+ } else if (p_from==patches) {
- }
-
- _update_group_tree();
-
- updating=false;
+ Dictionary d = p_data;
+ if (!d.has("type") || String(d["type"])!="export_patch")
+ return;
+ int from_pos = d["patch"];
-}
+ TreeItem *item = patches->get_item_at_pos(p_point);
+ if (!item)
+ return;
-bool ProjectExportDialog::_update_group_treef(TreeItem *p_parent,EditorFileSystemDirectory *p_dir,const Set<String>& p_extensions,const String& p_groups,const Map<StringName,int>& p_group_index) {
+ int to_pos = item->get_cell_mode(0)==TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
- TreeItem *ti = group_images->create_item(p_parent);
- ti->set_text(0,p_dir->get_name()+"/");
- bool has_child=false;
- for(int i=0;i<p_dir->get_subdir_count();i++) {
-
- if (_update_group_treef(ti,p_dir->get_subdir(i),p_extensions,p_groups,p_group_index)) {
- has_child=true;
+ if (to_pos==from_pos)
+ return;
+ else if (to_pos>from_pos) {
+ to_pos--;
}
- }
-
- String filter=group_images_filter->get_text();
- StringName current_group = _get_selected_group();
- String check_text=TTR("Include");
-
- for(int i=0;i<p_dir->get_file_count();i++) {
-
- String fname = p_dir->get_file(i);
- if (p_extensions.has(fname.to_lower().extension())) {
- String path = p_dir->get_file_path(i);
-
- if (filter!=String() && path.find(filter)==-1)
- continue;
- has_child=true;
- TreeItem *file = group_images->create_item(ti);
- file->set_text(0,fname);
+ Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ String patch = preset->get_patch(from_pos);
+ preset->remove_patch(from_pos);
+ preset->add_patch(patch,to_pos);
- StringName g = EditorImportExport::get_singleton()->image_get_export_group(path);
+ _edit_preset(presets->get_current());
- if (current_group==g || g==StringName()) {
-
- file->set_cell_mode(1,TreeItem::CELL_MODE_CHECK);
- file->set_text(1,check_text);
- file->set_editable(1,true);
- file->set_checked(1,current_group==g);
- } else {
-
- file->set_text(1,g);
- file->set_editable(1,false);
- file->set_selectable(1,false);
- }
-
- file->set_metadata(0,path);
- }
- }
-
- if (!has_child) {
- memdelete(ti);
- return false;
}
- return true;
-
}
-void ProjectExportDialog::_update_group_tree() {
+
+void ProjectExportDialog::_export_type_changed(int p_which) {
if (updating)
return;
- group_images->clear();
-
- if (_get_selected_group()=="")
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ if (current.is_null())
return;
+ current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
updating=true;
- print_line("****UGT");
- List<String> img_extensions;
- ImageLoader::get_recognized_extensions(&img_extensions);
- Set<String> extensions;
- for(List<String>::Element *E=img_extensions.front();E;E=E->next()) {
-
- extensions.insert(E->get());
- }
-
- List<StringName> grouplist;
- EditorImportExport::get_singleton()->image_export_get_groups(&grouplist);
- grouplist.sort_custom<StringName::AlphCompare>();
- Map<StringName,int> group_index;
- group_index[StringName()]=0;
- int idx=1;
- String groupenum="--";
- for(List<StringName>::Element *E=grouplist.front();E;E=E->next()) {
-
- group_index[E->get()]=idx++;
- groupenum+=","+String(E->get());
- }
-
+ _fill_resource_tree();
updating=false;
-
- _update_group_treef(NULL,EditorFileSystem::get_singleton()->get_filesystem(),extensions,groupenum,group_index);
-
}
-void ProjectExportDialog::_group_changed(Variant v) {
+void ProjectExportDialog::_filter_changed(const String& p_filter) {
if (updating)
return;
- if (_get_selected_group()=="")
- return;
- updating=true;
- StringName name = _get_selected_group();
- EditorNode::get_undo_redo()->create_action(TTR("Change Image Group"));
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,group_image_action->get_selected());
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,group_atlas->is_pressed());
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,group_shrink->get_value());
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,group_lossy_quality->get_value());
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->commit_action();
- updating=false;
- // update atlas preview button
- _update_group();
-}
-void ProjectExportDialog::_group_item_edited() {
-
- TreeItem *item = group_images->get_edited();
- if (!item)
- return;
- if (_get_selected_group()==String())
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ if (current.is_null())
return;
- StringName path = item->get_metadata(0);
- String group;
- if (item->is_checked(1)) {
- group=_get_selected_group();
- } else {
- group=String();
- }
+ current->set_include_filter(include_filters->get_text());
+ current->set_exclude_filter(exclude_filters->get_text());
+
- print_line("changed "+path+" to group: "+group);
- EditorNode::get_undo_redo()->create_action(TTR("Change Image Group"));
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,group);
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",path,EditorImportExport::get_singleton()->image_get_export_group(path));
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->commit_action();
}
-void ProjectExportDialog::_group_add() {
+void ProjectExportDialog::_fill_resource_tree() {
- String name = group_new_name->get_text();
+ include_files->clear();
+ include_label->hide();
+ include_margin->hide();
- if (name=="") {
- group_new_name_error->show();
- group_new_name_error->set_text(TTR("Group name can't be empty!"));
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ if (current.is_null())
return;
- }
- if (name.find("/")!=-1 || name.find(":")!=-1 || name.find(",")!=-1 || name.find("-")!=-1) {
- group_new_name_error->set_text(TTR("Invalid character in group name!"));
- group_new_name_error->show();
- return;
- }
- if (EditorImportExport::get_singleton()->image_export_has_group(name)) {
- group_new_name_error->set_text(TTR("Group name already exists!"));
- group_new_name_error->show();
+ EditorExportPreset::ExportFilter f = current->get_export_filter();
+
+ if (f==EditorExportPreset::EXPORT_ALL_RESOURCES) {
return;
}
- group_new_name_error->hide();
-
- String current=_get_selected_group();
+ include_label->show();
+ include_margin->show();
- EditorNode::get_undo_redo()->create_action(TTR("Add Image Group"));
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_create",name);
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_remove",name);
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_list");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_list");
- EditorNode::get_undo_redo()->add_do_method(this,"_select_group",name);
- if (current!="")
- EditorNode::get_undo_redo()->add_undo_method(this,"_select_group",current);
+ TreeItem *root = include_files->create_item();
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->commit_action();
+ _fill_tree(EditorFileSystem::get_singleton()->get_filesystem(),root,current,f==EditorExportPreset::EXPORT_SELECTED_SCENES);
}
-void ProjectExportDialog::_group_del(Object *p_item, int p_column, int p_button){
-
- TreeItem *item = p_item->cast_to<TreeItem>();
- if (!item)
- return;
- String name = item->get_text(0);
-
- EditorNode::get_undo_redo()->create_action(TTR("Delete Image Group"));
- List<StringName> images_used;
- EditorImportExport::get_singleton()->image_export_get_images_in_group(name,&images_used);
- for (List<StringName>::Element*E=images_used.front();E;E=E->next()) {
-
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),StringName());
-
- }
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_export_group_remove",name);
-
+bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> &current,bool p_only_scenes) {
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_create",name);
- for (List<StringName>::Element*E=images_used.front();E;E=E->next()) {
+ p_item->set_icon(0,get_icon("folder","FileDialog"));
+ p_item->set_text(0,p_dir->get_name()+"/");
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),name);
+ bool used=false;
+ for(int i=0;i<p_dir->get_subdir_count();i++) {
+ TreeItem *subdir = include_files->create_item(p_item);
+ if (_fill_tree(p_dir->get_subdir(i),subdir,current,p_only_scenes)==false) {
+ memdelete(subdir);
+ } else {
+ used=true;
+ }
}
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_image_action",name,EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_make_atlas",name,EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_shrink",name,EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_export_group_set_lossy_quality",name,EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
-
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_list");
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_list");
- EditorNode::get_undo_redo()->add_undo_method(this,"_select_group",name);
-
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->commit_action();
-
-}
-
-void ProjectExportDialog::_group_select_all() {
- String group = _get_selected_group();
- if (group=="")
- return;
-
- TreeItem *item = group_images->get_root();
- if (!item)
- return;
-
- List<StringName> items;
- while(item) {
+ for(int i=0;i<p_dir->get_file_count();i++) {
- if (item->get_cell_mode(1)==TreeItem::CELL_MODE_CHECK && !item->is_checked(1))
- items.push_back(item->get_metadata(0));
- item=item->get_next_visible();
- }
+ String type = p_dir->get_file_type(i);
+ if (p_only_scenes && type!="PackedScene")
+ continue;
+ TreeItem *file = include_files->create_item(p_item);
+ file->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
+ file->set_text(0,p_dir->get_file(i));
- if (items.size()==0)
- return;
+ Ref<Texture> tex;
+ if (has_icon(type,editor_icons)) {
+ tex = get_icon(type,editor_icons);
+ } else {
+ tex = get_icon("Object",editor_icons);
+ }
- EditorNode::get_undo_redo()->create_action(TTR("Select All"));
+ String path = p_dir->get_file_path(i);
- for (List<StringName>::Element *E=items.front();E;E=E->next()) {
+ file->set_icon(0,tex);
+ file->set_editable(0,true);
+ file->set_checked(0,current->has_export_file(path));
+ file->set_metadata(0,path);
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),group);
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),String());
+ used=true;
}
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
-
- EditorNode::get_undo_redo()->commit_action();
+ return used;
}
-void ProjectExportDialog::_group_select_none(){
+void ProjectExportDialog::_tree_changed() {
- String group = _get_selected_group();
- if (group=="")
+ if (updating)
return;
- TreeItem *item = group_images->get_root();
- if (!item)
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ if (current.is_null())
return;
- List<StringName> items;
- while(item) {
-
- if (item->get_cell_mode(1)==TreeItem::CELL_MODE_CHECK && item->is_checked(1))
- items.push_back(item->get_metadata(0));
- item=item->get_next_visible();
- }
-
-
- if (items.size()==0)
+ TreeItem *item = include_files->get_edited();
+ if (!item)
return;
- EditorNode::get_undo_redo()->create_action(TTR("Select All"));
-
- for (List<StringName>::Element *E=items.front();E;E=E->next()) {
+ String path = item->get_metadata(0);
+ bool added = item->is_checked(0);
- EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),String());
- EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(),"image_add_to_export_group",E->get(),group);
+ if (added) {
+ current->add_export_file(path);
+ } else {
+ current->remove_export_file(path);
}
- EditorNode::get_undo_redo()->add_do_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_undo_method(this,"_update_group_tree");
- EditorNode::get_undo_redo()->add_do_method(this,"_save_export_cfg");
- EditorNode::get_undo_redo()->add_undo_method(this,"_save_export_cfg");
-
- EditorNode::get_undo_redo()->commit_action();
-
}
-void ProjectExportDialog::_group_atlas_preview() {
-
- StringName group = _get_selected_group();
- if (!group)
- return;
-
- atlas_preview_frame->set_texture(Ref<Texture>()); //clear previous
-
- List<StringName> images;
- EditorImportExport::get_singleton()->image_export_get_images_in_group(group,&images);
- images.sort_custom<StringName::AlphCompare>();
-
- String dst_file = EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-preview.tex";
- Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata );
- //imd->set_editor();
-
- for (List<StringName>::Element *F=images.front();F;F=F->next()) {
-
- imd->add_source(EditorImportPlugin::validate_source_path(F->get()));
- }
-
-
- int flags=0;
-
- if (GlobalConfig::get_singleton()->get("image_loader/filter"))
- flags|=EditorTextureImportPlugin::IMAGE_FLAG_FILTER;
- if (!GlobalConfig::get_singleton()->get("image_loader/gen_mipmaps"))
- flags|=EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS;
- if (!GlobalConfig::get_singleton()->get("image_loader/repeat"))
- flags|=EditorTextureImportPlugin::IMAGE_FLAG_REPEAT;
-
- flags|=EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA;
-
- imd->set_option("format",EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS);
- imd->set_option("flags",flags);
- imd->set_option("quality",0.7);
- imd->set_option("atlas",true);
- imd->set_option("crop",true);
-
- Ref<EditorTextureImportPlugin> plugin = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture");
- Error err = plugin->import2(dst_file,imd,EditorExportPlatform::IMAGE_COMPRESSION_NONE,true);
- if (err) {
-
- EditorNode::add_io_error(TTR("Error saving atlas:")+" "+dst_file.get_file());
- return;
- }
- Ref<Texture> tex = ResourceLoader::load(dst_file);
- atlas_preview_frame->set_texture(tex); //clear previous
- atlas_preview_dialog->set_title(TTR("Atlas Preview")+" ("+itos(tex->get_width())+"x"+itos(tex->get_height())+")");
- atlas_preview_dialog->popup_centered_ratio(0.9);
+void ProjectExportDialog::_export_pck_zip() {
+ export_pck_zip->popup_centered_ratio();
}
-void ProjectExportDialog::_update_script() {
+void ProjectExportDialog::_export_pck_zip_selected(const String& p_path) {
- if (updating_script)
- return;
- updating_script=true;
- script_mode->select(EditorImportExport::get_singleton()->script_get_action());
- script_key->set_text(EditorImportExport::get_singleton()->script_get_encryption_key());
- updating_script=false;
+ Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
+ ERR_FAIL_COND (current.is_null());
+ Ref<EditorExportPlatform> platform = current->get_platform();
+ ERR_FAIL_COND( platform.is_null() );
+ if (p_path.ends_with(".zip")) {
+ platform->save_zip(current,p_path);
+ } else if (p_path.ends_with(".pck")) {
+ platform->save_pack(current,p_path);
+ }
}
-void ProjectExportDialog::_image_filter_changed(String) {
-
- _update_group_tree();
-}
void ProjectExportDialog::_bind_methods() {
-
- ClassDB::bind_method(_MD("_rescan"),&ProjectExportDialog::_rescan);
- ClassDB::bind_method(_MD("_tree_changed"),&ProjectExportDialog::_tree_changed);
- ClassDB::bind_method(_MD("_scan_finished"),&ProjectExportDialog::_scan_finished);
- ClassDB::bind_method(_MD("_platform_selected"),&ProjectExportDialog::_platform_selected);
- ClassDB::bind_method(_MD("_prop_edited"),&ProjectExportDialog::_prop_edited);
- ClassDB::bind_method(_MD("_export_mode_changed"),&ProjectExportDialog::_export_mode_changed);
- ClassDB::bind_method(_MD("_filters_edited"),&ProjectExportDialog::_filters_edited);
- ClassDB::bind_method(_MD("_filters_exclude_edited"),&ProjectExportDialog::_filters_exclude_edited);
- ClassDB::bind_method(_MD("_export_action"),&ProjectExportDialog::_export_action);
- ClassDB::bind_method(_MD("_export_action_pck"),&ProjectExportDialog::_export_action_pck);
- ClassDB::bind_method(_MD("_quality_edited"),&ProjectExportDialog::_quality_edited);
- ClassDB::bind_method(_MD("_shrink_edited"),&ProjectExportDialog::_shrink_edited);
- ClassDB::bind_method(_MD("_image_export_edited"),&ProjectExportDialog::_image_export_edited);
- ClassDB::bind_method(_MD("_format_toggled"),&ProjectExportDialog::_format_toggled);
- ClassDB::bind_method(_MD("_group_changed"),&ProjectExportDialog::_group_changed);
- ClassDB::bind_method(_MD("_group_add"),&ProjectExportDialog::_group_add);
- ClassDB::bind_method(_MD("_group_del"),&ProjectExportDialog::_group_del);
- ClassDB::bind_method(_MD("_group_selected"),&ProjectExportDialog::_group_selected);
- ClassDB::bind_method(_MD("_update_group"),&ProjectExportDialog::_update_group);
- ClassDB::bind_method(_MD("_update_group_list"),&ProjectExportDialog::_update_group_list);
- ClassDB::bind_method(_MD("_select_group"),&ProjectExportDialog::_select_group);
- ClassDB::bind_method(_MD("_update_group_tree"),&ProjectExportDialog::_update_group_tree);
- ClassDB::bind_method(_MD("_group_item_edited"),&ProjectExportDialog::_group_item_edited);
- ClassDB::bind_method(_MD("_save_export_cfg"),&ProjectExportDialog::_save_export_cfg);
- ClassDB::bind_method(_MD("_image_filter_changed"),&ProjectExportDialog::_image_filter_changed);
- ClassDB::bind_method(_MD("_group_atlas_preview"),&ProjectExportDialog::_group_atlas_preview);
- ClassDB::bind_method(_MD("_group_select_all"),&ProjectExportDialog::_group_select_all);
- ClassDB::bind_method(_MD("_group_select_none"),&ProjectExportDialog::_group_select_none);
- ClassDB::bind_method(_MD("_script_edited"),&ProjectExportDialog::_script_edited);
- ClassDB::bind_method(_MD("_update_script"),&ProjectExportDialog::_update_script);
- ClassDB::bind_method(_MD("_sample_convert_edited"),&ProjectExportDialog::_sample_convert_edited);
-
-
- ClassDB::bind_method(_MD("export_platform"),&ProjectExportDialog::export_platform);
- ClassDB::bind_method(_MD("_create_android_keystore"),&ProjectExportDialog::_create_android_keystore);
- ClassDB::bind_method(_MD("_check_keystore_path"),&ProjectExportDialog::_check_keystore_path);
- ClassDB::bind_method(_MD("_keystore_dir_selected"),&ProjectExportDialog::_keystore_dir_selected);
- ClassDB::bind_method(_MD("_keystore_created"),&ProjectExportDialog::_keystore_created);
-
-
-// ADD_SIGNAL(MethodInfo("instance"));
-// ADD_SIGNAL(MethodInfo("open"));
-
-}
-
-
-ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
-
- editor=p_editor;
- set_title(TTR("Project Export Settings"));
-
- sections = memnew( TabContainer );
- add_child(sections);
- //set_child_rect(sections);
-
- VBoxContainer *pvbox = memnew( VBoxContainer );
- sections->add_child(pvbox);
- pvbox->set_name(TTR("Target"));
-
- HBoxContainer *phbox = memnew( HBoxContainer );
- pvbox->add_child(phbox);
- phbox->set_v_size_flags(SIZE_EXPAND_FILL);
-
- plat_errors = memnew( HBoxContainer );
- pvbox->add_child(plat_errors);
- platform_error_string = memnew( Label );
- platform_error_string->set_h_size_flags(SIZE_EXPAND_FILL);
- plat_errors->add_child(platform_error_string);
-
- VBoxContainer *vb = memnew( VBoxContainer );
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
- vb->set_v_size_flags(SIZE_EXPAND_FILL);
- phbox->add_child(vb);
- platforms = memnew( Tree );
- platforms->set_hide_root(true);
- vb->add_margin_child(TTR("Export to Platform"),platforms,true);
-
- platforms->connect("cell_selected",this,"_platform_selected");
-
-
- vb = memnew(VBoxContainer );
- phbox->add_child(vb);
- vb->set_h_size_flags(SIZE_EXPAND_FILL);
- vb->set_v_size_flags(SIZE_EXPAND_FILL);
- platform_options = memnew( PropertyEditor() );
- platform_options->hide_top_label();
- vb->add_margin_child(TTR("Options"),platform_options,true);
- platform_options->connect("property_edited",this,"_prop_edited");
-
-
-
- //////////////////
-
- vb = memnew( VBoxContainer );
- vb->set_name(TTR("Resources"));
- sections->add_child(vb);
-
- export_mode = memnew( OptionButton );
- export_mode->add_item(TTR("Export selected resources (including dependencies)."));
- export_mode->add_item(TTR("Export all resources in the project."));
- export_mode->add_item(TTR("Export all files in the project directory."));
- export_mode->connect("item_selected",this,"_export_mode_changed");
-
- vb->add_margin_child(TTR("Export Mode:"),export_mode);
-
-
-
- tree_vb = memnew( VBoxContainer );
- vb->add_child(tree_vb);
- tree_vb->set_v_size_flags(SIZE_EXPAND_FILL);
-
- tree = memnew( Tree );
- tree_vb->add_margin_child(TTR("Resources to Export:"),tree,true);
-
- tree->set_v_size_flags(SIZE_EXPAND_FILL);
- tree->connect("item_edited",this,"_tree_changed");
- tree->set_columns(2);
- tree->set_column_titles_visible(true);
- tree->set_column_title(0,TTR("File"));
- tree->set_column_title(1,TTR("Action"));
- tree->set_column_expand(1,false);
- tree->set_column_min_width(1,90);
-
- filters = memnew( LineEdit );
- vb->add_margin_child(TTR("Filters to export non-resource files (comma-separated, e.g.: *.json, *.txt):"),filters);
- filters->connect("text_changed",this,"_filters_edited");
- filters_exclude = memnew( LineEdit );
- vb->add_margin_child(TTR("Filters to exclude from export (comma-separated, e.g.: *.json, *.txt):"),filters_exclude);
- filters_exclude->connect("text_changed",this,"_filters_exclude_edited");
-
- convert_text_scenes = memnew( CheckButton );
- convert_text_scenes->set_text(TTR("Convert text scenes to binary on export."));
- vb->add_child(convert_text_scenes);
- convert_text_scenes->connect("toggled",this,"_export_mode_changed");
-
- image_vb = memnew( VBoxContainer );
- image_vb->set_name(TTR("Images"));
- image_action = memnew( OptionButton );
- image_action->add_item(TTR("Keep Original"));
- image_action->add_item(TTR("Compress for Disk (Lossy, WebP)"));
- image_action->add_item(TTR("Compress for RAM (BC/PVRTC/ETC)"));
- image_vb->add_margin_child(TTR("Convert Images (*.png):"),image_action);
- HBoxContainer *qhb = memnew( HBoxContainer );
- image_quality = memnew( HSlider );
- qhb->add_child(image_quality);
- image_quality->set_h_size_flags(SIZE_EXPAND_FILL);
- SpinBox *qspin = memnew( SpinBox );
- image_quality->share(qspin);
- qhb->add_child(qspin);
- image_quality->set_min(0);
- image_quality->set_max(1);
- image_quality->set_step(0.01);
- image_vb->add_margin_child(TTR("Compress for Disk (Lossy) Quality:"),qhb);
- image_shrink = memnew( SpinBox );
- image_shrink->set_min(1);
- image_shrink->set_max(8);
- image_shrink->set_step(0.1);
- image_vb->add_margin_child(TTR("Shrink All Images:"),image_shrink);
- sections->add_child(image_vb);
-
- image_formats=memnew(Tree);
- image_formats->set_hide_root(true);
- TreeItem *root = image_formats->create_item(NULL);
- List<String> fmts;
- ImageLoader::get_recognized_extensions(&fmts);
- for(List<String>::Element *E=fmts.front();E;E=E->next()) {
-
- TreeItem *fmt = image_formats->create_item(root);
- fmt->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
- fmt->set_text(0,E->get());
- fmt->set_editable(0,true);
- formats.push_back(fmt);
- }
- image_vb->add_margin_child(TTR("Compress Formats:")+" ",image_formats,true);
-
- /// groups
- HBoxContainer *group_hb = memnew( HBoxContainer );
- group_hb->set_name(TTR("Image Groups"));
- sections->add_child(group_hb);
- VBoxContainer *group_vb_left = memnew( VBoxContainer);
- group_hb->add_child(group_vb_left);
-
- VBoxContainer *gvb = memnew(VBoxContainer);
- HBoxContainer *ghb = memnew(HBoxContainer);
- gvb->add_child(ghb);
-
- group_new_name = memnew( LineEdit );
- group_new_name->set_h_size_flags(SIZE_EXPAND_FILL);
- ghb->add_child(group_new_name);
-
- group_add = memnew(ToolButton);
- group_add->connect("pressed",this,"_group_add");
- ghb->add_child(group_add);
-
- group_new_name_error = memnew( Label );
- group_new_name_error->add_color_override("font_color",Color(1,0.4,0.4));
- gvb->add_child(group_new_name_error);
- group_new_name_error->hide();
-
- groups=memnew(Tree);
- groups->set_v_size_flags(SIZE_EXPAND_FILL);
- groups->connect("cell_selected",this,"_group_selected",varray(),CONNECT_DEFERRED);
- groups->connect("button_pressed",this,"_group_del",varray(),CONNECT_DEFERRED);
- groups->set_hide_root(true);
- gvb->add_child(groups);
-
- group_vb_left->add_margin_child(TTR("Groups:"),gvb,true);
- //group_vb_left->add_child( memnew( HSeparator));
- group_options = memnew(VBoxContainer);
- group_vb_left->add_child(group_options);
-
-
- group_image_action = memnew(OptionButton);
- group_image_action->add_item(TTR("Default"));
- group_image_action->add_item(TTR("Compress Disk"));
- group_image_action->add_item(TTR("Compress RAM"));
- group_image_action->add_item(TTR("Keep Original"));
- group_options->add_margin_child(TTR("Compress Mode:"),group_image_action);
- group_image_action->connect("item_selected",this,"_group_changed");
-
- group_lossy_quality = memnew( HSlider );
- group_lossy_quality->set_min(0.1);
- group_lossy_quality->set_max(1.0);
- group_lossy_quality->set_step(0.01);
- group_lossy_quality->set_value(0.7);
- group_lossy_quality->connect("value_changed",this,"_quality_edited");
-
- HBoxContainer *gqhb = memnew( HBoxContainer );
- SpinBox *gqspin = memnew( SpinBox );
- group_lossy_quality->share(gqspin);
- group_lossy_quality->set_h_size_flags(SIZE_EXPAND_FILL);
- gqhb->add_child(group_lossy_quality);
- gqhb->add_child(gqspin);
- group_options->add_margin_child(TTR("Lossy Quality:"),gqhb);
-
- group_atlas = memnew(CheckButton);
- group_atlas->set_pressed(true);
- group_options->add_margin_child(TTR("Atlas:"),group_atlas);
- group_atlas->connect("toggled",this,"_group_changed");
-
- group_shrink = memnew(SpinBox);
- group_shrink->set_min(1);
- group_shrink->set_max(8);
- group_shrink->set_value(1);
- group_shrink->set_step(0.001);
- group_options->add_margin_child(TTR("Shrink By:"),group_shrink);
- group_shrink->connect("value_changed",this,"_group_changed");
-
- atlas_preview = memnew( Button );
- atlas_preview->set_text(TTR("Preview Atlas"));
- group_options->add_child(atlas_preview);
- atlas_preview->show();
- atlas_preview->connect("pressed",this,"_group_atlas_preview");
- Control *ec = memnew(Control );
- ec->set_custom_minimum_size(Size2(150,1));
- gvb->add_child(ec);
-
- VBoxContainer *group_vb_right = memnew( VBoxContainer );
- group_hb->add_child(group_vb_right);
- group_vb_right->set_h_size_flags(SIZE_EXPAND_FILL);
-
- HBoxContainer *filter_hb = memnew (HBoxContainer);
-
- group_images_filter = memnew( LineEdit );
- group_vb_right->add_margin_child(TTR("Image Filter:"),filter_hb);
- filter_hb->add_child(group_images_filter);
- group_images_filter->set_h_size_flags(SIZE_EXPAND_FILL);
- group_images_filter->connect("text_changed",this,"_image_filter_changed");
- group_images = memnew( Tree );
- group_images->set_v_size_flags(SIZE_EXPAND_FILL);
- group_vb_right->add_margin_child(TTR("Images:"),group_images,true);
-
- Button *filt_select_all = memnew( Button );
- filt_select_all->set_text(TTR("Select All"));
- filter_hb->add_child(filt_select_all);
- filt_select_all->connect("pressed",this,"_group_select_all");
-
- Button *filt_select_none = memnew( Button );
- filt_select_none->set_text(TTR("Select None"));
- filter_hb->add_child(filt_select_none);
- filt_select_none->connect("pressed",this,"_group_select_none");
-
- atlas_preview_dialog = memnew( AcceptDialog );
- ScrollContainer *scroll = memnew( ScrollContainer );
- atlas_preview_dialog->add_child(scroll);
- //atlas_preview_dialog->set_child_rect(scroll);
- atlas_preview_frame = memnew( TextureFrame );
- scroll->add_child(atlas_preview_frame);
- add_child(atlas_preview_dialog);
-
-
- group_images->set_hide_root(true);
- group_images->set_columns(2);
- group_images->set_column_expand(0,true);
- group_images->set_column_expand(1,false);
- group_images->set_column_min_width(1,100);
- group_images->set_column_titles_visible(true);
- group_images->set_column_title(0,TTR("Images"));
- group_images->set_column_title(1,TTR("Group"));
- group_images->connect("item_edited",this,"_group_item_edited",varray(),CONNECT_DEFERRED);
-
-/* SpinBox *group_shrink;
- CheckButton *group_atlas;
- OptionButton *group_image_action;*/
-
-
-/* progress = memnew( Label );
- add_child(progress);
- progress->set_area_as_parent_rect();
- progress->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,25);
- progress->hide();
- progress->set_align(Label::ALIGN_CENTER);*/
-
-/*
- button_reload = memnew( Button );
- button_reload->set_pos(Point2(3,2));
- button_reload->set_size(Point2(20,5));
- button_reload->set_flat(true);
- //add_child(button_reload);
- button_reload->connect("pressed",this,"_rescan");
- hbc->add_child(button_reload);
-*/
-
-
- sample_vbox = memnew( VBoxContainer );
- sample_vbox->set_name(TTR("Samples"));
- sections->add_child(sample_vbox);
- sample_mode = memnew( OptionButton );
- sample_vbox->add_margin_child(TTR("Sample Conversion Mode: (.wav files):"),sample_mode);
- sample_mode->add_item(TTR("Keep"));
- sample_mode->add_item(TTR("Compress (RAM - IMA-ADPCM)"));
- sample_max_hz = memnew( SpinBox );
- sample_max_hz->set_max(192000);
- sample_max_hz->set_min(8000);
- sample_vbox->add_margin_child(TTR("Sampling Rate Limit (Hz):"),sample_max_hz);
- sample_trim = memnew( CheckButton );
- sample_trim->set_text(TTR("Trim"));
- sample_vbox->add_margin_child(TTR("Trailing Silence:"),sample_trim);
-
- script_vbox = memnew( VBoxContainer );
- script_vbox->set_name(TTR("Script"));
- sections->add_child(script_vbox);
- script_mode = memnew( OptionButton );
- script_vbox->add_margin_child(TTR("Script Export Mode:"),script_mode);
- script_mode->add_item(TTR("Text"));
- script_mode->add_item(TTR("Compiled"));
- script_mode->add_item(TTR("Encrypted (Provide Key Below)"));
- script_key = memnew( LineEdit );
- script_vbox->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"),script_key);
-
-
+ ClassDB::bind_method("_add_preset",&ProjectExportDialog::_add_preset);
+ ClassDB::bind_method("_edit_preset",&ProjectExportDialog::_edit_preset);
+ ClassDB::bind_method("_runnable_pressed",&ProjectExportDialog::_runnable_pressed);
+ ClassDB::bind_method("_name_changed",&ProjectExportDialog::_name_changed);
+ ClassDB::bind_method("_delete_preset",&ProjectExportDialog::_delete_preset);
+ ClassDB::bind_method("_delete_preset_confirm",&ProjectExportDialog::_delete_preset_confirm);
+ ClassDB::bind_method("get_drag_data_fw",&ProjectExportDialog::get_drag_data_fw);
+ ClassDB::bind_method("can_drop_data_fw",&ProjectExportDialog::can_drop_data_fw);
+ ClassDB::bind_method("drop_data_fw",&ProjectExportDialog::drop_data_fw);
+ ClassDB::bind_method("_export_type_changed",&ProjectExportDialog::_export_type_changed);
+ ClassDB::bind_method("_filter_changed",&ProjectExportDialog::_filter_changed);
+ ClassDB::bind_method("_tree_changed",&ProjectExportDialog::_tree_changed);
+ ClassDB::bind_method("_patch_button_pressed",&ProjectExportDialog::_patch_button_pressed);
+ ClassDB::bind_method("_patch_selected",&ProjectExportDialog::_patch_selected);
+ ClassDB::bind_method("_patch_deleted",&ProjectExportDialog::_patch_deleted);
+ ClassDB::bind_method("_patch_edited",&ProjectExportDialog::_patch_edited);
+ ClassDB::bind_method("_export_pck_zip",&ProjectExportDialog::_export_pck_zip);
+ ClassDB::bind_method("_export_pck_zip_selected",&ProjectExportDialog::_export_pck_zip_selected);
+
+
+}
+ProjectExportDialog::ProjectExportDialog() {
+
+ set_title(TTR("Export"));
+ set_resizable(true);
+
+ HBoxContainer *hbox = memnew( HBoxContainer );
+ add_child(hbox);
+
+ VBoxContainer *preset_vb = memnew( VBoxContainer );
+ preset_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ hbox->add_child(preset_vb);
+
+ HBoxContainer *preset_hb = memnew( HBoxContainer );
+ preset_hb->add_child(memnew(Label(TTR("Presets"))));
+ preset_hb->add_spacer();
+ preset_vb->add_child(preset_hb);
+
+ add_preset = memnew( MenuButton );
+ add_preset->set_text(TTR("Add.."));
+ add_preset->get_popup()->connect("index_pressed",this,"_add_preset");
+ preset_hb->add_child(add_preset);
+ MarginContainer *mc = memnew( MarginContainer );
+ preset_vb->add_child(mc);
+ mc->set_v_size_flags(SIZE_EXPAND_FILL);
+ presets = memnew( ItemList );
+ presets->set_drag_forwarding(this);
+ mc->add_child(presets);
+ presets->connect("item_selected",this,"_edit_preset");
+ delete_preset = memnew( ToolButton );
+ preset_hb->add_child(delete_preset);
+ delete_preset->connect("pressed",this,"_delete_preset");
+
+ VBoxContainer *settings_vb = memnew( VBoxContainer );
+ settings_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ hbox->add_child(settings_vb);
+
+ name = memnew(LineEdit);
+ settings_vb->add_margin_child(TTR("Name:"),name);
+ name->connect("text_changed",this,"_name_changed");
+ runnable = memnew(CheckButton);
+ runnable->set_text(TTR("Runnable"));
+ runnable->connect("pressed",this,"_runnable_pressed");
+ settings_vb->add_child(runnable);
+
+ sections = memnew (TabContainer );
+ settings_vb->add_child(sections);
+ sections->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ parameters = memnew (PropertyEditor );
+ sections->add_child(parameters);
+ parameters->set_name(TTR("Options"));
+ parameters->hide_top_label();
+ parameters->set_v_size_flags(SIZE_EXPAND_FILL);
+ parameters->set_hide_script(true);
+
+ VBoxContainer *resources_vb = memnew( VBoxContainer );
+ sections->add_child(resources_vb);
+ resources_vb->set_name(TTR("Resources"));
+
+ export_filter = memnew( OptionButton );
+ export_filter->add_item(TTR("Export all resources in the project"));
+ export_filter->add_item(TTR("Export selected scenes (and dependencies)"));
+ export_filter->add_item(TTR("Export selected resources (and dependencies)"));
+ resources_vb->add_margin_child(TTR("Export Mode:"),export_filter);
+ export_filter->connect("item_selected",this,"_export_type_changed");
+
+ include_label = memnew( Label );
+ include_label->set_text(TTR("Resources to export:"));
+ resources_vb->add_child(include_label);
+ include_margin = memnew( MarginContainer );
+ include_margin->set_v_size_flags(SIZE_EXPAND_FILL);
+ resources_vb->add_child(include_margin);
+
+ include_files = memnew(Tree);
+ include_margin->add_child(include_files);
+ include_files->connect("item_edited",this,"_tree_changed");
+
+ include_filters = memnew( LineEdit );
+ resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"),include_filters);
+ include_filters->connect("text_changed",this,"_filter_changed");
+
+ exclude_filters = memnew( LineEdit );
+ resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"),exclude_filters);
+ exclude_filters->connect("text_changed",this,"_filter_changed");
+
+ VBoxContainer *patch_vb = memnew( VBoxContainer );
+ sections->add_child(patch_vb);
+ patch_vb->set_name(TTR("Patches"));
+
+ patches = memnew( Tree );
+ patch_vb->add_child(patches);
+ patches->set_v_size_flags(SIZE_EXPAND_FILL);
+ patches->set_hide_root(true);
+ patches->connect("button_pressed",this,"_patch_button_pressed");
+ patches->connect("item_edited",this,"_patch_edited");
+ patches->set_drag_forwarding(this);
+ patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
+
+ HBoxContainer *patches_hb = memnew( HBoxContainer );
+ patch_vb->add_child(patches_hb);
+ patches_hb->add_spacer();
+ patch_export = memnew( Button );
+ patch_export->set_text(TTR("Make Patch"));
+ patches_hb->add_child(patch_export);
+ patches_hb->add_spacer();
+
+ patch_dialog = memnew( FileDialog );
+ patch_dialog->add_filter("*.pck ; Pack File");
+ patch_dialog->set_mode(FileDialog::MODE_OPEN_FILE);
+ patch_dialog->connect("file_selected",this,"_patch_selected");
+ add_child(patch_dialog);
+
+ patch_erase = memnew( ConfirmationDialog );
+ patch_erase->get_ok()->set_text(TTR("Delete"));
+ patch_erase->connect("confirmed",this,"_patch_deleted");
+ add_child(patch_erase);
+
+
+ //disable by default
+ name->set_editable(false);
+ runnable->set_disabled(true);
+ delete_preset->set_disabled(true);
+ sections->hide();
+ parameters->edit(NULL);
+
+ delete_confirm = memnew( ConfirmationDialog );
+ add_child(delete_confirm);
+ delete_confirm->get_ok()->set_text(TTR("Delete"));
+ delete_confirm->connect("confirmed",this,"_delete_preset_confirm");
updating=false;
- error = memnew( AcceptDialog );
- add_child(error);
-
- confirm = memnew( ConfirmationDialog );
- add_child(confirm);
- confirm->connect("confirmed",this,"_confirmed");
-
- get_ok()->set_text(TTR("Export PCK/Zip"));
-
+ get_ok()->set_text("Export PCK/Zip");
+ export_button = add_button("Export Project",!OS::get_singleton()->get_swap_ok_cancel(),"export");
- expopt="--,Export,Bundle";
+ export_pck_zip = memnew( FileDialog );
+ export_pck_zip->add_filter("*.zip ; ZIP File");
+ export_pck_zip->add_filter("*.pck ; Godot Game Pack");
+ export_pck_zip->set_access(FileDialog::ACCESS_FILESYSTEM);
+ export_pck_zip->set_mode(FileDialog::MODE_SAVE_FILE);
+ add_child(export_pck_zip);
+ export_pck_zip->connect("file_selected",this,"_export_pck_zip_selected");
- file_export = memnew( EditorFileDialog );
- add_child(file_export);
- file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- file_export->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_export_path") );
-
- file_export->set_title(TTR("Export Project"));
- file_export->connect("file_selected", this,"_export_action");
-
- file_export_password = memnew( LineEdit );
- file_export_password->set_secret(true);
- file_export_password->set_editable(false);
- file_export->get_vbox()->add_margin_child(TTR("Password:"),file_export_password);
-
- pck_export = memnew( EditorFileDialog );
- pck_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
- pck_export->set_current_dir( EditorSettings::get_singleton()->get("filesystem/directories/default_project_export_path") );
- pck_export->set_title(TTR("Export Project PCK"));
- pck_export->connect("file_selected", this,"_export_action_pck");
- pck_export->add_filter("*.pck ; Data Pack");
- pck_export->add_filter("*.zip ; Zip");
- add_child(pck_export);
+ set_hide_on_ok(false);
- button_export = add_button(TTR("Export.."),!OS::get_singleton()->get_swap_ok_cancel(),"export_pck");
- updating_script=false;
- ei="EditorIcons";
- ot="Object";
- pending_update_tree=true;
- _create_android_keystore_window();
+ editor_icons = "EditorIcons";
}
-
ProjectExportDialog::~ProjectExportDialog() {
}
-
-void ProjectExport::popup_export() {
-
- Set<String> presets;
- presets.insert("default");
-
- List<PropertyInfo> pi;
- GlobalConfig::get_singleton()->get_property_list(&pi);
- export_preset->clear();
-
- for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
-
- if (!E->get().name.begins_with("export_presets/"))
- continue;
- presets.insert(E->get().name.get_slice("/",1));
- }
-
- for(Set<String>::Element *E=presets.front();E;E=E->next()) {
-
- export_preset->add_item(E->get());
- }
-
-
-
- popup_centered(Size2(300,100));
-
-
-
-}
-Error ProjectExport::export_project(const String& p_preset) {
-
- return OK;
-
-#if 0
-
- String selected=p_preset;
-
- PoolVector<String> preset_settings = GlobalConfig::get_singleton()->get("export_presets/"+selected);
- String preset_path=GlobalConfig::get_singleton()->get("export_presets_path/"+selected);
- if (preset_path=="") {
-
- error->set_text("Export path empty, see export options");
- error->popup_centered_minsize(Size2(300,100));
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
-
- int pc=preset_settings.size();
-
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- if (d->change_dir(preset_path)!=OK) {
-
- memdelete(d);
- error->set_text("Can't access to export path:\n "+preset_path);
- error->popup_centered_minsize(Size2(300,100));
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
-
- if (pc==0) {
- memdelete(d);
- return OK;
- }
- if (pc%3 != 0 ) {
- memdelete(d);
- error->set_text("Corrupted export data..");
- error->popup_centered_minsize(Size2(300,100));
- ERR_EXPLAIN("Corrupted export data...");
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
-
- Map<String,ProjectExportSettings::ItemData> export_action;
-
-
- Map<String,Map<String,String> > remapped_paths;
-
- Set<String> scene_extensions;
- Set<String> resource_extensions;
-
- {
-
- List<String> l;
-// SceneLoader::get_recognized_extensions(&l);
-// for(List<String>::Element *E=l.front();E;E=E->next()) {
-//
-// scene_extensions.insert(E->get());
-// }
- ResourceLoader::get_recognized_extensions_for_type("",&l);
- for(List<String>::Element *E=l.front();E;E=E->next()) {
-
- resource_extensions.insert(E->get());
- }
- }
-
- Vector<String> names = GlobalConfig::get_singleton()->get_optimizer_presets();
-
- //prepare base paths
-
- for(int i=0;i<pc;i+=3) {
-
-
- String name = preset_settings[i+0];
- String pname=preset_settings[i+1];
- String deps=preset_settings[i+2];
- int idx=1;
- if (pname=="") {
- pname="copy";
- } else {
-
- for(int j=0;j<names.size();j++) {
- if (pname==names[j]) {
- idx=j+2;
- break;
- }
- }
- }
-
- int dep_idx=0;
-
- for(int j=0;j<ProjectExportSettings::DA_MAX;j++) {
- if (ProjectExportSettings::da_string[j]==deps) {
- dep_idx=j;
- break;
- }
- }
-
- if (idx>=0) {
- export_action[name].action=idx;
- export_action[name].depaction=dep_idx;
- }
-
- }
-
-
- Set<String> bundle_exceptions;
- for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) {
- bundle_exceptions.insert(E->key());
- }
-
-
- {
-
- // find dependencies and add them to export
-
- Map<String,ProjectExportSettings::ItemData> dependencies;
-
- for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) {
-
- ProjectExportSettings::ItemData &id=E->get();
-
- if (id.depaction!=ProjectExportSettings::DA_COPY && id.depaction!=ProjectExportSettings::DA_OPTIMIZE)
- continue; //no copy or optimize, go on
- List<String> deplist;
- ResourceLoader::get_dependencies(E->key(),&deplist);
-
- while (deplist.size()) {
-
- String dependency = deplist.front()->get();
- deplist.pop_front();
- if (export_action.has(dependency))
- continue; //taged to export, will not override
- if (dependencies.has(dependency)) {
-
- if (id.action <= dependencies[dependency].action )
- continue;
- }
-
- ProjectExportSettings::ItemData depid;
- if (id.depaction==ProjectExportSettings::DA_COPY || id.action==ProjectExportSettings::DA_COPY)
- depid.action=ProjectExportSettings::DA_COPY;
- else if (id.depaction==ProjectExportSettings::DA_OPTIMIZE)
- depid.action=id.action;
- depid.depaction=0;
-
- dependencies[dependency]=depid;
-
- ResourceLoader::get_dependencies(dependency,&deplist);
- }
-
-
- }
-
- for (Map<String,ProjectExportSettings::ItemData>::Element *E=dependencies.front();E;E=E->next()) {
- export_action[E->key()]=E->get();
- }
- }
-
-
-
- int idx=0;
- for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next(),idx++) {
-
-
- String path=E->key();
- if (E->get().action==0)
- continue; //nothing to do here
- String preset;
- if (E->get().action==1)
- preset="";
- else
- preset=names[E->get().action-2];
-
- print_line("Exporting "+itos(idx)+"/"+itos(export_action.size())+": "+path);
-
- String base_dir = GlobalConfig::get_singleton()->localize_path(path.get_base_dir()).replace("\\","/").replace("res://","");
- DirAccess *da=DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- String cwd = d->get_current_dir();
- da->change_dir(cwd);
- print_line("base dir: "+base_dir);
- String remap_platform="all";
-
- for(int j=0;j<base_dir.get_slice_count("/");j++) {
-
- String p = base_dir.get_slice("/",j);
- if (da->change_dir(p)!=OK) {
-
- Error err = da->make_dir(p);
- if (err!=OK) {
- memdelete(da);
- memdelete(d);
- ERR_EXPLAIN("Cannot make dir: "+cwd+"/"+p);
- ERR_FAIL_V(ERR_CANT_CREATE);
- }
-
- if (da->change_dir(p)!=OK) {
-
- memdelete(da);
- memdelete(d);
- ERR_EXPLAIN("Cannot change to dir: "+cwd+"/"+p);
- ERR_FAIL_V(ERR_CANT_CREATE);
- }
-
- }
-
- cwd=da->get_current_dir();
- }
-
- memdelete(da);
- //cwd is the target dir
-
- String source_file;
-
- print_line("Exporting: "+source_file);
- bool delete_source=false;
- if (preset=="") {
- //just copy!
-
- source_file=path;
- delete_source=false;
- } else {
-
- delete_source=true;
- //create an optimized source file
-
- if (!GlobalConfig::get_singleton()->has("optimizer_presets/"+preset)) {
- memdelete(d);
- ERR_EXPLAIN("Unknown optimizer preset: "+preset);
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
-
-
- Dictionary dc = GlobalConfig::get_singleton()->get("optimizer_presets/"+preset);
-
- ERR_FAIL_COND_V(!dc.has("__type__"),ERR_INVALID_DATA);
- String type=dc["__type__"];
-
- Ref<EditorOptimizedSaver> saver;
-
- for(int i=0;i<editor_data->get_optimized_saver_count();i++) {
-
- if (editor_data->get_optimized_saver(i)->get_target_name()==type) {
- saver=editor_data->get_optimized_saver(i);
- }
- }
-
- if (saver.is_null()) {
- memdelete(d);
- ERR_EXPLAIN("Preset '"+preset+"' references nonexistent saver: "+type);
- ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA);
- }
-
- List<Variant> keys;
- dc.get_key_list(&keys);
-
- saver->clear();
-
- for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
-
- saver->set(E->get(),dc[E->get()]);
- }
-
-
- remap_platform=saver->get_target_platform();
- if (remap_platform=="")
- remap_platform="all";
-
-
- if (resource_extensions.has(path.extension().to_lower())) {
-
- uint32_t flags=0;
-
-// if (saver->is_bundle_scenes_enabled())
-// flags|=Reso::FLAG_BUNDLE_INSTANCED_SCENES;
- saver->set_bundle_exceptions(NULL);
- if (E->get().depaction>=ProjectExportSettings::DA_BUNDLE) {
- flags|=ResourceSaver::FLAG_BUNDLE_RESOURCES;
- if (E->get().depaction==ProjectExportSettings::DA_BUNDLE)
- saver->set_bundle_exceptions(&bundle_exceptions);
-
- }
-
- if (saver->is_remove_editor_data_enabled())
- flags|=ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
- if (saver->is_big_endian_data_enabled())
- flags|=ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
-
- RES res = ResourceLoader::load(path);
-
- if (res.is_null()) {
-
- memdelete(d);
- ERR_EXPLAIN("Error loading resource to optimize: "+path);
- ERR_FAIL_V(ERR_INVALID_DATA);
- }
-
- if (saver->is_compress_translations_enabled() && res->get_type()=="Translation") {
-
- Ref<PHashTranslation> ct = Ref<PHashTranslation>( memnew( PHashTranslation ) );
- ct->generate(res);
- res=ct;
- }
-
-
- //dst_file=path.get_file();
- //dst_file = cwd+"/"+dst_file.substr(0,dst_file.length()-dst_file.extension().length())+"opt.scn";
-
- //String write_file = path.substr(0,path.length()-path.extension().length())+"optimized.res";
- String write_file = path+".opt.res";
-
-
- print_line("DST RES FILE: "+write_file);
- Error err = ResourceSaver::save(write_file,res,flags,saver);
- if (err) {
- memdelete(d);
- ERR_EXPLAIN("Error saving optimized resource: "+write_file);
- ERR_FAIL_COND_V(err,ERR_CANT_OPEN);
- }
- source_file=write_file;
- // project_settings->add_remapped_path(src_scene,path,platform);
-
- }
-
-
- }
-
- String dst_file;
- dst_file=cwd+"/"+source_file.get_file();
- print_line("copying from: "+source_file);
- print_line("copying to: "+dst_file);
- Error err = d->copy(source_file,dst_file);
-
- if (delete_source)
- d->remove(source_file);
-
- if (err) {
-
-
- ERR_EXPLAIN("Error copying from: "+source_file+" to "+dst_file+".");
- ERR_FAIL_COND_V(err,err);
- }
-
- String src_remap=path;
- String dst_remap=source_file;
- print_line("remap from: "+src_remap);
- print_line("remap to: "+dst_remap);
- if (src_remap!=dst_remap) {
-
-
- remapped_paths[remap_platform][src_remap]=dst_remap;
- }
-
- //do the copy man...
-
- }
-
- Map<String,Variant> added_settings;
-
-
- for (Map<String,Map<String,String> >::Element *E=remapped_paths.front();E;E=E->next()) {
-
- String platform=E->key();
- PoolVector<String> remaps;
- for(Map<String,String>::Element *F=E->get().front();F;F=F->next() ) {
-
- remaps.push_back(F->key());
- remaps.push_back(F->get());
- }
-
-
-
-// added_settings["remap/"+platform]=remaps;`
- added_settings["remap/"+platform]=Variant(remaps).operator Array();
- }
-
- String engine_cfg_path=d->get_current_dir()+"/engine.cfg";
- print_line("enginecfg: "+engine_cfg_path);
- GlobalConfig::get_singleton()->save_custom(engine_cfg_path,added_settings);
-
- memdelete(d);
- return OK;
-#endif
-}
-
-ProjectExport::ProjectExport(EditorData* p_data) {
-
- editor_data=p_data;
- VBoxContainer *vbc = memnew( VBoxContainer );
- add_child(vbc);
- //set_child_rect(vbc);
- set_title(TTR("Project Export"));
- label = memnew( Label );
- label->set_text(TTR("Export Preset:"));
- vbc->add_child(label);
- export_preset = memnew (OptionButton);
- vbc->add_child(export_preset);
- get_ok()->set_text(TTR("Export"));
- set_hide_on_ok(false);
- error = memnew( AcceptDialog );
- add_child(error);
-
-
-}
diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h
index 2110c54b9d..c977e90e56 100644
--- a/tools/editor/project_export.h
+++ b/tools/editor/project_export.h
@@ -35,6 +35,7 @@
#include "scene/gui/label.h"
#include "tools/editor/editor_file_dialog.h"
#include "scene/gui/button.h"
+#include "scene/gui/file_dialog.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
#include "os/dir_access.h"
@@ -44,201 +45,98 @@
#include "scene/gui/slider.h"
#include "tools/editor/editor_file_system.h"
#include "property_editor.h"
-#include "editor_import_export.h"
+#include "editor_export.h"
+
class EditorNode;
class ProjectExportDialog : public ConfirmationDialog {
GDCLASS( ProjectExportDialog, ConfirmationDialog );
-public:
- enum ExportAction {
- ACTION_NONE,
- ACTION_COPY,
- ACTION_BUNDLE,
- ACTION_MAX
-
- };
-
- static const char *da_string[ACTION_MAX];
-
private:
- EditorNode *editor;
- String expopt;
-
TabContainer *sections;
- bool updating_tree;
- bool pending_update_tree;
- AcceptDialog *error;
- ConfirmationDialog *confirm;
- ConfirmationDialog *confirm_keystore;
- Button *button_reload;
- LineEdit *filters, *filters_exclude;
- HBoxContainer *plat_errors;
- Label *platform_error_string;
+ MenuButton *add_preset;
+ Button *delete_preset;
+ ItemList *presets;
- StringName ei;
- StringName ot;
+ LineEdit *name;
+ PropertyEditor *parameters;
+ CheckButton *runnable;
- Tree * tree;
EditorFileDialog *pck_export;
EditorFileDialog *file_export;
- LineEdit *file_export_password;
Button *button_export;
- String _delete_attempt;
-
bool updating;
- void _tree_changed();
- void _update_tree();
-
- bool _create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir);
- void _rescan();
-// void _confirmed();
- void _scan_finished();
-
- void _validate_platform();
- ///////////////////
-
- Tree * platforms;
- PropertyEditor *platform_options;
-
- OptionButton *export_mode;
- CheckButton *convert_text_scenes;
- VBoxContainer *tree_vb;
-
- VBoxContainer *image_vb;
- OptionButton *image_action;
- HSlider *image_quality;
- SpinBox *image_shrink;
- Tree *image_formats;
- Vector<TreeItem*> formats;
-
- LineEdit *group_new_name;
- HSlider *group_lossy_quality;
- Label *group_new_name_error;
- VBoxContainer *group_options;
- Tree *groups;
- SpinBox *group_shrink;
- CheckButton *group_atlas;
- OptionButton *group_image_action;
- Button *group_add;
- Tree *group_images;
- LineEdit *group_images_filter;
- Button *atlas_preview;
-
-
- AcceptDialog *atlas_preview_dialog;
- TextureFrame *atlas_preview_frame;
-
-
- VBoxContainer *script_vbox;
- OptionButton *script_mode;
- LineEdit *script_key;
+ ConfirmationDialog *delete_confirm;
- VBoxContainer *sample_vbox;
- OptionButton *sample_mode;
- SpinBox *sample_max_hz;
- CheckButton *sample_trim;
+ OptionButton *export_filter;
+ LineEdit *include_filters;
+ LineEdit *exclude_filters;
+ Tree *include_files;
- ConfirmationDialog* keystore_create_dialog;
- EditorFileDialog* keystore_file_dialog;
+ Label* include_label;
+ MarginContainer *include_margin;
+ StringName editor_icons;
- void _export_mode_changed(int p_idx);
- void _prop_edited(String what);
+ Tree *patches;
+ Button *patch_export;
+ int patch_index;
+ FileDialog *patch_dialog;
+ ConfirmationDialog *patch_erase;
- void _update_platform();
- void _update_exporter();
- void _platform_selected();
+ Button *export_button;
- void _filters_edited(String what);
- void _filters_exclude_edited(String what);
- void _update_group_tree();
+ void _patch_selected(const String& p_path);
+ void _patch_deleted();
- void _image_filter_changed(String);
- bool _update_group_treef(TreeItem *p_parent,EditorFileSystemDirectory *p_dir,const Set<String>& p_extensions,const String& p_groups,const Map<StringName,int>& p_group_index);
- void _group_item_edited();
- void _group_atlas_preview();
+ void _runnable_pressed();
+ void _name_changed(const String& p_string);
+ void _add_preset(int p_platform);
+ void _edit_preset(int p_index);
+ void _delete_preset();
+ void _delete_preset_confirm();
+ void _update_presets();
+ void _export_type_changed(int p_which);
+ void _filter_changed(const String& p_filter);
+ void _fill_resource_tree();
+ bool _fill_tree(EditorFileSystemDirectory *p_dir,TreeItem *p_item,Ref<EditorExportPreset> &current,bool p_only_scenes);
+ void _tree_changed();
- void _quality_edited(float what);
- void _image_export_edited(int what);
- void _shrink_edited(float what);
-
- void _sample_convert_edited(int what);
-
- void _update_group_list();
- void _select_group(const String& p_by_name);
-
+ void _patch_button_pressed(Object* p_item,int p_column,int p_id);
+ void _patch_edited();
- String _get_selected_group();
- void _update_group();
- void _group_changed(Variant v);
- void _group_selected();
- void _group_add();
- void _group_select_all();
- void _group_select_none();
- void _group_del(Object *item,int p_column, int p_button);
- bool updating_script;
- void _update_script();
- void _script_edited(Variant v);
- void _export_action(const String& p_file);
- void _export_action_pck(const String& p_file);
- void ok_pressed();
- void custom_action(const String&);
- LineEdit* _create_keystore_input(Control* container, const String& p_label, const String& name);
- void _create_android_keystore_window();
- void _create_android_keystore();
- bool _check_android_setting(const Ref<EditorExportPlatform>& exporter);
- void _check_keystore_path(const String& path);
- void _keystore_dir_selected(const String& path);
- void _keystore_created();
+ Variant get_drag_data_fw(const Point2& p_point,Control* p_from);
+ bool can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const;
+ void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
- void _save_export_cfg();
- void _format_toggled();
+ FileDialog *export_pck_zip;
+ void _export_pck_zip();
+ void _export_pck_zip_selected(const String& p_path);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
- String get_selected_path() const;
-
- Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false);
-
void popup_export();
- ProjectExportDialog(EditorNode *p_editor);
+
+ ProjectExportDialog();
~ProjectExportDialog();
};
-class EditorData;
-class ProjectExport : public ConfirmationDialog {
- GDCLASS( ProjectExport, ConfirmationDialog );
-
- EditorData *editor_data;
-
- AcceptDialog *error;
- Label *label;
- OptionButton *export_preset;
-public:
-
- Error export_project(const String& p_preset);
- void popup_export();
-
-
- ProjectExport(EditorData* p_data);
-
-};
#endif // PROJECT_EXPORT_SETTINGS_H
+
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index fa41090624..34b2d3e82c 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -26,8 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "version.h"
#include "project_manager.h"
+
+#include "version.h"
#include "os/os.h"
#include "os/dir_access.h"
#include "os/file_access.h"
@@ -36,20 +37,16 @@
#include "scene/gui/separator.h"
#include "scene/gui/tool_button.h"
#include "io/config_file.h"
-
#include "scene/gui/line_edit.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/center_container.h"
#include "io/stream_peer_ssl.h"
-
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/margin_container.h"
#include "io/resource_saver.h"
-
#include "editor_themes.h"
#include "editor_initialize_ssl.h"
#include "editor_scale.h"
-
#include "io/zip_io.h"
class NewProjectDialog : public ConfirmationDialog {
@@ -95,18 +92,18 @@ private:
if (mode!=MODE_IMPORT) {
- if (d->file_exists("engine.cfg")) {
+ if (d->file_exists("godot.cfg")) {
- error->set_text(TTR("Invalid project path, engine.cfg must not exist."));
+ error->set_text(TTR("Invalid project path, godot.cfg must not exist."));
memdelete(d);
return "";
}
} else {
- if (valid_path != "" && !d->file_exists("engine.cfg")) {
+ if (valid_path != "" && !d->file_exists("godot.cfg")) {
- error->set_text(TTR("Invalid project path, engine.cfg must exist."));
+ error->set_text(TTR("Invalid project path, godot.cfg must exist."));
memdelete(d);
return "";
}
@@ -140,7 +137,7 @@ private:
String p = p_path;
if (mode==MODE_IMPORT) {
- if (p.ends_with("engine.cfg")) {
+ if (p.ends_with("godot.cfg")) {
p=p.get_base_dir();
}
@@ -166,7 +163,7 @@ private:
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
- fdialog->add_filter("engine.cfg ; " _MKSTR(VERSION_NAME) " Project");
+ fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project");
} else {
fdialog->set_mode(FileDialog::MODE_OPEN_DIR);
}
@@ -193,9 +190,9 @@ private:
- FileAccess *f = FileAccess::open(dir.plus_file("/engine.cfg"),FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"),FileAccess::WRITE);
if (!f) {
- error->set_text(TTR("Couldn't create engine.cfg in project path."));
+ error->set_text(TTR("Couldn't create godot.cfg in project path."));
} else {
f->store_line("; Engine configuration file.");
@@ -404,7 +401,7 @@ public:
VBoxContainer *vb = memnew( VBoxContainer );
add_child(vb);
- // set_child_rect(vb);
+ //set_child_rect(vb);
Label* l = memnew(Label);
l->set_text(TTR("Project Path:"));
@@ -488,7 +485,7 @@ void ProjectManager::_notification(int p_what) {
} else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- set_process_unhandled_input(is_visible());
+ set_process_unhandled_input(is_visible_in_tree());
}
}
@@ -762,7 +759,7 @@ void ProjectManager::_load_recent_projects() {
continue;
String project = _name.get_slice("/",1);
- String conf=path.plus_file("engine.cfg");
+ String conf=path.plus_file("godot.cfg");
bool favorite = (_name.begins_with("favorite_projects/"))?true:false;
uint64_t last_modified = 0;
@@ -869,7 +866,7 @@ void ProjectManager::_load_recent_projects() {
favorite_box->add_child(favorite);
hb->add_child(favorite_box);
- TextureFrame *tf = memnew( TextureFrame );
+ TextureRect *tf = memnew( TextureRect );
tf->set_texture(icon);
hb->add_child(tf);
@@ -1003,7 +1000,7 @@ void ProjectManager::_run_project_confirm() {
Error err = OS::get_singleton()->execute(exec,args,false,&pid);
ERR_FAIL_COND(err);
}
- // get_scene()->quit(); do not quit
+ //get_scene()->quit(); do not quit
}
void ProjectManager::_run_project() {
@@ -1030,7 +1027,7 @@ void ProjectManager::_scan_dir(DirAccess *da,float pos, float total,List<String>
while(n!=String()) {
if (da->current_is_dir() && !n.begins_with(".")) {
subdirs.push_front(n);
- } else if (n=="engine.cfg") {
+ } else if (n=="godot.cfg") {
r_projects->push_back(da->get_current_dir());
}
n=da->get_next();
@@ -1154,7 +1151,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
dir->list_dir_begin();
String file = dir->get_next();
while(confirm && file!=String()) {
- if (!dir->current_is_dir() && file.ends_with("engine.cfg")) {
+ if (!dir->current_is_dir() && file.ends_with("godot.cfg")) {
confirm = false;
}
file = dir->get_next();
@@ -1203,7 +1200,7 @@ void ProjectManager::_bind_methods() {
ClassDB::bind_method("_favorite_pressed",&ProjectManager::_favorite_pressed);
ClassDB::bind_method("_install_project",&ProjectManager::_install_project);
ClassDB::bind_method("_files_dropped",&ProjectManager::_files_dropped);
- ClassDB::bind_method(_MD("_scan_multiple_folders", "files"),&ProjectManager::_scan_multiple_folders);
+ ClassDB::bind_method(D_METHOD("_scan_multiple_folders", "files"),&ProjectManager::_scan_multiple_folders);
}
@@ -1486,9 +1483,9 @@ void ProjectListFilter::_notification(int p_what) {
void ProjectListFilter::_bind_methods() {
- ClassDB::bind_method(_MD("_command"),&ProjectListFilter::_command);
- ClassDB::bind_method(_MD("_search_text_changed"), &ProjectListFilter::_search_text_changed);
- ClassDB::bind_method(_MD("_filter_option_selected"), &ProjectListFilter::_filter_option_selected);
+ ClassDB::bind_method(D_METHOD("_command"),&ProjectListFilter::_command);
+ ClassDB::bind_method(D_METHOD("_search_text_changed"), &ProjectListFilter::_search_text_changed);
+ ClassDB::bind_method(D_METHOD("_filter_option_selected"), &ProjectListFilter::_filter_option_selected);
ADD_SIGNAL( MethodInfo("filter_changed") );
}
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 968333d466..15019b8ca8 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -27,8 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "project_settings.h"
+
#include "scene/gui/tab_container.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/keyboard.h"
#include "editor_node.h"
#include "scene/gui/margin_container.h"
@@ -72,34 +73,38 @@ static const char* _axis_names[JOY_AXIS_MAX*2] = {
void ProjectSettings::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- globals_editor->edit(GlobalConfig::get_singleton());
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ globals_editor->edit(GlobalConfig::get_singleton());
- search_button->set_icon(get_icon("Zoom","EditorIcons"));
- clear_button->set_icon(get_icon("Close","EditorIcons"));
+ search_button->set_icon(get_icon("Zoom","EditorIcons"));
+ clear_button->set_icon(get_icon("Close","EditorIcons"));
- translation_list->connect("button_pressed",this,"_translation_delete");
- _update_actions();
- popup_add->add_icon_item(get_icon("Keyboard","EditorIcons"),TTR("Key "),InputEvent::KEY);//"Key " - because the word 'key' has already been used as a key animation
- popup_add->add_icon_item(get_icon("JoyButton","EditorIcons"),TTR("Joy Button"),InputEvent::JOYPAD_BUTTON);
- popup_add->add_icon_item(get_icon("JoyAxis","EditorIcons"),TTR("Joy Axis"),InputEvent::JOYPAD_MOTION);
- popup_add->add_icon_item(get_icon("Mouse","EditorIcons"),TTR("Mouse Button"),InputEvent::MOUSE_BUTTON);
+ translation_list->connect("button_pressed",this,"_translation_delete");
+ _update_actions();
+ popup_add->add_icon_item(get_icon("Keyboard","EditorIcons"),TTR("Key "),InputEvent::KEY);//"Key " - because the word 'key' has already been used as a key animation
+ popup_add->add_icon_item(get_icon("JoyButton","EditorIcons"),TTR("Joy Button"),InputEvent::JOYPAD_BUTTON);
+ popup_add->add_icon_item(get_icon("JoyAxis","EditorIcons"),TTR("Joy Axis"),InputEvent::JOYPAD_MOTION);
+ popup_add->add_icon_item(get_icon("Mouse","EditorIcons"),TTR("Mouse Button"),InputEvent::MOUSE_BUTTON);
- List<String> tfn;
- ResourceLoader::get_recognized_extensions_for_type("Translation",&tfn);
- for (List<String>::Element *E=tfn.front();E;E=E->next()) {
+ List<String> tfn;
+ ResourceLoader::get_recognized_extensions_for_type("Translation",&tfn);
+ for (List<String>::Element *E=tfn.front();E;E=E->next()) {
- translation_file_open->add_filter("*."+E->get());
- }
+ translation_file_open->add_filter("*."+E->get());
+ }
- List<String> rfn;
- ResourceLoader::get_recognized_extensions_for_type("Resource",&rfn);
- for (List<String>::Element *E=rfn.front();E;E=E->next()) {
+ List<String> rfn;
+ ResourceLoader::get_recognized_extensions_for_type("Resource",&rfn);
+ for (List<String>::Element *E=rfn.front();E;E=E->next()) {
- translation_res_file_open->add_filter("*."+E->get());
- translation_res_option_file_open->add_filter("*."+E->get());
- }
+ translation_res_file_open->add_filter("*."+E->get());
+ translation_res_option_file_open->add_filter("*."+E->get());
+ }
+ } break;
+ case NOTIFICATION_POPUP_HIDE: {
+ EditorSettings::get_singleton()->set("interface/dialogs/project_settings_bounds", get_rect());
+ } break;
}
}
@@ -241,7 +246,7 @@ void ProjectSettings::_device_input_add() {
undo_redo->add_undo_method(this,"_settings_changed");
undo_redo->commit_action();
- _show_last_added(ie);
+ _show_last_added(ie, name);
}
@@ -278,12 +283,14 @@ void ProjectSettings::_press_a_key_confirm() {
undo_redo->add_undo_method(this,"_settings_changed");
undo_redo->commit_action();
- _show_last_added(ie);
+ _show_last_added(ie, name);
}
-void ProjectSettings::_show_last_added(const InputEvent& p_event) {
+void ProjectSettings::_show_last_added(const InputEvent& p_event, const String &p_name) {
TreeItem *r = input_editor->get_root();
+ String name = p_name;
+ name.erase(0,6);
if (!r)
return;
r=r->get_children();
@@ -291,6 +298,10 @@ void ProjectSettings::_show_last_added(const InputEvent& p_event) {
return;
bool found = false;
while(r){
+ if (r->get_text(0) != name) {
+ r=r->get_next();
+ continue;
+ }
TreeItem *child = r->get_children();
while(child){
Variant input = child->get_meta("__input");
@@ -376,7 +387,7 @@ void ProjectSettings::_add_item(int p_item){
} break;
case InputEvent::JOYPAD_BUTTON: {
- device_id->set_value(3);
+ device_id->set_value(0);
device_index_label->set_text(TTR("Joypad Button Index:"));
device_index->clear();
@@ -572,8 +583,12 @@ void ProjectSettings::_update_actions() {
void ProjectSettings::popup_project_settings() {
- //popup_centered(Size2(500,400));
- popup_centered_ratio();
+ // Restore valid window bounds or pop up at default size.
+ if (EditorSettings::get_singleton()->has("interface/dialogs/project_settings_bounds")) {
+ popup(EditorSettings::get_singleton()->get("interface/dialogs/project_settings_bounds"));
+ } else {
+ popup_centered_ratio();
+ }
globals_editor->update_category_list();
_update_translations();
autoload_settings->update_autoload();
@@ -779,7 +794,7 @@ void ProjectSettings::_copy_to_platform(int p_which) {
String name = catname+"/"+propname;
Variant value=GlobalConfig::get_singleton()->get(name);
- catname+="."+popup_platform->get_popup()->get_item_text(p_which);;
+ catname+="."+popup_platform->get_popup()->get_item_text(p_which);
name = catname+"/"+propname;
GlobalConfig::get_singleton()->set(name,value);
@@ -1174,41 +1189,41 @@ void ProjectSettings::set_plugins_page() {
void ProjectSettings::_bind_methods() {
- ClassDB::bind_method(_MD("_item_selected"),&ProjectSettings::_item_selected);
- ClassDB::bind_method(_MD("_item_add"),&ProjectSettings::_item_add);
- ClassDB::bind_method(_MD("_item_adds"),&ProjectSettings::_item_adds);
- ClassDB::bind_method(_MD("_item_del"),&ProjectSettings::_item_del);
- ClassDB::bind_method(_MD("_item_checked"),&ProjectSettings::_item_checked);
- ClassDB::bind_method(_MD("_save"),&ProjectSettings::_save);
- ClassDB::bind_method(_MD("_action_add"),&ProjectSettings::_action_add);
- ClassDB::bind_method(_MD("_action_adds"),&ProjectSettings::_action_adds);
- ClassDB::bind_method(_MD("_action_selected"),&ProjectSettings::_action_selected);
- ClassDB::bind_method(_MD("_action_edited"),&ProjectSettings::_action_edited);
- ClassDB::bind_method(_MD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
- ClassDB::bind_method(_MD("_update_actions"),&ProjectSettings::_update_actions);
- ClassDB::bind_method(_MD("_wait_for_key"),&ProjectSettings::_wait_for_key);
- ClassDB::bind_method(_MD("_add_item"),&ProjectSettings::_add_item);
- ClassDB::bind_method(_MD("_device_input_add"),&ProjectSettings::_device_input_add);
- ClassDB::bind_method(_MD("_press_a_key_confirm"),&ProjectSettings::_press_a_key_confirm);
- ClassDB::bind_method(_MD("_settings_prop_edited"),&ProjectSettings::_settings_prop_edited);
- ClassDB::bind_method(_MD("_copy_to_platform"),&ProjectSettings::_copy_to_platform);
- ClassDB::bind_method(_MD("_update_translations"),&ProjectSettings::_update_translations);
- ClassDB::bind_method(_MD("_translation_delete"),&ProjectSettings::_translation_delete);
- ClassDB::bind_method(_MD("_settings_changed"),&ProjectSettings::_settings_changed);
- ClassDB::bind_method(_MD("_translation_add"),&ProjectSettings::_translation_add);
- ClassDB::bind_method(_MD("_translation_file_open"),&ProjectSettings::_translation_file_open);
-
- ClassDB::bind_method(_MD("_translation_res_add"),&ProjectSettings::_translation_res_add);
- ClassDB::bind_method(_MD("_translation_res_file_open"),&ProjectSettings::_translation_res_file_open);
- ClassDB::bind_method(_MD("_translation_res_option_add"),&ProjectSettings::_translation_res_option_add);
- ClassDB::bind_method(_MD("_translation_res_option_file_open"),&ProjectSettings::_translation_res_option_file_open);
- ClassDB::bind_method(_MD("_translation_res_select"),&ProjectSettings::_translation_res_select);
- ClassDB::bind_method(_MD("_translation_res_option_changed"),&ProjectSettings::_translation_res_option_changed);
- ClassDB::bind_method(_MD("_translation_res_delete"),&ProjectSettings::_translation_res_delete);
- ClassDB::bind_method(_MD("_translation_res_option_delete"),&ProjectSettings::_translation_res_option_delete);
-
- ClassDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
- ClassDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
+ 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_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);
+ 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);
}
@@ -1216,7 +1231,8 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
singleton=this;
- set_title(TTR("Project Settings (engine.cfg)"));
+ set_title(TTR("Project Settings (godot.cfg)"));
+ set_resizable(true);
undo_redo=&p_data->get_undo_redo();
data=p_data;
@@ -1341,7 +1357,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
hbc->add_spacer();
- List<StringName> ep;
+ /*List<StringName> ep;
EditorImportExport::get_singleton()->get_export_platforms(&ep);
ep.sort_custom<StringName::AlphCompare>();
@@ -1349,7 +1365,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
popup_platform->get_popup()->add_item( E->get() );
- }
+ }*/
popup_platform->get_popup()->connect("id_pressed",this,"_copy_to_platform");
get_ok()->set_text(TTR("Close"));
@@ -1357,12 +1373,12 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
message = memnew( ConfirmationDialog );
add_child(message);
-// message->get_cancel()->hide();
+ //message->get_cancel()->hide();
message->set_hide_on_ok(true);
Control *input_base = memnew( Control );
input_base->set_name(TTR("Input Map"));
- input_base->set_area_as_parent_rect();;
+ input_base->set_area_as_parent_rect();
tab_container->add_child(input_base);
VBoxContainer *vbc = memnew( VBoxContainer );
@@ -1424,7 +1440,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
hbc = memnew( HBoxContainer );
device_input->add_child(hbc);
-// device_input->set_child_rect(hbc);
+ //device_input->set_child_rect(hbc);
VBoxContainer *vbc_left = memnew( VBoxContainer );
hbc->add_child(vbc_left);
diff --git a/tools/editor/project_settings.h b/tools/editor/project_settings.h
index bb925a5fd9..96ac2e2c11 100644
--- a/tools/editor/project_settings.h
+++ b/tools/editor/project_settings.h
@@ -111,7 +111,7 @@ class ProjectSettings : public AcceptDialog {
void _action_button_pressed(Object* p_obj, int p_column,int p_id);
void _wait_for_key(const InputEvent& p_event);
void _press_a_key_confirm();
- void _show_last_added(const InputEvent& p_event);
+ void _show_last_added(const InputEvent& p_event, const String& p_name);
void _settings_prop_edited(const String& p_name);
void _settings_changed();
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 59538ffc6a..533a5b156b 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -27,17 +27,20 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "property_editor.h"
+
#include "scene/gui/label.h"
#include "io/resource_loader.h"
#include "io/image_loader.h"
-#include "object_type_db.h"
+#include "os/input.h"
+#include "os/keyboard.h"
+#include "class_db.h"
#include "print_string.h"
-#include "globals.h"
+#include "global_config.h"
#include "scene/resources/font.h"
#include "pair.h"
#include "scene/scene_string_names.h"
#include "editor_settings.h"
-#include "editor_import_export.h"
+#include "editor_export.h"
#include "editor_node.h"
#include "multi_node_edit.h"
#include "array_property_edit.h"
@@ -47,7 +50,7 @@
#include "editor_file_system.h"
#include "create_dialog.h"
#include "property_selector.h"
-#include "globals.h"
+#include "global_config.h"
void CustomPropertyEditor::_notification(int p_what) {
@@ -117,7 +120,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
Set<String> valid_extensions;
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
-
+ print_line("found: "+E->get());
valid_extensions.insert(E->get());
}
@@ -207,13 +210,13 @@ void CustomPropertyEditor::_menu_option(int p_which) {
case OBJ_MENU_REIMPORT: {
RES r=v;
- if (r.is_valid() && r->get_import_metadata().is_valid()) {
+/* if (r.is_valid() && r->get_import_metadata().is_valid()) {
Ref<ResourceImportMetadata> rimd = r->get_import_metadata();
Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor());
if (eip.is_valid()) {
eip->import_dialog(r->get_path());
}
- }
+ }*/
} break;
case OBJ_MENU_NEW_SCRIPT: {
@@ -221,6 +224,14 @@ void CustomPropertyEditor::_menu_option(int p_which) {
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>());
} break;
+ case OBJ_MENU_SHOW_IN_FILE_SYSTEM: {
+ RES r=v;
+ FileSystemDock *file_system_dock=EditorNode::get_singleton()->get_filesystem_dock();
+ file_system_dock->navigate_to_path(r->get_path());
+ // Ensure that the FileSystem dock is visible.
+ TabContainer* tab_container=(TabContainer*)file_system_dock->get_parent_control();
+ tab_container->set_current_tab(file_system_dock->get_position_in_parent());
+ } break;
default: {
@@ -271,6 +282,7 @@ Variant CustomPropertyEditor::get_variant() const {
return v;
}
+
String CustomPropertyEditor::get_name() const {
return name;
@@ -282,6 +294,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
updating=true;
name=p_name;
v=p_variant;
+ field_names.clear();
hint=p_hint;
hint_text=p_hint_text;
type_button->hide();
@@ -525,7 +538,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} else if (hint==PROPERTY_HINT_TYPE_STRING) {
-
+ /* FIXME: This is repeated twice, with slightly different behavior! Which one? Check line 644 */
if (!create_dialog) {
create_dialog = memnew( CreateDialog );
create_dialog->connect("create",this,"_create_dialog_callback");
@@ -642,6 +655,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} else if (hint==PROPERTY_HINT_TYPE_STRING) {
if (!create_dialog) {
+ /* FIXME: ... and here. See line 529 */
create_dialog = memnew( CreateDialog );
create_dialog->connect("create",this,"_create_dialog_callback");
add_child(create_dialog);
@@ -657,22 +671,20 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::VECTOR2: {
- List<String> names;
- names.push_back("x");
- names.push_back("y");
- config_value_editors(2,2,10,names);
+ field_names.push_back("x");
+ field_names.push_back("y");
+ config_value_editors(2,2,10,field_names);
Vector2 vec=v;
value_editor[0]->set_text( String::num( vec.x) );
value_editor[1]->set_text( String::num( vec.y) );
} break;
case Variant::RECT2: {
- List<String> names;
- names.push_back("x");
- names.push_back("y");
- names.push_back("w");
- names.push_back("h");
- config_value_editors(4,4,10,names);
+ field_names.push_back("x");
+ field_names.push_back("y");
+ field_names.push_back("w");
+ field_names.push_back("h");
+ config_value_editors(4,4,10,field_names);
Rect2 r=v;
value_editor[0]->set_text( String::num( r.pos.x) );
value_editor[1]->set_text( String::num( r.pos.y) );
@@ -681,11 +693,10 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::VECTOR3: {
- List<String> names;
- names.push_back("x");
- names.push_back("y");
- names.push_back("z");
- config_value_editors(3,3,10,names);
+ field_names.push_back("x");
+ field_names.push_back("y");
+ field_names.push_back("z");
+ config_value_editors(3,3,10,field_names);
Vector3 vec=v;
value_editor[0]->set_text( String::num( vec.x) );
value_editor[1]->set_text( String::num( vec.y) );
@@ -693,12 +704,11 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::PLANE: {
- List<String> names;
- names.push_back("x");
- names.push_back("y");
- names.push_back("z");
- names.push_back("d");
- config_value_editors(4,4,10,names);
+ field_names.push_back("x");
+ field_names.push_back("y");
+ field_names.push_back("z");
+ field_names.push_back("d");
+ config_value_editors(4,4,10,field_names);
Plane plane=v;
value_editor[0]->set_text( String::num( plane.normal.x ) );
value_editor[1]->set_text( String::num( plane.normal.y ) );
@@ -708,12 +718,11 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::QUAT: {
- List<String> names;
- names.push_back("x");
- names.push_back("y");
- names.push_back("z");
- names.push_back("w");
- config_value_editors(4,4,10,names);
+ field_names.push_back("x");
+ field_names.push_back("y");
+ field_names.push_back("z");
+ field_names.push_back("w");
+ config_value_editors(4,4,10,field_names);
Quat q=v;
value_editor[0]->set_text( String::num( q.x ) );
value_editor[1]->set_text( String::num( q.y ) );
@@ -723,14 +732,13 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::RECT3: {
- List<String> names;
- names.push_back("px");
- names.push_back("py");
- names.push_back("pz");
- names.push_back("sx");
- names.push_back("sy");
- names.push_back("sz");
- config_value_editors(6,3,16,names);
+ field_names.push_back("px");
+ field_names.push_back("py");
+ field_names.push_back("pz");
+ field_names.push_back("sx");
+ field_names.push_back("sy");
+ field_names.push_back("sz");
+ config_value_editors(6,3,16,field_names);
Rect3 aabb=v;
value_editor[0]->set_text( String::num( aabb.pos.x ) );
@@ -743,14 +751,13 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::TRANSFORM2D: {
- List<String> names;
- names.push_back("xx");
- names.push_back("xy");
- names.push_back("yx");
- names.push_back("yy");
- names.push_back("ox");
- names.push_back("oy");
- config_value_editors(6,2,16,names);
+ field_names.push_back("xx");
+ field_names.push_back("xy");
+ field_names.push_back("yx");
+ field_names.push_back("yy");
+ field_names.push_back("ox");
+ field_names.push_back("oy");
+ config_value_editors(6,2,16,field_names);
Transform2D basis=v;
for(int i=0;i<6;i++) {
@@ -761,17 +768,16 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
} break;
case Variant::BASIS: {
- List<String> names;
- names.push_back("xx");
- names.push_back("xy");
- names.push_back("xz");
- names.push_back("yx");
- names.push_back("yy");
- names.push_back("yz");
- names.push_back("zx");
- names.push_back("zy");
- names.push_back("zz");
- config_value_editors(9,3,16,names);
+ field_names.push_back("xx");
+ field_names.push_back("xy");
+ field_names.push_back("xz");
+ field_names.push_back("yx");
+ field_names.push_back("yy");
+ field_names.push_back("yz");
+ field_names.push_back("zx");
+ field_names.push_back("zy");
+ field_names.push_back("zz");
+ config_value_editors(9,3,16,field_names);
Basis basis=v;
for(int i=0;i<9;i++) {
@@ -783,20 +789,19 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
case Variant::TRANSFORM: {
- List<String> names;
- names.push_back("xx");
- names.push_back("xy");
- names.push_back("xz");
- names.push_back("xo");
- names.push_back("yx");
- names.push_back("yy");
- names.push_back("yz");
- names.push_back("yo");
- names.push_back("zx");
- names.push_back("zy");
- names.push_back("zz");
- names.push_back("zo");
- config_value_editors(12,4,16,names);
+ field_names.push_back("xx");
+ field_names.push_back("xy");
+ field_names.push_back("xz");
+ field_names.push_back("xo");
+ field_names.push_back("yx");
+ field_names.push_back("yy");
+ field_names.push_back("yz");
+ field_names.push_back("yo");
+ field_names.push_back("zx");
+ field_names.push_back("zy");
+ field_names.push_back("zz");
+ field_names.push_back("zo");
+ config_value_editors(12,4,16,field_names);
Transform tr=v;
for(int i=0;i<9;i++) {
@@ -824,7 +829,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
color_picker->show();
color_picker->set_edit_alpha(hint!=PROPERTY_HINT_COLOR_NO_ALPHA);
- color_picker->set_color(v);
+ color_picker->set_pick_color(v);
set_size( Size2(300*EDSCALE, color_picker->get_combined_minimum_size().height+10*EDSCALE));
color_picker->set_focus_on_line_edit();
/*
@@ -888,7 +893,7 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->clear();
menu->set_size(Size2(1,1));
- if (p_name=="script/script" && hint_text=="Script" && owner->cast_to<Node>()) {
+ if (p_name=="script" && hint_text=="Script" && owner->cast_to<Node>()) {
menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT);
menu->add_separator();
} else if (hint_text!="") {
@@ -945,9 +950,13 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
menu->add_icon_item(get_icon("Del","EditorIcons"),"Clear",OBJ_MENU_CLEAR);
menu->add_icon_item(get_icon("Duplicate","EditorIcons"),"Make Unique",OBJ_MENU_MAKE_UNIQUE);
RES r = v;
- if (r.is_valid() && r->get_path().is_resource_file() && r->get_import_metadata().is_valid()) {
+ if (r.is_valid() && r->get_path().is_resource_file()) {
+ /*if (r->get_import_metadata().is_valid()) {
+ menu->add_separator();
+ menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
+ }*/
menu->add_separator();
- menu->add_icon_item(get_icon("ReloadSmall","EditorIcons"),"Re-Import",OBJ_MENU_REIMPORT);
+ menu->add_item(TTR("Show in File System"),OBJ_MENU_SHOW_IN_FILE_SYSTEM);
}
/*if (r.is_valid() && r->get_path().is_resource_file()) {
menu->set_item_tooltip(1,r->get_path());
@@ -1036,6 +1045,14 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
return true;
}
+////void CustomPropertyEditor::_save_properties_values(List<String> p_names) {
+////
+//// field_names=p_names;
+//// for (int i=0;i<p_names.size();i++) {
+//// field_values.push_back(v.get(p_names[i]));
+//// }
+////}
+
void CustomPropertyEditor::_file_selected(String p_file) {
switch(type) {
@@ -1502,12 +1519,12 @@ void CustomPropertyEditor::_drag_easing(const InputEvent& p_ev) {
bool sg = val < 0;
val = Math::absf(val);
- val = Math::log(val)/Math::log(2);
+ val = Math::log(val)/Math::log((float)2.0);
//logspace
val+=rel*0.05;
//
- val = Math::pow(2,val);
+ val = Math::pow(2.0f,val);
if (sg)
val=-val;
@@ -1629,7 +1646,7 @@ void CustomPropertyEditor::_modified(String p_string) {
vec.y=value_editor[1]->get_text().to_double();
}
v=vec;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::RECT2: {
@@ -1647,7 +1664,7 @@ void CustomPropertyEditor::_modified(String p_string) {
r2.size.y=value_editor[3]->get_text().to_double();
}
v=r2;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
@@ -1664,7 +1681,7 @@ void CustomPropertyEditor::_modified(String p_string) {
vec.z=value_editor[2]->get_text().to_double();
}
v=vec;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::PLANE: {
@@ -1682,7 +1699,7 @@ void CustomPropertyEditor::_modified(String p_string) {
pl.d=value_editor[3]->get_text().to_double();
}
v=pl;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::QUAT: {
@@ -1700,7 +1717,7 @@ void CustomPropertyEditor::_modified(String p_string) {
q.w=value_editor[3]->get_text().to_double();
}
v=q;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::RECT3: {
@@ -1724,7 +1741,7 @@ void CustomPropertyEditor::_modified(String p_string) {
size.z=value_editor[5]->get_text().to_double();
}
v=Rect3(pos,size);
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::TRANSFORM2D: {
@@ -1739,7 +1756,7 @@ void CustomPropertyEditor::_modified(String p_string) {
}
v=m;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::BASIS: {
@@ -1755,7 +1772,7 @@ void CustomPropertyEditor::_modified(String p_string) {
}
v=m;
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
case Variant::TRANSFORM: {
@@ -1783,7 +1800,7 @@ void CustomPropertyEditor::_modified(String p_string) {
}
v=Transform(basis,origin);
- emit_signal("variant_changed");
+ _emit_changed_whole_or_field();
} break;
@@ -1850,6 +1867,15 @@ void CustomPropertyEditor::_modified(String p_string) {
updating=false;
}
+void CustomPropertyEditor::_emit_changed_whole_or_field() {
+
+ if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ emit_signal("variant_changed");
+ } else {
+ emit_signal("variant_field_changed",field_names[focused_value_editor]);
+ }
+}
+
void CustomPropertyEditor::_range_modified(double p_value)
{
v=p_value;
@@ -1871,6 +1897,7 @@ void CustomPropertyEditor::_focus_enter() {
case Variant::TRANSFORM: {
for (int i=0;i<MAX_VALUE_EDITORS;++i) {
if (value_editor[i]->has_focus()) {
+ focused_value_editor=i;
value_editor[i]->select_all();
break;
}
@@ -1983,6 +2010,7 @@ void CustomPropertyEditor::_bind_methods() {
ADD_SIGNAL( MethodInfo("variant_changed") );
+ ADD_SIGNAL( MethodInfo("variant_field_changed",PropertyInfo(Variant::STRING,"field")) );
ADD_SIGNAL( MethodInfo("resource_edit_request") );
}
CustomPropertyEditor::CustomPropertyEditor() {
@@ -2003,6 +2031,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
value_editor[i]->connect("focus_entered", this, "_focus_enter");
value_editor[i]->connect("focus_exited", this, "_focus_exit");
}
+ focused_value_editor=-1;
for(int i=0;i<4;i++) {
@@ -2084,7 +2113,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
scene_tree->connect("selected", this,"_node_path_selected");
scene_tree->get_scene_tree()->set_show_enabled_subscene(true);
- texture_preview = memnew( TextureFrame );
+ texture_preview = memnew( TextureRect );
add_child( texture_preview);
texture_preview->hide();
@@ -2161,7 +2190,7 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_p
bool found=false;
-// print_line("for prop - "+String(p_prop));
+ //print_line("for prop - "+String(p_prop));
while(node) {
@@ -2174,13 +2203,13 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_p
} else {
ss=node->get_scene_instance_state();
}
- // print_line("at - "+String(edited_scene->get_path_to(node)));
+ //print_line("at - "+String(edited_scene->get_path_to(node)));
if (ss.is_valid()) {
NodePath np = node->get_path_to(orig);
int node_idx = ss->find_node_by_path(np);
- // print_line("\t valid, nodeidx "+itos(node_idx));
+ //print_line("\t valid, nodeidx "+itos(node_idx));
if (node_idx>=0) {
bool lfound=false;
Variant lvar;
@@ -2189,7 +2218,7 @@ bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_p
found=true;
value=lvar;
- // print_line("\t found value "+String(value));
+ //print_line("\t found value "+String(value));
}
}
}
@@ -2215,7 +2244,7 @@ bool PropertyEditor::_is_property_different(const Variant& p_current, const Vari
Node* edited_scene =EditorNode::get_singleton()->get_edited_scene();
bool found_state=false;
- // print_line("for prop - "+String(p_prop));
+ //print_line("for prop - "+String(p_prop));
while(node) {
@@ -2371,6 +2400,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
p_item->set_range(1, obj->get( p_name ) );
} else {
+ /* FIXME: Why are both statements equal? */
p_item->set_range(1, obj->get( p_name ) );
}
@@ -2430,7 +2460,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
} break;
case Variant::COLOR: {
- p_item->set_custom_bg_color(1,obj->get(p_name));
+ tree->update();
//p_item->set_text(1,obj->get(p_name));
} break;
@@ -2802,13 +2832,13 @@ void PropertyEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAG_BEGIN) {
- if (is_visible() && tree->get_root()) {
+ if (is_visible_in_tree() && tree->get_root()) {
_mark_drop_fields(tree->get_root());
}
}
if (p_what==NOTIFICATION_DRAG_END) {
- if (is_visible() && tree->get_root()) {
+ if (is_visible_in_tree() && tree->get_root()) {
_clear_drop_fields(tree->get_root());
}
@@ -2867,7 +2897,7 @@ TreeItem *PropertyEditor::get_parent_node(String p_path,HashMap<String,TreeItem*
item = item_paths.get(p_path);
} else {
-// printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() );
+ //printf("path %s parent path %s - item name %s\n",p_path.ascii().get_data(),p_path.left( p_path.find_last("/") ).ascii().get_data(),p_path.right( p_path.find_last("/") ).ascii().get_data() );
TreeItem *parent = get_parent_node( p_path.left( p_path.find_last("/") ),item_paths,root );
item = tree->create_item( parent );
@@ -3139,6 +3169,10 @@ void PropertyEditor::update_tree() {
} else if ( ! (p.usage&PROPERTY_USAGE_EDITOR ) )
continue;
+
+ if (hide_script && p.name=="script")
+ continue;
+
String basename=p.name;
if (group!="") {
if (group_base!="") {
@@ -3174,8 +3208,10 @@ void PropertyEditor::update_tree() {
//printf("property %s\n",basename.ascii().get_data());
TreeItem * parent = get_parent_node(path,item_path,current_category?current_category:root );
- //if (parent->get_parent()==root)
- // parent=root;
+ /*
+ if (parent->get_parent()==root)
+ parent=root;
+ */
int level = 0;
if (parent!=root) {
level++;
@@ -3359,7 +3395,7 @@ void PropertyEditor::update_tree() {
item->set_range_config(1,min,max,step,p.hint==PROPERTY_HINT_EXP_RANGE);
} else if (p.hint==PROPERTY_HINT_ENUM) {
-// int c = p.hint_string.get_slice_count(",");
+ //int c = p.hint_string.get_slice_count(",");
item->set_text(1,p.hint_string);
if (show_type_icons)
item->set_icon( 0,get_icon("Enum","EditorIcons") );
@@ -3368,7 +3404,7 @@ void PropertyEditor::update_tree() {
break;
} else if (p.hint==PROPERTY_HINT_OBJECT_ID) {
-// int c = p.hint_string.get_slice_count(",");
+ //int c = p.hint_string.get_slice_count(",");
item->set_cell_mode(1,TreeItem::CELL_MODE_CUSTOM);
String type=p.hint_string;
@@ -3704,8 +3740,8 @@ void PropertyEditor::update_tree() {
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM );
item->set_editable( 1, !read_only );
-// item->set_text(1,obj->get(p.name));
- item->set_custom_bg_color(1,obj->get(p.name));
+ //item->set_text(1,obj->get(p.name));
+ item->set_custom_draw(1,this,"_draw_transparency");
if (show_type_icons)
item->set_icon( 0,get_icon("Color","EditorIcons") );
@@ -3728,7 +3764,7 @@ void PropertyEditor::update_tree() {
item->set_cell_mode(1, TreeItem::CELL_MODE_STRING);
item->set_editable( 1, !read_only );
item->set_text(1,obj->get(p.name));
- item->add_button(1, get_icon("Collapse", "EditorIcons"));
+ item->add_button(1, get_icon("CopyNodePath", "EditorIcons"));
} break;
case Variant::OBJECT: {
@@ -3790,7 +3826,7 @@ void PropertyEditor::update_tree() {
item->set_icon( 0, get_icon("Object","EditorIcons") );
}
-// item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) );
+ //item->double_click_signal.connect( Method1<int>( Method2<int,String>( this, &Editoritem_obj_edited ), p.name ) );
} break;
default: {};
@@ -3853,6 +3889,25 @@ void PropertyEditor::update_tree() {
}
}
+void PropertyEditor::_draw_transparency(Object *t, const Rect2& p_rect) {
+
+ TreeItem *ti=t->cast_to<TreeItem>();
+ if (!ti)
+ return;
+
+ Color color=obj->get(ti->get_metadata(1));
+ Ref<Texture> arrow=tree->get_icon("select_arrow");
+
+ // make a little space between consecutive color fields
+ Rect2 area=p_rect;
+ area.pos.y+=1;
+ area.size.height-=2;
+ area.size.width-=arrow->get_size().width+5;
+ tree->draw_texture_rect(get_icon("Transparent", "EditorIcons"), area, true);
+ tree->draw_rect(area, color);
+
+}
+
void PropertyEditor::_item_selected() {
@@ -3864,7 +3919,7 @@ void PropertyEditor::_item_selected() {
}
-void PropertyEditor::_edit_set(const String& p_name, const Variant& p_value) {
+void PropertyEditor::_edit_set(const String& p_name, const Variant& p_value, bool p_refresh_all, const String& p_changed_field) {
if (autoclear) {
TreeItem *item = tree->get_selected();
@@ -3874,22 +3929,35 @@ void PropertyEditor::_edit_set(const String& p_name, const Variant& p_value) {
}
}
- if (!undo_redo || obj->cast_to<MultiNodeEdit>() || obj->cast_to<ArrayPropertyEdit>()) { //kind of hacky
+ if (!undo_redo|| obj->cast_to<ArrayPropertyEdit>()) { //kind of hacky
obj->set(p_name,p_value);
- _changed_callbacks(obj,p_name);
+ if (p_refresh_all)
+ _changed_callbacks(obj,"");
+ else
+ _changed_callbacks(obj,p_name);
+
emit_signal(_prop_edited,p_name);
+ } else if (obj->cast_to<MultiNodeEdit>()) {
+ obj->cast_to<MultiNodeEdit>()->set_property_field(p_name,p_value,p_changed_field);
+ _changed_callbacks(obj,p_name);
+ emit_signal(_prop_edited,p_name);
} else {
undo_redo->create_action(TTR("Set")+" "+p_name,UndoRedo::MERGE_ENDS);
undo_redo->add_do_property(obj,p_name,p_value);
undo_redo->add_undo_property(obj,p_name,obj->get(p_name));
+ if (p_refresh_all) {
+ undo_redo->add_do_method(this,"_changed_callback",obj,"");
+ undo_redo->add_undo_method(this,"_changed_callback",obj,"");
+ } else {
- undo_redo->add_do_method(this,"_changed_callback",obj,p_name);
- undo_redo->add_undo_method(this,"_changed_callback",obj,p_name);
+ undo_redo->add_do_method(this,"_changed_callback",obj,p_name);
+ undo_redo->add_undo_method(this,"_changed_callback",obj,p_name);
+ }
Resource *r = obj->cast_to<Resource>();
if (r) {
@@ -3951,6 +4019,9 @@ void PropertyEditor::_item_edited() {
int type=d["type"];
int hint= d["hint"];
+ int usage = d["usage"];
+ bool refresh_all = usage&PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED;
+
String hint_text=d["hint_text"];
switch(type) {
@@ -3959,7 +4030,7 @@ void PropertyEditor::_item_edited() {
} break;
case Variant::BOOL: {
- _edit_set(name,item->is_checked(1));
+ _edit_set(name,item->is_checked(1),refresh_all);
item->set_tooltip(1, item->is_checked(1) ? "True" : "False");
} break;
case Variant::INT:
@@ -3973,9 +4044,9 @@ void PropertyEditor::_item_edited() {
break;
if (type==Variant::INT)
- _edit_set(name,int(item->get_range(1)));
+ _edit_set(name,int(item->get_range(1)),refresh_all);
else
- _edit_set(name,item->get_range(1));
+ _edit_set(name,item->get_range(1),refresh_all);
} break;
case Variant::STRING: {
@@ -3990,9 +4061,9 @@ void PropertyEditor::_item_edited() {
txt=strings[idx];
}
- _edit_set(name,txt);
+ _edit_set(name,txt,refresh_all);
} else {
- _edit_set(name,item->get_text(1));
+ _edit_set(name,item->get_text(1),refresh_all);
}
} break;
// math types
@@ -4023,7 +4094,7 @@ void PropertyEditor::_item_edited() {
} break;
case Variant::NODE_PATH: {
- _edit_set(name, NodePath(item->get_text(1)));
+ _edit_set(name, NodePath(item->get_text(1)),refresh_all);
} break;
@@ -4077,10 +4148,19 @@ void PropertyEditor::_custom_editor_edited() {
if (!obj)
return;
-
_edit_set(custom_editor->get_name(), custom_editor->get_variant());
}
+void PropertyEditor::_custom_editor_edited_field(const String& p_field_name) {
+
+ ERR_FAIL_COND(p_field_name=="");
+
+ if (!obj)
+ return;
+
+ _edit_set(custom_editor->get_name(), custom_editor->get_variant(), false, p_field_name);
+}
+
void PropertyEditor::_custom_editor_request(bool p_arrow) {
TreeItem * item = tree->get_edited();
@@ -4353,6 +4433,7 @@ void PropertyEditor::_bind_methods() {
ClassDB::bind_method( "_item_selected",&PropertyEditor::_item_selected);
ClassDB::bind_method( "_custom_editor_request",&PropertyEditor::_custom_editor_request);
ClassDB::bind_method( "_custom_editor_edited",&PropertyEditor::_custom_editor_edited);
+ ClassDB::bind_method( "_custom_editor_edited_field",&PropertyEditor::_custom_editor_edited_field,DEFVAL(""));
ClassDB::bind_method( "_resource_edit_request",&PropertyEditor::_resource_edit_request);
ClassDB::bind_method( "_node_removed",&PropertyEditor::_node_removed);
ClassDB::bind_method( "_edit_button",&PropertyEditor::_edit_button);
@@ -4363,10 +4444,11 @@ void PropertyEditor::_bind_methods() {
ClassDB::bind_method( "update_tree",&PropertyEditor::update_tree);
ClassDB::bind_method( "_resource_preview_done",&PropertyEditor::_resource_preview_done);
ClassDB::bind_method( "refresh",&PropertyEditor::refresh);
+ ClassDB::bind_method( "_draw_transparency",&PropertyEditor::_draw_transparency);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &PropertyEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &PropertyEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &PropertyEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &PropertyEditor::drop_data_fw);
ADD_SIGNAL( MethodInfo("property_toggled",PropertyInfo( Variant::STRING, "property"),PropertyInfo( Variant::BOOL, "value")));
ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@@ -4453,6 +4535,8 @@ PropertyEditor::PropertyEditor() {
_prop_edited="property_edited";
+ hide_script=false;
+
undo_redo=NULL;
obj=NULL;
search_box=NULL;
@@ -4496,6 +4580,7 @@ PropertyEditor::PropertyEditor() {
tree->connect("custom_popup_edited", this,"_custom_editor_request");
tree->connect("button_pressed", this,"_edit_button");
custom_editor->connect("variant_changed", this,"_custom_editor_edited");
+ custom_editor->connect("variant_field_changed", this,"_custom_editor_edited_field");
custom_editor->connect("resource_edit_request", this,"_resource_edit_request",make_binds(),CONNECT_DEFERRED);
tree->set_hide_folding(true);
@@ -4658,7 +4743,7 @@ void SectionedPropertyEditor::_section_selected() {
void SectionedPropertyEditor::set_current_section(const String& p_section) {
if (section_map.has(p_section)) {
- section_map[p_section]->select(0);;
+ section_map[p_section]->select(0);
}
}
@@ -4739,7 +4824,7 @@ void SectionedPropertyEditor::update_category_list() {
else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) )
continue;
- if (pi.name.find(":")!=-1 || pi.name=="script/script" || pi.name=="resource_name" || pi.name=="resource_path")
+ if (pi.name.find(":")!=-1 || pi.name=="script" || pi.name=="resource_name" || pi.name=="resource_path")
continue;
int sp = pi.name.find("/");
if (sp==-1)
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 8f429ab979..e31a3313c1 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -37,7 +37,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/color_picker.h"
#include "scene/gui/menu_button.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/check_button.h"
#include "scene/gui/split_container.h"
@@ -67,8 +67,8 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_PASTE=5,
OBJ_MENU_REIMPORT=6,
OBJ_MENU_NEW_SCRIPT=7,
+ OBJ_MENU_SHOW_IN_FILE_SYSTEM=8,
TYPE_BASE_ID=100
-
};
enum {
@@ -88,15 +88,17 @@ class CustomPropertyEditor : public Popup {
String name;
Variant::Type type;
Variant v;
+ List<String> field_names;
int hint;
String hint_text;
LineEdit *value_editor[MAX_VALUE_EDITORS];
+ int focused_value_editor;
Label *value_label[MAX_VALUE_EDITORS];
HScrollBar *scroll[4];
Button *action_buttons[MAX_ACTION_BUTTONS];
MenuButton *type_button;
Vector<String> inheritors_array;
- TextureFrame *texture_preview;
+ TextureRect *texture_preview;
ColorPicker *color_picker;
TextEdit *text_edit;
bool read_only;
@@ -141,6 +143,8 @@ class CustomPropertyEditor : public Popup {
void config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings);
void config_action_buttons(const List<String>& p_strings);
+ void _emit_changed_whole_or_field();
+
protected:
@@ -192,6 +196,7 @@ class PropertyEditor : public Control {
bool use_doc_hints;
bool use_filter;
bool subsection_selectable;
+ bool hide_script;
HashMap<String,String> pending;
String selected_property;
@@ -203,6 +208,7 @@ class PropertyEditor : public Control {
void _resource_edit_request();
void _custom_editor_edited();
+ void _custom_editor_edited_field(const String& p_field_name);
void _custom_editor_request(bool p_arrow);
void _item_selected();
@@ -224,7 +230,7 @@ class PropertyEditor : public Control {
void _node_removed(Node *p_node);
friend class ProjectExportDialog;
- void _edit_set(const String& p_name, const Variant& p_value);
+ void _edit_set(const String& p_name, const Variant& p_value,bool p_refresh_all=false, const String& p_changed_field="");
void _draw_flags(Object *ti,const Rect2& p_rect);
bool _might_be_in_instance();
@@ -245,6 +251,7 @@ friend class ProjectExportDialog;
void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from);
void _resource_preview_done(const String& p_path,const Ref<Texture>& p_preview,Variant p_ud);
+ void _draw_transparency(Object *t, const Rect2& p_rect);
UndoRedo *undo_redo;
protected:
@@ -275,6 +282,7 @@ public:
void set_show_categories(bool p_show);
void set_use_doc_hints(bool p_enable) { use_doc_hints=p_enable; }
+ void set_hide_script(bool p_hide) { hide_script=p_hide; }
void set_use_filter(bool p_use);
void register_text_enter(Node *p_line_edit);
diff --git a/tools/editor/property_selector.cpp b/tools/editor/property_selector.cpp
index 3d9695ac2a..71ffae4729 100644
--- a/tools/editor/property_selector.cpp
+++ b/tools/editor/property_selector.cpp
@@ -1,6 +1,34 @@
+/*************************************************************************/
+/* property_selector.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 "property_selector.h"
-#include "editor_scale.h"
+#include "editor_scale.h"
#include "os/keyboard.h"
void PropertySelector::_text_changed(const String& p_newtext) {
@@ -559,10 +587,10 @@ void PropertySelector::select_property_from_instance(Object* p_instance, const S
void PropertySelector::_bind_methods() {
- ClassDB::bind_method(_MD("_text_changed"),&PropertySelector::_text_changed);
- ClassDB::bind_method(_MD("_confirmed"),&PropertySelector::_confirmed);
- ClassDB::bind_method(_MD("_sbox_input"),&PropertySelector::_sbox_input);
- ClassDB::bind_method(_MD("_item_selected"),&PropertySelector::_item_selected);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&PropertySelector::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"),&PropertySelector::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&PropertySelector::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_item_selected"),&PropertySelector::_item_selected);
ADD_SIGNAL(MethodInfo("selected",PropertyInfo(Variant::STRING,"name")));
diff --git a/tools/editor/property_selector.h b/tools/editor/property_selector.h
index 4823d50e0f..d29183f85e 100644
--- a/tools/editor/property_selector.h
+++ b/tools/editor/property_selector.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* property_selector.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* 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 PROPERTYSELECTOR_H
#define PROPERTYSELECTOR_H
diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp
index 7f84d8d00e..b130f6c773 100644
--- a/tools/editor/pvrtc_compress.cpp
+++ b/tools/editor/pvrtc_compress.cpp
@@ -27,12 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "pvrtc_compress.h"
+
#include "editor_settings.h"
#include "scene/resources/texture.h"
#include "io/resource_saver.h"
#include "io/resource_loader.h"
#include "os/os.h"
#include "os/file_access.h"
+
static void (*_base_image_compress_pvrtc2_func)(Image *)=NULL;
static void (*_base_image_compress_pvrtc4_func)(Image *)=NULL;
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp
index ff5ecdf01b..f43189a7bf 100644
--- a/tools/editor/quick_open.cpp
+++ b/tools/editor/quick_open.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "quick_open.h"
-#include "os/keyboard.h"
+#include "os/keyboard.h"
void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
@@ -252,9 +252,9 @@ StringName EditorQuickOpen::get_base_type() const {
void EditorQuickOpen::_bind_methods() {
- ClassDB::bind_method(_MD("_text_changed"),&EditorQuickOpen::_text_changed);
- ClassDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed);
- ClassDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input);
+ ClassDB::bind_method(D_METHOD("_text_changed"),&EditorQuickOpen::_text_changed);
+ ClassDB::bind_method(D_METHOD("_confirmed"),&EditorQuickOpen::_confirmed);
+ ClassDB::bind_method(D_METHOD("_sbox_input"),&EditorQuickOpen::_sbox_input);
ADD_SIGNAL(MethodInfo("quick_open"));
diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp
index a8909b0772..c5b74d9006 100644
--- a/tools/editor/reparent_dialog.cpp
+++ b/tools/editor/reparent_dialog.cpp
@@ -30,8 +30,6 @@
#include "scene/gui/label.h"
#include "scene/gui/box_container.h"
-
-
#include "print_string.h"
void ReparentDialog::_notification(int p_what) {
@@ -88,7 +86,7 @@ ReparentDialog::ReparentDialog() {
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
-// set_child_rect(vbc);
+ //set_child_rect(vbc);
tree = memnew( SceneTreeEditor(false) );
tree->set_show_enabled_subscene(true);
@@ -107,7 +105,7 @@ ReparentDialog::ReparentDialog() {
vbc->add_child(keep_transform);
- //vbc->add_margin_child("Options:",node_only);;
+ //vbc->add_margin_child("Options:",node_only);
//cancel->connect("pressed", this,"_cancel");
diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp
index c8fa1eda77..8648361bae 100644
--- a/tools/editor/resources_dock.cpp
+++ b/tools/editor/resources_dock.cpp
@@ -27,12 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resources_dock.h"
+
#include "editor_node.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "editor_settings.h"
#include "project_settings.h"
-#include "globals.h"
+#include "global_config.h"
#include "editor_file_system.h"
@@ -122,12 +123,14 @@ void ResourcesDock::_notification(int p_what) {
void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_resource) {
- editor->get_editor_data().apply_changes_in_editors();;
+ editor->get_editor_data().apply_changes_in_editors();
int flg=0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
- //if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
- // flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ /*
+ if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
+ flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ */
String path = GlobalConfig::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
@@ -137,7 +140,7 @@ void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_re
accept->popup_centered_minsize();
return;
}
-// EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
+ //EditorFileSystem::get_singleton()->update_file(path,p_resource->get_type());
((Resource*)p_resource.ptr())->set_path(path);
editor->emit_signal("resource_saved",p_resource);
@@ -319,12 +322,12 @@ void ResourcesDock::_create() {
void ResourcesDock::_bind_methods() {
- ClassDB::bind_method(_MD("_tool_selected"),&ResourcesDock::_tool_selected);
- ClassDB::bind_method(_MD("_create"),&ResourcesDock::_create);
- ClassDB::bind_method(_MD("_resource_selected"),&ResourcesDock::_resource_selected);
- ClassDB::bind_method(_MD("_delete"),&ResourcesDock::_delete);
- ClassDB::bind_method(_MD("remove_resource"),&ResourcesDock::remove_resource);
- ClassDB::bind_method(_MD("_file_action"),&ResourcesDock::_file_action);
+ ClassDB::bind_method(D_METHOD("_tool_selected"),&ResourcesDock::_tool_selected);
+ ClassDB::bind_method(D_METHOD("_create"),&ResourcesDock::_create);
+ ClassDB::bind_method(D_METHOD("_resource_selected"),&ResourcesDock::_resource_selected);
+ ClassDB::bind_method(D_METHOD("_delete"),&ResourcesDock::_delete);
+ ClassDB::bind_method(D_METHOD("remove_resource"),&ResourcesDock::remove_resource);
+ ClassDB::bind_method(D_METHOD("_file_action"),&ResourcesDock::_file_action);
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index c171c49c7b..4f3700adb5 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -27,8 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scene_tree_dock.h"
+
#include "editor_node.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/keyboard.h"
#include "scene/resources/packed_scene.h"
#include "editor_settings.h"
@@ -104,6 +105,9 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) {
_tool_selected(TOOL_ERASE, true);
}
+ else if(ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) {
+ _tool_selected(TOOL_COPY_NODE_PATH);
+ }
else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) {
_tool_selected(TOOL_ERASE);
}
@@ -295,10 +299,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
switch(p_tool) {
case TOOL_NEW: {
-
-
- //if (!_validate_no_foreign())
- // break;
+ /*
+ if (!_validate_no_foreign())
+ break;
+ */
create_dialog->popup(true);
} break;
case TOOL_INSTANCE: {
@@ -319,8 +323,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
}
- //if (!_validate_no_foreign())
- // break;
+ /*
+ if (!_validate_no_foreign())
+ break;
+ */
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
@@ -345,10 +351,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!current)
break;
- //if (!_validate_no_foreign())
- // break;
- //connect_dialog->popup_centered_ratio();
- //connect_dialog->set_node(current);
+ /*
+ if (!_validate_no_foreign())
+ break;
+ connect_dialog->popup_centered_ratio();
+ connect_dialog->set_node(current);
+ */
} break;
case TOOL_GROUP: {
@@ -356,10 +364,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *current = scene_tree->get_selected();
if (!current)
break;
- //if (!_validate_no_foreign())
- // break;
- //groups_editor->set_current(current);
- //groups_editor->popup_centered_ratio();
+ /*
+ if (!_validate_no_foreign())
+ break;
+ groups_editor->set_current(current);
+ groups_editor->popup_centered_ratio();
+ */
} break;
case TOOL_ATTACH_SCRIPT: {
@@ -367,8 +377,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (!selected)
break;
- //if (!_validate_no_foreign())
- // break;
+ /*
+ if (!_validate_no_foreign())
+ break;
+ */
Ref<Script> existing = selected->get_script();
if (existing.is_valid())
@@ -391,6 +403,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if(existing.is_valid()) {
const RefPtr empty;
selected->set_script(empty);
+ button_create_script->show();
+ button_clear_script->hide();
}
} break;
@@ -637,6 +651,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
Node *tocopy = selection.front()->get();
+ if (tocopy==scene){
+ accept->get_ok()->set_text(TTR("I see.."));
+ accept->set_text(TTR("Can not perform with the root node."));
+ accept->popup_centered_minsize();
+ break;
+ }
+
if (tocopy!=editor_data->get_edited_scene_root() && tocopy->get_filename()!="") {
accept->get_ok()->set_text(TTR("I see.."));
accept->set_text(TTR("This operation can't be done on instanced scenes."));
@@ -665,7 +686,17 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
new_scene_from_dialog->set_title(TTR("Save New Scene As.."));
} break;
+ case TOOL_COPY_NODE_PATH: {
+ 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();
+ NodePath path = root->get_path().rel_path_to(node->get_path());
+ OS::get_singleton()->set_clipboard(path);
+ }
+ }
+ } break;
}
}
@@ -689,7 +720,7 @@ void SceneTreeDock::_notification(int p_what) {
button_add->set_icon(get_icon("Add","EditorIcons"));
button_instance->set_icon(get_icon("Instance","EditorIcons"));
button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
- button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
+ button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons"));
filter_icon->set_texture(get_icon("Zoom","EditorIcons"));
@@ -722,7 +753,7 @@ void SceneTreeDock::_node_selected() {
return;
}
- if (ScriptEditor::get_singleton()->is_visible()) {
+ if (ScriptEditor::get_singleton()->is_visible_in_tree()) {
restore_script_editor_on_drag=true;
}
@@ -746,6 +777,7 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node*,Node*> &duplimap) {
ERR_FAIL_COND_V(!sd.is_valid(),NULL);
node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
ERR_FAIL_COND_V(!node,NULL);
+ node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder());
//node->generate_instance_state();
} else {
Object *obj = ClassDB::instance(p_node->get_class());
@@ -1222,6 +1254,8 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) {
return;
selected->set_script(p_script.get_ref_ptr());
editor->push_item(p_script.operator->());
+ button_create_script->hide();
+ button_clear_script->show();
}
@@ -1556,8 +1590,10 @@ void SceneTreeDock::_new_scene_from(String p_file) {
int flg=0;
if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources"))
flg|=ResourceSaver::FLAG_COMPRESS;
- //if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
- // flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ /*
+ if (EditorSettings::get_singleton()->get("filesystem/on_save/save_paths_as_relative"))
+ flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
+ */
err = ResourceSaver::save(p_file,sdata,flg);
@@ -1736,7 +1772,9 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) {
for(int i=0;i<p_nodes.size();i++) {
Node *n=get_node((p_nodes[i]));
- nodes.push_back(n);
+ if (n) {
+ nodes.push_back(n);
+ }
}
if (nodes.size()==0)
@@ -1784,7 +1822,7 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
menu->add_separator();
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
- menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
+ menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
menu->add_separator();
}
@@ -1796,12 +1834,12 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) {
if (selection.size()==1) {
menu->add_separator();
menu->add_icon_shortcut(get_icon("Blend","EditorIcons"),ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
- menu->add_icon_shortcut(get_icon("Save","EditorIcons"),ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
+ 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);
}
menu->add_separator();
-
menu->add_icon_shortcut(get_icon("Remove","EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
-
menu->set_size(Size2(1,1));
menu->set_pos(p_menu_pos);
menu->popup();
@@ -1848,33 +1886,33 @@ void SceneTreeDock::open_script_dialog(Node* p_for_node) {
void SceneTreeDock::_bind_methods() {
- ClassDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false));
- ClassDB::bind_method(_MD("_create"),&SceneTreeDock::_create);
- //ClassDB::bind_method(_MD("_script_created"),&SceneTreeDock::_script_created);
- ClassDB::bind_method(_MD("_node_reparent"),&SceneTreeDock::_node_reparent);
- ClassDB::bind_method(_MD("_set_owners"),&SceneTreeDock::_set_owners);
- ClassDB::bind_method(_MD("_node_selected"),&SceneTreeDock::_node_selected);
- ClassDB::bind_method(_MD("_node_renamed"),&SceneTreeDock::_node_renamed);
- ClassDB::bind_method(_MD("_script_created"),&SceneTreeDock::_script_created);
- ClassDB::bind_method(_MD("_load_request"),&SceneTreeDock::_load_request);
- ClassDB::bind_method(_MD("_script_open_request"),&SceneTreeDock::_script_open_request);
- ClassDB::bind_method(_MD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input);
- ClassDB::bind_method(_MD("_input"),&SceneTreeDock::_input);
- ClassDB::bind_method(_MD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin);
- ClassDB::bind_method(_MD("_delete_confirm"),&SceneTreeDock::_delete_confirm);
- ClassDB::bind_method(_MD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed);
- ClassDB::bind_method(_MD("_import_subscene"),&SceneTreeDock::_import_subscene);
- ClassDB::bind_method(_MD("_selection_changed"),&SceneTreeDock::_selection_changed);
- ClassDB::bind_method(_MD("_new_scene_from"),&SceneTreeDock::_new_scene_from);
- ClassDB::bind_method(_MD("_nodes_dragged"),&SceneTreeDock::_nodes_dragged);
- ClassDB::bind_method(_MD("_files_dropped"),&SceneTreeDock::_files_dropped);
- ClassDB::bind_method(_MD("_script_dropped"),&SceneTreeDock::_script_dropped);
- ClassDB::bind_method(_MD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
- ClassDB::bind_method(_MD("_filter_changed"),&SceneTreeDock::_filter_changed);
- ClassDB::bind_method(_MD("_focus_node"),&SceneTreeDock::_focus_node);
-
-
- ClassDB::bind_method(_MD("instance"),&SceneTreeDock::instance);
+ ClassDB::bind_method(D_METHOD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("_create"),&SceneTreeDock::_create);
+ //ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
+ ClassDB::bind_method(D_METHOD("_node_reparent"),&SceneTreeDock::_node_reparent);
+ ClassDB::bind_method(D_METHOD("_set_owners"),&SceneTreeDock::_set_owners);
+ ClassDB::bind_method(D_METHOD("_node_selected"),&SceneTreeDock::_node_selected);
+ ClassDB::bind_method(D_METHOD("_node_renamed"),&SceneTreeDock::_node_renamed);
+ ClassDB::bind_method(D_METHOD("_script_created"),&SceneTreeDock::_script_created);
+ ClassDB::bind_method(D_METHOD("_load_request"),&SceneTreeDock::_load_request);
+ ClassDB::bind_method(D_METHOD("_script_open_request"),&SceneTreeDock::_script_open_request);
+ ClassDB::bind_method(D_METHOD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input);
+ ClassDB::bind_method(D_METHOD("_input"),&SceneTreeDock::_input);
+ ClassDB::bind_method(D_METHOD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin);
+ ClassDB::bind_method(D_METHOD("_delete_confirm"),&SceneTreeDock::_delete_confirm);
+ ClassDB::bind_method(D_METHOD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed);
+ ClassDB::bind_method(D_METHOD("_import_subscene"),&SceneTreeDock::_import_subscene);
+ ClassDB::bind_method(D_METHOD("_selection_changed"),&SceneTreeDock::_selection_changed);
+ ClassDB::bind_method(D_METHOD("_new_scene_from"),&SceneTreeDock::_new_scene_from);
+ ClassDB::bind_method(D_METHOD("_nodes_dragged"),&SceneTreeDock::_nodes_dragged);
+ ClassDB::bind_method(D_METHOD("_files_dropped"),&SceneTreeDock::_files_dropped);
+ ClassDB::bind_method(D_METHOD("_script_dropped"),&SceneTreeDock::_script_dropped);
+ ClassDB::bind_method(D_METHOD("_tree_rmb"),&SceneTreeDock::_tree_rmb);
+ ClassDB::bind_method(D_METHOD("_filter_changed"),&SceneTreeDock::_filter_changed);
+ ClassDB::bind_method(D_METHOD("_focus_node"),&SceneTreeDock::_focus_node);
+
+
+ ClassDB::bind_method(D_METHOD("instance"),&SceneTreeDock::instance);
}
@@ -1903,6 +1941,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
ED_SHORTCUT("scene_tree/reparent", TTR("Reparent"));
ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene"));
ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene"));
+ ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KEY_MASK_CMD|KEY_C);
ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT|KEY_DELETE);
ED_SHORTCUT("scene_tree/delete", TTR("Delete"), KEY_DELETE);
@@ -1926,9 +1965,9 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
filter = memnew( LineEdit );
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter_hbc->add_child(filter);
- filter_icon = memnew( TextureFrame );
+ filter_icon = memnew( TextureRect );
filter_hbc->add_child(filter_icon);
- filter_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
+ filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
filter->connect("text_changed",this,"_filter_changed");
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 8dade67337..2ee7ba3d06 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -68,6 +68,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_MERGE_FROM_SCENE,
TOOL_MULTI_EDIT,
TOOL_ERASE,
+ TOOL_COPY_NODE_PATH,
TOOL_BUTTON_MAX
};
@@ -102,7 +103,7 @@ class SceneTreeDock : public VBoxContainer {
EditorFileDialog *new_scene_from_dialog;
LineEdit *filter;
- TextureFrame *filter_icon;
+ TextureRect *filter_icon;
PopupMenu * menu;
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index 1c881dfd5e..0e15040a35 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -27,13 +27,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scene_tree_editor.h"
+
#include "scene/gui/label.h"
#include "editor_node.h"
#include "print_string.h"
#include "message_queue.h"
#include "scene/main/viewport.h"
#include "tools/editor/plugins/canvas_item_editor_plugin.h"
-
#include "scene/resources/packed_scene.h"
Node *SceneTreeEditor::get_scene_node() {
@@ -208,14 +208,15 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
if (n->is_class("Spatial")) {
- bool v = !bool(n->call("is_hidden"));
+ bool v = bool(n->call("is_visible"));
undo_redo->create_action(TTR("Toggle Spatial Visible"));
- undo_redo->add_do_method(n,"_set_visible_",!v);
- undo_redo->add_undo_method(n,"_set_visible_",v);
+ undo_redo->add_do_method(n,"set_visible",!v);
+ undo_redo->add_undo_method(n,"set_visible",v);
undo_redo->commit_action();
+
} else if (n->is_class("CanvasItem")) {
- bool v = !bool(n->call("is_hidden"));
+ bool v = bool(n->call("is_visible"));
undo_redo->create_action(TTR("Toggle CanvasItem Visible"));
undo_redo->add_do_method(n,v?"hide":"show");
undo_redo->add_undo_method(n,v?"show":"hide");
@@ -393,11 +394,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
if (is_grouped)
item->add_button(0,get_icon("Group", "EditorIcons"), BUTTON_GROUP);
- bool h = p_node->call("is_hidden");
- if (h)
- item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
- else
+ bool v = p_node->call("is_visible");
+ if (v)
item->add_button(0,get_icon("Visible","EditorIcons"),BUTTON_VISIBILITY);
+ else
+ item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
@@ -405,11 +406,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) {
_update_visibility_color(p_node, item);
} else if (p_node->is_class("Spatial")) {
- bool h = p_node->call("is_hidden");
- if (h)
- item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
- else
+ bool v = p_node->call("is_visible");
+ if (v)
item->add_button(0,get_icon("Visible","EditorIcons"),BUTTON_VISIBILITY);
+ else
+ item->add_button(0,get_icon("Hidden","EditorIcons"),BUTTON_VISIBILITY);
if (!p_node->is_connected("visibility_changed",this,"_node_visibility_changed"))
p_node->connect("visibility_changed",this,"_node_visibility_changed",varray(p_node));
@@ -470,15 +471,16 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) {
bool visible=false;
if (p_node->is_class("CanvasItem")) {
- visible = !p_node->call("is_hidden");
+ visible = p_node->call("is_visible");
+ CanvasItemEditor::get_singleton()->get_viewport_control()->update();
} else if (p_node->is_class("Spatial")) {
- visible = !p_node->call("is_hidden");
+ visible = p_node->call("is_visible");
}
- if (!visible)
- item->set_button(0,idx,get_icon("Hidden","EditorIcons"));
- else
+ if (visible)
item->set_button(0,idx,get_icon("Visible","EditorIcons"));
+ else
+ item->set_button(0,idx,get_icon("Hidden","EditorIcons"));
_update_visibility_color(p_node, item);
}
@@ -671,8 +673,8 @@ void SceneTreeEditor::_notification(int p_what) {
EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
-// get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED);
-// get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED);
+ //get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED);
+ //get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED);
_update_tree();
}
if (p_what==NOTIFICATION_EXIT_TREE) {
@@ -953,7 +955,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
if (i<list_max){
HBoxContainer *hb = memnew( HBoxContainer );
- TextureFrame *tf = memnew(TextureFrame);
+ TextureRect *tf = memnew(TextureRect);
tf->set_texture(icons[i]);
hb->add_child(tf);
Label *label = memnew( Label( selected[i]->get_name() ) );
@@ -1081,7 +1083,7 @@ void SceneTreeEditor::_warning_changed(Node* p_for_node) {
//should use a timer
update_timer->start();
-// print_line("WARNING CHANGED "+String(p_for_node->get_name()));
+ //print_line("WARNING CHANGED "+String(p_for_node->get_name()));
}
@@ -1122,11 +1124,11 @@ void SceneTreeEditor::_bind_methods() {
ClassDB::bind_method("_editor_settings_changed", &SceneTreeEditor::_editor_settings_changed);
- ClassDB::bind_method(_MD("get_drag_data_fw"), &SceneTreeEditor::get_drag_data_fw);
- ClassDB::bind_method(_MD("can_drop_data_fw"), &SceneTreeEditor::can_drop_data_fw);
- ClassDB::bind_method(_MD("drop_data_fw"), &SceneTreeEditor::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SceneTreeEditor::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SceneTreeEditor::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw"), &SceneTreeEditor::drop_data_fw);
- ClassDB::bind_method(_MD("update_tree"), &SceneTreeEditor::update_tree);
+ ClassDB::bind_method(D_METHOD("update_tree"), &SceneTreeEditor::update_tree);
ADD_SIGNAL( MethodInfo("node_selected") );
ADD_SIGNAL( MethodInfo("node_renamed") );
@@ -1186,7 +1188,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open
tree->connect("item_edited", this,"_renamed",varray(),CONNECT_DEFERRED);
tree->connect("multi_selected",this,"_cell_multi_selected");
tree->connect("button_pressed",this,"_cell_button_pressed");
-// tree->connect("item_edited", this,"_renamed",Vector<Variant>(),true);
+ //tree->connect("item_edited", this,"_renamed",Vector<Variant>(),true);
error = memnew( AcceptDialog );
add_child(error);
@@ -1264,7 +1266,7 @@ void SceneTreeDialog::_notification(int p_what) {
get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && is_visible()) {
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED && is_visible_in_tree()) {
tree->update_tree();
}
diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h
index 3cc1bd2388..5586f02c00 100644
--- a/tools/editor/scene_tree_editor.h
+++ b/tools/editor/scene_tree_editor.h
@@ -175,8 +175,8 @@ class SceneTreeDialog : public ConfirmationDialog {
GDCLASS( SceneTreeDialog, ConfirmationDialog );
SceneTreeEditor *tree;
-// Button *select;
-// Button *cancel;
+ //Button *select;
+ //Button *cancel;
void update_tree();
void _select();
diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp
index d1095271fc..dfaa1f645c 100644
--- a/tools/editor/script_create_dialog.cpp
+++ b/tools/editor/script_create_dialog.cpp
@@ -27,8 +27,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_create_dialog.h"
+
#include "script_language.h"
-#include "globals.h"
+#include "global_config.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "editor_file_system.h"
@@ -38,7 +39,7 @@ void ScriptCreateDialog::config(const String& p_base_name,const String&p_base_pa
class_name->set_text("");
parent_name->set_text(p_base_name);
if (p_base_path!="") {
- initial_bp=p_base_path.basename();
+ initial_bp=p_base_path.get_basename();
file_path->set_text(initial_bp+"."+ScriptServer::get_language( language_menu->get_selected() )->get_extension());
} else {
initial_bp="";
@@ -127,7 +128,7 @@ void ScriptCreateDialog::_create_new() {
Ref<Script> 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_last_selected_language(selected_language);
+ editor_settings->set_project_metadata("script_setup", "last_selected_language", selected_language);
if (cname!="")
scr->set_name(cname);
@@ -182,7 +183,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
String path=file_path->get_text();
String extension="";
if (path.find(".")>=0) {
- extension=path.extension();
+ extension=path.get_extension();
}
if (extension.length()==0) {
@@ -199,7 +200,7 @@ void ScriptCreateDialog::_lang_changed(int l) {
for(List<String>::Element *E=extensions.front();E;E=E->next()) {
if (E->get().nocasecmp_to(extension)==0) {
- path=path.basename()+selected_ext;
+ path=path.get_basename()+selected_ext;
_path_changed(path);
break;
}
@@ -288,7 +289,7 @@ void ScriptCreateDialog::_path_changed(const String& p_path) {
create_new=!f->file_exists(p);
memdelete(f);
- String extension=p.extension();
+ String extension=p.get_extension();
List<String> extensions;
// get all possible extensions for script
@@ -379,7 +380,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
}
editor_settings = EditorSettings::get_singleton();
- String last_selected_language = editor_settings->get_last_selected_language();
+ String last_selected_language = editor_settings->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/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp
index 24b7befb9f..fa33ffe5c7 100644
--- a/tools/editor/script_editor_debugger.cpp
+++ b/tools/editor/script_editor_debugger.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "script_editor_debugger.h"
+
#include "scene/gui/separator.h"
#include "scene/gui/label.h"
#include "scene/gui/split_container.h"
@@ -38,7 +39,7 @@
#include "scene/gui/rich_text_label.h"
#include "scene/gui/margin_container.h"
#include "property_editor.h"
-#include "globals.h"
+#include "global_config.h"
#include "editor_node.h"
#include "main/performance.h"
#include "editor_profiler.h"
@@ -177,7 +178,7 @@ void ScriptEditorDebugger::debug_next() {
ERR_FAIL_COND(!breaked);
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
Array msg;
msg.push_back("next");
ppeer->put_var(msg);
@@ -189,7 +190,7 @@ void ScriptEditorDebugger::debug_step() {
ERR_FAIL_COND(!breaked);
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
Array msg;
msg.push_back("step");
@@ -202,7 +203,7 @@ void ScriptEditorDebugger::debug_break() {
ERR_FAIL_COND(breaked);
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
Array msg;
msg.push_back("break");
@@ -214,7 +215,7 @@ void ScriptEditorDebugger::debug_continue() {
ERR_FAIL_COND(!breaked);
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id());
@@ -294,7 +295,7 @@ void ScriptEditorDebugger::_scene_tree_property_select_object(ObjectID p_object)
void ScriptEditorDebugger::_scene_tree_request() {
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
Array msg;
msg.push_back("request_scene_tree");
@@ -305,7 +306,7 @@ void ScriptEditorDebugger::_scene_tree_request() {
void ScriptEditorDebugger::_video_mem_request() {
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
Array msg;
msg.push_back("request_video_mem");
@@ -520,7 +521,7 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
d["frame"]=i;
s->set_metadata(0,d);
-// String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
+ //String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"])+" - at func: "+d["function"];
String line = itos(i)+" - "+String(d["file"])+":"+itos(d["line"]);
s->set_text(0,line);
@@ -580,7 +581,7 @@ void ScriptEditorDebugger::_parse_message(const String& p_msg,const Array& p_dat
String t = p_data[i];
//LOG
- if (EditorNode::get_log()->is_hidden()) {
+ if (!EditorNode::get_log()->is_visible()) {
if (EditorNode::get_singleton()->are_bottom_panels_hidden()) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
}
@@ -825,7 +826,7 @@ void ScriptEditorDebugger::_performance_draw() {
Ref<StyleBox> graph_sb = get_stylebox("normal","TextEdit");
Ref<Font> graph_font = get_font("font","TextEdit");
- int cols = Math::ceil(Math::sqrt(which.size()));
+ int cols = Math::ceil(Math::sqrt((float)which.size()));
int rows = (which.size()+1)/cols;
if (which.size()==1)
rows=1;
@@ -905,7 +906,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
inspect_scene_tree_timeout-=get_process_delta_time();
if (inspect_scene_tree_timeout<0) {
inspect_scene_tree_timeout=EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
- if (inspect_scene_tree->is_visible()) {
+ if (inspect_scene_tree->is_visible_in_tree()) {
_scene_tree_request();
if (inspected_object_id!=0) {
@@ -921,7 +922,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
inspect_edited_object_timeout-=get_process_delta_time();
if (inspect_edited_object_timeout<0) {
inspect_edited_object_timeout=EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
- if (inspect_scene_tree->is_visible() && inspected_object_id) {
+ if (inspect_scene_tree->is_visible_in_tree() && inspected_object_id) {
//take the chance and re-inspect selected object
Array msg;
msg.push_back("inspect_object");
@@ -993,7 +994,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
};
- if (!connection->is_connected()) {
+ if (!connection->is_connected_to_host()) {
stop();
editor->notify_child_process_exited(); //somehow, exited
break;
@@ -1087,7 +1088,7 @@ void ScriptEditorDebugger::start() {
stop();
- if (is_visible()) {
+ if (is_visible_in_tree()) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
}
@@ -1146,7 +1147,7 @@ void ScriptEditorDebugger::stop(){
if (hide_on_stop) {
- if (is_visible())
+ if (is_visible_in_tree())
EditorNode::get_singleton()->hide_bottom_panel();
emit_signal("show_debugger",false);
}
@@ -1183,12 +1184,12 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
void ScriptEditorDebugger::_profiler_seeked() {
- if (!connection.is_valid() || !connection->is_connected())
+ if (!connection.is_valid() || !connection->is_connected_to_host())
return;
if (breaked)
return;
- debug_break();;
+ debug_break();
}
@@ -1205,7 +1206,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() {
emit_signal("goto_script_line",s,int(d["line"])-1);
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
///
Array msg;
@@ -1620,7 +1621,7 @@ void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
void ScriptEditorDebugger::_paused() {
ERR_FAIL_COND(connection.is_null());
- ERR_FAIL_COND(!connection->is_connected());
+ ERR_FAIL_COND(!connection->is_connected_to_host());
if (!breaked && EditorNode::get_singleton()->get_pause_button()->is_pressed()) {
debug_break();
@@ -1634,39 +1635,39 @@ void ScriptEditorDebugger::_paused() {
void ScriptEditorDebugger::_bind_methods() {
- ClassDB::bind_method(_MD("_stack_dump_frame_selected"),&ScriptEditorDebugger::_stack_dump_frame_selected);
- ClassDB::bind_method(_MD("debug_next"),&ScriptEditorDebugger::debug_next);
- ClassDB::bind_method(_MD("debug_step"),&ScriptEditorDebugger::debug_step);
- ClassDB::bind_method(_MD("debug_break"),&ScriptEditorDebugger::debug_break);
- ClassDB::bind_method(_MD("debug_continue"),&ScriptEditorDebugger::debug_continue);
- ClassDB::bind_method(_MD("_output_clear"),&ScriptEditorDebugger::_output_clear);
- ClassDB::bind_method(_MD("_performance_draw"),&ScriptEditorDebugger::_performance_draw);
- ClassDB::bind_method(_MD("_performance_select"),&ScriptEditorDebugger::_performance_select);
- ClassDB::bind_method(_MD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request);
- ClassDB::bind_method(_MD("_video_mem_request"),&ScriptEditorDebugger::_video_mem_request);
- ClassDB::bind_method(_MD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set);
- ClassDB::bind_method(_MD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear);
-
- ClassDB::bind_method(_MD("_error_selected"),&ScriptEditorDebugger::_error_selected);
- ClassDB::bind_method(_MD("_error_stack_selected"),&ScriptEditorDebugger::_error_stack_selected);
- ClassDB::bind_method(_MD("_profiler_activate"),&ScriptEditorDebugger::_profiler_activate);
- ClassDB::bind_method(_MD("_profiler_seeked"),&ScriptEditorDebugger::_profiler_seeked);
-
- ClassDB::bind_method(_MD("_paused"),&ScriptEditorDebugger::_paused);
-
- ClassDB::bind_method(_MD("_scene_tree_selected"),&ScriptEditorDebugger::_scene_tree_selected);
- ClassDB::bind_method(_MD("_scene_tree_folded"),&ScriptEditorDebugger::_scene_tree_folded);
-
-
- ClassDB::bind_method(_MD("live_debug_create_node"),&ScriptEditorDebugger::live_debug_create_node);
- ClassDB::bind_method(_MD("live_debug_instance_node"),&ScriptEditorDebugger::live_debug_instance_node);
- ClassDB::bind_method(_MD("live_debug_remove_node"),&ScriptEditorDebugger::live_debug_remove_node);
- ClassDB::bind_method(_MD("live_debug_remove_and_keep_node"),&ScriptEditorDebugger::live_debug_remove_and_keep_node);
- ClassDB::bind_method(_MD("live_debug_restore_node"),&ScriptEditorDebugger::live_debug_restore_node);
- ClassDB::bind_method(_MD("live_debug_duplicate_node"),&ScriptEditorDebugger::live_debug_duplicate_node);
- ClassDB::bind_method(_MD("live_debug_reparent_node"),&ScriptEditorDebugger::live_debug_reparent_node);
- ClassDB::bind_method(_MD("_scene_tree_property_select_object"),&ScriptEditorDebugger::_scene_tree_property_select_object);
- ClassDB::bind_method(_MD("_scene_tree_property_value_edited"),&ScriptEditorDebugger::_scene_tree_property_value_edited);
+ ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"),&ScriptEditorDebugger::_stack_dump_frame_selected);
+ ClassDB::bind_method(D_METHOD("debug_next"),&ScriptEditorDebugger::debug_next);
+ ClassDB::bind_method(D_METHOD("debug_step"),&ScriptEditorDebugger::debug_step);
+ ClassDB::bind_method(D_METHOD("debug_break"),&ScriptEditorDebugger::debug_break);
+ ClassDB::bind_method(D_METHOD("debug_continue"),&ScriptEditorDebugger::debug_continue);
+ ClassDB::bind_method(D_METHOD("_output_clear"),&ScriptEditorDebugger::_output_clear);
+ ClassDB::bind_method(D_METHOD("_performance_draw"),&ScriptEditorDebugger::_performance_draw);
+ ClassDB::bind_method(D_METHOD("_performance_select"),&ScriptEditorDebugger::_performance_select);
+ ClassDB::bind_method(D_METHOD("_scene_tree_request"),&ScriptEditorDebugger::_scene_tree_request);
+ ClassDB::bind_method(D_METHOD("_video_mem_request"),&ScriptEditorDebugger::_video_mem_request);
+ ClassDB::bind_method(D_METHOD("_live_edit_set"),&ScriptEditorDebugger::_live_edit_set);
+ ClassDB::bind_method(D_METHOD("_live_edit_clear"),&ScriptEditorDebugger::_live_edit_clear);
+
+ ClassDB::bind_method(D_METHOD("_error_selected"),&ScriptEditorDebugger::_error_selected);
+ ClassDB::bind_method(D_METHOD("_error_stack_selected"),&ScriptEditorDebugger::_error_stack_selected);
+ ClassDB::bind_method(D_METHOD("_profiler_activate"),&ScriptEditorDebugger::_profiler_activate);
+ ClassDB::bind_method(D_METHOD("_profiler_seeked"),&ScriptEditorDebugger::_profiler_seeked);
+
+ ClassDB::bind_method(D_METHOD("_paused"),&ScriptEditorDebugger::_paused);
+
+ ClassDB::bind_method(D_METHOD("_scene_tree_selected"),&ScriptEditorDebugger::_scene_tree_selected);
+ ClassDB::bind_method(D_METHOD("_scene_tree_folded"),&ScriptEditorDebugger::_scene_tree_folded);
+
+
+ ClassDB::bind_method(D_METHOD("live_debug_create_node"),&ScriptEditorDebugger::live_debug_create_node);
+ ClassDB::bind_method(D_METHOD("live_debug_instance_node"),&ScriptEditorDebugger::live_debug_instance_node);
+ ClassDB::bind_method(D_METHOD("live_debug_remove_node"),&ScriptEditorDebugger::live_debug_remove_node);
+ ClassDB::bind_method(D_METHOD("live_debug_remove_and_keep_node"),&ScriptEditorDebugger::live_debug_remove_and_keep_node);
+ ClassDB::bind_method(D_METHOD("live_debug_restore_node"),&ScriptEditorDebugger::live_debug_restore_node);
+ ClassDB::bind_method(D_METHOD("live_debug_duplicate_node"),&ScriptEditorDebugger::live_debug_duplicate_node);
+ ClassDB::bind_method(D_METHOD("live_debug_reparent_node"),&ScriptEditorDebugger::live_debug_reparent_node);
+ ClassDB::bind_method(D_METHOD("_scene_tree_property_select_object"),&ScriptEditorDebugger::_scene_tree_property_select_object);
+ ClassDB::bind_method(D_METHOD("_scene_tree_property_value_edited"),&ScriptEditorDebugger::_scene_tree_property_value_edited);
ADD_SIGNAL(MethodInfo("goto_script_line"));
ADD_SIGNAL(MethodInfo("breaked",PropertyInfo(Variant::BOOL,"reallydid"),PropertyInfo(Variant::BOOL,"can_debug")));
@@ -1986,7 +1987,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
ScriptEditorDebugger::~ScriptEditorDebugger() {
-// inspector->edit(NULL);
+ //inspector->edit(NULL);
memdelete(variables);
ppeer->set_stream_peer(Ref<StreamPeer>());
diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp
index c72f2641b7..7d8d6ffcec 100644
--- a/tools/editor/settings_config_dialog.cpp
+++ b/tools/editor/settings_config_dialog.cpp
@@ -27,9 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "settings_config_dialog.h"
+
#include "editor_settings.h"
#include "scene/gui/margin_container.h"
-#include "globals.h"
+#include "global_config.h"
#include "editor_file_system.h"
#include "editor_node.h"
#include "os/keyboard.h"
@@ -92,10 +93,14 @@ void EditorSettingsDialog::popup_edit_settings() {
search_box->grab_focus();
_update_shortcuts();
- popup_centered_ratio(0.7);
-}
-
+ // Restore valid window bounds or pop up at default size.
+ if (EditorSettings::get_singleton()->has("interface/dialogs/editor_settings_bounds")) {
+ popup(EditorSettings::get_singleton()->get("interface/dialogs/editor_settings_bounds"));
+ } else {
+ popup_centered_ratio(0.7);
+ }
+}
void EditorSettingsDialog::_clear_search_box() {
@@ -120,10 +125,14 @@ void EditorSettingsDialog::_filter_shortcuts(const String& p_filter) {
void EditorSettingsDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
- clear_button->set_icon(get_icon("Close","EditorIcons"));
- shortcut_clear_button->set_icon(get_icon("Close","EditorIcons"));
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ clear_button->set_icon(get_icon("Close", "EditorIcons"));
+ shortcut_clear_button->set_icon(get_icon("Close", "EditorIcons"));
+ } break;
+ case NOTIFICATION_POPUP_HIDE: {
+ EditorSettings::get_singleton()->set("interface/dialogs/editor_settings_bounds", get_rect());
+ } break;
}
}
@@ -288,22 +297,23 @@ void EditorSettingsDialog::_press_a_key_confirm() {
void EditorSettingsDialog::_bind_methods() {
- ClassDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
- ClassDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
- ClassDB::bind_method(_MD("_settings_property_edited"),&EditorSettingsDialog::_settings_property_edited);
- ClassDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
- ClassDB::bind_method(_MD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box);
- ClassDB::bind_method(_MD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
- ClassDB::bind_method(_MD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts);
- ClassDB::bind_method(_MD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
- ClassDB::bind_method(_MD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
- ClassDB::bind_method(_MD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
+ ClassDB::bind_method(D_METHOD("_settings_save"),&EditorSettingsDialog::_settings_save);
+ ClassDB::bind_method(D_METHOD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
+ ClassDB::bind_method(D_METHOD("_settings_property_edited"),&EditorSettingsDialog::_settings_property_edited);
+ ClassDB::bind_method(D_METHOD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
+ ClassDB::bind_method(D_METHOD("_clear_shortcut_search_box"),&EditorSettingsDialog::_clear_shortcut_search_box);
+ ClassDB::bind_method(D_METHOD("_shortcut_button_pressed"),&EditorSettingsDialog::_shortcut_button_pressed);
+ ClassDB::bind_method(D_METHOD("_filter_shortcuts"),&EditorSettingsDialog::_filter_shortcuts);
+ ClassDB::bind_method(D_METHOD("_update_shortcuts"),&EditorSettingsDialog::_update_shortcuts);
+ ClassDB::bind_method(D_METHOD("_press_a_key_confirm"),&EditorSettingsDialog::_press_a_key_confirm);
+ ClassDB::bind_method(D_METHOD("_wait_for_key"),&EditorSettingsDialog::_wait_for_key);
}
EditorSettingsDialog::EditorSettingsDialog() {
set_title(TTR("Editor Settings"));
+ set_resizable(true);
tabs = memnew( TabContainer );
add_child(tabs);
diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp
index 62de22a4b3..825db5356b 100644
--- a/tools/editor/spatial_editor_gizmos.cpp
+++ b/tools/editor/spatial_editor_gizmos.cpp
@@ -27,6 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "spatial_editor_gizmos.h"
+
#include "geometry.h"
#include "scene/3d/camera.h"
#include "scene/resources/surface_tool.h"
@@ -285,7 +286,8 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
Vector<Vector3> normals;
int vtx_idx=0;
-#define ADD_VTX(m_idx);\
+
+#define ADD_VTX(m_idx) \
vertices.push_back( (face_points[m_idx]*HANDLE_HALF_SIZE+p_handles[ih]) );\
normals.push_back( normal_points[m_idx] );\
vtx_idx++;\
@@ -616,14 +618,14 @@ void EditorSpatialGizmo::free(){
void EditorSpatialGizmo::_bind_methods() {
- ClassDB::bind_method(_MD("add_lines","lines","material:Material","billboard"),&EditorSpatialGizmo::add_lines,DEFVAL(false));
- ClassDB::bind_method(_MD("add_mesh","mesh:Mesh","billboard","skeleton"),&EditorSpatialGizmo::add_mesh,DEFVAL(false),DEFVAL(RID()));
- ClassDB::bind_method(_MD("add_collision_segments","segments"),&EditorSpatialGizmo::add_collision_segments);
- ClassDB::bind_method(_MD("add_collision_triangles","triangles:TriangleMesh"),&EditorSpatialGizmo::add_collision_triangles);
- ClassDB::bind_method(_MD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1));
- ClassDB::bind_method(_MD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false));
- ClassDB::bind_method(_MD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node);
- ClassDB::bind_method(_MD("clear"),&EditorSpatialGizmo::clear);
+ ClassDB::bind_method(D_METHOD("add_lines","lines","material:Material","billboard"),&EditorSpatialGizmo::add_lines,DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_mesh","mesh:Mesh","billboard","skeleton"),&EditorSpatialGizmo::add_mesh,DEFVAL(false),DEFVAL(RID()));
+ ClassDB::bind_method(D_METHOD("add_collision_segments","segments"),&EditorSpatialGizmo::add_collision_segments);
+ ClassDB::bind_method(D_METHOD("add_collision_triangles","triangles:TriangleMesh"),&EditorSpatialGizmo::add_collision_triangles);
+ ClassDB::bind_method(D_METHOD("add_unscaled_billboard","material:Material","default_scale"),&EditorSpatialGizmo::add_unscaled_billboard,DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("add_handles","handles","billboard","secondary"),&EditorSpatialGizmo::add_handles,DEFVAL(false),DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("set_spatial_node","node:Spatial"),&EditorSpatialGizmo::_set_spatial_node);
+ ClassDB::bind_method(D_METHOD("clear"),&EditorSpatialGizmo::clear);
BIND_VMETHOD( MethodInfo("redraw"));
BIND_VMETHOD( MethodInfo(Variant::STRING,"get_handle_name",PropertyInfo(Variant::INT,"index")));
@@ -837,8 +839,8 @@ void LightSpatialGizmo::redraw() {
for(int i=0;i<=360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
@@ -879,8 +881,8 @@ void LightSpatialGizmo::redraw() {
for(int i=0;i<360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
@@ -953,28 +955,6 @@ LightSpatialGizmo::LightSpatialGizmo(Light* p_light){
set_spatial_node(p_light);
}
-//////
-
-void ListenerSpatialGizmo::redraw() {
-
- clear();
-
- add_unscaled_billboard(SpatialEditorGizmos::singleton->listener_icon, 0.05);
-
- add_mesh(SpatialEditorGizmos::singleton->listener_line_mesh);
- Vector<Vector3> cursor_points;
- cursor_points.push_back(Vector3(0, 0, 0));
- cursor_points.push_back(Vector3(0, 0, -1.0));
- add_collision_segments(cursor_points);
-
-}
-
-ListenerSpatialGizmo::ListenerSpatialGizmo(Listener* p_listener){
-
- set_spatial_node(p_listener);
- listener = p_listener;
-}
-
//////
@@ -1391,32 +1371,6 @@ SkeletonSpatialGizmo::SkeletonSpatialGizmo(Skeleton* p_skel) {
set_spatial_node(p_skel);
}
-/////
-
-
-void SpatialPlayerSpatialGizmo::redraw() {
-
- clear();
- if (splayer->cast_to<SpatialStreamPlayer>()) {
-
- add_unscaled_billboard(SpatialEditorGizmos::singleton->stream_player_icon,0.05);
-
- } else if (splayer->cast_to<SpatialSamplePlayer>()) {
-
- add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon,0.05);
-
- }
-
-}
-
-SpatialPlayerSpatialGizmo::SpatialPlayerSpatialGizmo(SpatialPlayer* p_splayer){
-
- set_spatial_node(p_splayer);
- splayer=p_splayer;
-}
-
-
-/////
void RoomSpatialGizmo::redraw() {
@@ -1565,8 +1519,8 @@ void VehicleWheelSpatialGizmo::redraw() {
const int skip=10;
for(int i=0;i<=360;i+=skip) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+skip);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+skip);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
@@ -1872,8 +1826,8 @@ void CollisionShapeSpatialGizmo::redraw(){
for(int i=0;i<=360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
@@ -1953,8 +1907,8 @@ void CollisionShapeSpatialGizmo::redraw(){
Vector3 d(0,0,height*0.5);
for(int i=0;i<360;i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+1);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
@@ -2168,7 +2122,7 @@ void VisibilityNotifierGizmo::set_handle(int p_idx,Camera *p_camera, const Point
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
Vector3 sg[2]={gi.xform(ray_from),gi.xform(ray_from+ray_dir*4096)};
- Vector3 ofs = aabb.pos+aabb.size*0.5;;
+ Vector3 ofs = aabb.pos+aabb.size*0.5;
Vector3 axis;
axis[p_idx]=1.0;
@@ -2530,7 +2484,7 @@ void GIProbeGizmo::redraw(){
}
- add_lines(lines,SpatialEditorGizmos::singleton->reflection_probe_material_internal);
+ add_lines(lines,SpatialEditorGizmos::singleton->gi_probe_material_internal);
Vector<Vector3> handles;
@@ -2890,8 +2844,8 @@ void ConeTwistJointSpatialGizmo::redraw() {
//swing
for(int i=0;i<360;i+=10) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+10);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+10);
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w;
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*w;
@@ -2922,8 +2876,8 @@ void ConeTwistJointSpatialGizmo::redraw() {
for(int i=0;i<int(ts);i+=5) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+5);
+ float ra=Math::deg2rad((float)i);
+ float rb=Math::deg2rad((float)i+5);
float c = i/720.0;
float cn = (i+5)/720.0;
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*w*c;
@@ -3117,8 +3071,8 @@ void Generic6DOFJointSpatialGizmo::redraw() {
float s = ll+i*(Math_PI*2.0)/points;
float n = ll+(i+1)*(Math_PI*2.0)/points;
-// Vector3 from=Vector3(0,Math::cos(s),-Math::sin(s) )*cs;
-// Vector3 to=Vector3( 0,Math::cos(n),-Math::sin(n) )*cs;
+ //Vector3 from=Vector3(0,Math::cos(s),-Math::sin(s) )*cs;
+ //Vector3 to=Vector3( 0,Math::cos(n),-Math::sin(n) )*cs;
Vector3 from;
SET_VTX(from,0, Math::cos(s), -Math::sin(s) );
@@ -3165,11 +3119,7 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return lsg;
}
- if (p_spatial->cast_to<Listener>()) {
- Ref<ListenerSpatialGizmo> misg = memnew(ListenerSpatialGizmo(p_spatial->cast_to<Listener>()));
- return misg;
- }
if (p_spatial->cast_to<Camera>()) {
@@ -3227,12 +3177,6 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
- if (p_spatial->cast_to<SpatialPlayer>()) {
-
- Ref<SpatialPlayerSpatialGizmo> misg = memnew( SpatialPlayerSpatialGizmo(p_spatial->cast_to<SpatialPlayer>()) );
- return misg;
- }
-
if (p_spatial->cast_to<CollisionShape>()) {
Ref<CollisionShapeSpatialGizmo> misg = memnew( CollisionShapeSpatialGizmo(p_spatial->cast_to<CollisionShape>()) );
@@ -3462,7 +3406,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
reflection_probe_material = create_line_material(Color(0.5,1.0,0.7));
reflection_probe_material_internal = create_line_material(Color(0.3,0.8,0.5,0.15));
gi_probe_material = create_line_material(Color(0.7,1.0,0.5));
- gi_probe_material_internal = create_line_material(Color(0.5,0.8,0.3,0.4));
+ gi_probe_material_internal = create_line_material(Color(0.5,0.8,0.3,0.1));
joint_material = create_line_material(Color(0.6,0.8,1.0));
stream_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
@@ -3494,7 +3438,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
PoolVector<Vector3> vertices;
#undef ADD_VTX
-#define ADD_VTX(m_idx);\
+#define ADD_VTX(m_idx) \
vertices.push_back( face_points[m_idx] );
for (int i=0;i<6;i++) {
diff --git a/tools/editor/spatial_editor_gizmos.h b/tools/editor/spatial_editor_gizmos.h
index 8fde52b05a..8a63d4f81e 100644
--- a/tools/editor/spatial_editor_gizmos.h
+++ b/tools/editor/spatial_editor_gizmos.h
@@ -35,8 +35,6 @@
#include "scene/3d/listener.h"
#include "scene/3d/camera.h"
#include "scene/3d/position_3d.h"
-#include "scene/3d/spatial_sample_player.h"
-#include "scene/3d/spatial_stream_player.h"
#include "scene/3d/test_cube.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/body_shape.h"
@@ -146,19 +144,6 @@ public:
};
-class ListenerSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(ListenerSpatialGizmo, EditorSpatialGizmo);
-
- Listener* listener;
-
-public:
-
- void redraw();
- ListenerSpatialGizmo(Listener* p_listener = NULL);
-
-};
-
class CameraSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(CameraSpatialGizmo,EditorSpatialGizmo);
@@ -220,23 +205,6 @@ public:
};
-
-
-class SpatialPlayerSpatialGizmo : public EditorSpatialGizmo {
-
- GDCLASS(SpatialPlayerSpatialGizmo,EditorSpatialGizmo);
-
- SpatialPlayer* splayer;
-
-public:
-
- void redraw();
- SpatialPlayerSpatialGizmo(SpatialPlayer* p_splayer=NULL);
-
-};
-
-
-
class TestCubeSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(TestCubeSpatialGizmo,EditorSpatialGizmo);
diff --git a/tools/translations/Makefile b/tools/editor/translations/Makefile
index bea20e877d..bea20e877d 100644
--- a/tools/translations/Makefile
+++ b/tools/editor/translations/Makefile
diff --git a/tools/translations/README.md b/tools/editor/translations/README.md
index 351bc9e2d1..351bc9e2d1 100644
--- a/tools/translations/README.md
+++ b/tools/editor/translations/README.md
diff --git a/tools/translations/ar.po b/tools/editor/translations/ar.po
index 0bfef1cfe1..539b94ab62 100644
--- a/tools/translations/ar.po
+++ b/tools/editor/translations/ar.po
@@ -3252,7 +3252,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5844,11 +5844,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5860,7 +5860,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6094,7 +6094,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/bg.po b/tools/editor/translations/bg.po
index 9197a6e702..fe711e1b30 100644
--- a/tools/translations/bg.po
+++ b/tools/editor/translations/bg.po
@@ -3295,7 +3295,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5890,11 +5890,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5906,7 +5906,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6140,7 +6140,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/bn.po b/tools/editor/translations/bn.po
index a3a3a072fc..0b1993caa0 100644
--- a/tools/translations/bn.po
+++ b/tools/editor/translations/bn.po
@@ -3381,8 +3381,8 @@ msgid "Compress"
msgstr "সঙ্কোচন করুন"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "প্রকল্পে সংযুক্ত করুন (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "প্রকল্পে সংযুক্ত করুন (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5989,12 +5989,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "অকার্যকর প্রকল্পের পথ, পথটি অবশ্যই বিদ্যমান হতে হবে!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "অকার্যকর প্রকল্পের পথ, engine.cfg অবশ্যই অনুপস্থিত হতে হবে।"
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "অকার্যকর প্রকল্পের পথ, godot.cfg অবশ্যই অনুপস্থিত হতে হবে।"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "অকার্যকর প্রকল্পের পথ, engine.cfg অবশ্যই উপস্থিত হতে হবে।"
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "অকার্যকর প্রকল্পের পথ, godot.cfg অবশ্যই উপস্থিত হতে হবে।"
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6005,8 +6005,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "অকার্যকর প্রকল্পের পথ (কোনোকিছু পরিবর্তন করেছেন?)।"
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "প্রকল্পের পথে engine.cfg তৈরি করা সম্ভব হয়নি।"
+msgid "Couldn't create godot.cfg in project path."
+msgstr "প্রকল্পের পথে godot.cfg তৈরি করা সম্ভব হয়নি।"
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6241,8 +6241,8 @@ msgid "Remove Resource Remap Option"
msgstr "রিসোর্সের পুনঃ-নকশার সিদ্ধান্ত অপসারণ করুন"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "প্রকল্পের সেটিংস (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "প্রকল্পের সেটিংস (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/ca.po b/tools/editor/translations/ca.po
index 266551ee60..c45cad964b 100644
--- a/tools/translations/ca.po
+++ b/tools/editor/translations/ca.po
@@ -3406,7 +3406,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -6004,11 +6004,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6020,7 +6020,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6254,8 +6254,8 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Configuració del Projecte (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Configuració del Projecte (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/cs.po b/tools/editor/translations/cs.po
index 4020725d74..3dc52fa536 100644
--- a/tools/translations/cs.po
+++ b/tools/editor/translations/cs.po
@@ -3321,7 +3321,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5918,11 +5918,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5934,7 +5934,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6168,7 +6168,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/da.po b/tools/editor/translations/da.po
index e0d4d9bd98..6148d0b82d 100644
--- a/tools/translations/da.po
+++ b/tools/editor/translations/da.po
@@ -3323,7 +3323,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5918,11 +5918,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5934,7 +5934,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6168,7 +6168,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/de.po b/tools/editor/translations/de.po
index 68ce048b5b..0545ea2f21 100644
--- a/tools/translations/de.po
+++ b/tools/editor/translations/de.po
@@ -3419,8 +3419,8 @@ msgid "Compress"
msgstr "Komprimieren"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Zu Projekt hinzufügen (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Zu Projekt hinzufügen (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6036,12 +6036,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Ungültiger Projektpfad, der Pfad muss existieren!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Ungültiger Projektpfad, engine.cfg darf nicht existieren."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Ungültiger Projektpfad, godot.cfg darf nicht existieren."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Ungültiger Projektpfad, engine.cfg muss existieren."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Ungültiger Projektpfad, godot.cfg muss existieren."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6052,8 +6052,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Ungültiger Projektpfad (etwas geändert?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Konnte engine.cfg in Projektpfad nicht erzeugen."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Konnte godot.cfg in Projektpfad nicht erzeugen."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6288,8 +6288,8 @@ msgid "Remove Resource Remap Option"
msgstr "Ressourcen-Remap-Option entfernen"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Projekteinstellungen (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Projekteinstellungen (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/de_CH.po b/tools/editor/translations/de_CH.po
index e6e0efdb23..0420d3fc97 100644
--- a/tools/translations/de_CH.po
+++ b/tools/editor/translations/de_CH.po
@@ -3295,8 +3295,8 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Zum Projekt hinzufügen (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Zum Projekt hinzufügen (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5900,12 +5900,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Ungültiger Projektpfad, Pfad existiert nicht!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Ungültiger Projektpfad, engine.cfg vorhanden!"
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Ungültiger Projektpfad, godot.cfg vorhanden!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Ungültiger Projektpfad, engine.cfg nicht vorhanden!"
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Ungültiger Projektpfad, godot.cfg nicht vorhanden!"
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -5916,8 +5916,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Ungültiger Projektpfad, (wurde was geändert?)!"
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Die engine.cfg kann im Projektverzeichnis nicht erstellt werden."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Die godot.cfg kann im Projektverzeichnis nicht erstellt werden."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6150,7 +6150,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/es.po b/tools/editor/translations/es.po
index cec4730148..a1108822fa 100644
--- a/tools/translations/es.po
+++ b/tools/editor/translations/es.po
@@ -3449,8 +3449,8 @@ msgid "Compress"
msgstr "Comprimir"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Añadir al proyecto (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Añadir al proyecto (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6084,12 +6084,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "¡La ruta del proyecto no es correcta, tiene que existir!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "La ruta del proyecto no es correcta, engine.cfg no debe existir."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "La ruta del proyecto no es correcta, godot.cfg no debe existir."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "¡La ruta del proyecto no es correcta, engine.cfg debe existir."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "¡La ruta del proyecto no es correcta, godot.cfg debe existir."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6100,8 +6100,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "La ruta del proyecto no es correcta (¿has cambiado algo?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "No se pudo crear engine.cfg en la ruta de proyecto."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "No se pudo crear godot.cfg en la ruta de proyecto."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6338,8 +6338,8 @@ msgid "Remove Resource Remap Option"
msgstr "Quitar opción de remapeo de recursos"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Ajustes de proyecto (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Ajustes de proyecto (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/es_AR.po b/tools/editor/translations/es_AR.po
index 08376f39c5..d921254859 100644
--- a/tools/translations/es_AR.po
+++ b/tools/editor/translations/es_AR.po
@@ -3403,8 +3403,8 @@ msgid "Compress"
msgstr "Comprimir"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Agregar al Proyecto (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Agregar al Proyecto (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6019,12 +6019,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Ruta de proyecto inválida, la ruta debe existir!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Ruta de proyecto inválida, engine.cfg no debe existir."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Ruta de proyecto inválida, godot.cfg no debe existir."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Ruta de proyecto inválida, engine.cfg debe existir."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Ruta de proyecto inválida, godot.cfg debe existir."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6035,8 +6035,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Ruta de proyecto inválida (cambiaste algo?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "No se pudo crear engine.cfg en la ruta de proyecto."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "No se pudo crear godot.cfg en la ruta de proyecto."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6273,8 +6273,8 @@ msgid "Remove Resource Remap Option"
msgstr "Remover Opción de Remapeo de Recursos"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Ajustes de Proyecto (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Ajustes de Proyecto (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/extract.py b/tools/editor/translations/extract.py
index 1192c19011..1192c19011 100755
--- a/tools/translations/extract.py
+++ b/tools/editor/translations/extract.py
diff --git a/tools/translations/fa.po b/tools/editor/translations/fa.po
index 8e29cda45f..41a686ba52 100644
--- a/tools/translations/fa.po
+++ b/tools/editor/translations/fa.po
@@ -3350,7 +3350,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5948,11 +5948,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5964,7 +5964,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6200,7 +6200,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/fr.po b/tools/editor/translations/fr.po
index 10f82e2840..2c4f7144fe 100644
--- a/tools/translations/fr.po
+++ b/tools/editor/translations/fr.po
@@ -3437,8 +3437,8 @@ msgid "Compress"
msgstr "Compresser"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Ajouter au projet (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Ajouter au projet (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6072,12 +6072,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Chemin de projet invalide, le chemin doit exister !"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Chemin de projet invalide, engine.cfg ne doit pas exister."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Chemin de projet invalide, godot.cfg ne doit pas exister."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Chemin de projet invalide, engine.cfg doit exister."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Chemin de projet invalide, godot.cfg doit exister."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6088,9 +6088,9 @@ msgid "Invalid project path (changed anything?)."
msgstr "Chemin de projet non valide (avez-vous changé quelque chose ?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
-"Impossible de créer le fichier engine.cfg dans le répertoire du projet."
+"Impossible de créer le fichier godot.cfg dans le répertoire du projet."
#: tools/editor/project_manager.cpp
#, fuzzy
@@ -6332,8 +6332,8 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Paramètres du projet (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Paramètres du projet (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/hu.po b/tools/editor/translations/hu.po
index ef78f27138..335ab25c6a 100644
--- a/tools/translations/hu.po
+++ b/tools/editor/translations/hu.po
@@ -3245,7 +3245,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5836,11 +5836,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5852,7 +5852,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6086,7 +6086,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/id.po b/tools/editor/translations/id.po
index 917bd21e82..30bd357a21 100644
--- a/tools/translations/id.po
+++ b/tools/editor/translations/id.po
@@ -3410,7 +3410,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -6006,11 +6006,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6022,7 +6022,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6256,7 +6256,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/it.po b/tools/editor/translations/it.po
index f49c953a7d..8fefe67677 100644
--- a/tools/translations/it.po
+++ b/tools/editor/translations/it.po
@@ -3416,8 +3416,8 @@ msgid "Compress"
msgstr "Comprimi"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Aggiungi a Progetto (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Aggiungi a Progetto (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6031,12 +6031,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Percorso di progetto invalido, il percorso deve esistere!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Percorso di progetto invalido, engine.cfg non deve esistere."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Percorso di progetto invalido, godot.cfg non deve esistere."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Percorso di progetto invalido, engine.cfg deve esistere."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Percorso di progetto invalido, godot.cfg deve esistere."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6047,8 +6047,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Percorso di progetto invalido (cambiato qualcosa?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Impossibile creare engine.cfg nel percorso di progetto."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Impossibile creare godot.cfg nel percorso di progetto."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6283,8 +6283,8 @@ msgid "Remove Resource Remap Option"
msgstr "Rimuovi Opzione di Remap Rimorse"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Impostazioni Progetto (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Impostazioni Progetto (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/ja.po b/tools/editor/translations/ja.po
index 279f59c9c8..ea314db101 100644
--- a/tools/translations/ja.po
+++ b/tools/editor/translations/ja.po
@@ -3347,7 +3347,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5945,11 +5945,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5961,7 +5961,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6195,7 +6195,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/ko.po b/tools/editor/translations/ko.po
index ea2b130d37..a0ecb70bf5 100644
--- a/tools/translations/ko.po
+++ b/tools/editor/translations/ko.po
@@ -3350,8 +3350,8 @@ msgid "Compress"
msgstr "압축"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "프로젝트에 추가 (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "프로젝트에 추가 (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5954,12 +5954,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "프로젝트 경로가 유효하지 않습니다. 경로가 반드시 존재해야 합니다!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "프로젝트 경로가 유효하지 않습니다. engine.cfg가 있으면 안됩니다."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "프로젝트 경로가 유효하지 않습니다. godot.cfg가 있으면 안됩니다."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "프로젝트 경로가 유효하지 않습니다. engine.cfg가 존재해야합니다."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "프로젝트 경로가 유효하지 않습니다. godot.cfg가 존재해야합니다."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -5970,8 +5970,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "유효하지 않은 프로젝트 경로 (뭔가 변경하신 거라도?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "프로젝트 경로에 engine.cfg를 생성할 수 없습니다."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "프로젝트 경로에 godot.cfg를 생성할 수 없습니다."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6205,8 +6205,8 @@ msgid "Remove Resource Remap Option"
msgstr "리소스 리맵핑 옵션 제거"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "프로젝트 설정 (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "프로젝트 설정 (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/nb.po b/tools/editor/translations/nb.po
index ff659eae8b..cbd2a09951 100644
--- a/tools/translations/nb.po
+++ b/tools/editor/translations/nb.po
@@ -3245,7 +3245,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5836,11 +5836,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5852,7 +5852,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6086,7 +6086,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/pl.po b/tools/editor/translations/pl.po
index 465fbe133d..50afecad1b 100644
--- a/tools/translations/pl.po
+++ b/tools/editor/translations/pl.po
@@ -1601,7 +1601,7 @@ msgstr ""
#: tools/editor/dependency_editor.cpp
msgid "Remove selected files from the project? (no undo)"
-msgstr "Usunąć wybrane pliki z projektu? (Nie można tego cofnąć)"
+msgstr "Usunąć wybrane pliki z projektu? (Nie można tego cofnąć)"
#: tools/editor/dependency_editor.cpp
msgid "Error loading:"
@@ -3388,8 +3388,8 @@ msgid "Compress"
msgstr "Skompresuj"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Dodaj do projektu (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Dodaj do projektu (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5995,12 +5995,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Niepoprawna ścieżka projektu, ścieżka musi istnieć!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Niepoprawna ścieżka projektu, engine.cfg nie może istnieć."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Niepoprawna ścieżka projektu, godot.cfg nie może istnieć."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Niepoprawna ścieżka projektu, engine.cfg musi istnieć."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Niepoprawna ścieżka projektu, godot.cfg musi istnieć."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6011,8 +6011,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Niepoprawna ścieżka projektu (zmienić cokolwiek?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Nie można było utworzyć engine.cfg w ścieżce projektu."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Nie można było utworzyć godot.cfg w ścieżce projektu."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6245,8 +6245,8 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Ustawienia projektu (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Ustawienia projektu (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
@@ -6884,7 +6884,7 @@ msgstr "Skróty"
#: tools/editor/spatial_editor_gizmos.cpp
msgid "Change Light Radius"
-msgstr "Zmień promień światła"
+msgstr "Zmień promień światła"
#: tools/editor/spatial_editor_gizmos.cpp
msgid "Change Camera FOV"
@@ -6912,7 +6912,7 @@ msgstr "Zmień wysokośc Capsule Shape"
#: tools/editor/spatial_editor_gizmos.cpp
msgid "Change Ray Shape Length"
-msgstr "Zmień długość Ray Shape"
+msgstr "Zmień długość Ray Shape"
#: tools/editor/spatial_editor_gizmos.cpp
msgid "Change Notifier Extents"
diff --git a/tools/translations/pr.po b/tools/editor/translations/pr.po
index f8a9505066..8ea2967a22 100644
--- a/tools/translations/pr.po
+++ b/tools/editor/translations/pr.po
@@ -3263,7 +3263,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5854,11 +5854,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5870,7 +5870,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6104,7 +6104,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/pt_BR.po b/tools/editor/translations/pt_BR.po
index 106142b4ea..9ab81786b1 100644
--- a/tools/translations/pt_BR.po
+++ b/tools/editor/translations/pt_BR.po
@@ -3388,8 +3388,8 @@ msgid "Compress"
msgstr "Comprimir"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Adicionar ao Projeto (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Adicionar ao Projeto (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6012,12 +6012,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Caminho de projeto inválido, o caminho deve existir!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Caminho de projeto inválido, engine.cfg não deve existir."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Caminho de projeto inválido, godot.cfg não deve existir."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Caminho de projeto inválido, engine.cfg deve existir."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Caminho de projeto inválido, godot.cfg deve existir."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6028,8 +6028,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Caminho de projeto inválido (mudou alguma coisa?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Não se pôde criar engine.cfg no caminho do projeto."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Não se pôde criar godot.cfg no caminho do projeto."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6265,8 +6265,8 @@ msgid "Remove Resource Remap Option"
msgstr "Remover Opção de Remapeamento de Recurso"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Configurações do Projeto (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Configurações do Projeto (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/pt_PT.po b/tools/editor/translations/pt_PT.po
index 7b3c814f8c..da9d971347 100644
--- a/tools/translations/pt_PT.po
+++ b/tools/editor/translations/pt_PT.po
@@ -3258,7 +3258,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5850,11 +5850,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5866,7 +5866,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6100,7 +6100,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/ru.po b/tools/editor/translations/ru.po
index 73262dbd5e..0595a675b3 100644
--- a/tools/translations/ru.po
+++ b/tools/editor/translations/ru.po
@@ -3391,8 +3391,8 @@ msgid "Compress"
msgstr "Сжимать"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Добавить в проект (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Добавить в проект (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -6004,12 +6004,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Неверный путь к проекту, путь должен существовать!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Недопустимый путь к проекту, engine.cfg не должен существовать."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Недопустимый путь к проекту, godot.cfg не должен существовать."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Недопустимый путь к проекту, engine.cfg должен существовать."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Недопустимый путь к проекту, godot.cfg должен существовать."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6020,8 +6020,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Неверный путь к проекту (Что-то изменили?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "Не могу создать engine.cfg в папке проекта."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "Не могу создать godot.cfg в папке проекта."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6256,8 +6256,8 @@ msgid "Remove Resource Remap Option"
msgstr "Удалён параметр ресурса перенаправления"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Настройки проекта (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Настройки проекта (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/sk.po b/tools/editor/translations/sk.po
index f1bd9f1300..6aa2e16664 100644
--- a/tools/translations/sk.po
+++ b/tools/editor/translations/sk.po
@@ -3261,7 +3261,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5857,11 +5857,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5873,7 +5873,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6107,7 +6107,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/sl.po b/tools/editor/translations/sl.po
index 12903cba83..4934be97d7 100644
--- a/tools/translations/sl.po
+++ b/tools/editor/translations/sl.po
@@ -3270,7 +3270,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5862,11 +5862,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5878,7 +5878,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6112,7 +6112,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/tools.pot b/tools/editor/translations/tools.pot
index 447067beb3..8e54d88989 100644
--- a/tools/translations/tools.pot
+++ b/tools/editor/translations/tools.pot
@@ -3239,7 +3239,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5830,11 +5830,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5846,7 +5846,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6080,7 +6080,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/tr.po b/tools/editor/translations/tr.po
index b930e302f2..5c0b6ebca8 100644
--- a/tools/translations/tr.po
+++ b/tools/editor/translations/tr.po
@@ -3382,8 +3382,8 @@ msgid "Compress"
msgstr "Sıkıştır"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "Tasarıya Ekle (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "Tasarıya Ekle (godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5994,12 +5994,12 @@ msgid "Invalid project path, the path must exist!"
msgstr "Geçersiz tasarı yolu, yolun var olması gerekir!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
-msgstr "Geçersiz tasarı yolu, engine.cfg var olmaması gerekir."
+msgid "Invalid project path, godot.cfg must not exist."
+msgstr "Geçersiz tasarı yolu, godot.cfg var olmaması gerekir."
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
-msgstr "Geçersiz tasarı yolu, engine.cfg var olması gerekir."
+msgid "Invalid project path, godot.cfg must exist."
+msgstr "Geçersiz tasarı yolu, godot.cfg var olması gerekir."
#: tools/editor/project_manager.cpp
msgid "Imported Project"
@@ -6010,8 +6010,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "Geçersiz tasarı yolu (bir şey değişti mi?)."
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "engine.cfg tasarı yolunda oluşturulamadı."
+msgid "Couldn't create godot.cfg in project path."
+msgstr "godot.cfg tasarı yolunda oluşturulamadı."
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6247,8 +6247,8 @@ msgid "Remove Resource Remap Option"
msgstr "Kaynak Yeniden Eşle Seçeneğini Kaldır"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "Tasarı Ayarları (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "Tasarı Ayarları (godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/ur_PK.po b/tools/editor/translations/ur_PK.po
index 0eed08b52a..b898301d0c 100644
--- a/tools/translations/ur_PK.po
+++ b/tools/editor/translations/ur_PK.po
@@ -3255,7 +3255,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5850,11 +5850,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5866,7 +5866,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6100,7 +6100,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/zh_CN.po b/tools/editor/translations/zh_CN.po
index 58f79fac56..47c77f6170 100644
--- a/tools/translations/zh_CN.po
+++ b/tools/editor/translations/zh_CN.po
@@ -3312,8 +3312,8 @@ msgid "Compress"
msgstr "压缩"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
-msgstr "添加到项目(engine.cfg)"
+msgid "Add to Project (godot.cfg)"
+msgstr "添加到项目(godot.cfg)"
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
msgid "Import Languages:"
@@ -5912,11 +5912,11 @@ msgid "Invalid project path, the path must exist!"
msgstr "项目目录不存在!"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr "项目目录下必须包含engin.cfg文件。"
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr "项目目录下必须包含engin.cfg文件。"
#: tools/editor/project_manager.cpp
@@ -5928,8 +5928,8 @@ msgid "Invalid project path (changed anything?)."
msgstr "项目路径非法(被外部修改?)。"
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
-msgstr "无法在项目目录下创建engine.cfg文件。"
+msgid "Couldn't create godot.cfg in project path."
+msgstr "无法在项目目录下创建godot.cfg文件。"
#: tools/editor/project_manager.cpp
msgid "The following files failed extraction from package:"
@@ -6162,8 +6162,8 @@ msgid "Remove Resource Remap Option"
msgstr "移除资源重定向选项"
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
-msgstr "项目设置(engine.cfg)"
+msgid "Project Settings (godot.cfg)"
+msgstr "项目设置(godot.cfg)"
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
msgid "General"
diff --git a/tools/translations/zh_HK.po b/tools/editor/translations/zh_HK.po
index 60f2b51464..b0bb11d527 100644
--- a/tools/translations/zh_HK.po
+++ b/tools/editor/translations/zh_HK.po
@@ -3272,7 +3272,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5872,11 +5872,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5888,7 +5888,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6122,7 +6122,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp
diff --git a/tools/translations/zh_TW.po b/tools/editor/translations/zh_TW.po
index efad7ee167..3e9b61ec0f 100644
--- a/tools/translations/zh_TW.po
+++ b/tools/editor/translations/zh_TW.po
@@ -3259,7 +3259,7 @@ msgid "Compress"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
-msgid "Add to Project (engine.cfg)"
+msgid "Add to Project (godot.cfg)"
msgstr ""
#: tools/editor/io_plugins/editor_translation_import_plugin.cpp
@@ -5850,11 +5850,11 @@ msgid "Invalid project path, the path must exist!"
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must not exist."
+msgid "Invalid project path, godot.cfg must not exist."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Invalid project path, engine.cfg must exist."
+msgid "Invalid project path, godot.cfg must exist."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -5866,7 +5866,7 @@ msgid "Invalid project path (changed anything?)."
msgstr ""
#: tools/editor/project_manager.cpp
-msgid "Couldn't create engine.cfg in project path."
+msgid "Couldn't create godot.cfg in project path."
msgstr ""
#: tools/editor/project_manager.cpp
@@ -6100,7 +6100,7 @@ msgid "Remove Resource Remap Option"
msgstr ""
#: tools/editor/project_settings.cpp
-msgid "Project Settings (engine.cfg)"
+msgid "Project Settings (godot.cfg)"
msgstr ""
#: tools/editor/project_settings.cpp tools/editor/settings_config_dialog.cpp